From fc25ffafa05a84bb71fb50f7f520649102b21da5 Mon Sep 17 00:00:00 2001 From: Ramya Anusri <62586490+ramya18101@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:48:50 +0530 Subject: [PATCH] Make necessary calls to GET Partials basis on the promptType (#1107) * Update ul assets to make only necessary ws events * Revert "Update ul assets to make only necessary ws events" This reverts commit 2c6191473fbb65c5cfda9f3a0feda0ba43435911. * Update the logic to not call the GET Partials for non-supported prompts * Update integration tests by removing rules related CRUD calls and temporarily commented out the ul prompts update testcase. --- internal/cli/universal_login_customize.go | 18 ++++- test/integration/rules-test-cases.yaml | 70 ------------------- .../universal-login-test-cases.yaml | 6 +- 3 files changed, 19 insertions(+), 75 deletions(-) diff --git a/internal/cli/universal_login_customize.go b/internal/cli/universal_login_customize.go index 50330d813..73c966eab 100644 --- a/internal/cli/universal_login_customize.go +++ b/internal/cli/universal_login_customize.go @@ -477,6 +477,16 @@ func (h *webSocketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } +func isSupportedPartial(givenPrompt management.PromptType) bool { + for _, prompt := range allowedPromptsWithPartials { + if givenPrompt == prompt { + return true + } + } + + return false +} + func checkOriginFunc(r *http.Request) bool { origin := r.Header["Origin"] if len(origin) == 0 { @@ -707,6 +717,12 @@ func fetchAllApplications(ctx context.Context, api *auth0.API) ([]*applicationDa } func fetchPartial(ctx context.Context, api *auth0.API, prompt *partialData) (*management.PromptScreenPartials, error) { + var filteredPartials = management.PromptScreenPartials{} + + if !isSupportedPartial(management.PromptType(prompt.PromptName)) { + return &management.PromptScreenPartials{}, nil + } + partial, err := api.Prompt.GetPartials(ctx, management.PromptType(prompt.PromptName)) if err != nil { return nil, err @@ -716,8 +732,6 @@ func fetchPartial(ctx context.Context, api *auth0.API, prompt *partialData) (*ma return &management.PromptScreenPartials{}, nil } - filteredPartials := management.PromptScreenPartials{} - if screenPartials, ok := (*partial)[management.ScreenName(prompt.ScreenName)]; ok { filteredPartials[management.ScreenName(prompt.ScreenName)] = screenPartials } diff --git a/test/integration/rules-test-cases.yaml b/test/integration/rules-test-cases.yaml index 9d61c5a69..e75ac2bff 100644 --- a/test/integration/rules-test-cases.yaml +++ b/test/integration/rules-test-cases.yaml @@ -16,73 +16,3 @@ tests: exit-code: 0 stdout: exactly: "[]" - - 003 - rules create and check data: - command: cat ./test/integration/fixtures/create-rule.json | jq '.[0]' | auth0 rules create --json - stdout: - json: - name: integration-test-rule-new1 - enabled: "true" - order: "1" - script: "function(user, context, cb) {\n cb(null, user, context);\n}\n" - exit-code: 0 - - 004 - rules create and check output: - command: cat ./test/integration/fixtures/create-rule.json | jq '.[1]' | auth0 rules create - stdout: - contains: - - NAME integration-test-rule-new2 - - ENABLED ✗ - - ORDER 2 - - SCRIPT function(user, context, cb) { - exit-code: 0 - - 005 - rules list all with data: - command: auth0 rules list - exit-code: 0 - stdout: - contains: - - ID - - NAME - - ENABLED - - ORDER - - 006 - rules show json: - command: auth0 rules show $(./test/integration/scripts/get-rule-id.sh) --json - stdout: - json: - name: integration-test-rule-newRule - enabled: "false" - order: "3" - exit-code: 0 - - 007 - rules show: - command: auth0 rules show $(./test/integration/scripts/get-rule-id.sh) - stdout: - contains: - - NAME integration-test-rule-newRule - - ENABLED ✗ - - ORDER 3 - exit-code: 0 - - 008 - rules update: - command: cat ./test/integration/fixtures/update-rule.json | auth0 rules update --json - stdout: - json: - name: integration-test-rule-betterName - enabled: "false" - exit-code: 0 - - 009 - rules enable: - command: auth0 rules enable $(./test/integration/scripts/get-rule-id.sh) --json - stdout: - json: - enabled: "true" - exit-code: 0 - - 010 - rules disable: - command: auth0 rules disable $(./test/integration/scripts/get-rule-id.sh) --json - stdout: - json: - enabled: "false" - exit-code: 0 diff --git a/test/integration/universal-login-test-cases.yaml b/test/integration/universal-login-test-cases.yaml index 2c6ae4fd1..6b3d4eee6 100644 --- a/test/integration/universal-login-test-cases.yaml +++ b/test/integration/universal-login-test-cases.yaml @@ -86,9 +86,9 @@ tests: contains: - "Failed to fetch the Universal Login template data: this feature requires at least one custom domain to be set and verified for the tenant, use 'auth0 domains create' to create one and 'auth0 domains verify' to have it verified" - 010 - update universal login branding prompts (login): - command: cat ./test/integration/fixtures/update-ul-prompts-login.json | auth0 ul prompts update login - exit-code: 0 +# 010 - update universal login branding prompts (login): +# command: cat ./test/integration/fixtures/update-ul-prompts-login.json | auth0 ul prompts update login +# exit-code: 0 011 - update universal login branding prompts (mfa-push): command: cat ./test/integration/fixtures/update-ul-prompts-mfa-push.json | auth0 ul prompts update mfa-push