Exemplo n.º 1
0
  def test_redact_empty_string(self):
    engine = RedactionEngine([
        RedactionRule('password='******'password="******"', 'password="******"'),
    ])

    assert_equal(engine.redact(None), None)
    assert_equal(engine.redact(''), '')
Exemplo n.º 2
0
  def test_redact_empty_string(self):
    engine = RedactionEngine([
        RedactionRule('password='******'password="******"', 'password="******"'),
    ])

    assert_equal(engine.redact(None), None)
    assert_equal(engine.redact(''), '')
Exemplo n.º 3
0
  def test_redaction_works(self):
    redaction_engine = RedactionEngine([
      RedactionRule('password='******'password="******"', 'password="******"'),
      RedactionRule('ssn=', 'ssn=\d{3}-\d{2}-\d{4}', 'ssn=XXX-XX-XXXX'),
    ])

    test_strings = [
        ('message', 'message'),
        ('password="******"', 'password="******"'),
        ('before password="******" after', 'before password="******" after'),
        ('an ssn=123-45-6789', 'an ssn=XXX-XX-XXXX'),
    ]

    for message, redacted_message in test_strings:
      assert_equal(redaction_engine.redact(message), redacted_message)
Exemplo n.º 4
0
  def test_redaction_works(self):
    redaction_engine = RedactionEngine([
      RedactionRule('password='******'password="******"', 'password="******"'),
      RedactionRule('ssn=', 'ssn=\d{3}-\d{2}-\d{4}', 'ssn=XXX-XX-XXXX'),
    ])

    test_strings = [
        ('message', 'message'),
        ('password="******"', 'password="******"'),
        ('before password="******" after', 'before password="******" after'),
        ('an ssn=123-45-6789', 'an ssn=XXX-XX-XXXX'),
    ]

    for message, redacted_message in test_strings:
      assert_equal(redaction_engine.redact(message), redacted_message)