def test_lazy_kms_client(self): self.mock_kms_client.encrypt.return_value = dict( CiphertextBlob=self.ciphertext_blob) ciphertext, decrypt_params = kms.encrypt('a', 'region1', 'key1') self.boto3_client.assert_called_with('kms', region_name='region1') ciphertext, decrypt_params = kms.encrypt('a', 'region2', 'key2') self.boto3_client.assert_called_with('kms', region_name='region2') self.boto3_client.reset_mock() ciphertext, decrypt_params = kms.encrypt('a', 'region1', 'key1') self.boto3_client.assert_not_called()
def test_lazy_kms_client(self): self.mock_kms_client.encrypt.return_value = dict(CiphertextBlob=self.ciphertext_blob) ciphertext, decrypt_params = kms.encrypt('a', 'region1', 'key1') self.boto3_client.assert_called_with( 'kms', region_name='region1' ) ciphertext, decrypt_params = kms.encrypt('a', 'region2', 'key2') self.boto3_client.assert_called_with( 'kms', region_name='region2' ) self.boto3_client.reset_mock() ciphertext, decrypt_params = kms.encrypt('a', 'region1', 'key1') self.boto3_client.assert_not_called()
def test_encrypt(self): self.mock_kms_client.encrypt.return_value = dict( CiphertextBlob=self.ciphertext_blob) ciphertext, decrypt_params = kms.encrypt(self.plaintext, self.region, self.key) self.boto3_client.assert_called_with('kms', region_name=self.region) self.mock_kms_client.encrypt.assert_called_with( KeyId=self.key, Plaintext=self.plaintext_bytes) self.assertEqual(ciphertext, self.ciphertext) self.assertEqual(decrypt_params, dict(region=self.region))
def test_encrypt(self): self.mock_kms_client.encrypt.return_value = dict(CiphertextBlob=self.ciphertext_blob) ciphertext, decrypt_params = kms.encrypt(self.plaintext, self.region, self.key) self.boto3_client.assert_called_with( 'kms', region_name=self.region ) self.mock_kms_client.encrypt.assert_called_with( KeyId=self.key, Plaintext=self.plaintext_bytes ) self.assertEqual(ciphertext, self.ciphertext) self.assertEqual(decrypt_params, dict(region=self.region))