Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make necessary calls to GET Partials basis on the promptType #1107

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions internal/cli/universal_login_customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
70 changes: 0 additions & 70 deletions test/integration/rules-test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions test/integration/universal-login-test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down