Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
32 changes: 10 additions & 22 deletions management/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,27 +501,6 @@ type PromptRenderingList struct {
PromptRenderings []*PromptRendering `json:"configs"`
}

// MarshalJSON implements a custom [json.Marshaler].
func (c *PromptRendering) MarshalJSON() ([]byte, error) {
type RenderingSubSet struct {
RenderingMode *RenderingMode `json:"rendering_mode,omitempty"`
ContextConfiguration *[]string `json:"context_configuration,omitempty"`
DefaultHeadTagsDisabled *bool `json:"default_head_tags_disabled,omitempty"`
HeadTags []interface{} `json:"head_tags,omitempty"`
Filters *PromptRenderingFilters `json:"filters,omitempty"`
UsePageTemplate *bool `json:"use_page_template,omitempty"`
}

return json.Marshal(&RenderingSubSet{
RenderingMode: c.RenderingMode,
ContextConfiguration: c.ContextConfiguration,
DefaultHeadTagsDisabled: c.DefaultHeadTagsDisabled,
HeadTags: c.HeadTags,
Filters: c.Filters,
UsePageTemplate: c.UsePageTemplate,
})
}

// MarshalJSON implements a custom [json.Marshaler].
func (c *PromptPartials) MarshalJSON() ([]byte, error) {
body := map[string]PromptPartials{
Expand Down Expand Up @@ -688,14 +667,23 @@ func (m *PromptManager) ReadRendering(ctx context.Context, prompt PromptType, sc
err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(prompt), "screen", string(screen), "rendering"), &c, opts...)
return
}

func (c *PromptRendering) cleanForPatch() *PromptRendering {
if c.RenderingMode != nil && *c.RenderingMode == RenderingModeStandard {
return &PromptRendering{
RenderingMode: c.RenderingMode,
}
}

return c
return &PromptRendering{
RenderingMode: c.RenderingMode,
ContextConfiguration: c.ContextConfiguration,
DefaultHeadTagsDisabled: c.DefaultHeadTagsDisabled,
HeadTags: c.HeadTags,
Tenant: c.Tenant,
Filters: c.Filters,
UsePageTemplate: c.UsePageTemplate,
}
}

// UpdateRendering updates the settings for the ACUL.
Expand Down
6 changes: 6 additions & 0 deletions management/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ func TestPromptManager_ListRendering(t *testing.T) {
for _, r := range actual.PromptRenderings {
if r.RenderingMode != nil && expected.RenderingMode != nil &&
*r.GetRenderingMode() == *expected.GetRenderingMode() &&
*r.GetScreen() == *expected.Screen &&
*r.GetPrompt() == *expected.GetPrompt() &&
assert.Equal(t, expected.GetContextConfiguration(), r.GetContextConfiguration()) &&
assert.Equal(t, expected.GetDefaultHeadTagsDisabled(), r.GetDefaultHeadTagsDisabled()) &&
assert.Equal(t, expected.GetFilters(), r.GetFilters()) &&
Expand Down Expand Up @@ -503,6 +505,10 @@ func givenAPromptRendering(t *testing.T, mode RenderingMode, clientID string) *P
err := api.Prompt.UpdateRendering(context.Background(), PromptSignup, ScreenSignup, settings)
assert.NoError(t, err)

settings, _ = api.Prompt.ReadRendering(context.Background(), PromptSignup, ScreenSignup)

assert.NoError(t, err)

return settings
}

Expand Down
57 changes: 45 additions & 12 deletions test/data/recordings/TestPromptManager_ListRendering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,39 @@ interactions:
status: 200 OK
code: 200
duration: 332.258583ms
- id: 4
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
User-Agent:
- Go-Auth0/1.22.2
url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/screen/signup/rendering
method: GET
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: -1
uncompressed: true
body: '{"tenant":"go-auth0-dev.eu.auth0.com","prompt":"signup","screen":"signup","rendering_mode":"advanced","context_configuration":["branding.settings","branding.themes.default"],"default_head_tags_disabled":false,"head_tags":[{"tag":"script","content":"","attributes":{"src":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js","async":true,"defer":true,"integrity":["sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="]}}],"filters":{"match_type":"includes_any","clients":[{"id":"SPOw9QzF554tNbQP7i3EZKgRSjgLnw0B","metadata":{"key1":"value1"}}]},"use_page_template":true}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 419.255042ms
- id: 4
request:
proto: HTTP/1.1
Expand Down Expand Up @@ -192,7 +225,7 @@ interactions:
body: ""
form: {}
headers:
User-Agent:
User-Agent:
- Go-Auth0/1.23.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients/SPOw9QzF554tNbQP7i3EZKgRSjgLnw0B
method: DELETE
Expand All @@ -205,9 +238,8 @@ interactions:
content_length: 0
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
headers:Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 683.974042ms
Expand All @@ -225,8 +257,8 @@ interactions:
body: ""
form: {}
headers:
User-Agent:
- Go-Auth0/1.23.0
User-Agent:
- Go-Auth0/1.23.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login
method: DELETE
response:
Expand All @@ -239,8 +271,8 @@ interactions:
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 338.899292ms
Expand All @@ -258,8 +290,9 @@ interactions:
body: ""
form: {}
headers:
User-Agent:
- Go-Auth0/1.23.0

User-Agent:
- Go-Auth0/1.23.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_hv7NGPLTPFhPcF6l
method: DELETE
response:
Expand All @@ -272,8 +305,8 @@ interactions:
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 510.367375ms
33 changes: 33 additions & 0 deletions test/data/recordings/TestPromptManager_ReadRendering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,39 @@ interactions:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 386.038416ms
- id: 4
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
User-Agent:
- Go-Auth0/1.22.2
url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/screen/signup/rendering
method: GET
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: -1
uncompressed: true
body: '{"tenant":"go-auth0-dev.eu.auth0.com","prompt":"signup","screen":"signup","rendering_mode":"advanced","context_configuration":["branding.settings","branding.themes.default"],"default_head_tags_disabled":false,"head_tags":[{"tag":"script","content":"","attributes":{"src":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js","async":true,"defer":true,"integrity":["sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="]}}],"filters":{"match_type":"includes_any","clients":[{"id":"SeunfRe6p8EXxV6I0g9kMYdT1DxpfC38","metadata":{"key1":"value1"}}]},"use_page_template":true}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 315.528459ms
- id: 5
request:
Expand Down
52 changes: 42 additions & 10 deletions test/data/recordings/TestPromptManager_UpdateRendering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,39 @@ interactions:
code: 200
duration: 647.619458ms
- id: 4
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ''
request_uri: ''
body: ''
form: {}
headers:
User-Agent:
- Go-Auth0/1.22.2
url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/screen/signup/rendering
method: GET
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: -1
uncompressed: true
body: '{"tenant":"go-auth0-dev.eu.auth0.com","prompt":"signup","screen":"signup","rendering_mode":"standard","context_configuration":["branding.settings","branding.themes.default"],"default_head_tags_disabled":false,"head_tags":[{"tag":"script","content":"","attributes":{"src":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js","async":true,"defer":true,"integrity":["sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="]}}],"filters":null,"use_page_template":false}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 385.340125ms
- id: 2
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -156,8 +189,7 @@ interactions:
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"context_configuration":["branding.settings","branding.themes.default","client.logo_uri"],"default_head_tags_disabled":true,"filters":{"match_type":"excludes_any","clients":[{"id":"qkTxebDC5HUGmUiaSrwQNPD5f1Q0W8px","metadata":{"key2":"value2"}}]},"use_page_template":false}
body: '{"context_configuration":["branding.settings","branding.themes.default","client.logo_uri"],"default_head_tags_disabled":true,"filters":{"match_type":"excludes_any","clients":[{"id":"qkTxebDC5HUGmUiaSrwQNPD5f1Q0W8px","metadata":{"key2":"value2"}}]},"use_page_template":false}'
form: {}
headers:
Content-Type:
Expand Down Expand Up @@ -209,8 +241,8 @@ interactions:
uncompressed: true
body: '{"tenant":"go-auth0-dev.eu.auth0.com","prompt":"signup","screen":"signup","rendering_mode":"advanced","context_configuration":["branding.settings","branding.themes.default","client.logo_uri"],"default_head_tags_disabled":true,"head_tags":[{"tag":"script","content":"","attributes":{"src":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js","async":true,"defer":true,"integrity":["sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="]}}],"filters":{"clients":[{"id":"qkTxebDC5HUGmUiaSrwQNPD5f1Q0W8px","metadata":{"key2":"value2"}}],"match_type":"excludes_any"},"use_page_template":false}'
headers:
Content-Type:
- application/json; charset=utf-8
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 344.398791ms
Expand Down Expand Up @@ -242,8 +274,8 @@ interactions:
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 443.196334ms
Expand All @@ -261,8 +293,8 @@ interactions:
body: ""
form: {}
headers:
User-Agent:
- Go-Auth0/1.23.0
User-Agent:
- Go-Auth0/1.23.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login
method: DELETE
response:
Expand All @@ -275,8 +307,8 @@ interactions:
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 400.1235ms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,39 @@ interactions:
status: 200 OK
code: 200
duration: 367.547209ms
- id: 4
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
User-Agent:
- Go-Auth0/1.22.2
url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/screen/signup/rendering
method: GET
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: -1
uncompressed: true
body: '{"tenant":"go-auth0-dev.eu.auth0.com","prompt":"signup","screen":"signup","rendering_mode":"standard","context_configuration":["branding.settings","branding.themes.default"],"default_head_tags_disabled":false,"head_tags":[{"tag":"script","content":"","attributes":{"src":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js","async":true,"defer":true,"integrity":["sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="]}}],"filters":null,"use_page_template":false}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 454.538042ms
- id: 4
request:
proto: HTTP/1.1
Expand All @@ -157,7 +190,7 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"rendering_mode":"advanced","context_configuration":["branding.settings","branding.themes.default","client.logo_uri"],"default_head_tags_disabled":true,"filters":{"match_type":"excludes_any","clients":[{"id":"753twTkstH6aaBMqb63cyLx72pSfqWND","metadata":{"key2":"value2"}}]},"use_page_template":false}
{"rendering_mode":"advanced","context_configuration":["branding.settings","branding.themes.default","client.logo_uri"],"default_head_tags_disabled":true,"filters":{"match_type":"excludes_any","clients":[{"id":"753twTkstH6aaBMqb63cyLx72pSfqWND","metadata":{"key2":"value2"}}]},"use_page_template":false}
form: {}
headers:
Content-Type:
Expand Down Expand Up @@ -209,8 +242,8 @@ interactions:
uncompressed: true
body: '{"tenant":"go-auth0-dev.eu.auth0.com","prompt":"signup","screen":"signup","rendering_mode":"advanced","context_configuration":["branding.settings","branding.themes.default","client.logo_uri"],"default_head_tags_disabled":true,"head_tags":[{"tag":"script","content":"","attributes":{"src":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js","async":true,"defer":true,"integrity":["sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="]}}],"filters":{"clients":[{"id":"753twTkstH6aaBMqb63cyLx72pSfqWND","metadata":{"key2":"value2"}}],"match_type":"excludes_any"},"use_page_template":false}'
headers:
Content-Type:
- application/json; charset=utf-8
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 311.432542ms
Expand Down
Loading
Loading