def test_encrypt_data_key(self, mock_wrapped_serialize): test_master_key = RawMasterKey( key_id=VALUES['wrapped_keys']['raw']['key_info'], provider_id=VALUES['provider_id'], wrapping_key=self.mock_wrapping_key) test = test_master_key._encrypt_data_key( data_key=self.mock_data_key, algorithm=sentinel.algorithm, encryption_context=sentinel.encryption_context) self.mock_wrapping_key.encrypt.assert_called_once_with( plaintext_data_key=VALUES['data_key'], encryption_context=sentinel.encryption_context) mock_wrapped_serialize.assert_called_once_with( key_provider=test_master_key.key_provider, wrapping_algorithm=self.mock_wrapping_algorithm, wrapping_key_id=VALUES['wrapped_keys']['raw']['key_info'], encrypted_wrapped_key=sentinel.encrypted_data) assert test is sentinel.wrapped_key
def test_encrypt_data_key(self, mock_wrapped_serialize): test_master_key = RawMasterKey( key_id=VALUES["wrapped_keys"]["raw"]["key_info"], provider_id=VALUES["provider_id"], wrapping_key=self.mock_wrapping_key, ) test = test_master_key._encrypt_data_key( data_key=self.mock_data_key, algorithm=sentinel.algorithm, encryption_context=sentinel.encryption_context) self.mock_wrapping_key.encrypt.assert_called_once_with( plaintext_data_key=VALUES["data_key"], encryption_context=sentinel.encryption_context) mock_wrapped_serialize.assert_called_once_with( key_provider=test_master_key.key_provider, wrapping_algorithm=self.mock_wrapping_algorithm, wrapping_key_id=VALUES["wrapped_keys"]["raw"]["key_info"], encrypted_wrapped_key=sentinel.encrypted_data, ) assert test is sentinel.wrapped_key