Example #1
0
def test_local_request_config_not_found():
    with pytest.raises(ValueError):
        lambda_handler(VALID_TEST_REQUEST,
                       context=Context,
                       ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                       entropy_check=False,
                       config_file=os.path.join(os.path.dirname(__file__),
                                                'none'))
Example #2
0
def test_local_request_config_not_found():
    with pytest.raises(ValueError):
        lambda_handler(
            VALID_TEST_REQUEST,
            context=Context,
            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
            entropy_check=False,
            config_file=os.path.join(os.path.dirname(__file__), "none"),
        )
Example #3
0
def test_local_request_with_empty_certificate_extensions():
    output = lambda_handler(VALID_TEST_REQUEST, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-with-certificate-extensions-empty.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #4
0
def test_local_request_with_empty_certificate_extensions():
    output = lambda_handler(VALID_TEST_REQUEST, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-with-certificate-extensions-empty.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #5
0
def test_invalid_kmsauth_request():
    output = lambda_handler(VALID_TEST_REQUEST_KMSAUTH, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
def test_invalid_request_with_unallowed_remote():
    output = lambda_handler(INVALID_TEST_KMSAUTH_REQUEST_DIFFERENT_REMOTE_USER, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth-different-remote.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
Example #7
0
def test_local_request_with_multiple_principals():
    output = lambda_handler(VALID_TEST_REQUEST_MULTIPLE_PRINCIPALS, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #8
0
def test_invalid_request_with_unallowed_remote():
    output = lambda_handler(INVALID_TEST_KMSAUTH_REQUEST_DIFFERENT_REMOTE_USER, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth-different-remote.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
Example #9
0
def test_invalid_request_with_multiple_principals():
    output = lambda_handler(INVALID_TEST_REQUEST_MULTIPLE_PRINCIPALS, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #10
0
def test_local_request_with_multiple_principals():
    output = lambda_handler(VALID_TEST_REQUEST_MULTIPLE_PRINCIPALS, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #11
0
def test_invalid_username_request():
    output = lambda_handler(INVALID_TEST_REQUEST_USERNAME_INVALID, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #12
0
def test_invalid_request_with_multiple_principals():
    output = lambda_handler(INVALID_TEST_REQUEST_MULTIPLE_PRINCIPALS, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #13
0
def test_local_request_invalid_pub_key():
    invalid_key_request = {
        "remote_username": "******",
        "public_key_to_sign": EXAMPLE_ED25519_PUBLIC_KEY,
        "command": "ssh user@server",
        "bastion_ip": "127.0.0.1",
        "bastion_user": "******",
        "bastion_user_ip": "127.0.0.1"
    }
    with pytest.raises(TypeError):
        lambda_handler(invalid_key_request,
                       context=Context,
                       ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                       entropy_check=False,
                       config_file=os.path.join(os.path.dirname(__file__),
                                                'bless-test.cfg'))
Example #14
0
def test_invalid_kmsauth_request():
    output = lambda_handler(VALID_TEST_REQUEST_KMSAUTH, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
Example #15
0
def test_invalid_username_request():
    output = lambda_handler(INVALID_TEST_REQUEST_USERNAME_INVALID, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #16
0
def test_local_request_missing_field():
    output = lambda_handler(
        INVALID_TEST_REQUEST_MISSING_FIELD,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), 'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #17
0
def test_invalid_uncompressed_with_bz2(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password': '******',
        'bless_ca_ca_private_key_file': 'tests/aws_lambda/only-use-for-unit-tests.pem',
        'bless_ca_ca_private_key_compression': 'bz2',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    with pytest.raises(OSError):
        lambda_handler(VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD, context=Context,
                       ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                       entropy_check=False,
                       config_file=os.path.join(os.path.dirname(__file__), ''))
Example #18
0
def test_valid_request_with_allowed_remote(mocker):
    mocker.patch("kmsauth.KMSTokenValidator.decrypt_token")
    output = lambda_handler(VALID_TEST_KMSAUTH_REQUEST_DIFFERENT_REMOTE_USER, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth-different-remote.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #19
0
def test_basic_local_unused_kmsauth_request():
    output = lambda_handler(
        VALID_TEST_REQUEST_KMSAUTH,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), 'bless-test.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #20
0
def test_local_request_invalid_pub_key():
    invalid_key_request = {
        "remote_username": "******",
        "public_key_to_sign": EXAMPLE_ED25519_PUBLIC_KEY,
        "command": "ssh user@server",
        "bastion_ip": "127.0.0.1",
        "bastion_user": "******",
        "bastion_user_ip": "127.0.0.1",
    }
    with pytest.raises(TypeError):
        lambda_handler(
            invalid_key_request,
            context=Context,
            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
            entropy_check=False,
            config_file=os.path.join(os.path.dirname(__file__), "bless-test.cfg"),
        )
def test_valid_request_with_allowed_remote(mocker):
    mocker.patch("kmsauth.KMSTokenValidator.decrypt_token")
    output = lambda_handler(VALID_TEST_KMSAUTH_REQUEST_DIFFERENT_REMOTE_USER, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth-different-remote.cfg'))
    assert output['certificate'].startswith('[email protected] ')
Example #22
0
def test_basic_local_request():
    cert = lambda_handler(
        VALID_TEST_REQUEST,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), "bless-test.cfg"),
    )
    assert cert.startswith("[email protected] ")
Example #23
0
def test_basic_local_request_with_wrapper():
    output = lambda_handler(
        VALID_TEST_REQUEST,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), "bless-test.cfg"),
    )
    assert output["certificate"].startswith("[email protected] ")
Example #24
0
def test_invalid_request_with_mismatched_bastion_and_remote():
    '''
    Test default kmsauth behavior, that a bastion_user and remote_usernames must match
    :return: 
    '''
    output = lambda_handler(INVALID_TEST_KMSAUTH_REQUEST_USERNAME_DOESNT_MATCH_REMOTE, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
def test_invalid_request_with_mismatched_bastion_and_remote():
    '''
    Test default kmsauth behavior, that a bastion_user and remote_usernames must match
    :return: 
    '''
    output = lambda_handler(INVALID_TEST_KMSAUTH_REQUEST_USERNAME_DOESNT_MATCH_REMOTE, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
Example #26
0
def test_invalid_uncompressed_with_bz2(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password':
        '******',
        'bless_ca_ca_private_key_file':
        'tests/aws_lambda/only-use-for-unit-tests.pem',
        'bless_ca_ca_private_key_compression': 'bz2',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    with pytest.raises(OSError):
        lambda_handler(
            VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD,
            context=Context,
            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
            entropy_check=False,
            config_file=os.path.join(os.path.dirname(__file__), ''))
Example #27
0
def test_invalid_request_with_allowed_remote_and_not_allowed_iam_group(mocker):
    mocker.patch("kmsauth.KMSTokenValidator.decrypt_token")
    clientmock = mocker.MagicMock()
    clientmock.list_groups_for_user.return_value = {"Groups": [{"GroupName": "ssh-notalloweduser"}]}
    botomock = mocker.patch('boto3.client')
    botomock.return_value = clientmock
    output = lambda_handler(VALID_TEST_KMSAUTH_REQUEST_DIFFERENT_REMOTE_USER, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__),
                                                     'bless-test-kmsauth-iam-group-validation.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
Example #28
0
def test_basic_local_request_blacklisted(monkeypatch):
    extra_environment_variables = {
        'bless_options_remote_usernames_blacklist': 'root|balrog',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(INVALID_TEST_REQUEST_BLACKLISTED_REMOTE_USERNAME, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), 'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #29
0
def test_basic_local_request_blacklisted(monkeypatch):
    extra_environment_variables = {
        'bless_options_remote_usernames_blacklist': 'root|balrog',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(
        INVALID_TEST_REQUEST_BLACKLISTED_REMOTE_USERNAME,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), 'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #30
0
def test_basic_local_username_validation_email_remote_usernames_useradd(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password': '******',
        'bless_ca_ca_private_key_file': 'tests/aws_lambda/only-use-for-unit-tests.pem',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), ''))
    assert output['certificate'].startswith('[email protected] ')
Example #31
0
def test_basic_local_username_validation_email_remote_usernames_useradd(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password': '******',
        'bless_ca_ca_private_key_file': 'tests/aws_lambda/only-use-for-unit-tests.pem',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), ''))
    assert output['certificate'].startswith('[email protected] ')
Example #32
0
def test_basic_ca_private_key_env_bz2(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password': '******',
        'bless_ca_ca_private_key': 'QlpoOTFBWSZTWadq1y0AAD9fgCAQQA7/8D////A////wYAhvr3b709499zXn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LJSxfHjwk4688t2Ymj8E2nwHbsQuagzTCnVnEheSqWCaVahd4uIVRm2i+CeneJc4/VD7HEDj0sdPbXOg+jy8qkUboO60ZiTMk3J2ywaVyVr5TMPQggw21zFpybPNL5x8a41ECJZDM90JQ8EjAWOO9xfnOIcxruEQLa7A4NphTjTcQ4MXg1jfr52OvnK0EYkwmYDTlarVBvOI5bGK7W+8q1ZRyThbDMxNuQZd3/IM8RKFSt9Y7KUYPVSinSpAaegEObwnNpRU+gk5WvA5f4XckU4UJCnatctA==',
        'bless_ca_ca_private_key_compression': 'bz2',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), ''))
    assert output['certificate'].startswith('[email protected] ')
Example #33
0
def test_basic_ca_private_key_env_zlib(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password': '******',
        'bless_ca_ca_private_key': 'eJxtl7XOxYqOhfs8xelzj8J0u3Cywwxddphhh59+/pl63FqyLOtby/a///4FJ8qq+Y/rsf/YrhqyvviPJib/m/gXsLc5/9d/lvK//+D/EU3eTWxfFABB1P5Vp2r+7z+s6P2LoPS/PMf/hycwHGEIikYlVBAonCNRhJYkCRcwiSIoEgB+w3h+RpVdTXl6Rhw5/VxZi8XKgvTzZUqocTd5QJq1dtz6rHKOyVGCuEhfo+4ocCYPwDOSZG3thKq8U6HaSLjU5NVSauoBcmQ3jTpC/8FO2RmKAeEch7WsJlei9GEjtZlbENCan0aJTWLo+aTubI5EkvU6DxNoThKlIWteqS74Q52Z6Jw0SO44el1pgcyNl5htZQfMsVRK9Rmm5cnn6vrjfrZ/i89HKVTeO54Sd09Umz1Fu/zuXUtCEkZY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uyF8KUtBonjFwZyYvmrfEl1ycbYGDlnCNFxgelbJOoIpBzGwaZDHF23DJzmczAcrJBHkOcMcn+zBIq2tso3bP79h+oogslNx+0Deu3gpSiqs0yE6kEB5aBbjRLuH+r1q2+j3bTG0b+MP0pV2Rq/MVOnuW1tnSXR/8fsQMWoQ2bMgqUwedUBhS4IiQkGNC54OukzytOl+W1afsUF8zQsTmhyN1jllxEQpfxAeG7tGb2JJcx/nKHlgRIrjZ85rt49Z8YMIy6zo0b3KZWEbbvcnmiy/Ix6QLMO0tzp3ll4X4UKR1NByn4wTgGSECBknsSXoEpPBQOF+9NFwlqX/mWM1KUetir1HiCb2XXBKhMwgzZ9WGs6FCNwlxIGvMLf2bN7r0uCHS9TXQo9Q6zngNB4fUx40t2xjIVjbi9rfbtTu0T8iBmkrlPz5kLABJZXOUbR+wk3n9NuKEtf3ZBP5rXlAvTJvgY5u9yf+DT4tNSwPxw11wBoDbMfIXlPLBNiO5Hi7GX+jW2prRTid45m8vI3fi/jz7gNdg+jsB9sYP+fEovyeDWEsvs+8wPdLCCfghri6Mw9jKbeXu+j3T+3DIBBC5d5ncGXJb+K5lqm3kYiHpbfocDSX2rzt5v07aW3yC8BJT1B/LOPGTh4NyzPRuuQ7bDP8Wh8+FK09drVfH4Nb9FSEZqwHPccnuZSXdtjlQAGWQ8Ukl8y26ufjhs44mik8QvtyuW6qqC5ngvgN6f3PLESFsTE+pHAeLyS/TZuG/kIPAKcd1FpxwmOKFFmEHVr7OYr++x2wckg3Jim+fdIcyTKKuwuNxnxEiXD4Mtu7LsLGEPB/X4xoCv//d/M/z4BBFQ==',
        'bless_ca_ca_private_key_compression': 'zlib',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), ''))
    assert output['certificate'].startswith('[email protected] ')
Example #34
0
def test_invalid_request_with_allowed_remote_and_not_allowed_iam_group(mocker):
    mocker.patch("kmsauth.KMSTokenValidator.decrypt_token")
    clientmock = mocker.MagicMock()
    clientmock.list_groups_for_user.return_value = {
        "Groups": [{
            "GroupName": "ssh-notalloweduser"
        }]
    }
    botomock = mocker.patch('boto3.client')
    botomock.return_value = clientmock
    output = lambda_handler(
        VALID_TEST_KMSAUTH_REQUEST_DIFFERENT_REMOTE_USER,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(
            os.path.dirname(__file__),
            'bless-test-kmsauth-iam-group-validation.cfg'))
    assert output['errorType'] == 'KMSAuthValidationError'
Example #35
0
def test_basic_ca_private_key_env_bz2(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password':
        '******',
        'bless_ca_ca_private_key':
        'QlpoOTFBWSZTWadq1y0AAD9fgCAQQA7/8D////A////wYAhvr3b709499zXnfbb5333dbobvZ9vvvve9e+d3e9ZiqntTamQwTTaCGp6ZNNGmCnqeA0aCEGVT9mhMmU9GBNTaaaYnoT0MgBMaQqYOninkZMCY1PUMptpkyTU/VPInppgEyjQZVP8TATE0aejI0yEaNMgegmCZIapjKn6ank0fqNGQE0MieCZME0ZGGlP1KPUxVU/yMRqPQmmU8ApsE01T2BMmp4SbUmm0EACITlGJPkAA72rrnlOel4E7KfRSXbkjUxZ3d06nQ7lyxcbem0o5sL6PykCQKgNYeUMx+oIVrb8kV2vUU7sXpuM5c2PP3iELdRPcwYdeQvgJu8VYAfSIO4ISJN+dP31H1z/o6w+oBe4/dvmHwhM5ixIfNLkGxwBWz5Rm/kam1XX4Lpfr4zZh39Nw69G6GPq6POEIO02v34m3J0Zm1F8mn5sc4X28E1v7lfSop4VgCPltGwK10SPaAbxtBnHtmzDH/MHUHqUtGiZn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JidTbxyl2SpBJcBWKw8+AdT7NJGxlt1jSbfICOi7y2K61oSZDX69NiBXjc16VodRVtV/u5F/J/Hk7zrRbrYkd144ZLTHy45dipqiSfu2zAswPk1iuYFAPtiFJfC3Y71mQUIW2kmUBjZPBbf7T7CTO+YlgbSMJRww/VfeuzE1YrjrbcRoxQQr0ugQtx708PpgfEfIGtZAkETNBHW4CULBOQWY2uCzKV7o5EH0MxwGOvU30rosaov2sI2JAxdsV4moBlw5WWmdrN+LqKNcm87MBSxl7nc35s7rPHXnfC9jG+2AUB0yJDXJb8ly2XWqcpGxF13cz/RwC47r8lt9LNA/hJC1+YsoJK5cJo8+5KT8WFyQhNm7mMlfeai6IypNi/8cff92PZpapqZSdKkoT0kMT+3ETf5CWzIaMWB2xFY0gaQt51+bdqKbl0olo8qUY5rpGoVUlU7xWAMKLDovD7qadMJ4boR3+WEekP4XOKvw4iHrOoEx1bgCuDEkRSCFx4fc9x1uORdUVUYi3Xg+cOC17TR/adYaskkfdOidCnpde9OULUzpjXfwisVvD4FdfK6Pqwo4V4NF0NYPFrJg+iIHPLvG8WU4yOCXhKLJSxfHjwk4688t2Ymj8E2nwHbsQuagzTCnVnEheSqWCaVahd4uIVRm2i+CeneJc4/VD7HEDj0sdPbXOg+jy8qkUboO60ZiTMk3J2ywaVyVr5TMPQggw21zFpybPNL5x8a41ECJZDM90JQ8EjAWOO9xfnOIcxruEQLa7A4NphTjTcQ4MXg1jfr52OvnK0EYkwmYDTlarVBvOI5bGK7W+8q1ZRyThbDMxNuQZd3/IM8RKFSt9Y7KUYPVSinSpAaegEObwnNpRU+gk5WvA5f4XckU4UJCnatctA==',
        'bless_ca_ca_private_key_compression': 'bz2',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(
        VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), ''))
    assert output['certificate'].startswith('[email protected] ')
Example #36
0
def test_basic_ca_private_key_env_zlib(monkeypatch):
    extra_environment_variables = {
        'bless_ca_default_password':
        '******',
        'bless_ca_ca_private_key':
        'eJxtl7XOxYqOhfs8xelzj8J0u3Cywwxddphhh59+/pl63FqyLOtby/a///4FJ8qq+Y/rsf/YrhqyvviPJib/m/gXsLc5/9d/lvK//+D/EU3eTWxfFABB1P5Vp2r+7z+s6P2LoPS/PMf/hycwHGEIikYlVBAonCNRhJYkCRcwiSIoEgB+w3h+RpVdTXl6Rhw5/VxZi8XKgvTzZUqocTd5QJq1dtz6rHKOyVGCuEhfo+4ocCYPwDOSZG3thKq8U6HaSLjU5NVSauoBcmQ3jTpC/8FO2RmKAeEch7WsJlei9GEjtZlbENCan0aJTWLo+aTubI5EkvU6DxNoThKlIWteqS74Q52Z6Jw0SO44el1pgcyNl5htZQfMsVRK9Rmm5cnn6vrjfrZ/i89HKVTeO54Sd09Umz1Fu/zuXUtCEkZYF5t9IUU3LfEZ8MZ2qPpRxb7Xt5nSRctxuBfkX+V/rStY2WipNZWUJ1/WaFk3kUA57o+/qdPupJAvfgGGuXDNrj/CStoJ+fREroqsBoaRAR3Gb4TiXMAxNNljqNK6SbK+wwc2YNa9eaixC7YG7FdSX0jc6s8MBp1mxiF5yaQAo1j0ewmxRUs6TjXcOX+cmVz2qa22gBP3x4J6LBafGUg7Lb8/HkkyZODpu2126ZU1zgFeRBiY807sfQKlp7mY/vW1X527ofDYCd/jen1Q3hIYxQkT5iPWnJeC0DbGfz2Yt7aXTtP8jduPOZhBVFnQp0FZf6kNFsxiRzLCEmTK0jElYIXTGY16cMZ/lPApZxLOQdJ+Te5ZwhnlZINmLf2noQxLoWx7Xl8VlQP6pXad29ZXYgCYNRMWBDVfoyuRtcmRtUtJid95BdcfAfqGJ3rfAQ6ZtCkPq3bX34SPV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rXlAvTJvgY5u9yf+DT4tNSwPxw11wBoDbMfIXlPLBNiO5Hi7GX+jW2prRTid45m8vI3fi/jz7gNdg+jsB9sYP+fEovyeDWEsvs+8wPdLCCfghri6Mw9jKbeXu+j3T+3DIBBC5d5ncGXJb+K5lqm3kYiHpbfocDSX2rzt5v07aW3yC8BJT1B/LOPGTh4NyzPRuuQ7bDP8Wh8+FK09drVfH4Nb9FSEZqwHPccnuZSXdtjlQAGWQ8Ukl8y26ufjhs44mik8QvtyuW6qqC5ngvgN6f3PLESFsTE+pHAeLyS/TZuG/kIPAKcd1FpxwmOKFFmEHVr7OYr++x2wckg3Jim+fdIcyTKKuwuNxnxEiXD4Mtu7LsLGEPB/X4xoCv//d/M/z4BBFQ==',
        'bless_ca_ca_private_key_compression': 'zlib',
        'bless_options_username_validation': 'email',
        'bless_options_remote_usernames_validation': 'useradd',
    }

    for k, v in extra_environment_variables.items():
        monkeypatch.setenv(k, v)

    output = lambda_handler(
        VALID_TEST_REQUEST_USERNAME_VALIDATION_EMAIL_REMOTE_USERNAMES_USERADD,
        context=Context,
        ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
        entropy_check=False,
        config_file=os.path.join(os.path.dirname(__file__), ''))
    assert output['certificate'].startswith('[email protected] ')
Example #37
0
def test_user_request(mock_func):
    bless_lambda.lambda_handler(USER_REQUEST)
    mock_func.assert_called()
Example #38
0
def test_host_request(mock_func):
    bless_lambda.lambda_handler(HOST_REQUEST)
    mock_func.assert_called()
Example #39
0
def test_local_request_missing_field():
    output = lambda_handler(INVALID_TEST_REQUEST_MISSING_FIELD, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), 'bless-test.cfg'))
    assert output['errorType'] == 'InputValidationError'
Example #40
0
def test_basic_local_unused_kmsauth_request():
    output = lambda_handler(VALID_TEST_REQUEST_KMSAUTH, context=Context,
                            ca_private_key_password=RSA_CA_PRIVATE_KEY_PASSWORD,
                            entropy_check=False,
                            config_file=os.path.join(os.path.dirname(__file__), 'bless-test.cfg'))
    assert output['certificate'].startswith('[email protected] ')