Skip to content

Commit

Permalink
Fixed code smells
Browse files Browse the repository at this point in the history
Signed-off-by: Josef Kopriva <[email protected]>
  • Loading branch information
jkopriva committed Oct 3, 2023
1 parent 3384b45 commit 70e0d75
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
7 changes: 4 additions & 3 deletions test/e2e/proxy/applications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@ func TestProxyApplicationsFlow(t *testing.T) {

t.Run("successful workspace context request with proxy plugin", func(t *testing.T) {
// we are going to repurpose a well known, always running route as a proxy plugin to contact through the registration service
CreateProxyPluginWithCleanup(t, hostAwait, "openshift-console", "openshift-console", "console")
VerifyProxyPlugin(t, hostAwait, "openshift-console")
proxyPluginWorkspaceURL := hostAwait.PluginProxyURLWithWorkspaceContext("openshift-console", user.CompliantUsername)
openshiftConsoleString := "openshift-console"
CreateProxyPluginWithCleanup(t, hostAwait, openshiftConsoleString, openshiftConsoleString, "console")
VerifyProxyPlugin(t, hostAwait, openshiftConsoleString)
proxyPluginWorkspaceURL := hostAwait.PluginProxyURLWithWorkspaceContext(openshiftConsoleString, user.CompliantUsername)
client := http.Client{
Timeout: 30 * time.Second,
Transport: &http.Transport{
Expand Down
10 changes: 0 additions & 10 deletions test/e2e/proxy/shared_workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ import (
"k8s.io/apimachinery/pkg/types"
)

// full flow from usersignup with approval down to namespaces creation and cleanup
//
// !!! Additional context !!!
// The test uses a dummy HAS API type called Application. The reason is that the regular
// user doesn't have full permission for the standard types like ConfigMap. This means
// that we could do create/read operations on that resource from this test.
// To work around this limitation, we created a dummy HAS API type that has the same name
// and the same group as the actual one. The CRD is created as part of the test setup
// and since the CRD name & group name matches, then RBAC allow us to execute create/read
// operations on that resource using the user permissions.
func TestSharedWorkspaces(t *testing.T) {
t.Parallel()
// given
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/proxy/space_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestSpaceLister(t *testing.T) {
VerifyHasExpectedWorkspace(t, ExpectedWorkspaceFor(t, awaitilities.Host(), users["bus"], true), *busWS)
})

t.Run("can get car workspace", func(t *testing.T) {
t.Run("can get car workspace(bus)", func(t *testing.T) {
// when
carWS, err := users["bus"].GetWorkspace(t, hostAwait, users["car"].CompliantUsername)

Expand Down Expand Up @@ -135,7 +135,7 @@ func TestSpaceLister(t *testing.T) {
VerifyHasExpectedWorkspace(t, ExpectedWorkspaceFor(t, awaitilities.Host(), users["bus"], false), *busWS)
})

t.Run("can get car workspace", func(t *testing.T) {
t.Run("can get car workspace(bicycle)", func(t *testing.T) {
// when
carWS, err := users["bicycle"].GetWorkspace(t, hostAwait, users["car"].CompliantUsername)

Expand Down
12 changes: 3 additions & 9 deletions testsupport/appstudio/proxy_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ func (u *ProxyUser) ShareSpaceWith(t *testing.T, hostAwait *wait.HostAwaitility,
}

func (u *ProxyUser) ListWorkspaces(t *testing.T, hostAwait *wait.HostAwaitility) []toolchainv1alpha1.Workspace {
proxyCl := u.createProxyClient(t, hostAwait)
proxyCl := u.CreateProxyClient(t, hostAwait)

workspaces := &toolchainv1alpha1.WorkspaceList{}
err := proxyCl.List(context.TODO(), workspaces)
require.NoError(t, err)
return workspaces.Items
}

func (u *ProxyUser) createProxyClient(t *testing.T, hostAwait *wait.HostAwaitility) client.Client {
func (u *ProxyUser) CreateProxyClient(t *testing.T, hostAwait *wait.HostAwaitility) client.Client {
proxyCl, err := hostAwait.CreateAPIProxyClient(t, u.Token, hostAwait.APIProxyURL)
require.NoError(t, err)
return proxyCl
}

func (u *ProxyUser) GetWorkspace(t *testing.T, hostAwait *wait.HostAwaitility, workspaceName string) (*toolchainv1alpha1.Workspace, error) {
proxyCl := u.createProxyClient(t, hostAwait)
proxyCl := u.CreateProxyClient(t, hostAwait)

workspace := &toolchainv1alpha1.Workspace{}
var cause error
Expand Down Expand Up @@ -134,12 +134,6 @@ func (u *ProxyUser) GetApplicationWithoutProxy(t *testing.T, applicationName str
return app
}

func (u *ProxyUser) CreateProxyClient(t *testing.T, hostAwait *wait.HostAwaitility) client.Client {
proxyCl, err := hostAwait.CreateAPIProxyClient(t, u.Token, hostAwait.APIProxyURL)
require.NoError(t, err)
return proxyCl
}

func (u *ProxyUser) GetApplicationName(i int) string {
return fmt.Sprintf("%s-test-app-%d", u.CompliantUsername, i)
}
Expand Down

0 comments on commit 70e0d75

Please sign in to comment.