Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#3184 from xiaoweim/fix-testCre…
Browse files Browse the repository at this point in the history
…ateNoChangeUpdateDelete-bigquery

fix:TestCreateNoChangeUpdateDelete/bigquery
  • Loading branch information
google-oss-prow[bot] authored Nov 18, 2024
2 parents 7411838 + 44819e1 commit 8df6b85
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 26 deletions.
3 changes: 3 additions & 0 deletions mockgcp/mockserviceusage/serviceusagev1beta1.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func (s *ServiceUsageV1Beta1) GenerateServiceIdentity(ctx context.Context, req *
case "secretmanager.googleapis.com":
identity.Email = "service-" + strconv.FormatInt(name.Project.Number, 10) + "@gcp-sa-secretmanager.iam.gserviceaccount.com"
identity.UniqueId = "123456789006"
case "bigquery.googleapis.com":
identity.Email = "bq-" + strconv.FormatInt(name.Project.Number, 10) + "@bigquery-encryption.iam.gserviceaccount.com"
identity.UniqueId = "123456789007"
default:
return nil, fmt.Errorf("generating serviceIdentity for service %q not implemented in mock", name.ServiceName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,33 @@ X-Xss-Protection: 0

---

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"
}
}

---

GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}:getIamPolicy?alt=json&options.requestedPolicyVersion=3&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

Expand Down Expand Up @@ -276,7 +303,7 @@ X-Xss-Protection: 0

---

GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

404 Not Found
Expand Down Expand Up @@ -312,7 +339,7 @@ Content-Type: application/json
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

{
"accountId": "bigquerydataset-dep",
"accountId": "iamsa-${uniqueId}",
"serviceAccount": {}
}

Expand All @@ -328,17 +355,17 @@ X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"email": "bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"email": "iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"etag": "abcdef0123A=",
"name": "projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"name": "projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"oauth2ClientId": "888888888888888888888",
"projectId": "${projectId}",
"uniqueId": "111111111111111111111"
}

---

GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Expand All @@ -353,9 +380,9 @@ X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"email": "bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"email": "iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"etag": "abcdef0123A=",
"name": "projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"name": "projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"oauth2ClientId": "888888888888888888888",
"projectId": "${projectId}",
"uniqueId": "111111111111111111111"
Expand Down Expand Up @@ -777,7 +804,7 @@ X-Xss-Protection: 0

---

GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Expand All @@ -792,17 +819,17 @@ X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"email": "bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"email": "iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"etag": "abcdef0123A=",
"name": "projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"name": "projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"oauth2ClientId": "888888888888888888888",
"projectId": "${projectId}",
"uniqueId": "111111111111111111111"
}

---

DELETE https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
DELETE https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ spec:
keyRingRef:
name: kmskeyring-${uniqueId}
---
apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
kind: ServiceIdentity
metadata:
name: serviceidentity-${uniqueId}
annotations:
cnrm.cloud.google.com/deletion-policy: "abandon"
spec:
projectRef:
external: ${projectId}
resourceID: bigquery.googleapis.com
---
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicy
metadata:
Expand All @@ -50,4 +61,4 @@ kind: IAMServiceAccount
metadata:
annotations:
cnrm.cloud.google.com/project-id: "${projectId}"
name: bigquerydataset-dep
name: iamsa-${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ spec:
- role: READER
domain: google.com
- role: OWNER
userByEmail: bigquerydataset-dep@${projectId}.iam.gserviceaccount.com
userByEmail: iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com
storageBillingModel: LOGICAL
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,33 @@ X-Xss-Protection: 0

---

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"
}
}

---

GET https://cloudkms.googleapis.com/v1/projects/${projectId}/locations/us/keyRings/kmskeyring-${uniqueId}/cryptoKeys/kmscryptokey-${uniqueId}:getIamPolicy?alt=json&options.requestedPolicyVersion=3&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

Expand Down Expand Up @@ -276,7 +303,7 @@ X-Xss-Protection: 0

---

GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

404 Not Found
Expand Down Expand Up @@ -312,7 +339,7 @@ Content-Type: application/json
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

{
"accountId": "bigquerydataset-dep",
"accountId": "iamsa-${uniqueId}",
"serviceAccount": {}
}

Expand All @@ -328,17 +355,17 @@ X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"email": "bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"email": "iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"etag": "abcdef0123A=",
"name": "projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"name": "projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"oauth2ClientId": "888888888888888888888",
"projectId": "${projectId}",
"uniqueId": "111111111111111111111"
}

---

GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Expand All @@ -353,9 +380,9 @@ X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"email": "bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"email": "iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"etag": "abcdef0123A=",
"name": "projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"name": "projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"oauth2ClientId": "888888888888888888888",
"projectId": "${projectId}",
"uniqueId": "111111111111111111111"
Expand Down Expand Up @@ -698,7 +725,7 @@ X-Xss-Protection: 0

---

GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
GET https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Expand All @@ -713,17 +740,17 @@ X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"email": "bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"email": "iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"etag": "abcdef0123A=",
"name": "projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com",
"name": "projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com",
"oauth2ClientId": "888888888888888888888",
"projectId": "${projectId}",
"uniqueId": "111111111111111111111"
}

---

DELETE https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/bigquerydataset-dep@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
DELETE https://iam.googleapis.com/v1/projects/${projectId}/serviceAccounts/iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ spec:
keyRingRef:
name: kmskeyring-${uniqueId}
---
apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
kind: ServiceIdentity
metadata:
name: serviceidentity-${uniqueId}
annotations:
cnrm.cloud.google.com/deletion-policy: "abandon"
spec:
projectRef:
external: ${projectId}
resourceID: bigquery.googleapis.com
---
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicy
metadata:
Expand All @@ -48,4 +59,4 @@ kind: IAMServiceAccount
metadata:
annotations:
cnrm.cloud.google.com/project-id: "${projectId}"
name: bigquerydataset-dep
name: iamsa-${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ spec:
- role: READER
domain: google.com
- role: OWNER
userByEmail: bigquerydataset-dep@${projectId}.iam.gserviceaccount.co
userByEmail: iamsa-${uniqueId}@${projectId}.iam.gserviceaccount.com
storageBillingModel: LOGICAL

0 comments on commit 8df6b85

Please sign in to comment.