Skip to content

Commit

Permalink
Tests for new usersignup get response (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajivnathan authored Jul 3, 2023
1 parent 14690a5 commit 649847b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/e2e/parallel/registration_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -518,6 +519,8 @@ func TestPhoneVerification(t *testing.T) {
// Call get signup endpoint with a valid token and make sure it's pending approval
mp, mpStatus = ParseResponse(t, InvokeEndpoint(t, "GET", route+"/api/v1/signup", token0, "", http.StatusOK))
assert.Equal(t, "", mp["compliantUsername"])
assert.Empty(t, mp["defaultUserNamespace"])
assert.Empty(t, mp["rhodsMemberURL"])
assert.Equal(t, identity0.Username, mp["username"])
require.IsType(t, false, mpStatus["ready"])
assert.False(t, mpStatus["ready"].(bool))
Expand Down Expand Up @@ -781,12 +784,16 @@ func assertGetSignupStatusProvisioned(t *testing.T, await wait.Awaitilities, use
require.True(t, found)
assert.Equal(t, memberCluster.Spec.APIEndpoint, mp["apiEndpoint"])
assert.Equal(t, hostAwait.APIProxyURL, mp["proxyURL"])
assert.Equal(t, fmt.Sprintf("%s-dev", transformedUsername), mp["defaultUserNamespace"])
assertRHODSClusterURL(t, memberAwait, mp)
}

func assertGetSignupStatusPendingApproval(t *testing.T, await wait.Awaitilities, username, bearerToken string) {
route := await.Host().RegistrationServiceURL
mp, mpStatus := ParseResponse(t, InvokeEndpoint(t, "GET", route+"/api/v1/signup", bearerToken, "", http.StatusOK))
assert.Equal(t, username, mp["username"])
assert.Empty(t, mp["defaultUserNamespace"])
assert.Empty(t, mp["rhodsMemberURL"])
require.IsType(t, false, mpStatus["ready"])
assert.False(t, mpStatus["ready"].(bool))
assert.Equal(t, "PendingApproval", mpStatus["reason"])
Expand All @@ -797,6 +804,13 @@ func assertGetSignupReturnsNotFound(t *testing.T, await wait.Awaitilities, beare
InvokeEndpoint(t, "GET", route+"/api/v1/signup", bearerToken, "", http.StatusNotFound)
}

func assertRHODSClusterURL(t *testing.T, memberAwait *wait.MemberAwaitility, response map[string]interface{}) {
require.Containsf(t, memberAwait.GetConsoleURL(t), ".apps.", "expected to find .apps. in the console URL %s", memberAwait.GetConsoleURL(t))
index := strings.Index(memberAwait.GetConsoleURL(t), ".apps.")
appsURL := memberAwait.GetConsoleURL(t)[index:]
assert.Equal(t, fmt.Sprintf("https://%s%s", "rhods-dashboard-redhat-ods-applications", appsURL), response["rhodsMemberURL"])
}

// waitForUserSignupReadyInRegistrationService waits and checks that the UserSignup is ready according to registration service /signup endpoint
func waitForUserSignupReadyInRegistrationService(t *testing.T, registrationServiceURL, name, bearerToken string) map[string]interface{} {
t.Logf("waiting and verifying that UserSignup '%s' is ready according to registration service", name)
Expand Down

0 comments on commit 649847b

Please sign in to comment.