diff --git a/pkg/portal/middleware/intAAD.go b/pkg/portal/middleware/intAAD.go index 75355ead0d2..6e7c1842c76 100644 --- a/pkg/portal/middleware/intAAD.go +++ b/pkg/portal/middleware/intAAD.go @@ -18,8 +18,6 @@ const ( // IntAAD effectively disable authentication for testing purposes type IntAAD struct { - // used to auth test traffic - sessionKey []byte log *logrus.Entry elevatedGroups []string } @@ -35,7 +33,6 @@ func (a IntAAD) Callback(w http.ResponseWriter, r *http.Request) { } func (a IntAAD) Login(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) } func (a IntAAD) AAD(h http.Handler) http.Handler { @@ -47,9 +44,6 @@ func (a IntAAD) AAD(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { a.log.Errorf("running AAD middleware from int") a.log.Errorf("there are %d cookies", len(r.Cookies())) - for _, v := range r.Cookies() { - a.log.Errorf("cookies name %s value %s", v.Name, v.Value) - } ctx := r.Context() ctx = context.WithValue(ctx, ContextKeyUsername, "test") @@ -62,7 +56,5 @@ func (a IntAAD) AAD(h http.Handler) http.Handler { func (a IntAAD) Logout(url string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.SetCookie(w, &http.Cookie{Name: OIDCCookie, MaxAge: -1}) - http.Redirect(w, r, url, http.StatusSeeOther) }) } diff --git a/test/e2e/setup.go b/test/e2e/setup.go index e29e8acb7c1..2f722f0e3c0 100644 --- a/test/e2e/setup.go +++ b/test/e2e/setup.go @@ -5,15 +5,11 @@ package e2e import ( "context" - "encoding/json" "fmt" - "math" "net/url" "os" "path/filepath" "regexp" - "strconv" - "strings" "time" . "github.com/onsi/ginkgo/v2" @@ -39,13 +35,11 @@ import ( "github.com/Azure/ARO-RP/pkg/env" "github.com/Azure/ARO-RP/pkg/hive" aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned" - "github.com/Azure/ARO-RP/pkg/portal/middleware" "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/compute" "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/features" "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/network" redhatopenshift20220904 "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/redhatopenshift/2022-09-04/redhatopenshift" "github.com/Azure/ARO-RP/pkg/util/cluster" - "github.com/Azure/ARO-RP/pkg/util/keyvault" utillog "github.com/Azure/ARO-RP/pkg/util/log" "github.com/Azure/ARO-RP/pkg/util/uuid" "github.com/Azure/ARO-RP/test/util/kubeadminkubeconfig" @@ -201,70 +195,6 @@ func adminPortalSessionSetup() (string, *selenium.WebDriver) { log.Infof("Could not get to %s. With error : %s", host, err.Error()) } - elevatedGroups, ok := os.LookupEnv("AZURE_PORTAL_ELEVATED_GROUP_IDS") - if !ok { - log.Fatal("AZURE_PORTAL_ELEVATED_GROUPS_IDS is not set") - } - log.Infof("adding groups %s", elevatedGroups) - - msiKVAuthorizer, err := _env.NewMSIAuthorizer(env.MSIContextRP, _env.Environment().KeyVaultScope) - if err != nil { - log.Fatal(err) - } - - if err := env.ValidateVars(KeyVaultPrefix); err != nil { - log.Fatal(err) - } - keyVaultPrefix := os.Getenv(KeyVaultPrefix) - portalKeyvaultURI := keyvault.URI(_env, env.PortalKeyvaultSuffix, keyVaultPrefix) - portalKeyvault := keyvault.NewManager(msiKVAuthorizer, portalKeyvaultURI) - - sessionKey, err := portalKeyvault.GetBase64Secret(context.Background(), env.PortalServerSessionKeySecretName, "") - if err != nil { - log.Fatal("could not retrieve the session key") - } - uuid := uuid.DefaultGenerator.Generate() - os.Setenv("SESSION", uuid) - - // cookieAuth := &selenium.Cookie{ - // Name: middleware.IntPasswordKey, - // Value: string(sessionKey), - // Expiry: math.MaxUint32, - // } - // cookieGroup := &selenium.Cookie{ - // Name: middleware.IntGroupsKey, - // Value: elevatedGroups, - // Expiry: math.MaxUint32, - // } - type userinfo struct { - Username string - Password []byte - Groups string - } - domain := strings.TrimPrefix(host, "https://") - domain = strings.TrimSuffix(domain, ":"+strconv.Itoa(hostPort)) - - userInfo, err := json.Marshal(userinfo{"test", sessionKey, elevatedGroups}) - if err != nil { - panic(err) - } - cookieUser := &selenium.Cookie{ - Name: middleware.IntUsernameKey, - Value: string(userInfo), - Expiry: math.MaxUint32, - Domain: domain, - } - - // if err := wd.AddCookie(cookieGroup); err != nil { - // panic("error while adding the cookie:" + err.Error()) - // } - if err := wd.AddCookie(cookieUser); err != nil { - panic("error while adding the cookie:" + err.Error()) - } - // if err := wd.AddCookie(cookieAuth); err != nil { - // panic("error while adding the cookie:" + err.Error()) - // } - return host, &wd }