Esempio n. 1
0
def test_anonymize(config_dir, tmpdir):
    """Confirm default anonymization removes password and IP address."""
    _anonymize_dir(config_dir, str(tmpdir))

    # Confirm the password is anonymized but IP address is left alone, per anonymization config
    with open(os.path.join(str(tmpdir), _CONFIG_FILE), "r") as f:
        anon_text = f.read()
        assert _CONFIG_PASSWORD not in anon_text
        assert _CONFIG_IP_ADDR not in anon_text
Esempio n. 2
0
def test_anonymize_custom(config_dir, tmpdir):
    """Confirm custom anonymization removes only what is specified in config."""
    # Generate Netconan config which will anonymize passwords but NOT IP addresses
    with tempfile.NamedTemporaryFile(mode="w") as f:
        f.write("anonymize-passwords\n")
        f.seek(0)
        _anonymize_dir(config_dir, str(tmpdir), netconan_config=f.name)

    # Confirm the password is anonymized but IP address is left alone, per anonymization config
    with open(os.path.join(str(tmpdir), _CONFIG_FILE), "r") as f:
        anon_text = f.read()
        assert _CONFIG_PASSWORD not in anon_text
        assert _CONFIG_IP_ADDR in anon_text