예제 #1
0
def test_is_aws_keys_setup(tmp_path):
    # Mock default configuration
    ConfigService.init_default_config()
    mongo.db = MockObject()
    mongo.db.config = MockObject()
    ConfigService.encrypt_config(ConfigService.default_config)
    mongo.db.config.find_one = MagicMock(return_value=ConfigService.default_config)
    assert not is_aws_keys_setup()

    bogus_key_value = get_datastore_encryptor().encrypt("bogus_aws_key")
    dpath.util.set(
        ConfigService.default_config, AWS_KEYS_PATH + ["aws_secret_access_key"], bogus_key_value
    )
    dpath.util.set(
        ConfigService.default_config, AWS_KEYS_PATH + ["aws_access_key_id"], bogus_key_value
    )

    assert is_aws_keys_setup()
예제 #2
0
def test_is_aws_keys_setup():
    # Mock default configuration
    ConfigService.init_default_config()
    mongo.db = MockObject()
    mongo.db.config = MockObject()
    ConfigService.encrypt_config(ConfigService.default_config)
    mongo.db.config.find_one = MagicMock(
        return_value=ConfigService.default_config)
    assert not is_aws_keys_setup()

    # Make sure noone changed config path and broke this function
    bogus_key_value = encryptor.encryptor.enc('bogus_aws_key')
    dpath.util.set(ConfigService.default_config,
                   AWS_KEYS_PATH + ['aws_secret_access_key'], bogus_key_value)
    dpath.util.set(ConfigService.default_config,
                   AWS_KEYS_PATH + ['aws_access_key_id'], bogus_key_value)

    assert is_aws_keys_setup()