def main():
    module = AnsibleModule(argument_spec={
        'token': {
            'type': 'str',
            'no_log': True,
            'required': True
        },
        'endpoint': {
            'default': DEFAULT_API_ENDPOINT
        },
        'state': {
            'type': 'str',
            'choices': ['present', 'absent'],
            'required': True
        },
        'name': {},
        'public_key': {},
        'fingerprint': {},
        'replace': {
            'type': 'bool',
            'default': False
        }
    },
                           supports_check_mode=True)
    try:
        sc_ssh_key = ScSshKey(endpoint=module.params['endpoint'],
                              token=module.params['token'],
                              name=module.params['name'],
                              state=module.params['state'],
                              public_key=module.params['public_key'],
                              fingerprint=module.params['fingerprint'],
                              replace=module.params['replace'],
                              checkmode=module.check_mode)
        module.exit_json(**sc_ssh_key.run())
    except SCBaseError as e:
        module.exit_json(**e.fail())
def test_classify_matching_keys_partial_match2():
    assert ScSshKey.classify_matching_keys(
        KEYS_EXAMPLE_1, KEY1['name'],
        KEY2['fingerprint']) == ([], [KEY1, KEY2], [KEY1, KEY2])
def test_classify_matching_keys_simple_match():
    assert ScSshKey.classify_matching_keys(KEYS_EXAMPLE_1, KEY1['name'],
                                           KEY1['fingerprint']) == ([KEY1], [],
                                                                    [KEY1])
def test_classify_matching_keys_nomatch():
    assert ScSshKey.classify_matching_keys(KEYS_EXAMPLE_1, KEY_NOT['name'],
                                           KEY_NOT['fingerprint']) == ([], [],
                                                                       [])
def test_classify_matching_keys_trivial():
    assert ScSshKey.classify_matching_keys([], None, None) == ([], [], [])
def test_extract_fingerprint():
    example_line = 'ssh-dss AAAAB3NzaC1kc3MAAACBAItIoLYw/bzUTxi3J6e1xIbh+A4sw7gISo3b1mVBRN9Ri2ZFNG6Ly2ICmDzsi2v7itWJM0Dfuy4t+hQ6YS3qkBPIdhqFjX71kitQLmIxIqHNi4907AWko2YRGAaARHLJtpfG7sv8jrGDGVZfNcoIlZBM6558+5S6yFtRfhy7I41bAAAAFQD6dMEZZ0yAyO+q+vtQq4QqD5owywAAAIBq4pbyP+KDlayxG/+ImVLcpluJdz8rYILKoAcHxYj5baGn4Lmu5nhcCanjZ8LA2lk8f2YNK44hYRmfd2ZgfxuDEoliYBAqf00miFTSrUdQVZQNYaHO1IytBp1ECPopmzVe7wDkvk+3z1L0LeFepIpCQAOxYerEJ2gTt75Djr/gqAAAAIBEfGC+L06OcHVj3up6GAJg0AK0udjyravBnBzau6BLZivkA3WYy1sIdoRhIegMmy7zbOG2ajTsARxwZNCYjDZELt8tTNuc1DGAMOx1bQgkAE9VCtuuGEhiOSipgefSLre2lDo720aZSOXiwIxVBHo9FEH8D1Y0NO8oRSw2f5z0xg== tail@message'  # noqa
    # extracted by ssh-keygen -E md5 -l -f key.pub
    expected_digest = '2a:aa:58:61:88:b3:b0:d9:a5:cf:46:4d:75:b1:15:b7'
    assert ScSshKey.extract_fingerprint(example_line) == expected_digest