Skip to content

Commit

Permalink
More details on webhook tests (aws#4343)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude authored Dec 9, 2022
1 parent 8608c5e commit 7b23ee4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pkg/api/v1alpha1/gitopsconfig_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestClusterValidateUpdateGitOpsRepoImmutable(t *testing.T) {

c.Spec.Flux.Github.Repository = "fancyNewRepo"
g := NewWithT(t)
g.Expect(c.ValidateUpdate(&gOld)).NotTo(Succeed())
g.Expect(c.ValidateUpdate(&gOld)).To(MatchError(ContainSubstring("GitOpsConfig: Forbidden: config is immutable")))
}

func TestClusterValidateUpdateGitOpsBranchImmutable(t *testing.T) {
Expand All @@ -26,7 +26,7 @@ func TestClusterValidateUpdateGitOpsBranchImmutable(t *testing.T) {

c.Spec.Flux.Github.Repository = "newMain"
g := NewWithT(t)
g.Expect(c.ValidateUpdate(&gOld)).NotTo(Succeed())
g.Expect(c.ValidateUpdate(&gOld)).To(MatchError(ContainSubstring("GitOpsConfig: Forbidden: config is immutable")))
}

func TestClusterValidateUpdateGitOpsSubtractionImmutable(t *testing.T) {
Expand All @@ -36,7 +36,7 @@ func TestClusterValidateUpdateGitOpsSubtractionImmutable(t *testing.T) {

c.Spec = v1alpha1.GitOpsConfigSpec{}
g := NewWithT(t)
g.Expect(c.ValidateUpdate(&gOld)).NotTo(Succeed())
g.Expect(c.ValidateUpdate(&gOld)).To(MatchError(ContainSubstring("GitOpsConfig: Forbidden: config is immutable")))
}

func gitOpsConfig() v1alpha1.GitOpsConfig {
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/v1alpha1/oidcconfig_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestValidateUpdateOIDCClientIdMgmtCluster(t *testing.T) {

c.Spec.ClientId = "test2"
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCGroupsClaimMgmtCluster(t *testing.T) {
Expand All @@ -109,7 +109,7 @@ func TestValidateUpdateOIDCGroupsClaimMgmtCluster(t *testing.T) {

c.Spec.GroupsClaim = "test2"
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCGroupsPrefixMgmtCluster(t *testing.T) {
Expand All @@ -119,7 +119,7 @@ func TestValidateUpdateOIDCGroupsPrefixMgmtCluster(t *testing.T) {

c.Spec.GroupsPrefix = "test2"
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCIssuerUrlMgmtCluster(t *testing.T) {
Expand All @@ -129,7 +129,7 @@ func TestValidateUpdateOIDCIssuerUrlMgmtCluster(t *testing.T) {

c.Spec.IssuerUrl = "test2"
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCUsernameClaimMgmtCluster(t *testing.T) {
Expand All @@ -139,7 +139,7 @@ func TestValidateUpdateOIDCUsernameClaimMgmtCluster(t *testing.T) {

c.Spec.UsernameClaim = "test2"
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCUsernamePrefixMgmtCluster(t *testing.T) {
Expand All @@ -149,7 +149,7 @@ func TestValidateUpdateOIDCUsernamePrefixMgmtCluster(t *testing.T) {

c.Spec.UsernamePrefix = "test2"
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCRequiredClaimsMgmtCluster(t *testing.T) {
Expand All @@ -159,7 +159,7 @@ func TestValidateUpdateOIDCRequiredClaimsMgmtCluster(t *testing.T) {

c.Spec.RequiredClaims = []v1alpha1.OIDCConfigRequiredClaim{{Claim: "test", Value: "value2"}}
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestValidateUpdateOIDCRequiredClaimsMultipleMgmtCluster(t *testing.T) {
Expand All @@ -172,7 +172,7 @@ func TestValidateUpdateOIDCRequiredClaimsMultipleMgmtCluster(t *testing.T) {
Value: "value2",
})
o := NewWithT(t)
o.Expect(c.ValidateUpdate(&ocOld)).NotTo(Succeed())
o.Expect(c.ValidateUpdate(&ocOld)).To(MatchError(ContainSubstring("OIDCConfig: Forbidden: config is immutable")))
}

func TestClusterValidateUpdateOIDCclientIdMutableUpdateNameWorkloadCluster(t *testing.T) {
Expand Down

0 comments on commit 7b23ee4

Please sign in to comment.