diff --git a/internal/cli/universal_login.go b/internal/cli/universal_login.go index 1bf1cca23..4e3d802fa 100644 --- a/internal/cli/universal_login.go +++ b/internal/cli/universal_login.go @@ -178,7 +178,7 @@ func updateUniversalLoginCmd(cli *cli) *cobra.Command { b := &management.Branding{} isAccentColorSet := len(inputs.AccentColor) > 0 isBackgroundColorSet := len(inputs.BackgroundColor) > 0 - currentHasColors := current.Colors != nil + currentHasColors := current.GetColors() != nil if isAccentColorSet || isBackgroundColorSet || currentHasColors { b.Colors = &management.BrandingColors{} @@ -196,15 +196,11 @@ func updateUniversalLoginCmd(cli *cli) *cobra.Command { } } - if len(inputs.LogoURL) == 0 { - b.LogoURL = current.LogoURL - } else { + if len(inputs.LogoURL) != 0 { b.LogoURL = &inputs.LogoURL } - if len(inputs.FaviconURL) == 0 { - b.FaviconURL = current.FaviconURL - } else { + if len(inputs.FaviconURL) != 0 { b.FaviconURL = &inputs.FaviconURL } @@ -213,14 +209,6 @@ func updateUniversalLoginCmd(cli *cli) *cobra.Command { b.Font = &management.BrandingFont{URL: &inputs.CustomFontURL} } - if b.Font != nil { - if len(inputs.CustomFontURL) == 0 { - b.Font.URL = current.Font.URL - } else { - b.Font.URL = &inputs.CustomFontURL - } - } - // Update branding if err := ansi.Waiting(func() error { return cli.api.Branding.Update(b) diff --git a/test/integration/scripts/test-cleanup.sh b/test/integration/scripts/test-cleanup.sh index fd53bfbe1..2d36915ca 100755 --- a/test/integration/scripts/test-cleanup.sh +++ b/test/integration/scripts/test-cleanup.sh @@ -122,4 +122,7 @@ for action in $( echo "${actions}" | jq -r '.[] | @base64' ); do fi done +# Reset universal login branding +auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo.png" --favicon "https://example.com/favicon.png" --font https://example.com/font.woff --no-input + rm -rf test/integration/identifiers diff --git a/test/integration/universal-login-test-cases.yaml b/test/integration/universal-login-test-cases.yaml new file mode 100644 index 000000000..4dcf24da5 --- /dev/null +++ b/test/integration/universal-login-test-cases.yaml @@ -0,0 +1,73 @@ +config: + inherit-env: true + +tests: + 001 - sets default expected values: + command: auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo.png" --favicon "https://example.com/favicon.png" --font https://example.com/font.woff --no-input + exit-code: 0 + + 002 - it successfully shows universal login branding: + command: auth0 ul show + exit-code: 0 + stdout: + contains: + - "ACCENT COLOR #2A2E35" + - "BACKGROUND COLOR #FF4F40" + - LOGO URL https://example.com/logo.png + - FAVICON URL https://example.com/favicon.png + - CUSTOM FONT URL https://example.com/font.woff + + 003 - it successfully shows universal login branding in json: + command: auth0 ul show --json + exit-code: 0 + stdout: + json: + colors.primary: "#2A2E35" + colors.page_background: "#FF4F40" + favicon_url: "https://example.com/favicon.png" + logo_url: "https://example.com/logo.png" + font.url: "https://example.com/font.woff" + + 004 - it successfully updates universal login branding: + command: auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo-updated.png" --favicon "https://example.com/favicon-updated.png" --font https://example.com/font-updated.woff + exit-code: 0 + stdout: + contains: + - "ACCENT COLOR #2A2E35" + - "BACKGROUND COLOR #FF4F40" + - LOGO URL https://example.com/logo-updated.png + - FAVICON URL https://example.com/favicon-updated.png + - CUSTOM FONT URL https://example.com/font-updated.woff + + 005 - it successfully updates universal login branding and outputs as json: + command: auth0 ul update --accent "#FF4F40" --background "#2A2E35" --logo "https://example.com/logo-updated-json.png" --favicon "https://example.com/favicon-updated-json.png" --font https://example.com/font-updated-json.woff --json + exit-code: 0 + stdout: + json: + colors.primary: "#FF4F40" + colors.page_background: "#2A2E35" + favicon_url: "https://example.com/favicon-updated-json.png" + logo_url: "https://example.com/logo-updated-json.png" + font.url: "https://example.com/font-updated-json.woff" + + 006 - it successfully updates universal login branding and persists previous colors: + command: auth0 ul update --logo "https://example.com/logo-updated-2.png" --favicon "https://example.com/favicon-updated-2.png" --font https://example.com/font-updated-2.woff --json + exit-code: 0 + stdout: + json: + colors.primary: "#FF4F40" + colors.page_background: "#2A2E35" + favicon_url: "https://example.com/favicon-updated-2.png" + logo_url: "https://example.com/logo-updated-2.png" + font.url: "https://example.com/font-updated-2.woff" + + 007 - it successfully updates universal login branding and persists previous URLs: + command: auth0 ul update --accent "#2A2E35" --background "#FF4F40" --json + exit-code: 0 + stdout: + json: + colors.primary: "#2A2E35" + colors.page_background: "#FF4F40" + favicon_url: "https://example.com/favicon-updated-2.png" + logo_url: "https://example.com/logo-updated-2.png" + font.url: "https://example.com/font-updated-2.woff"