def test_upload_blob_with_kms(): with tempfile.NamedTemporaryFile() as source_file: source_file.write(b"test") storage_upload_with_kms_key.upload_blob_with_kms( BUCKET, source_file.name, "test_upload_blob_encrypted", KMS_KEY) bucket = storage.Client().bucket(BUCKET) kms_blob = bucket.get_blob("test_upload_blob_encrypted") assert kms_blob.kms_key_name.startswith(KMS_KEY)
def test_object_get_kms_key(test_bucket): with tempfile.NamedTemporaryFile() as source_file: storage_upload_with_kms_key.upload_blob_with_kms( test_bucket.name, source_file.name, "test_upload_blob_encrypted", KMS_KEY) kms_key = storage_object_get_kms_key.object_get_kms_key( test_bucket.name, "test_upload_blob_encrypted") assert kms_key.startswith(KMS_KEY)