Skip to content

Commit

Permalink
OCM-7537 | ci: fix id:45161,id:49137,id:66362,id:36128,id:43046
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwang-RH committed May 7, 2024
1 parent da3615e commit 85641e2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/zalando/go-keyring v0.2.3 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/crypto v0.22.0
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.19.0 // indirect
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/test_rosacli_network_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ var _ = Describe("Network verifier",
"--hosted-cp",
)
Expect(err).ToNot(HaveOccurred())

})

})
7 changes: 1 addition & 6 deletions tests/e2e/test_rosacli_oidc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ var _ = Describe("OIDC provider",
Expect(err).To(BeNil())

By("Check if cluster is using reusable oidc config")
UsingReusableOIDCConfig, err := clusterService.IsUsingReusableOIDCConfig(clusterID)
Expect(err).To(BeNil())

notExistedClusterID := "notexistedclusterid111"
Expand All @@ -61,11 +60,7 @@ var _ = Describe("OIDC provider",
"-y")
Expect(err).To(BeNil())
textData := rosaClient.Parser.TextData.Input(output).Parse().Tip()
if UsingReusableOIDCConfig {
Expect(textData).To(ContainSubstring("OIDC provider already exists"))
} else {
Expect(textData).To(ContainSubstring("is ready and does not need additional configuration"))
}
Expect(textData).To(ContainSubstring("OIDC provider already exists"))
case false:
By("Create oidc-provider on classic non-sts cluster")
output, err := ocmResourceService.CreateOIDCProvider(
Expand Down
27 changes: 11 additions & 16 deletions tests/e2e/test_rosacli_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,27 @@ var _ = Describe("Edit User",
)

By("Try to list the user when there is no one")
rosaClient.Runner.JsonFormat()
defer func() {
rosaClient.Runner.UnsetFormat()
}()

_, output, err := userService.ListUsers(clusterID)
Expect(err).ToNot(HaveOccurred())
textData := rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expect(textData).To(ContainSubstring("INFO: There are no users configured for cluster '%s'", clusterID))
if output.String() == "[]" {
textData := rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expect(textData).To(ContainSubstring("INFO: There are no users configured for cluster '%s'", clusterID))
}

By("Grant dedicated-admins user")
rosaClient.Runner.UnsetFormat()
out, err := userService.GrantUser(
clusterID,
dedicatedAdminsGroupName,
dedicatedAdminsUserName,
)
Expect(err).ToNot(HaveOccurred())
textData = rosaClient.Parser.TextData.Input(out).Parse().Tip()
textData := rosaClient.Parser.TextData.Input(out).Parse().Tip()
Expect(textData).Should(ContainSubstring("Granted role '%s' to user '%s' on cluster '%s'", dedicatedAdminsGroupName, dedicatedAdminsUserName, clusterID))

By("Grant cluster-admins user")
Expand Down Expand Up @@ -129,7 +137,6 @@ var _ = Describe("Validate user",
defer GinkgoRecover()
var (
invalidPassword = "password1" // disallowed password
validPassword = "Th3long,validpassword"
clusterID string

rosaClient *rosacli.Client
Expand Down Expand Up @@ -164,18 +171,6 @@ var _ = Describe("Validate user",
textData = rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expect(err).To(HaveOccurred())
Expect(textData).Should(ContainSubstring("assword must be at least"))

By("Try to create Hypershift cluster with admin username and password set (unsupported)")
output, err = clusterService.CreateDryRun(clusterID, "--hosted-cp",
"--cluster-admin-password", validPassword,
"--region", "us-west-2",
"--support-role-arn", "fake",
"--controlplane-iam-role", "fake",
"--worker-iam-role", "fake",
"--mode", "auto", "-y")
textData = rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expect(err).To(HaveOccurred())
Expect(textData).Should(ContainSubstring("is only supported in classic"))
})

})
10 changes: 5 additions & 5 deletions tests/utils/common/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ package common

import (
"fmt"
"os/exec"
"strings"

"golang.org/x/crypto/bcrypt"

. "github.com/openshift/rosa/tests/utils/log"
)

// Generate htpasspwd key value pair, return with a string
func GenerateHtpasswdPair(user string, pass string) (string, string, string, error) {
generateCMD := fmt.Sprintf("htpasswd -Bbn %s %s", user, pass)
output, err := exec.Command("bash", "-c", generateCMD).Output()
htpasswdPair := strings.TrimSpace(string(output))
parts := strings.SplitN(htpasswdPair, ":", 2)
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(pass), bcrypt.DefaultCost)
if err != nil {
Logger.Errorf("Fail to generate htpasswd file: %v", err)
return "", "", "", err
}
htpasswdPair := fmt.Sprintf("%s:%s", user, string(hashedPassword))
parts := strings.SplitN(htpasswdPair, ":", 2)
return htpasswdPair, parts[0], parts[1], nil
}

Expand Down
1 change: 1 addition & 0 deletions tests/utils/config/cluster_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (c *command) GetFlagValue(flag string, flagWithVaue bool) string {
// Add flags to the command
func (c *command) AddFlags(flags ...string) {
for _, flag := range flags {
c.cmd = strings.TrimSpace(c.cmd)
// combine the command with space
c.cmd += " " + flag
}
Expand Down

0 comments on commit 85641e2

Please sign in to comment.