def test_decrypt_all_encrypted(self, kms_stub): obj = EnvironmentDict( TREEHUGGER_APP='foo', TREEHUGGER_STAGE='bar', baz=Encrypted(base64.b64encode(b'qux').decode('utf-8')), corge=ToEncrypt('grault'), ) kms_stub.add_response( 'decrypt', expected_params={ 'CiphertextBlob': b'qux', 'EncryptionContext': { 'treehugger_app': 'foo', 'treehugger_key': 'baz', 'treehugger_stage': 'bar', } }, service_response={ 'KeyId': 'treehugger', 'Plaintext': b'quux', } ) assert obj.decrypt_all_encrypted() == EnvironmentDict( TREEHUGGER_APP='foo', TREEHUGGER_STAGE='bar', baz=ToEncrypt('quux'), corge=ToEncrypt('grault'), )
def test_remove_all_encrypted(self): obj = EnvironmentDict( TREEHUGGER_APP='foo', TREEHUGGER_STAGE='bar', baz=ToEncrypt('qux'), corge=Encrypted('grault'), ) assert obj.remove_all_encrypted() == EnvironmentDict( TREEHUGGER_APP='foo', TREEHUGGER_STAGE='bar', baz=ToEncrypt('qux'), )
def test_to_yaml_dict_success_to_encrypt(self): obj = EnvironmentDict(foo=ToEncrypt('bar')) assert obj.to_yaml_dict() == {'foo': {'to_encrypt': 'bar'}}
def test_from_yaml_dict_success_to_encrypt(self): obj = EnvironmentDict.from_yaml_dict({'foo': {'to_encrypt': 'foo'}}) assert obj == EnvironmentDict({'foo': ToEncrypt('foo')})