Skip to content

Commit

Permalink
normalize field that change due to server generated fields. This prev…
Browse files Browse the repository at this point in the history
…ents tests from failing
  • Loading branch information
barney-s committed Jan 17, 2025
1 parent cb9af02 commit 9038f77
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
name: cloudidentitygroup-${uniqueId}
preferredMemberKey:
id: test2@${ISOLATED_TEST_ORG_NAME}
resourceID: 19471824c77
resourceID: ${membershipID}
roles:
- expiryDetail:
expireTime: "2222-10-02T15:01:23Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ X-Xss-Protection: 0
"@type": "type.googleapis.com/google.apps.cloudidentity.groups.v1beta1.Membership",
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471824c77",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -171,7 +171,7 @@ X-Xss-Protection: 0

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471824c77?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -189,7 +189,7 @@ X-Xss-Protection: 0
{
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471824c77",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -204,7 +204,7 @@ X-Xss-Protection: 0

---

POST https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471824c77:modifyMembershipRoles?alt=json
POST https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}:modifyMembershipRoles?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand Down Expand Up @@ -238,9 +238,9 @@ X-Xss-Protection: 0

{
"membership": {
"createTime": "2025-01-16T23:45:52.247648519Z",
"createTime": "2025-01-17T18:51:02.320337735Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471824c77",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -253,13 +253,13 @@ X-Xss-Protection: 0
}
],
"type": "USER",
"updateTime": "2025-01-16T23:45:52.247648519Z"
"updateTime": "2025-01-17T18:51:02.320337735Z"
}
}

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471824c77?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -277,7 +277,7 @@ X-Xss-Protection: 0
{
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471824c77",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -295,7 +295,7 @@ X-Xss-Protection: 0

---

DELETE https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471824c77?alt=json
DELETE https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -316,7 +316,7 @@ X-Xss-Protection: 0

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471824c77?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -334,7 +334,7 @@ X-Xss-Protection: 0
{
"error": {
"code": 403,
"message": "Error(2017): Permission denied for group resource 'groups/${groupID}/memberships/19471824c77' (or it may not exist).",
"message": "Error(2017): Permission denied for group resource 'groups/${groupID}/memberships/${membershipID}' (or it may not exist).",
"status": "PERMISSION_DENIED"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
name: cloudidentitygroup-${uniqueId}
preferredMemberKey:
id: test2@${ISOLATED_TEST_ORG_NAME}
resourceID: 19471803a55
resourceID: ${membershipID}
roles:
- name: MEMBER
- name: MANAGER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ X-Xss-Protection: 0
"@type": "type.googleapis.com/google.apps.cloudidentity.groups.v1beta1.Membership",
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471803a55",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -171,7 +171,7 @@ X-Xss-Protection: 0

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471803a55?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -189,7 +189,7 @@ X-Xss-Protection: 0
{
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471803a55",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -204,7 +204,7 @@ X-Xss-Protection: 0

---

POST https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471803a55:modifyMembershipRoles?alt=json
POST https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}:modifyMembershipRoles?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand Down Expand Up @@ -233,9 +233,9 @@ X-Xss-Protection: 0

{
"membership": {
"createTime": "2025-01-16T23:43:36.533190184Z",
"createTime": "2025-01-17T18:51:02.320337735Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471803a55",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -248,13 +248,13 @@ X-Xss-Protection: 0
}
],
"type": "USER",
"updateTime": "2025-01-16T23:43:36.533190184Z"
"updateTime": "2025-01-17T18:51:02.320337735Z"
}
}

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471803a55?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -272,7 +272,7 @@ X-Xss-Protection: 0
{
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471803a55",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -290,7 +290,7 @@ X-Xss-Protection: 0

---

DELETE https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471803a55?alt=json
DELETE https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -311,7 +311,7 @@ X-Xss-Protection: 0

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471803a55?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -329,7 +329,7 @@ X-Xss-Protection: 0
{
"error": {
"code": 403,
"message": "Error(2017): Permission denied for group resource 'groups/${groupID}/memberships/19471803a55' (or it may not exist).",
"message": "Error(2017): Permission denied for group resource 'groups/${groupID}/memberships/${membershipID}' (or it may not exist).",
"status": "PERMISSION_DENIED"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
name: cloudidentitygroup-${uniqueId}
preferredMemberKey:
id: test2@${ISOLATED_TEST_ORG_NAME}
resourceID: "19471798744"
resourceID: ${membershipID}
roles:
- name: MEMBER
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ X-Xss-Protection: 0
"@type": "type.googleapis.com/google.apps.cloudidentity.groups.v1beta1.Membership",
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471798744",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -177,7 +177,7 @@ X-Xss-Protection: 0

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471798744?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -195,7 +195,7 @@ X-Xss-Protection: 0
{
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471798744",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -213,7 +213,7 @@ X-Xss-Protection: 0

---

POST https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471798744:modifyMembershipRoles?alt=json
POST https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}:modifyMembershipRoles?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -238,9 +238,9 @@ X-Xss-Protection: 0

{
"membership": {
"createTime": "2025-01-16T23:36:17.476112624Z",
"createTime": "2025-01-17T18:51:02.320337735Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471798744",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -250,13 +250,13 @@ X-Xss-Protection: 0
}
],
"type": "USER",
"updateTime": "2025-01-16T23:36:17.476112624Z"
"updateTime": "2025-01-17T18:51:02.320337735Z"
}
}

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471798744?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -274,7 +274,7 @@ X-Xss-Protection: 0
{
"createTime": "2024-04-01T12:34:56.123456Z",
"deliverySetting": "DIGEST",
"name": "groups/${groupID}/memberships/19471798744",
"name": "groups/${groupID}/memberships/${membershipID}",
"preferredMemberKey": {
"id": "test2@${ISOLATED_TEST_ORG_NAME}"
},
Expand All @@ -289,7 +289,7 @@ X-Xss-Protection: 0

---

DELETE https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471798744?alt=json
DELETE https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -310,7 +310,7 @@ X-Xss-Protection: 0

---

GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/19471798744?alt=json
GET https://cloudidentity.googleapis.com/v1beta1/groups/${groupID}/memberships/${membershipID}?alt=json
Content-Type: application/json
User-Agent: kcc/controller-manager DeclarativeClientLib/0.0.1

Expand All @@ -328,7 +328,7 @@ X-Xss-Protection: 0
{
"error": {
"code": 403,
"message": "Error(2017): Permission denied for group resource 'groups/${groupID}/memberships/19471798744' (or it may not exist).",
"message": "Error(2017): Permission denied for group resource 'groups/${groupID}/memberships/${membershipID}' (or it may not exist).",
"status": "PERMISSION_DENIED"
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ func normalizeKRMObject(t *testing.T, u *unstructured.Unstructured, project test
// Specific to SecretManager
visitor.replacePaths[".expireTime"] = "2024-04-01T12:34:56.123456Z"

// Specific to CloudIdentityMembership
visitor.replacePaths[".membership.createTime"] = "2025-01-17T18:51:02.320337735Z"
visitor.replacePaths[".membership.updateTime"] = "2025-01-17T18:51:02.320337735Z"

// Specific to BigQueryConnectionConnection.
visitor.replacePaths[".status.observedState.aws.accessRole.identity"] = "048077221682493034546"
visitor.replacePaths[".status.observedState.azure.identity"] = "117243083562690747295"
Expand Down Expand Up @@ -340,6 +344,11 @@ func normalizeKRMObject(t *testing.T, u *unstructured.Unstructured, project test
visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string {
return strings.ReplaceAll(s, resourceID, "${groupID}")
})

case schema.GroupVersionKind{Group: "cloudidentity.cnrm.cloud.google.com", Version: "v1beta1", Kind: "CloudIdentityMembership"}:
visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string {
return strings.ReplaceAll(s, resourceID, "${membershipID}")
})
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/replacements.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func (r *Replacements) placeholderForGCPResource(resource string) string {
return "${firewallPolicyID}"
case "folders":
return "${folderID}"
case "memberships":
return "${membershipID}"
case "sslCertificates":
return "${sslCertificateID}"
case "serviceAttachments":
Expand Down

0 comments on commit 9038f77

Please sign in to comment.