Skip to content

refactor: remove encryption_config property from Backup #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions google/cloud/spanner_v1/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ def encryption_info(self):
"""
return self._encryption_info

@property
def encryption_config(self):
"""Encryption config for this database.
:rtype: :class:`~google.cloud.spanner_admin_instance_v1.types.CreateBackupEncryptionConfig`
:returns: an object representing the encryption config for this database
"""
return self._encryption_config

@classmethod
def from_pb(cls, backup_pb, instance):
"""Create an instance of this class from a protobuf message.
Expand Down Expand Up @@ -245,9 +237,9 @@ def create(self):
if not self._database:
raise ValueError("database not set")
if (
self.encryption_config
and self.encryption_config.kms_key_name
and self.encryption_config.encryption_type
self._encryption_config
and self._encryption_config.kms_key_name
and self._encryption_config.encryption_type
!= CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION
):
raise ValueError("kms_key_name only used with CUSTOMER_MANAGED_ENCRYPTION")
Expand Down
6 changes: 5 additions & 1 deletion tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ def test_backup_workflow(self):
from google.cloud.spanner_admin_database_v1 import (
CreateBackupEncryptionConfig,
EncryptionConfig,
EncryptionInfo,
RestoreDatabaseEncryptionConfig,
)
from datetime import datetime
Expand Down Expand Up @@ -780,7 +781,10 @@ def test_backup_workflow(self):
self.assertEqual(self.database_version_time, backup.version_time)
self.assertIsNotNone(backup.size_bytes)
self.assertIsNotNone(backup.state)
self.assertEqual(encryption_config, backup.encryption_config)
self.assertEqual(
EncryptionInfo.Type.GOOGLE_DEFAULT_ENCRYPTION,
backup.encryption_info.encryption_type,
)

# Update with valid argument.
valid_expire_time = datetime.utcnow() + timedelta(days=7)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_ctor_non_defaults(self):
self.assertEqual(backup._database, self.DATABASE_NAME)
self.assertIsNotNone(backup._expire_time)
self.assertIs(backup._expire_time, timestamp)
self.assertEqual(backup.encryption_config, encryption_config)
self.assertEqual(backup._encryption_config, encryption_config)

def test_ctor_w_encryption_config_dict(self):
from google.cloud.spanner_admin_database_v1 import CreateBackupEncryptionConfig
Expand All @@ -107,7 +107,7 @@ def test_ctor_w_encryption_config_dict(self):
self.assertEqual(backup._database, self.DATABASE_NAME)
self.assertIsNotNone(backup._expire_time)
self.assertIs(backup._expire_time, timestamp)
self.assertEqual(backup.encryption_config, expected_encryption_config)
self.assertEqual(backup._encryption_config, expected_encryption_config)

def test_from_pb_project_mismatch(self):
from google.cloud.spanner_admin_database_v1 import Backup
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_encryption_config_property(self):
encryption_type=CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION,
kms_key_name="kms_key_name",
)
self.assertEqual(backup.encryption_config, expected)
self.assertEqual(backup._encryption_config, expected)

def test_create_grpc_error(self):
from google.api_core.exceptions import GoogleAPICallError
Expand Down