From 8f6ac42f5fde8124ca7e40c5e32b909bcd12e850 Mon Sep 17 00:00:00 2001 From: Francisc Munteanu Date: Wed, 20 Sep 2023 18:14:27 +0200 Subject: [PATCH] wip test new spacelister api --- go.mod | 4 +++- go.sum | 6 ++---- test/e2e/proxy_test.go | 20 ++++++++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index b18dcbd8e..6c7a2a7c4 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/codeready-toolchain/toolchain-e2e require ( - github.com/codeready-toolchain/api v0.0.0-20230823083409-fe9ca973d9a9 + github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33 github.com/codeready-toolchain/toolchain-common v0.0.0-20230823084119-693476668406 github.com/davecgh/go-spew v1.1.1 github.com/fatih/color v1.12.0 @@ -121,3 +121,5 @@ require ( ) go 1.19 + +replace github.com/codeready-toolchain/toolchain-common => /Users/fmuntean/go/src/github.com/codeready-toolchain/toolchain-common diff --git a/go.sum b/go.sum index 21123c294..e785b1227 100644 --- a/go.sum +++ b/go.sum @@ -123,10 +123,8 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/codeready-toolchain/api v0.0.0-20230823083409-fe9ca973d9a9 h1:ytFqNSSEvgevqvwMilmmqlrrDH1O/qUwzg8bO3CxCiY= -github.com/codeready-toolchain/api v0.0.0-20230823083409-fe9ca973d9a9/go.mod h1:nn3W6eKb9PFIVwSwZW7wDeLACMBOwAV+4kddGuN+ARM= -github.com/codeready-toolchain/toolchain-common v0.0.0-20230823084119-693476668406 h1:AkBhFV2tJhQaejTjntIhFC7r1FeLlQEiAL2gcn5/oW0= -github.com/codeready-toolchain/toolchain-common v0.0.0-20230823084119-693476668406/go.mod h1:wvbndymhFMqyc8syiaanid91GsywkDfuVyiTjdyiqNM= +github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33 h1:hxXfcFq2JgFISVxrkISg8m9DZMzpcPWRjPspx3M3Sxo= +github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33/go.mod h1:nn3W6eKb9PFIVwSwZW7wDeLACMBOwAV+4kddGuN+ARM= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= diff --git a/test/e2e/proxy_test.go b/test/e2e/proxy_test.go index db1e7130c..b8a512cd2 100644 --- a/test/e2e/proxy_test.go +++ b/test/e2e/proxy_test.go @@ -665,6 +665,7 @@ func TestSpaceLister(t *testing.T) { identityID: uuid.Must(uuid.NewV4()), }, } + appStudioTierRolesWSoption := commonproxy.WithAvailableRoles([]string{"admin", "contributor", "maintainer"}) // create the users before the subtests, so they exist for the duration of the whole test for _, user := range users { @@ -692,7 +693,7 @@ func TestSpaceLister(t *testing.T) { // then require.NoError(t, err) - verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], true), *workspace) + verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], true, appStudioTierRolesWSoption), *workspace) }) t.Run("cannot get bus workspace", func(t *testing.T) { @@ -723,7 +724,7 @@ func TestSpaceLister(t *testing.T) { // then require.NoError(t, err) - verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], true), *busWS) + verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], true, appStudioTierRolesWSoption), *busWS) }) t.Run("can get car workspace", func(t *testing.T) { @@ -732,7 +733,7 @@ func TestSpaceLister(t *testing.T) { // then require.NoError(t, err) - verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false), *carWS) + verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false, appStudioTierRolesWSoption), *carWS) }) }) @@ -755,7 +756,7 @@ func TestSpaceLister(t *testing.T) { // then require.NoError(t, err) - verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], false), *busWS) + verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], false, appStudioTierRolesWSoption), *busWS) }) t.Run("can get car workspace", func(t *testing.T) { @@ -764,7 +765,7 @@ func TestSpaceLister(t *testing.T) { // then require.NoError(t, err) - verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false), *carWS) + verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false, appStudioTierRolesWSoption), *carWS) }) t.Run("can get bicycle workspace", func(t *testing.T) { @@ -773,7 +774,7 @@ func TestSpaceLister(t *testing.T) { // then require.NoError(t, err) - verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bicycle"], true), *bicycleWS) + verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bicycle"], true, appStudioTierRolesWSoption), *bicycleWS) }) }) @@ -1055,11 +1056,11 @@ func verifyHasExpectedWorkspace(t *testing.T, expectedWorkspace toolchainv1alpha t.Errorf("expected workspace %s not found", expectedWorkspace.Name) } -func expectedWorkspaceFor(t *testing.T, hostAwait *wait.HostAwaitility, user *proxyUser, isHomeWorkspace bool) toolchainv1alpha1.Workspace { +func expectedWorkspaceFor(t *testing.T, hostAwait *wait.HostAwaitility, user *proxyUser, isHomeWorkspace bool, additionalWSOptions ...commonproxy.WorkspaceOption) toolchainv1alpha1.Workspace { space, err := hostAwait.WaitForSpace(t, user.compliantUsername, wait.UntilSpaceHasAnyTargetClusterSet(), wait.UntilSpaceHasAnyTierNameSet()) require.NoError(t, err) - ws := commonproxy.NewWorkspace(user.compliantUsername, + commonWSoptions := []commonproxy.WorkspaceOption{ commonproxy.WithObjectMetaFrom(space.ObjectMeta), commonproxy.WithNamespaces([]toolchainv1alpha1.SpaceNamespace{ { @@ -1069,6 +1070,9 @@ func expectedWorkspaceFor(t *testing.T, hostAwait *wait.HostAwaitility, user *pr }), commonproxy.WithOwner(user.signup.Name), commonproxy.WithRole("admin"), + } + ws := commonproxy.NewWorkspace(user.compliantUsername, + append(commonWSoptions, additionalWSOptions...)..., ) // if the user is the same as the one who created the workspace, then expect type should be "home" if isHomeWorkspace {