Skip to content

Commit

Permalink
comments from PR codeready-toolchain#767
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek committed Aug 3, 2023
1 parent c179fcd commit 5edc316
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions test/e2e/parallel/serviceaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (

func TestDoNotOverrideServiceAccount(t *testing.T) {
// given
// Skipping the TestDoNotOverrideServiceAccount test instead of deleting it because we will need to create SAs as part
// of the environment sub-workspaces so the test & logic will be useful to keep.
t.Parallel()
awaitilities := WaitForDeployments(t)
member := awaitilities.Member1()
Expand Down Expand Up @@ -68,26 +66,31 @@ func TestDoNotOverrideServiceAccount(t *testing.T) {
sa, err := member.WaitForServiceAccount(t, fmt.Sprintf("%s-env", mur.Name), "namespace-manager")
require.NoError(t, err)
assert.Equal(t, "stay", sa.Annotations["should"])
secrets:
for j := 0; j < i; j++ {
expName := fmt.Sprintf("dummy-secret-%d", j)

for j := 0; j <= i; j++ {
expSecretName := fmt.Sprintf("dummy-secret-%d", j)
secretFound := false
for _, secretRef := range sa.Secrets {
if secretRef.Name == fmt.Sprintf("dummy-secret-%d", j) {
continue secrets
if secretRef.Name == expSecretName {
secretFound = true
break
}
}
assert.Fail(t, fmt.Sprintf("secret '%s' not found", expName))
}
if !secretFound {
assert.Fail(t, fmt.Sprintf("secret '%s' not found", expSecretName))
}

pullSecrets:
for j := 0; j < i; j++ {
expName := fmt.Sprintf("dummy-pull-secret-%d", j)
expPullSecretName := fmt.Sprintf("dummy-pull-secret-%d", j)
pullSecretFound := false
for _, pullSecretRef := range sa.ImagePullSecrets {
if pullSecretRef.Name == fmt.Sprintf("dummy-pull-secret-%d", j) {
continue pullSecrets
if pullSecretRef.Name == expPullSecretName {
pullSecretFound = true
break
}
}
assert.Fail(t, fmt.Sprintf("pull secret '%s' not found", expName))
if !pullSecretFound {
assert.Fail(t, fmt.Sprintf("pull secret '%s' not found", expPullSecretName))
}
}

// verify that the secrets created for SA is the same
Expand Down

0 comments on commit 5edc316

Please sign in to comment.