package services import ( "bytes" "encoding/base64" "encoding/json" "fmt" "io" "net/http" "net/http/httptest" "strings" "edge-infra.dev/pkg/edge/api/bsl/types" "edge-infra.dev/pkg/edge/api/graph/model" "edge-infra.dev/pkg/edge/api/testutils" "edge-infra.dev/pkg/edge/api/utils" ) const ( basicAuthPrefix = "Basic " bslUsername = "testing" enterpriseUnitFormat = "/provisioning/enterprise-units?typeNamePattern=organization&pageNumber=%d&pageSize=200" enterpriseUnitGrantFormat = "/provisioning/enterprise-unit-grants/unit-grants?username=acct:emerald-edge-dev@%s&pageNumber=%d&pageSize=200" enterpriseUnitGrantFormatFullname = "/provisioning/enterprise-unit-grants/unit-grants?username=acct:emerald-edge-dev@%s&pageNumber=%d&pageSize=200" ) var ( emptyBody = []byte(nil) ) func GetMockBspServer(testOrg, testOrgID, testUser, testUserRole, testEmail, testResetURL string) *httptest.Server { //nolint server := utils.NewMockHTTPTestServer().AddAllowedContentType("application/json").AddNotFound(notFound) // Post server.Post("Login", "/security/authentication/login", loginCallback, nil) server.Post("Recover Password", "/security/security-user-passwords/testing/recover", func(w http.ResponseWriter, r *http.Request) { recoverCallback(w, r, testResetURL) }, nil) server.Post("Create Enterprise Unit", "/provisioning/enterprise-units", createEnterpriseUnitCallback, nil) server.Post("Create Organization", "/provisioning/organizations", createOrganizationCallback, nil) server.Post("BSL Exchange Token", "/security/security-tokens/exchange", tokenExchangeCallback, nil) server.Post("Okta Exchange Token", "/security/authentication/okta-exchange", tokenExchangeCallback, nil) server.Post("Users Details for EU", "/provisioning/users/user-details", func(w http.ResponseWriter, _ *http.Request) { getEUUsersCallback(w) }, nil) //Get server.Get("Get User Profile", "/provisioning/user-profiles", func(w http.ResponseWriter, _ *http.Request) { getUserProfileCallback(w, testUser, testEmail) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.URL.Path == "/provisioning/user-profiles" }) server.Get("Get Users", "/provisioning/users?pageNumber=0&pageSize=200&userType=PRIMARY", func(w http.ResponseWriter, _ *http.Request) { getUsersCallback(w) }, nil) server.Get("Get External Users", "/provisioning/users?pageNumber=0&pageSize=200&userType=EXTERNAL", func(w http.ResponseWriter, _ *http.Request) { getExternalUsersCallback(w) }, nil) server.Get("Get EU Users", "/provisioning/enterprise-unit-grants/unit-grants?enterpriseUnitId=eu-banner-bsl-id&pageNumber=0&pageSize=200", func(w http.ResponseWriter, _ *http.Request) { findUnitGrantsResponseCallback(w) }, nil) server.Get("Get Group Memberships", "", func(w http.ResponseWriter, r *http.Request) { handleGetRoleResponse(w, r, testUser, testUserRole) }, func(_ http.ResponseWriter, r *http.Request) bool { return strings.Contains(r.URL.String(), "/security/group-memberships/groups?username=") }) server.Get("Get Enterprise Unit", "", func(w http.ResponseWriter, _ *http.Request) { getEnterpriseUnitCallback(w) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && strings.Contains(r.URL.String(), "/provisioning/enterprise-units/") && !strings.Contains(r.URL.String(), "test-bsl-id-for-deleted-eu") }) server.Get("Get Deleted Enterprise Unit", "", func(w http.ResponseWriter, _ *http.Request) { getDeletedEnterpriseUnitCallback(w) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && r.URL.String() == "/provisioning/enterprise-units/test-bsl-id-for-deleted-eu" }) server.Get("Get Organization", "", func(w http.ResponseWriter, _ *http.Request) { getOrganizationCallback(w, testOrg, testOrgID) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (r.URL.String() == "/provisioning/organizations/"+testOrg || strings.Contains(r.URL.String(), "/provisioning/organizations/find-by-parent?parentOrganizationName=")) }) server.Get("Get Deleted Organization", "", func(w http.ResponseWriter, _ *http.Request) { getDeletedOrganizationCallback(w) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (r.URL.String() == "/provisioning/organizations/test-bsl-id-for-deleted-org") }) server.Get("Get Organization by BSL ID", "/provisioning/organizations/3ea81a9de9564c3584015b98dd8bcfe9", func(w http.ResponseWriter, _ *http.Request) { getOrganizationCallback(w, testOrg, testOrgID) }, nil) server.Get("Get External User Account - No Data", "", func(w http.ResponseWriter, _ *http.Request) { getExternalUserNoDataCallback(w) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && strings.HasPrefix(r.URL.String(), "/provisioning/users/external/acct:emerald-edge-dev@nodata/accounts") }) server.Get("Get External User Accounts", "", func(w http.ResponseWriter, _ *http.Request) { getExternalUserCallback(w, testOrg, testOrgID) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (r.URL.String() == "/provisioning/users/external/acct:emerald-edge-dev@testing/accounts?pageNumber=0&pageSize=200" || r.URL.String() == "/provisioning/users/external/acct:test-org@multiple/accounts?pageNumber=0&pageSize=200" || r.URL.String() == "/provisioning/users/external/acct:emerald-edge-dev@multiple/accounts?pageNumber=0&pageSize=200" || r.URL.String() == "/provisioning/users/external/acct:emerald-edge-dev@multiple/accounts?pageNumber=0&pageSize=200" || r.URL.String() == "/provisioning/users/external/acct:test-org@/accounts?pageNumber=0&pageSize=200" || r.URL.String() == "/provisioning/users/external/test/accounts?pageNumber=0&pageSize=200") }) server.Get("Get User", "/provisioning/users/acct:edge-dev0-edge-b413cb@test", func(w http.ResponseWriter, _ *http.Request) { getUserCallback(w) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && strings.HasPrefix(r.URL.String(), "/provisioning/users/acct:") }) server.Get("Effective Organizations", "/provisioning/user-profiles/effective-organizations", func(w http.ResponseWriter, _ *http.Request) { getEffectiveOrganizationsCallback(w, 0, 1, 5, true, getEffectiveOrganizations()) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && r.URL.Path == "/provisioning/user-profiles/effective-organizations" }) server.Get("Get Effective Role Grants", "/provisioning/role-grants/user-grants/self/effective-roles", func(w http.ResponseWriter, _ *http.Request) { getEffectiveRolesCallback(w) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && r.URL.Path == "/provisioning/role-grants/user-grants/self/effective-roles" }) //Any server.Any("Get or Patch BSL Site", getBSLSiteCallback, func(_ http.ResponseWriter, r *http.Request) bool { return (r.Method == http.MethodGet || r.Method == http.MethodPatch) && strings.HasPrefix(r.URL.String(), BslSitePath) }) server.Any("Post or Put BSL Site", createBSLSiteCallback, func(_ http.ResponseWriter, r *http.Request) bool { return (r.Method == http.MethodPost || r.Method == http.MethodPut) && strings.HasPrefix(r.URL.String(), BslSitePath) }) server.Any("Get Enterprise Unit & Grant Format - LastPage False", func(w http.ResponseWriter, _ *http.Request) { pageContent := []*types.EnterpriseUnitData{ getEUData(), } getEnterpriseUnitAndGrantCallback(w, false, pageContent, 0, 1, 1) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitFormat, 0)) || strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormat, bslUsername, 0)) || strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormatFullname, bslUsername, 0))) }) server.Any("Get Enterprise Unit & Grant Format - No Page Content & No Pages", func(w http.ResponseWriter, _ *http.Request) { getEnterpriseUnitAndGrantCallback(w, true, nil, 0, 0, 0) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormat, "nodata", 0)) || strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormatFullname, "nodata", 0))) }) server.Any("Get Enterprise Unit & Grant Format - No Page Content", func(w http.ResponseWriter, _ *http.Request) { getEnterpriseUnitAndGrantCallback(w, true, nil, 1, 1, 1) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitFormat, 1)) || strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormat, bslUsername, 1)) || strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormatFullname, bslUsername, 1)) || r.URL.String() == "/provisioning/enterprise-unit-grants/unit-grants?username=acct:test-org@&pageNumber=0&pageSize=200" || r.URL.String() == "/provisioning/enterprise-unit-grants/unit-grants?username=test&pageNumber=0&pageSize=200") }) server.Any("Get Enterprise Unit & Grant Format - Multiple", func(w http.ResponseWriter, _ *http.Request) { pageContent := []*types.EnterpriseUnitData{ getEUData(), getEUData(), } getEnterpriseUnitAndGrantCallback(w, true, pageContent, 0, 1, 2) }, func(_ http.ResponseWriter, r *http.Request) bool { return r.Method == http.MethodGet && (strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormat, "multiple", 0)) || strings.HasSuffix(r.URL.String(), fmt.Sprintf(enterpriseUnitGrantFormatFullname, "multiple", 0))) }) //Put server.Put("Reset User Password", ResetPasswordWithTokenURLPath, resetPasswordCallback, nil) server.Put("Update User", "/provisioning/users", func(w http.ResponseWriter, _ *http.Request) { updateUserCallback(w) }, nil) return server.Server } // getMockBSLStoreSite returns a mock response of a BSL Site func getMockBSLStoreSite(id string) *model.StoreSiteInfo { storeName := "test-store" day := "Monday" description := "test day part" name := "store dayparts" startTime := "9am" endTime := "5pm" return &model.StoreSiteInfo{ ID: &id, EnterpriseUnitName: "test-enterprise-unit-name", SiteName: storeName, Status: ActiveStatus, Coordinates: &model.Coordinates{ Latitude: DefaultLatitude, Longitude: DefaultLongitude, }, EnterpriseSettings: []*model.EnterpriseSettings{ { EnterpriseUnitID: &storeName, }, }, Dayparts: []*model.Dayparts{ { Day: &day, Description: &description, Name: &name, StartTime: &startTime, EndTime: &endTime, }, }, } } // getBSLSiteID trims the /v1/sites/ path to obtain the BSL Site ID func getBSLSiteID(path string) string { return strings.TrimPrefix(path, BslSitePath) } func extractAuth(auth string) (string, string, error) { encodedCredentials := strings.Split(auth, " ")[1] userAndPassword, err := base64.StdEncoding.DecodeString(encodedCredentials) if err != nil { return "", "", err } token := strings.Split(string(userAndPassword), ":") // username may be, e.g. acct:@, with a `:` char. // assume password does not include `:` char, and is the last item in token // username should be all remaining items joined with a `:` char nuParts := len(token) password := token[nuParts-1] username := strings.Join(token[:nuParts-1], ":") return username, password, nil } func writeResponse(w http.ResponseWriter, v interface{}) { res, err := json.Marshal(v) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func loginCallback(w http.ResponseWriter, r *http.Request) { basicAuth := r.Header.Get("Authorization") if !strings.HasPrefix(basicAuth, basicAuthPrefix) { testutils.WriteHTTPBadResponse(w) return } username, password, err := extractAuth(basicAuth) if err != nil || password == "" { testutils.WriteHTTPBadResponse(w) return } authResponse := &types.SecurityTokenData{Token: "anything", Username: username, Authorities: []string{"NEP_IDENTITY_VIEWER"}, MaxSessionTime: 900} writeResponse(w, authResponse) } func getUsersCallback(w http.ResponseWriter) { emailOne := "johndoe@ncr.com" response := &types.FindUsersResponse{ LastPage: true, PageContent: []*model.User{ { Username: "acct:edge-banner-1@user1", FamilyName: "John", GivenName: "Doe", FullName: "John Doe", Email: &emailOne, Status: "ACTIVE", }, { Username: "test-bffuser", FamilyName: "BFF", GivenName: "User", FullName: "BFF User", Email: &emailOne, Status: "ACTIVE", }, }, PageNumber: 1, TotalPages: 1, TotalResults: 1, } res, err := json.Marshal(response) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getExternalUsersCallback(w http.ResponseWriter) { emailOne := "orguser@ncr.com" response := &types.FindUsersResponse{ LastPage: true, PageContent: []*model.User{ { Username: "acct:test-org-banner@orguser", FamilyName: "John", GivenName: "Doe", FullName: "John Doe", Email: &emailOne, Status: "ACTIVE", }, }, PageNumber: 1, TotalPages: 1, TotalResults: 1, } res, err := json.Marshal(response) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func findUnitGrantsResponseCallback(w http.ResponseWriter) { response := &types.FindUnitGrantsResponse{ LastPage: true, PageContent: []*types.UnitGrantViewData{ { Username: "acct:test_eu_banner@euuser", EnterpriseUnitID: "1", }, }, PageNumber: 1, TotalPages: 1, TotalResults: 1, } res, err := json.Marshal(response) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getEUUsersCallback(w http.ResponseWriter) { emailOne := "euuser@ncr.com" response := &types.GetUserDetailsResponse{ Users: []*model.User{ { Username: "acct:test_eu_banner@euuser", FamilyName: "John", GivenName: "Doe", FullName: "John Doe", Email: &emailOne, Status: "ACTIVE", }, }, } res, err := json.Marshal(response) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getUserCallback(w http.ResponseWriter) { email := "test@ncr.com" user := &model.User{ Username: "acct:edge-dev0-edge-b413cb@test", FamilyName: "Doe", GivenName: "Peter", FullName: "Peter Doe", Email: &email, Status: "INACTIVE", } writeResponse(w, user) } func recoverCallback(w http.ResponseWriter, r *http.Request, testResetURL string) { body, err := io.ReadAll(r.Body) if err != nil { writeHTTPBadResponse(w) return } rpReq := &types.RecoverPasswordRequest{} err = json.Unmarshal(body, rpReq) if err != nil { writeHTTPBadResponse(w) return } if rpReq.ResetURL != testResetURL || rpReq.TokenParam != "token" { writeHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(emptyBody) } func getUserProfileCallback(w http.ResponseWriter, testUser, testEmail string) { user := &model.User{ Username: testUser, FamilyName: "doe", GivenName: "john", FullName: "John Doe", Email: &testEmail, Status: "", } writeResponse(w, user) } func createEnterpriseUnitCallback(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil { testutils.WriteHTTPBadResponse(w) return } eu := &types.EnterpriseUnitData{} err = json.Unmarshal(body, eu) if err != nil { testutils.WriteHTTPBadResponse(w) return } eu.EnterpriseUnitID = "euid" res, err := json.Marshal(eu) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getEnterpriseUnitCallback(w http.ResponseWriter) { data := getEUData() res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getDeletedEnterpriseUnitCallback(w http.ResponseWriter) { data := getDeletedEUData() res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func createOrganizationCallback(w http.ResponseWriter, r *http.Request) { bd, err := io.ReadAll(r.Body) if err != nil { testutils.WriteHTTPBadResponse(w) return } rq := &types.CreateOrganizationRequest{} err = json.Unmarshal(bd, rq) if err != nil { testutils.WriteHTTPBadResponse(w) return } rp := &types.CreateOrganizationResponse{ ID: "euid", OrganizationName: rq.Name, Description: rq.Description, } res, err := json.Marshal(rp) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func tokenExchangeCallback(w http.ResponseWriter, _ *http.Request) { data := &model.AuthPayload{ Token: "test-token-exchange", } res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getOrganizationCallback(w http.ResponseWriter, testOrg, testOrgID string) { data := getOrgsData(testOrg, testOrgID) res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getDeletedOrganizationCallback(w http.ResponseWriter) { data := getDeletedOrgsData() res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getExternalUserNoDataCallback(w http.ResponseWriter) { orgs := &types.GetExternalUserResponse{ LastPage: true, PageNumber: 0, TotalPages: 1, TotalResults: 1, PageContent: nil, } res, err := json.Marshal(orgs) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getExternalUserCallback(w http.ResponseWriter, testOrg, testOrgID string) { orgs := getExternalUserDate(testOrg, testOrgID) res, err := json.Marshal(orgs) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func getBSLSiteCallback(w http.ResponseWriter, r *http.Request) { bslSiteID := getBSLSiteID(r.URL.Path) bslSite := getMockBSLStoreSite(strings.Trim(bslSiteID, "/")) response, err := json.Marshal(bslSite) if err != nil { testutils.WriteHTTPBadResponse(w) return } w.WriteHeader(200) _, _ = w.Write(response) } func createBSLSiteCallback(w http.ResponseWriter, r *http.Request) { bd, err := io.ReadAll(r.Body) if err != nil { writeHTTPBadResponse(w) return } rq := &types.BSLSite{} err = json.Unmarshal(bd, rq) if err != nil { writeHTTPBadResponse(w) return } rq.ID = "test-site-id" res, err := json.Marshal(rq) if err != nil { writeHTTPBadResponse(w) return } w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } func resetPasswordCallback(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil || bytes.Contains(body, []byte("bad-password")) { w.WriteHeader(http.StatusBadRequest) return } else if bytes.Contains(body, []byte("bad-token")) { w.WriteHeader(http.StatusForbidden) return } w.WriteHeader(http.StatusNoContent) } func updateUserCallback(w http.ResponseWriter) { email := "test@ncr.com" user := &model.User{ Username: "acct:edge-dev0-edge-b413cb@test", FamilyName: "Doe", GivenName: "John", FullName: "John Doe", Email: &email, Status: "ACTIVE", } writeResponse(w, user) } func getEnterpriseUnitAndGrantCallback(w http.ResponseWriter, lastpage bool, pageContent []*types.EnterpriseUnitData, pageNumber, totalPages, totalResults int) { data := &types.FindEnterpriseUnitsResponse{ LastPage: lastpage, PageContent: pageContent, PageNumber: pageNumber, TotalPages: totalPages, TotalResults: totalResults, } res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) } else { w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } } func getEffectiveOrganizationsCallback(w http.ResponseWriter, pageNumber, totalPages, totalResults int, lastpage bool, pageContent []*types.EffectiveOrganization) { data := &types.EffectiveOrganizationsResponse{ LastPage: lastpage, PageNumber: pageNumber, TotalPages: totalPages, TotalResults: totalResults, PageContent: pageContent, } res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) } else { w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } } func getEffectiveRolesCallback(w http.ResponseWriter) { data := &types.EffectiveRolesResponse{ Content: []types.EffectiveRole{ { RoleName: "NEP_IDENTITY_VIEWER", }, { RoleName: "EDGE_ORG_ADMIN", }, { RoleName: "CORE_INVITE_DELETE", }, { RoleName: "NEP_ENTERPRISE_GRANT_ENTERPRISE_UNIT", }, }, } res, err := json.Marshal(data) if err != nil { testutils.WriteHTTPBadResponse(w) } else { w.WriteHeader(http.StatusOK) _, _ = w.Write(res) } } func notFound(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil { testutils.WriteHTTPBadResponse(w) return } if bytes.Contains(body, []byte("org-not-exist")) { w.WriteHeader(http.StatusBadRequest) _, _ = w.Write(emptyBody) } else { w.WriteHeader(http.StatusOK) _, _ = w.Write(emptyBody) } } func handleGetRoleResponse(w http.ResponseWriter, r *http.Request, testUser, testUserRole string) { if strings.Contains(r.URL.String(), "nodata") { resp := &types.GroupDataResponse{ Username: testUser, } writeResponse(w, resp) return } resp := &types.GroupDataResponse{ Username: testUser, Memberships: []map[string]string{ { "groupName": testUserRole, }, }, } writeResponse(w, resp) } func writeHTTPBadResponse(w http.ResponseWriter) { w.WriteHeader(http.StatusBadRequest) _, _ = w.Write(emptyBody) } func getEUData() *types.EnterpriseUnitData { return &types.EnterpriseUnitData{ Active: true, Description: "test_description", EnterpriseTypeName: types.IsOrganization, EnterpriseUnitID: "eu-banner-bsl-id", Name: "test-banner-eu", } } func getDeletedEUData() *types.EnterpriseUnitData { return &types.EnterpriseUnitData{ Active: false, Description: "test_description", EnterpriseTypeName: types.IsOrganization, EnterpriseUnitID: "eu-banner-bsl-id", Name: "test-banner-eu-deleted-test-time", } } func getExternalUserDate(testOrg, testOrgID string) *types.GetExternalUserResponse { return &types.GetExternalUserResponse{ LastPage: true, PageNumber: 0, TotalPages: 1, TotalResults: 1, PageContent: []*types.ExternalUserData{ { ID: testOrgID, OrganizationName: testOrg, DisplayName: testOrg, Description: "test_description", Primary: false, }, { ID: "test-org-banner", OrganizationName: "test-org-banner", DisplayName: "test-org-banner", Description: "test_description", Primary: false, }, }, } } func getOrgsData(testOrg, testOrgID string) *types.GetOrganizationSubOrgsResponse { return &types.GetOrganizationSubOrgsResponse{ LastPage: true, PageNumber: 0, TotalPages: 1, TotalResults: 1, PageContent: []*types.OrganizationViewData{ { ID: testOrgID, OrganizationName: testOrg, DisplayName: testOrg, Parent: true, Description: "test_description", }, { ID: "test-org-banner", OrganizationName: "test-org-banner", DisplayName: "test-org-banner", Parent: true, Description: "test_description", }, { ID: "store-status", OrganizationName: "store-status-banner", DisplayName: "store-status-banner", Parent: true, Description: "test_description", }, { ID: "store-status02", OrganizationName: "store-status-banner02", DisplayName: "store-status-banner02", Parent: true, Description: "test_description", }, }, } } func getDeletedOrgsData() *types.OrganizationViewData { return &types.OrganizationViewData{ ID: "test-bsl-id-for-deleted-org", OrganizationName: "test-org-deleted", DisplayName: "test-org-deleted", Parent: true, Description: "test_description", } } func getEffectiveOrganizations() []*types.EffectiveOrganization { return []*types.EffectiveOrganization{ { ID: "test-id-1", DisplayName: "test-bsl-org-1", OrganizationName: "/customers/test-bsl-org-1", }, { ID: "test-id-2", DisplayName: "test-banner", OrganizationName: "/customers/test-bsl-org-1/test-banner", }, { ID: "test-id-3", DisplayName: "test-bsl-org-2", OrganizationName: "/customers/test-bsl-org-2", }, { ID: "test-id-4", DisplayName: "test-bsl-org-3", OrganizationName: "/customers/test-bsl-org-3", }, { ID: "test-id-5", DisplayName: "test-api-banner", OrganizationName: "/customers/test-bsl-org-3/test-api-banner", }, } }