Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Facchetti committed Jul 10, 2023
1 parent 75a81ef commit aae0c72
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 78 deletions.
8 changes: 0 additions & 8 deletions pkg/portal/middleware/intAAD.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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")
Expand All @@ -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)
})
}
70 changes: 0 additions & 70 deletions test/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit aae0c72

Please sign in to comment.