Esempio n. 1
0
def test_mask_secret_simple_positive():
    """
    Checking that mask_secret function works in a simple positive case.
    """
    secrets = ["8bca8d2e-1cd6", "683c08d7-bc07"]
    cmd = "ls -lh /tmp/8bca8d2e /tmp/683c08d7-bc07 /1cd6-4ec0-8e55"
    cmd_masked_expected = "ls -lh /tmp/8bca8d2e /tmp/***** /1cd6-4ec0-8e55"
    assert utils.mask_secrets(cmd, secrets) == cmd_masked_expected
Esempio n. 2
0
def test_mask_secret_nomatch():
    """
    Checking that mask_secret function works when there is no match.
    """
    secrets = [
        "8bca8d2e-1cd6-4ec0-8e55-9614aa01cf88",
        "683c08d7-bc07-4d72-b098-46ef00b74aec",
    ]
    assert utils.mask_secrets("ls -lh /tmp", secrets) == "ls -lh /tmp"
Esempio n. 3
0
def test_mask_secret_nosecrets():
    """
    Checking that mask_secret function doesn't change plaintext when secrets
    are not specified.
    """
    assert utils.mask_secrets("ls -lh /tmp", None) == "ls -lh /tmp"
Esempio n. 4
0
def test_mask_secret_null():
    """
    Checking that mask_secret function works with empty arguments.
    """
    assert utils.mask_secrets("", None) == ""