Skip to content

Commit

Permalink
Merge pull request #3167 from jingyih/bqcc
Browse files Browse the repository at this point in the history
mock: fix service account ID in connection mock
  • Loading branch information
google-oss-prow[bot] authored Nov 14, 2024
2 parents d486b9f + 21f6e1e commit ae288b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions mockgcp/mockbigqueryconnection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ func (s *ConnectionV1) CreateConnection(ctx context.Context, req *pb.CreateConne
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return fmt.Sprintf("bqcx-%s-%[email protected]", req.GetParent(), string(b))
return fmt.Sprintf("bqcx-%s-%[email protected]", strconv.FormatInt(name.Project.Number, 10), string(b))
}

buildPrimaryServiceAccountId := func() string {
return fmt.Sprintf("service-%[email protected]", req.GetParent())
return fmt.Sprintf("service-%[email protected]", strconv.FormatInt(name.Project.Number, 10))
}

buildGoogleIdentity := func() string {
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,13 @@ func normalizeHTTPResponses(t *testing.T, events test.LogEntries) {
visitor.ReplacePath(".settings.settingsVersion", "123")
}

// BigQueryConnection
{
visitor.ReplacePath(".cloudResource.serviceAccountId", "bqcx-${projectNumber}[email protected]")
visitor.ReplacePath(".creationTime", "123456789")
visitor.ReplacePath(".lastModifiedTime", "123456789")
}

// Run visitors
events.PrettifyJSON(func(obj map[string]any) {
if err := visitor.visitMap(obj, ""); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ X-Xss-Protection: 0

{
"cloudResource": {
"serviceAccountId": "bqcx-projects/${projectId}/locations/us-central1-reVy@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
"serviceAccountId": "bqcx-${projectNumber}-abcd@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
},
"creationTime": "1731379730",
"creationTime": "123456789",
"description": "BigQueryConnection Connection resource for acquisition",
"lastModifiedTime": "1731379730",
"lastModifiedTime": "123456789",
"name": "projects/${projectNumber}/locations/us-central1/connections/test-bqcc-acquisition"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ X-Xss-Protection: 0

{
"cloudResource": {
"serviceAccountId": "bqcx-projects/${projectId}/locations/us-central1-reVy@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
"serviceAccountId": "bqcx-${projectNumber}-abcd@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
},
"creationTime": "1731379730",
"creationTime": "123456789",
"description": "BigQueryConnection Connection resource for acquisition",
"lastModifiedTime": "1731379730",
"lastModifiedTime": "123456789",
"name": "projects/${projectNumber}/locations/us-central1/connections/test-bqcc-acquisition"
}

Expand All @@ -44,11 +44,11 @@ X-Xss-Protection: 0

{
"cloudResource": {
"serviceAccountId": "bqcx-projects/${projectId}/locations/us-central1-reVy@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
"serviceAccountId": "bqcx-${projectNumber}-abcd@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
},
"creationTime": "1731379730",
"creationTime": "123456789",
"description": "BigQueryConnection Connection resource for acquisition",
"lastModifiedTime": "1731379730",
"lastModifiedTime": "123456789",
"name": "projects/${projectNumber}/locations/us-central1/connections/test-bqcc-acquisition"
}

Expand All @@ -72,11 +72,11 @@ X-Xss-Protection: 0

{
"cloudResource": {
"serviceAccountId": "bqcx-projects/${projectId}/locations/us-central1-reVy@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
"serviceAccountId": "bqcx-${projectNumber}-abcd@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
},
"creationTime": "1731379730",
"creationTime": "123456789",
"description": "BigQueryConnection Connection resource for acquisition",
"lastModifiedTime": "1731379730",
"lastModifiedTime": "123456789",
"name": "projects/${projectNumber}/locations/us-central1/connections/test-bqcc-acquisition"
}

Expand Down Expand Up @@ -106,11 +106,11 @@ X-Xss-Protection: 0

{
"cloudResource": {
"serviceAccountId": "bqcx-projects/${projectId}/locations/us-central1-reVy@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
"serviceAccountId": "bqcx-${projectNumber}-abcd@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
},
"creationTime": "1731379730",
"creationTime": "123456789",
"description": "BigQueryConnection Connection resource for acquisition with updated description",
"lastModifiedTime": "1731379731",
"lastModifiedTime": "123456789",
"name": "projects/${projectNumber}/locations/us-central1/connections/test-bqcc-acquisition"
}

Expand All @@ -134,10 +134,10 @@ X-Xss-Protection: 0

{
"cloudResource": {
"serviceAccountId": "bqcx-projects/${projectId}/locations/us-central1-reVy@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
"serviceAccountId": "bqcx-${projectNumber}-abcd@gcp-sa-bigquery-condel.iam.gserviceaccount.com"
},
"creationTime": "1731379730",
"creationTime": "123456789",
"description": "BigQueryConnection Connection resource for acquisition with updated description",
"lastModifiedTime": "1731379731",
"lastModifiedTime": "123456789",
"name": "projects/${projectNumber}/locations/us-central1/connections/test-bqcc-acquisition"
}

0 comments on commit ae288b9

Please sign in to comment.