Skip to content
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

test:add a scenario test for unset fields in bigquerydataset #3329

Merged
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
4 changes: 4 additions & 0 deletions tests/e2e/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func normalizeKRMObject(t *testing.T, u *unstructured.Unstructured, project test
visitor.replacePaths[".status.ipAddress"] = "10.1.2.3"
visitor.replacePaths[".status.outboundPublicIpAddresses"] = []string{"6.6.6.6", "8.8.8.8"}

// Specific to CloudKMS
visitor.replacePaths[".primary.createTime"] = "2024-04-01T12:34:56.123456Z"
visitor.replacePaths[".primary.generateTime"] = "2024-04-01T12:34:56.123456Z"

// Specific to BigQuery
visitor.replacePaths[".spec.access[].userByEmail"] = "[email protected]"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
kind: BigQueryDataset
metadata:
annotations:
cnrm.cloud.google.com/delete-contents-on-destroy: "false"
labels:
managed-by-cnrm: "true"
name: bigquerydataset${uniqueId}
spec:
access:
- role: OWNER
specialGroup: projectOwners
defaultCollation: und:ci
defaultEncryptionConfiguration:
kmsKeyRef:
external: projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}
defaultPartitionExpirationMs: 3600000
defaultTableExpirationMs: 3600000
description: Fully Configured BigQuery Dataset
friendlyName: bigquerydataset-fullyconfigured
isCaseInsensitive: true
location: US
maxTimeTravelHours: "72"
projectRef:
external: ${projectId}
resourceID: bigquerydataset${uniqueId}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
kind: BigQueryDataset
metadata:
annotations:
cnrm.cloud.google.com/delete-contents-on-destroy: "false"
labels:
managed-by-cnrm: "true"
name: bigquerydataset${uniqueId}
spec:
access:
- role: OWNER
specialGroup: projectOwners
defaultCollation: und:ci
defaultEncryptionConfiguration:
kmsKeyRef:
external: projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}
defaultPartitionExpirationMs: 3600000
defaultTableExpirationMs: 3600000
description: Fully Configured BigQuery Dataset unset
friendlyName: bigquerydataset-fullyconfigured
isCaseInsensitive: true
location: US
maxTimeTravelHours: "72"
projectRef:
external: ${projectId}
resourceID: bigquerydataset${uniqueId}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
kind: BigQueryDataset
metadata:
annotations:
cnrm.cloud.google.com/delete-contents-on-destroy: "false"
labels:
managed-by-cnrm: "true"
name: bigquerydataset${uniqueId}
spec:
access:
- role: OWNER
specialGroup: projectOwners
defaultCollation: und:ci
defaultEncryptionConfiguration:
kmsKeyRef:
external: projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}
defaultPartitionExpirationMs: 3600000
defaultTableExpirationMs: 3600000
description: Fully Configured BigQuery Dataset set
friendlyName: bigquerydataset
isCaseInsensitive: true
location: US
maxTimeTravelHours: "72"
projectRef:
external: ${projectId}
resourceID: bigquerydataset${uniqueId}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

404 Not Found
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"error": {
"code": 404,
"message": "KeyRing projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId} not found.",
"status": "NOT_FOUND"
}
}

---

POST https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings?alt=json&keyRingId=kmskeyring-${uniqueId}
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"createTime": "2024-04-01T12:34:56.123456Z",
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}"
}

---

GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"createTime": "2024-04-01T12:34:56.123456Z",
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}"
}

---

GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"createTime": "2024-04-01T12:34:56.123456Z",
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

404 Not Found
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"error": {
"code": 404,
"message": "CryptoKey projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId} not found.",
"status": "NOT_FOUND"
}
}

---

POST https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys?alt=json&cryptoKeyId=kmscryptokey-${uniqueId}&skipInitialVersionCreation=false
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

{
"labels": {
"key-one": "value-one",
"managed-by-cnrm": "true"
},
"purpose": "ENCRYPT_DECRYPT"
}

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"createTime": "2024-04-01T12:34:56.123456Z",
"destroyScheduledDuration": "2592000s",
"labels": {
"key-one": "value-one",
"managed-by-cnrm": "true"
},
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}",
"primary": {
"algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
"createTime": "2024-04-01T12:34:56.123456Z",
"generateTime": "2024-04-01T12:34:56.123456Z",
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}/cryptoKeyVersions/1",
"protectionLevel": "SOFTWARE",
"state": "ENABLED"
},
"purpose": "ENCRYPT_DECRYPT",
"versionTemplate": {
"algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
"protectionLevel": "SOFTWARE"
}
}

---

GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"createTime": "2024-04-01T12:34:56.123456Z",
"destroyScheduledDuration": "2592000s",
"labels": {
"key-one": "value-one",
"managed-by-cnrm": "true"
},
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}",
"primary": {
"algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
"createTime": "2024-04-01T12:34:56.123456Z",
"generateTime": "2024-04-01T12:34:56.123456Z",
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}/cryptoKeyVersions/1",
"protectionLevel": "SOFTWARE",
"state": "ENABLED"
},
"purpose": "ENCRYPT_DECRYPT",
"versionTemplate": {
"algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
"protectionLevel": "SOFTWARE"
}
}

---

GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"createTime": "2024-04-01T12:34:56.123456Z",
"destroyScheduledDuration": "2592000s",
"labels": {
"key-one": "value-one",
"managed-by-cnrm": "true"
},
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}",
"primary": {
"algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
"createTime": "2024-04-01T12:34:56.123456Z",
"generateTime": "2024-04-01T12:34:56.123456Z",
"name": "projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}/cryptoKeyVersions/1",
"protectionLevel": "SOFTWARE",
"state": "ENABLED"
},
"purpose": "ENCRYPT_DECRYPT",
"versionTemplate": {
"algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
"protectionLevel": "SOFTWARE"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
POST https://serviceusage.googleapis.com/v1beta1/projects/${projectId}/services/bigquery.googleapis.com:generateServiceIdentity?alt=json
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"done": true,
"name": "operations/${operationID}",
"response": {
"@type": "type.googleapis.com/mockgcp.api.serviceusage.v1beta1.ServiceIdentity",
"email": "bq-${projectNumber}@bigquery-encryption.iam.gserviceaccount.com",
"uniqueId": "12345678"
}
}
Loading
Loading