Skip to content

Commit

Permalink
Correct the way how the e2e test framework checks the username
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Jun 30, 2023
1 parent f1980e1 commit fa9e8d2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions e2e/fixtures/kubernetes_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package fixtures
import (
ctx "context"
"log"
"regexp"

"github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -32,6 +31,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
namespaceRegEx = `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
)

// MultipleNamespaces creates multiple namespaces for HA testing.
func (factory *Factory) MultipleNamespaces(dcIDs []string) []string {
res := make([]string, len(dcIDs))
Expand Down Expand Up @@ -64,13 +67,8 @@ func (factory *Factory) createNamespace(suffix string) string {
namespace := factory.options.namespace

if namespace == "" {
gomega.Expect(factory.singleton.userName).To(gomega.MatchRegexp(namespaceRegEx), "user name contains invalid characters")
namespace = factory.singleton.userName + "-" + RandStringRunes(8)
matched, err := regexp.Match(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`, []byte(namespace))
if !matched {
return ""
}

gomega.Expect(err).ToNot(gomega.HaveOccurred())
}

if suffix != "" {
Expand Down

0 comments on commit fa9e8d2

Please sign in to comment.