Skip to content

Commit

Permalink
E2E tests - Fix Google Auth (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
FranBarrera committed Jul 21, 2023
1 parent cdc1c4d commit 646e63d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions test/e2e/sources/googlecloudauditlogs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var _ = Describe("Google Cloud Audit Logs source", func() {
)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(
`"spec.serviceAccountKey" must validate one and only one schema (oneOf).`))
`"spec.auth.serviceAccountKey" must validate one and only one schema (oneOf).`))
})
})
})
Expand Down Expand Up @@ -291,8 +291,8 @@ func withServiceAccountKey(key string) sourceOption {
}

return func(src *unstructured.Unstructured) {
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.serviceAccountKey field: %s", err)
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "auth", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.auth.serviceAccountKey field: %s", err)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/sources/googlecloudpubsub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ var _ = Describe("Google Cloud Pub/Sub source", func() {
)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(
`"spec.serviceAccountKey" must validate one and only one schema (oneOf).`))
`"spec.auth.serviceAccountKey" must validate one and only one schema (oneOf).`))
})
})
})
Expand Down Expand Up @@ -297,8 +297,8 @@ func withServiceAccountKey(key string) sourceOption {
}

return func(src *unstructured.Unstructured) {
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.serviceAccountKey field: %s", err)
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "auth", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.auth.serviceAccountKey field: %s", err)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/sources/googlecloudsourcerepositories/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ var _ = Describe("Google Cloud Source Repositories source", func() {
)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(
`"spec.serviceAccountKey" must validate one and only one schema (oneOf).`))
`"spec.auth.serviceAccountKey" must validate one and only one schema (oneOf).`))
})
})
})
Expand Down Expand Up @@ -263,8 +263,8 @@ func withServiceAccountKey(key string) sourceOption {
}

return func(src *unstructured.Unstructured) {
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.serviceAccountKey field: %s", err)
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "auth", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.auth.serviceAccountKey field: %s", err)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/sources/googlecloudstorage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ var _ = Describe("Google Cloud Storage source", func() {
)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(
`"spec.serviceAccountKey" must validate one and only one schema (oneOf).`))
`"spec.auth.serviceAccountKey" must validate one and only one schema (oneOf).`))
})
})
})
Expand Down Expand Up @@ -301,8 +301,8 @@ func withServiceAccountKey(key string) sourceOption {
}

return func(src *unstructured.Unstructured) {
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.serviceAccountKey field: %s", err)
if err := unstructured.SetNestedMap(src.Object, svcAccKeyMap, "spec", "auth", "serviceAccountKey"); err != nil {
framework.FailfWithOffset(3, "Failed to set spec.auth.serviceAccountKey field: %s", err)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/targets/googlecloudstorage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const (
targetResource = "googlecloudstoragetargets"
)

const gcpCredentialsJosnSecretKey = "credentialsJson"
const gcpServiceAccountKey = "serviceAccountKey"

var _ = Describe("Google Cloud Storage target", func() {
// NOTE: bucket names aren't allowed to contain "goog"
Expand Down Expand Up @@ -293,7 +293,7 @@ var _ = Describe("Google Cloud Storage target", func() {
)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(
"spec.credentialsJson: Required value"))
"spec.auth: Required value"))
})
})
})
Expand Down Expand Up @@ -335,15 +335,15 @@ func withDiscardCEContext() targetOption {

func withCredentials(secretName string) targetOption {
credentials := map[string]interface{}{
"secretKeyRef": map[string]interface{}{
"valueFromSecret": map[string]interface{}{
"name": secretName,
"key": gcpCredentialsJosnSecretKey,
"key": gcpServiceAccountKey,
},
}

return func(trgt *unstructured.Unstructured) {
if err := unstructured.SetNestedMap(trgt.Object, credentials, "spec", gcpCredentialsJosnSecretKey); err != nil {
framework.FailfWithOffset(2, "Failed to set spec.credentialsJson field: %s", err)
if err := unstructured.SetNestedMap(trgt.Object, credentials, "spec", "auth", gcpServiceAccountKey); err != nil {
framework.FailfWithOffset(2, "Failed to set spec.auth.serviceAccountKey field: %s", err)
}
}
}
Expand All @@ -356,7 +356,7 @@ func createGCPCredsSecret(c clientset.Interface, namespace string, creds string)
GenerateName: "gcp-creds-",
},
StringData: map[string]string{
gcpCredentialsJosnSecretKey: creds,
gcpServiceAccountKey: creds,
},
}

Expand Down

0 comments on commit 646e63d

Please sign in to comment.