From 3a0f6e6ba53068b299d07ccab0b6b2f51e1a3bbf Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Mon, 29 Jan 2024 13:31:55 -0500 Subject: [PATCH 01/14] feat: Add Custom Prompt Support --- management/custom_prompt.go | 71 ++++++++++++++++++++ management/custom_prompt_test.go | 110 +++++++++++++++++++++++++++++++ management/management.go | 4 ++ 3 files changed, 185 insertions(+) create mode 100644 management/custom_prompt.go create mode 100644 management/custom_prompt_test.go diff --git a/management/custom_prompt.go b/management/custom_prompt.go new file mode 100644 index 00000000..ec42a34a --- /dev/null +++ b/management/custom_prompt.go @@ -0,0 +1,71 @@ +package management + +import ( + "context" + "fmt" + "slices" +) + +// CustomPrompt to be used on authentication pages. +// +// See: https://auth0.com/docs/sign-up-prompt-customizations#-signup-prompt-entry-points +type CustomPrompt struct { + FormContentStart string `json:"form-content-start,omitempty"` + FormContentEnd string `json:"form-content-end,omitempty"` + FormFooterStart string `json:"form-footer-start,omitempty"` + FormFooterEnd string `json:"form-footer-end,omitempty"` + SecondaryActionsStart string `json:"secondary-actions-start,omitempty"` + SecondaryActionsEnd string `json:"secondary-actions-end,omitempty"` + + // Prompt state for custom prompt. Options are: + // - signup + // - signup-id + // - signup-password + Prompt CustomPromptType `json:"-"` +} + +// CustomPromptManager manages Auth0 CustomPrompt resources. +type CustomPromptManager manager + +type CustomPromptType string + +const ( + CustomPromptSignup CustomPromptType = "signup" + CustomPromptSignupID CustomPromptType = "signup-id" + CustomPromptSignupPassword CustomPromptType = "signup-password" +) + +var validPrompts = []CustomPromptType{CustomPromptSignup, CustomPromptSignupID, CustomPromptSignupPassword} + +// Create a new custom prompt partial. +func (m *CustomPromptManager) Create(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { + if !slices.Contains(validPrompts, c.Prompt) { + return fmt.Errorf("invalid custom prompt: %s", c.Prompt) + } + return m.management.Request(ctx, "POST", m.management.URI("prompts", string(c.Prompt), "partials"), c, opts...) +} + +// Update a custom prompt partial. +func (m *CustomPromptManager) Update(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { + if !slices.Contains(validPrompts, c.Prompt) { + return fmt.Errorf("invalid custom prompt: %s", c.Prompt) + } + return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Prompt), "partials"), c, opts...) +} + +// Read a custom prompt partial. +func (m *CustomPromptManager) Read(ctx context.Context, prompt CustomPromptType, opts ...RequestOption) (c *CustomPrompt, err error) { + if !slices.Contains(validPrompts, CustomPromptType(prompt)) { + return nil, fmt.Errorf("invalid custom prompt: %s", prompt) + } + err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(prompt), "partials"), &c, opts...) + return +} + +// Delete a custom prompt partial. +func (m *CustomPromptManager) Delete(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { + if !slices.Contains(validPrompts, c.Prompt) { + return fmt.Errorf("invalid custom prompt: %s", c.Prompt) + } + return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Prompt), "partials"), &CustomPrompt{}, opts...) +} diff --git a/management/custom_prompt_test.go b/management/custom_prompt_test.go new file mode 100644 index 00000000..81ecb0a1 --- /dev/null +++ b/management/custom_prompt_test.go @@ -0,0 +1,110 @@ +package management + +import ( + "context" + "errors" + "github.com/stretchr/testify/assert" + "net/http" + "testing" +) + +func TestCustomPromptManager_Read(t *testing.T) { + configureHTTPTestRecordings(t) + + prompt := CustomPromptSignup + expected := &CustomPrompt{Prompt: prompt} + got, err := api.CustomPrompt.Read(context.Background(), prompt) + + assertNoCustomDomainErr(t, err) + assert.Equal(t, expected, got) +} + +func TestCustomPromptManager_Create(t *testing.T) { + configureHTTPTestRecordings(t) + + prompt := CustomPromptSignup + original, err := api.CustomPrompt.Read(context.Background(), prompt) + assertNoCustomPromptError(t, err) + + expected := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} + + err = api.CustomPrompt.Create(context.Background(), expected) + assertNoCustomPromptError(t, err) + + got, err := api.CustomPrompt.Read(context.Background(), prompt) + assertNoCustomPromptError(t, err) + + assert.Equal(t, expected, got) + assert.NotEqual(t, original, got) + + t.Cleanup(func() { + cleanupCustomPrompt(t, prompt) + }) +} + +func TestCustomPromptManager_Update(t *testing.T) { + configureHTTPTestRecordings(t) + + prompt := CustomPromptSignup + original := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} + + err := api.CustomPrompt.Create(context.Background(), original) + assertNoCustomPromptError(t, err) + + expected := &CustomPrompt{Prompt: prompt, FormContentStart: `
Updated Test Content
`} + err = api.CustomPrompt.Update(context.Background(), expected) + assertNoCustomPromptError(t, err) + + got, err := api.CustomPrompt.Read(context.Background(), prompt) + assertNoCustomPromptError(t, err) + + assert.Equal(t, expected, got) + assert.NotEqual(t, original, expected) + + t.Cleanup(func() { + cleanupCustomPrompt(t, prompt) + }) +} + +func TestCustomPromptManager_Delete(t *testing.T) { + configureHTTPTestRecordings(t) + + prompt := CustomPromptSignup + original := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} + + err := api.CustomPrompt.Create(context.Background(), original) + assertNoCustomPromptError(t, err) + + expected := &CustomPrompt{Prompt: prompt} + err = api.CustomPrompt.Delete(context.Background(), expected) + assertNoCustomPromptError(t, err) + + got, err := api.CustomPrompt.Read(context.Background(), prompt) + assertNoCustomPromptError(t, err) + + assert.Equal(t, expected, got) + assert.NotEqual(t, original, expected) + + t.Cleanup(func() { + cleanupCustomPrompt(t, prompt) + }) +} + +func cleanupCustomPrompt(t *testing.T, prompt CustomPromptType) { + t.Helper() + + c := &CustomPrompt{Prompt: prompt} + err := api.CustomPrompt.Delete(context.Background(), c) + assertNoCustomPromptError(t, err) +} + +func assertNoCustomPromptError(t *testing.T, err error) { + if err != nil { + var mErr Error + if errors.As(err, &mErr) && mErr.Status() == http.StatusForbidden { + t.Skip(err) + return + } + t.Error(err) + } +} diff --git a/management/management.go b/management/management.go index f4cf979e..38b4ecd3 100644 --- a/management/management.go +++ b/management/management.go @@ -31,6 +31,9 @@ type Management struct { // CustomDomain manages Auth0 Custom Domains. CustomDomain *CustomDomainManager + // CustomPrompt manages Auth0 Custom Prompt Partials + CustomPrompt *CustomPromptManager + // Grant manages Auth0 Grants. Grant *GrantManager @@ -168,6 +171,7 @@ func New(domain string, options ...Option) (*Management, error) { m.ClientGrant = (*ClientGrantManager)(&m.common) m.Connection = (*ConnectionManager)(&m.common) m.CustomDomain = (*CustomDomainManager)(&m.common) + m.CustomPrompt = (*CustomPromptManager)(&m.common) m.EmailProvider = (*EmailProviderManager)(&m.common) m.EmailTemplate = (*EmailTemplateManager)(&m.common) m.Grant = (*GrantManager)(&m.common) From 83483762a0572c8a2b47b59bb0b367c35e27d2c0 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Mon, 29 Jan 2024 13:41:27 -0500 Subject: [PATCH 02/14] Use go 1.21.x for generics support --- go.mod | 2 +- go.sum | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index aa206f5d..ebc97764 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/auth0/go-auth0 -go 1.20 +go 1.21 require ( github.com/PuerkitoBio/rehttp v1.3.0 diff --git a/go.sum b/go.sum index a24ef6ca..a94ab5c8 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= From 2a07c39c7cbce6a245297f6e51551fb87333d7a1 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Tue, 30 Jan 2024 12:01:01 -0500 Subject: [PATCH 03/14] Remove dependency on go 1.21 --- go.mod | 2 +- management/custom_prompt.go | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index ebc97764..aa206f5d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/auth0/go-auth0 -go 1.21 +go 1.20 require ( github.com/PuerkitoBio/rehttp v1.3.0 diff --git a/management/custom_prompt.go b/management/custom_prompt.go index ec42a34a..75e73594 100644 --- a/management/custom_prompt.go +++ b/management/custom_prompt.go @@ -3,7 +3,6 @@ package management import ( "context" "fmt" - "slices" ) // CustomPrompt to be used on authentication pages. @@ -39,24 +38,24 @@ var validPrompts = []CustomPromptType{CustomPromptSignup, CustomPromptSignupID, // Create a new custom prompt partial. func (m *CustomPromptManager) Create(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if !slices.Contains(validPrompts, c.Prompt) { - return fmt.Errorf("invalid custom prompt: %s", c.Prompt) + if err := validatePrompt(c.Prompt); err != nil { + return err } return m.management.Request(ctx, "POST", m.management.URI("prompts", string(c.Prompt), "partials"), c, opts...) } // Update a custom prompt partial. func (m *CustomPromptManager) Update(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if !slices.Contains(validPrompts, c.Prompt) { - return fmt.Errorf("invalid custom prompt: %s", c.Prompt) + if err := validatePrompt(c.Prompt); err != nil { + return err } return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Prompt), "partials"), c, opts...) } // Read a custom prompt partial. func (m *CustomPromptManager) Read(ctx context.Context, prompt CustomPromptType, opts ...RequestOption) (c *CustomPrompt, err error) { - if !slices.Contains(validPrompts, CustomPromptType(prompt)) { - return nil, fmt.Errorf("invalid custom prompt: %s", prompt) + if err := validatePrompt(prompt); err != nil { + return nil, err } err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(prompt), "partials"), &c, opts...) return @@ -64,8 +63,17 @@ func (m *CustomPromptManager) Read(ctx context.Context, prompt CustomPromptType, // Delete a custom prompt partial. func (m *CustomPromptManager) Delete(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if !slices.Contains(validPrompts, c.Prompt) { - return fmt.Errorf("invalid custom prompt: %s", c.Prompt) + if err := validatePrompt(c.Prompt); err != nil { + return err } return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Prompt), "partials"), &CustomPrompt{}, opts...) } + +func validatePrompt(prompt CustomPromptType) error { + for _, p := range validPrompts { + if p == prompt { + return nil + } + } + return fmt.Errorf("invalid custom prompt: %s", prompt) +} From 90814793e5274c6c27bb5de8569d838a8ac873e0 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Tue, 30 Jan 2024 13:17:26 -0500 Subject: [PATCH 04/14] Add Login partials support --- management/custom_prompt.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/management/custom_prompt.go b/management/custom_prompt.go index 75e73594..2f14b1c1 100644 --- a/management/custom_prompt.go +++ b/management/custom_prompt.go @@ -32,9 +32,19 @@ const ( CustomPromptSignup CustomPromptType = "signup" CustomPromptSignupID CustomPromptType = "signup-id" CustomPromptSignupPassword CustomPromptType = "signup-password" + CustomPromptLogin CustomPromptType = "login" + CustomPromptLoginID CustomPromptType = "login-id" + CustomPromptLoginPassword CustomPromptType = "login-password" ) -var validPrompts = []CustomPromptType{CustomPromptSignup, CustomPromptSignupID, CustomPromptSignupPassword} +var validPrompts = []CustomPromptType{ + CustomPromptSignup, + CustomPromptSignupID, + CustomPromptSignupPassword, + CustomPromptLogin, + CustomPromptLoginID, + CustomPromptLoginPassword, +} // Create a new custom prompt partial. func (m *CustomPromptManager) Create(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { From fb845342dbafc708cd6291e95f0e991126419898 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Wed, 31 Jan 2024 10:08:00 -0500 Subject: [PATCH 05/14] Ensure Custom Domain added for Custom Prompt test runs --- .gitignore | 1 + management/custom_prompt_test.go | 18 +++++++++++++----- management/management.gen.go | 5 +++++ management/management.gen_test.go | 8 ++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f5a19a3c..415f4023 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ vendor/ ### Local .env file .env +.envrc diff --git a/management/custom_prompt_test.go b/management/custom_prompt_test.go index 81ecb0a1..58c58929 100644 --- a/management/custom_prompt_test.go +++ b/management/custom_prompt_test.go @@ -11,17 +11,21 @@ import ( func TestCustomPromptManager_Read(t *testing.T) { configureHTTPTestRecordings(t) + customDomain := givenACustomDomain(t) prompt := CustomPromptSignup expected := &CustomPrompt{Prompt: prompt} got, err := api.CustomPrompt.Read(context.Background(), prompt) - assertNoCustomDomainErr(t, err) + assertNoCustomPromptError(t, err) assert.Equal(t, expected, got) + + cleanupCustomDomain(t, customDomain.GetID()) } func TestCustomPromptManager_Create(t *testing.T) { configureHTTPTestRecordings(t) + customDomain := givenACustomDomain(t) prompt := CustomPromptSignup original, err := api.CustomPrompt.Read(context.Background(), prompt) assertNoCustomPromptError(t, err) @@ -38,13 +42,14 @@ func TestCustomPromptManager_Create(t *testing.T) { assert.NotEqual(t, original, got) t.Cleanup(func() { - cleanupCustomPrompt(t, prompt) + cleanupCustomPrompt(t, customDomain.GetID(), prompt) }) } func TestCustomPromptManager_Update(t *testing.T) { configureHTTPTestRecordings(t) + customDomain := givenACustomDomain(t) prompt := CustomPromptSignup original := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} @@ -62,13 +67,14 @@ func TestCustomPromptManager_Update(t *testing.T) { assert.NotEqual(t, original, expected) t.Cleanup(func() { - cleanupCustomPrompt(t, prompt) + cleanupCustomPrompt(t, customDomain.GetID(), prompt) }) } func TestCustomPromptManager_Delete(t *testing.T) { configureHTTPTestRecordings(t) + customDomain := givenACustomDomain(t) prompt := CustomPromptSignup original := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} @@ -86,16 +92,18 @@ func TestCustomPromptManager_Delete(t *testing.T) { assert.NotEqual(t, original, expected) t.Cleanup(func() { - cleanupCustomPrompt(t, prompt) + cleanupCustomPrompt(t, customDomain.GetID(), prompt) }) } -func cleanupCustomPrompt(t *testing.T, prompt CustomPromptType) { +func cleanupCustomPrompt(t *testing.T, customDomainID string, prompt CustomPromptType) { t.Helper() c := &CustomPrompt{Prompt: prompt} err := api.CustomPrompt.Delete(context.Background(), c) assertNoCustomPromptError(t, err) + + cleanupCustomDomain(t, customDomainID) } func assertNoCustomPromptError(t *testing.T, err error) { diff --git a/management/management.gen.go b/management/management.gen.go index 86d8b10f..51e7d80f 100644 --- a/management/management.gen.go +++ b/management/management.gen.go @@ -5874,6 +5874,11 @@ func (c *CustomDomainVerification) String() string { return Stringify(c) } +// String returns a string representation of CustomPrompt. +func (c *CustomPrompt) String() string { + return Stringify(c) +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (d *DailyStat) GetCreatedAt() time.Time { if d == nil || d.CreatedAt == nil { diff --git a/management/management.gen_test.go b/management/management.gen_test.go index 228451a3..9527f98d 100644 --- a/management/management.gen_test.go +++ b/management/management.gen_test.go @@ -7288,6 +7288,14 @@ func TestCustomDomainVerification_String(t *testing.T) { } } +func TestCustomPrompt_String(t *testing.T) { + var rawJSON json.RawMessage + v := &CustomPrompt{} + if err := json.Unmarshal([]byte(v.String()), &rawJSON); err != nil { + t.Errorf("failed to produce a valid json") + } +} + func TestDailyStat_GetCreatedAt(tt *testing.T) { var zeroValue time.Time d := &DailyStat{CreatedAt: &zeroValue} From 4eed3eda140fc2ddb3d037f44422b82b3bfe340f Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Wed, 31 Jan 2024 12:59:32 -0500 Subject: [PATCH 06/14] Refactor CustomPrompt into Prompt namespace --- management/custom_prompt.go | 89 ----------------------- management/custom_prompt_test.go | 118 ------------------------------- management/management.go | 4 -- management/prompt.go | 91 +++++++++++++++++++++++- management/prompt_test.go | 100 ++++++++++++++++++++++++++ 5 files changed, 190 insertions(+), 212 deletions(-) delete mode 100644 management/custom_prompt.go delete mode 100644 management/custom_prompt_test.go diff --git a/management/custom_prompt.go b/management/custom_prompt.go deleted file mode 100644 index 2f14b1c1..00000000 --- a/management/custom_prompt.go +++ /dev/null @@ -1,89 +0,0 @@ -package management - -import ( - "context" - "fmt" -) - -// CustomPrompt to be used on authentication pages. -// -// See: https://auth0.com/docs/sign-up-prompt-customizations#-signup-prompt-entry-points -type CustomPrompt struct { - FormContentStart string `json:"form-content-start,omitempty"` - FormContentEnd string `json:"form-content-end,omitempty"` - FormFooterStart string `json:"form-footer-start,omitempty"` - FormFooterEnd string `json:"form-footer-end,omitempty"` - SecondaryActionsStart string `json:"secondary-actions-start,omitempty"` - SecondaryActionsEnd string `json:"secondary-actions-end,omitempty"` - - // Prompt state for custom prompt. Options are: - // - signup - // - signup-id - // - signup-password - Prompt CustomPromptType `json:"-"` -} - -// CustomPromptManager manages Auth0 CustomPrompt resources. -type CustomPromptManager manager - -type CustomPromptType string - -const ( - CustomPromptSignup CustomPromptType = "signup" - CustomPromptSignupID CustomPromptType = "signup-id" - CustomPromptSignupPassword CustomPromptType = "signup-password" - CustomPromptLogin CustomPromptType = "login" - CustomPromptLoginID CustomPromptType = "login-id" - CustomPromptLoginPassword CustomPromptType = "login-password" -) - -var validPrompts = []CustomPromptType{ - CustomPromptSignup, - CustomPromptSignupID, - CustomPromptSignupPassword, - CustomPromptLogin, - CustomPromptLoginID, - CustomPromptLoginPassword, -} - -// Create a new custom prompt partial. -func (m *CustomPromptManager) Create(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if err := validatePrompt(c.Prompt); err != nil { - return err - } - return m.management.Request(ctx, "POST", m.management.URI("prompts", string(c.Prompt), "partials"), c, opts...) -} - -// Update a custom prompt partial. -func (m *CustomPromptManager) Update(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if err := validatePrompt(c.Prompt); err != nil { - return err - } - return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Prompt), "partials"), c, opts...) -} - -// Read a custom prompt partial. -func (m *CustomPromptManager) Read(ctx context.Context, prompt CustomPromptType, opts ...RequestOption) (c *CustomPrompt, err error) { - if err := validatePrompt(prompt); err != nil { - return nil, err - } - err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(prompt), "partials"), &c, opts...) - return -} - -// Delete a custom prompt partial. -func (m *CustomPromptManager) Delete(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if err := validatePrompt(c.Prompt); err != nil { - return err - } - return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Prompt), "partials"), &CustomPrompt{}, opts...) -} - -func validatePrompt(prompt CustomPromptType) error { - for _, p := range validPrompts { - if p == prompt { - return nil - } - } - return fmt.Errorf("invalid custom prompt: %s", prompt) -} diff --git a/management/custom_prompt_test.go b/management/custom_prompt_test.go deleted file mode 100644 index 58c58929..00000000 --- a/management/custom_prompt_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package management - -import ( - "context" - "errors" - "github.com/stretchr/testify/assert" - "net/http" - "testing" -) - -func TestCustomPromptManager_Read(t *testing.T) { - configureHTTPTestRecordings(t) - - customDomain := givenACustomDomain(t) - prompt := CustomPromptSignup - expected := &CustomPrompt{Prompt: prompt} - got, err := api.CustomPrompt.Read(context.Background(), prompt) - - assertNoCustomPromptError(t, err) - assert.Equal(t, expected, got) - - cleanupCustomDomain(t, customDomain.GetID()) -} - -func TestCustomPromptManager_Create(t *testing.T) { - configureHTTPTestRecordings(t) - - customDomain := givenACustomDomain(t) - prompt := CustomPromptSignup - original, err := api.CustomPrompt.Read(context.Background(), prompt) - assertNoCustomPromptError(t, err) - - expected := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} - - err = api.CustomPrompt.Create(context.Background(), expected) - assertNoCustomPromptError(t, err) - - got, err := api.CustomPrompt.Read(context.Background(), prompt) - assertNoCustomPromptError(t, err) - - assert.Equal(t, expected, got) - assert.NotEqual(t, original, got) - - t.Cleanup(func() { - cleanupCustomPrompt(t, customDomain.GetID(), prompt) - }) -} - -func TestCustomPromptManager_Update(t *testing.T) { - configureHTTPTestRecordings(t) - - customDomain := givenACustomDomain(t) - prompt := CustomPromptSignup - original := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} - - err := api.CustomPrompt.Create(context.Background(), original) - assertNoCustomPromptError(t, err) - - expected := &CustomPrompt{Prompt: prompt, FormContentStart: `
Updated Test Content
`} - err = api.CustomPrompt.Update(context.Background(), expected) - assertNoCustomPromptError(t, err) - - got, err := api.CustomPrompt.Read(context.Background(), prompt) - assertNoCustomPromptError(t, err) - - assert.Equal(t, expected, got) - assert.NotEqual(t, original, expected) - - t.Cleanup(func() { - cleanupCustomPrompt(t, customDomain.GetID(), prompt) - }) -} - -func TestCustomPromptManager_Delete(t *testing.T) { - configureHTTPTestRecordings(t) - - customDomain := givenACustomDomain(t) - prompt := CustomPromptSignup - original := &CustomPrompt{Prompt: prompt, FormContentStart: `
Test Content
`} - - err := api.CustomPrompt.Create(context.Background(), original) - assertNoCustomPromptError(t, err) - - expected := &CustomPrompt{Prompt: prompt} - err = api.CustomPrompt.Delete(context.Background(), expected) - assertNoCustomPromptError(t, err) - - got, err := api.CustomPrompt.Read(context.Background(), prompt) - assertNoCustomPromptError(t, err) - - assert.Equal(t, expected, got) - assert.NotEqual(t, original, expected) - - t.Cleanup(func() { - cleanupCustomPrompt(t, customDomain.GetID(), prompt) - }) -} - -func cleanupCustomPrompt(t *testing.T, customDomainID string, prompt CustomPromptType) { - t.Helper() - - c := &CustomPrompt{Prompt: prompt} - err := api.CustomPrompt.Delete(context.Background(), c) - assertNoCustomPromptError(t, err) - - cleanupCustomDomain(t, customDomainID) -} - -func assertNoCustomPromptError(t *testing.T, err error) { - if err != nil { - var mErr Error - if errors.As(err, &mErr) && mErr.Status() == http.StatusForbidden { - t.Skip(err) - return - } - t.Error(err) - } -} diff --git a/management/management.go b/management/management.go index 38b4ecd3..f4cf979e 100644 --- a/management/management.go +++ b/management/management.go @@ -31,9 +31,6 @@ type Management struct { // CustomDomain manages Auth0 Custom Domains. CustomDomain *CustomDomainManager - // CustomPrompt manages Auth0 Custom Prompt Partials - CustomPrompt *CustomPromptManager - // Grant manages Auth0 Grants. Grant *GrantManager @@ -171,7 +168,6 @@ func New(domain string, options ...Option) (*Management, error) { m.ClientGrant = (*ClientGrantManager)(&m.common) m.Connection = (*ConnectionManager)(&m.common) m.CustomDomain = (*CustomDomainManager)(&m.common) - m.CustomPrompt = (*CustomPromptManager)(&m.common) m.EmailProvider = (*EmailProviderManager)(&m.common) m.EmailTemplate = (*EmailTemplateManager)(&m.common) m.Grant = (*GrantManager)(&m.common) diff --git a/management/prompt.go b/management/prompt.go index f4ccfb64..25169dc2 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -1,6 +1,9 @@ package management -import "context" +import ( + "context" + "fmt" +) // Prompt is used within the Login Page. // @@ -16,6 +19,42 @@ type Prompt struct { WebAuthnPlatformFirstFactor *bool `json:"webauthn_platform_first_factor,omitempty"` } +// CustomPrompt to be used for Custom Prompt Partials. +// +// See: https://auth0.com/docs/sign-up-prompt-customizations +type CustomPrompt struct { + FormContentStart string `json:"form-content-start,omitempty"` + FormContentEnd string `json:"form-content-end,omitempty"` + FormFooterStart string `json:"form-footer-start,omitempty"` + FormFooterEnd string `json:"form-footer-end,omitempty"` + SecondaryActionsStart string `json:"secondary-actions-start,omitempty"` + SecondaryActionsEnd string `json:"secondary-actions-end,omitempty"` + + // Segment for custom prompt + Segment CustomPromptSegment `json:"-"` +} + +// CustomPromptSegment defines the partials segment that we are managing. +type CustomPromptSegment string + +const ( + CustomPromptSignup CustomPromptSegment = "signup" + CustomPromptSignupID CustomPromptSegment = "signup-id" + CustomPromptSignupPassword CustomPromptSegment = "signup-password" + CustomPromptLogin CustomPromptSegment = "login" + CustomPromptLoginID CustomPromptSegment = "login-id" + CustomPromptLoginPassword CustomPromptSegment = "login-password" +) + +var validCustomPromptSegments = []CustomPromptSegment{ + CustomPromptSignup, + CustomPromptSignupID, + CustomPromptSignupPassword, + CustomPromptLogin, + CustomPromptLoginID, + CustomPromptLoginPassword, +} + // PromptManager is used for managing a Prompt. type PromptManager manager @@ -49,3 +88,53 @@ func (m *PromptManager) SetCustomText(ctx context.Context, p string, l string, b err = m.management.Request(ctx, "PUT", m.management.URI("prompts", p, "custom-text", l), &b, opts...) return } + +// CreateCustomPartials creates new custom prompt partials for a given segment. +// +// See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts +func (m *PromptManager) CreateCustomPartials(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { + if err := validateCustomPromptSegment(c.Segment); err != nil { + return err + } + return m.management.Request(ctx, "POST", m.management.URI("prompts", string(c.Segment), "partials"), c, opts...) +} + +// UpdateCustomPartials updates custom prompt partials for a given segment. +// +// See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts +func (m *PromptManager) UpdateCustomPartials(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { + if err := validateCustomPromptSegment(c.Segment); err != nil { + return err + } + return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), c, opts...) +} + +// ReadCustomPartials reads custom prompt partials for a given segment. +// +// See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts +func (m *PromptManager) ReadCustomPartials(ctx context.Context, prompt CustomPromptSegment, opts ...RequestOption) (c *CustomPrompt, err error) { + if err := validateCustomPromptSegment(prompt); err != nil { + return nil, err + } + err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(prompt), "partials"), &c, opts...) + return +} + +// DeleteCustomPartials deletes custom prompt partials for a given segment. +// +// See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts +func (m *PromptManager) DeleteCustomPartials(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { + if err := validateCustomPromptSegment(c.Segment); err != nil { + return err + } + return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), &CustomPrompt{}, opts...) +} + +func validateCustomPromptSegment(segment CustomPromptSegment) error { + for _, p := range validCustomPromptSegments { + if p == segment { + return nil + } + } + return fmt.Errorf("invalid custom segment: %s", segment) +} diff --git a/management/prompt_test.go b/management/prompt_test.go index 3850ec8f..22b94e5e 100644 --- a/management/prompt_test.go +++ b/management/prompt_test.go @@ -78,3 +78,103 @@ func TestPromptCustomText(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "Welcome", texts["login"].(map[string]interface{})["title"]) } + +func TestPromptManager_ReadCustomPartials(t *testing.T) { + configureHTTPTestRecordings(t) + + customDomain := givenACustomDomain(t) + prompt := CustomPromptSignup + expected := &CustomPrompt{Segment: prompt} + got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + + assert.NoError(t, err) + assert.Equal(t, expected, got) + + t.Cleanup(func() { + cleanupCustomDomain(t, customDomain.GetID()) + }) +} + +func TestPromptManager_CreateCustomPartials(t *testing.T) { + configureHTTPTestRecordings(t) + + customDomain := givenACustomDomain(t) + prompt := CustomPromptSignup + original, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + assert.NoError(t, err) + + expected := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} + + err = api.Prompt.CreateCustomPartials(context.Background(), expected) + assert.NoError(t, err) + + got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + assert.NoError(t, err) + + assert.Equal(t, expected, got) + assert.NotEqual(t, original, got) + + t.Cleanup(func() { + cleanupCustomPrompt(t, customDomain.GetID(), prompt) + }) +} + +func TestPromptManager_UpdateCustomPartials(t *testing.T) { + configureHTTPTestRecordings(t) + + customDomain := givenACustomDomain(t) + prompt := CustomPromptSignup + original := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} + + err := api.Prompt.CreateCustomPartials(context.Background(), original) + assert.NoError(t, err) + + expected := &CustomPrompt{Segment: prompt, FormContentStart: `
Updated Test Content
`} + err = api.Prompt.UpdateCustomPartials(context.Background(), expected) + assert.NoError(t, err) + + got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + assert.NoError(t, err) + + assert.Equal(t, expected, got) + assert.NotEqual(t, original, expected) + + t.Cleanup(func() { + cleanupCustomPrompt(t, customDomain.GetID(), prompt) + }) +} + +func TestPromptManager_DeleteCustomPartials(t *testing.T) { + configureHTTPTestRecordings(t) + + customDomain := givenACustomDomain(t) + prompt := CustomPromptSignup + original := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} + + err := api.Prompt.CreateCustomPartials(context.Background(), original) + assert.NoError(t, err) + + expected := &CustomPrompt{Segment: prompt} + err = api.Prompt.DeleteCustomPartials(context.Background(), expected) + assert.NoError(t, err) + + got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + assert.NoError(t, err) + + assert.Equal(t, expected, got) + assert.NotEqual(t, original, expected) + + t.Cleanup(func() { + cleanupCustomPrompt(t, customDomain.GetID(), prompt) + }) +} + +func cleanupCustomPrompt(t *testing.T, customDomainID string, prompt CustomPromptSegment) { + t.Helper() + + c := &CustomPrompt{Segment: prompt} + err := api.Prompt.DeleteCustomPartials(context.Background(), c) + assert.NoError(t, err) + + cleanupCustomDomain(t, customDomainID) +} From e9f7c58256033c7f63aab25af8625b094cacb9d2 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 10:49:39 -0500 Subject: [PATCH 07/14] Implement Marshaler and Unmarshaler for CustomPrompt --- management/prompt.go | 33 +- management/prompt_test.go | 33 +- ...estPromptManager_CreateCustomPartials.yaml | 288 ++++++++++++++++ ...estPromptManager_DeleteCustomPartials.yaml | 324 ++++++++++++++++++ .../TestPromptManager_ReadCustomPartials.yaml | 216 ++++++++++++ ...estPromptManager_UpdateCustomPartials.yaml | 324 ++++++++++++++++++ 6 files changed, 1210 insertions(+), 8 deletions(-) create mode 100644 test/data/recordings/TestPromptManager_CreateCustomPartials.yaml create mode 100644 test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml create mode 100644 test/data/recordings/TestPromptManager_ReadCustomPartials.yaml create mode 100644 test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml diff --git a/management/prompt.go b/management/prompt.go index 25169dc2..537537c4 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -2,6 +2,7 @@ package management import ( "context" + "encoding/json" "fmt" ) @@ -34,6 +35,29 @@ type CustomPrompt struct { Segment CustomPromptSegment `json:"-"` } +func (c *CustomPrompt) MarshalJSON() ([]byte, error) { + body := map[string]CustomPrompt{string(c.Segment): *c} + return json.Marshal(body) +} + +func (c *CustomPrompt) UnmarshalJSON(data []byte) error { + var body map[string]map[string]string + if err := json.Unmarshal(data, &body); err != nil { + return err + } + + for k, v := range body { + c.FormContentStart = v["form-content-start"] + c.FormFooterEnd = v["form-content-end"] + c.FormFooterStart = v["form-footer-start"] + c.FormFooterEnd = v["form-footer-end"] + c.SecondaryActionsStart = v["secondary-actions-start"] + c.SecondaryActionsEnd = v["secondary-actions-end"] + c.Segment = CustomPromptSegment(k) + } + return nil +} + // CustomPromptSegment defines the partials segment that we are managing. type CustomPromptSegment string @@ -96,7 +120,7 @@ func (m *PromptManager) CreateCustomPartials(ctx context.Context, c *CustomPromp if err := validateCustomPromptSegment(c.Segment); err != nil { return err } - return m.management.Request(ctx, "POST", m.management.URI("prompts", string(c.Segment), "partials"), c, opts...) + return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), c, opts...) } // UpdateCustomPartials updates custom prompt partials for a given segment. @@ -112,11 +136,12 @@ func (m *PromptManager) UpdateCustomPartials(ctx context.Context, c *CustomPromp // ReadCustomPartials reads custom prompt partials for a given segment. // // See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts -func (m *PromptManager) ReadCustomPartials(ctx context.Context, prompt CustomPromptSegment, opts ...RequestOption) (c *CustomPrompt, err error) { - if err := validateCustomPromptSegment(prompt); err != nil { +func (m *PromptManager) ReadCustomPartials(ctx context.Context, segment CustomPromptSegment, opts ...RequestOption) (c *CustomPrompt, err error) { + if err := validateCustomPromptSegment(segment); err != nil { return nil, err } - err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(prompt), "partials"), &c, opts...) + c = &CustomPrompt{Segment: segment} + err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(segment), "partials"), c, opts...) return } diff --git a/management/prompt_test.go b/management/prompt_test.go index 22b94e5e..caa643d2 100644 --- a/management/prompt_test.go +++ b/management/prompt_test.go @@ -83,6 +83,7 @@ func TestPromptManager_ReadCustomPartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) + _ = givenAUniversalLogin(t) prompt := CustomPromptSignup expected := &CustomPrompt{Segment: prompt} got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) @@ -91,6 +92,7 @@ func TestPromptManager_ReadCustomPartials(t *testing.T) { assert.Equal(t, expected, got) t.Cleanup(func() { + cleanupUniversalLogin(t) cleanupCustomDomain(t, customDomain.GetID()) }) } @@ -99,13 +101,12 @@ func TestPromptManager_CreateCustomPartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) + _ = givenAUniversalLogin(t) prompt := CustomPromptSignup - original, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) - assert.NoError(t, err) - + original := &CustomPrompt{Segment: prompt} expected := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} - err = api.Prompt.CreateCustomPartials(context.Background(), expected) + err := api.Prompt.CreateCustomPartials(context.Background(), expected) assert.NoError(t, err) got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) @@ -123,6 +124,7 @@ func TestPromptManager_UpdateCustomPartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) + _ = givenAUniversalLogin(t) prompt := CustomPromptSignup original := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} @@ -148,6 +150,7 @@ func TestPromptManager_DeleteCustomPartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) + _ = givenAUniversalLogin(t) prompt := CustomPromptSignup original := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} @@ -169,6 +172,20 @@ func TestPromptManager_DeleteCustomPartials(t *testing.T) { }) } +func givenAUniversalLogin(t *testing.T) *BrandingUniversalLogin { + t.Helper() + + body := `{%- auth0:head -%}{%- auth0:widget -%}` + ul := &BrandingUniversalLogin{ + Body: auth0.String(body), + } + + err := api.Branding.SetUniversalLogin(context.Background(), ul) + assert.NoError(t, err) + + return ul +} + func cleanupCustomPrompt(t *testing.T, customDomainID string, prompt CustomPromptSegment) { t.Helper() @@ -176,5 +193,13 @@ func cleanupCustomPrompt(t *testing.T, customDomainID string, prompt CustomPromp err := api.Prompt.DeleteCustomPartials(context.Background(), c) assert.NoError(t, err) + cleanupUniversalLogin(t) cleanupCustomDomain(t, customDomainID) } + +func cleanupUniversalLogin(t *testing.T) { + t.Helper() + + err := api.Branding.DeleteUniversalLogin(context.Background()) + assert.NoError(t, err) +} diff --git a/test/data/recordings/TestPromptManager_CreateCustomPartials.yaml b/test/data/recordings/TestPromptManager_CreateCustomPartials.yaml new file mode 100644 index 00000000..d273459a --- /dev/null +++ b/test/data/recordings/TestPromptManager_CreateCustomPartials.yaml @@ -0,0 +1,288 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 99 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"domain":"1706802462.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 300 + uncompressed: false + body: '{"custom_domain_id":"cd_zlbyQ1KRsMq1U4wU","domain":"1706802462.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-zlbyq1krsmq1u4wu.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 3.18294075s + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 165 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + "\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e{%- auth0:head -%}\u003c/head\u003e\u003cbody\u003e{%- auth0:widget -%}\u003c/body\u003e\u003c/html\u003e" + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 2.361173625s + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 80 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{"form-content-start":"\u003cdiv\u003eTest Content\u003c/div\u003e"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signup":{"form-content-start":"
Test Content
"}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 299.663417ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 14 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signup":{"form-content-start":"
Test Content
"}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 204.141792ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 8 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 215.597667ms + - id: 5 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 388.773042ms + - id: 6 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_zlbyQ1KRsMq1U4wU + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 3.956540958s + - id: 7 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_zlbyQ1KRsMq1U4wU + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 208.044959ms diff --git a/test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml b/test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml new file mode 100644 index 00000000..18a6cec0 --- /dev/null +++ b/test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml @@ -0,0 +1,324 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 99 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"domain":"1706802539.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 300 + uncompressed: false + body: '{"custom_domain_id":"cd_eCPkkLLkx69hVURg","domain":"1706802539.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-ecpkkllkx69hvurg.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 3.667744667s + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 165 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + "\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e{%- auth0:head -%}\u003c/head\u003e\u003cbody\u003e{%- auth0:widget -%}\u003c/body\u003e\u003c/html\u003e" + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 2.452549917s + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 80 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{"form-content-start":"\u003cdiv\u003eTest Content\u003c/div\u003e"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signup":{"form-content-start":"
Test Content
"}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 208.344583ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 8 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 239.583667ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 14 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 196.406834ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 8 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 172.103792ms + - id: 6 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 319.958916ms + - id: 7 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_eCPkkLLkx69hVURg + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 4.594809583s + - id: 8 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_eCPkkLLkx69hVURg + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 188.793958ms diff --git a/test/data/recordings/TestPromptManager_ReadCustomPartials.yaml b/test/data/recordings/TestPromptManager_ReadCustomPartials.yaml new file mode 100644 index 00000000..ae91f698 --- /dev/null +++ b/test/data/recordings/TestPromptManager_ReadCustomPartials.yaml @@ -0,0 +1,216 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 99 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"domain":"1706802441.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 300 + uncompressed: false + body: '{"custom_domain_id":"cd_L8MBSI10kuieE21s","domain":"1706802441.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-l8mbsi10kuiee21s.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 3.884155s + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 165 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + "\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e{%- auth0:head -%}\u003c/head\u003e\u003cbody\u003e{%- auth0:widget -%}\u003c/body\u003e\u003c/html\u003e" + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 6.6820935s + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 14 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 207.958042ms + - id: 3 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 375.053917ms + - 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_L8MBSI10kuieE21s + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 3.897970791s + - id: 5 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_L8MBSI10kuieE21s + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 209.499375ms diff --git a/test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml b/test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml new file mode 100644 index 00000000..1a3bd1f6 --- /dev/null +++ b/test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml @@ -0,0 +1,324 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 99 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"domain":"1706802478.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 300 + uncompressed: false + body: '{"custom_domain_id":"cd_97puvOGOSkcnMuJA","domain":"1706802478.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-97puvogoskcnmuja.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 3.875995542s + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 165 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + "\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e{%- auth0:head -%}\u003c/head\u003e\u003cbody\u003e{%- auth0:widget -%}\u003c/body\u003e\u003c/html\u003e" + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 2.452238292s + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 80 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{"form-content-start":"\u003cdiv\u003eTest Content\u003c/div\u003e"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signup":{"form-content-start":"
Test Content
"}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 221.358041ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 88 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{"form-content-start":"\u003cdiv\u003eUpdated Test Content\u003c/div\u003e"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signup":{"form-content-start":"
Updated Test Content
"}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 189.848125ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 14 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"signup":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signup":{"form-content-start":"
Updated Test Content
"}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 194.394792ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 8 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"":{}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/prompts/signup/partials + method: PUT + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '{}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 205.682291ms + - id: 6 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/branding/templates/universal-login + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 300.043166ms + - id: 7 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_97puvOGOSkcnMuJA + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 3.798379667s + - id: 8 + 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: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.4.0 + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_97puvOGOSkcnMuJA + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 183.79625ms From e4b645109b45a1ec4cdebb4ab16fbb350ce04b74 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 10:52:17 -0500 Subject: [PATCH 08/14] Add public comments to clear linter --- management/prompt.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/management/prompt.go b/management/prompt.go index 537537c4..ff7eeb5c 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -35,11 +35,13 @@ type CustomPrompt struct { Segment CustomPromptSegment `json:"-"` } +// MarshalJSON implements a custom Marshaler func (c *CustomPrompt) MarshalJSON() ([]byte, error) { body := map[string]CustomPrompt{string(c.Segment): *c} return json.Marshal(body) } +// UnmarshalJSON implements a custom Unmarshaler func (c *CustomPrompt) UnmarshalJSON(data []byte) error { var body map[string]map[string]string if err := json.Unmarshal(data, &body); err != nil { From d58a375308e67e461cac02595c270b934f40dd2d Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 10:54:53 -0500 Subject: [PATCH 09/14] Add public comments to clear linter on const --- management/prompt.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/management/prompt.go b/management/prompt.go index ff7eeb5c..31953fb4 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -64,12 +64,23 @@ func (c *CustomPrompt) UnmarshalJSON(data []byte) error { type CustomPromptSegment string const ( - CustomPromptSignup CustomPromptSegment = "signup" - CustomPromptSignupID CustomPromptSegment = "signup-id" + // CustomPromptSignup represents the signup segment + CustomPromptSignup CustomPromptSegment = "signup" + + // CustomPromptSignupID represents the signup-id segment + CustomPromptSignupID CustomPromptSegment = "signup-id" + + // CustomPromptSignupPassword represents the signup-password segment CustomPromptSignupPassword CustomPromptSegment = "signup-password" - CustomPromptLogin CustomPromptSegment = "login" - CustomPromptLoginID CustomPromptSegment = "login-id" - CustomPromptLoginPassword CustomPromptSegment = "login-password" + + // CustomPromptLogin represents the login segment + CustomPromptLogin CustomPromptSegment = "login" + + // CustomPromptLoginID represents the login-id segment + CustomPromptLoginID CustomPromptSegment = "login-id" + + // CustomPromptLoginPassword represents the login-password segment + CustomPromptLoginPassword CustomPromptSegment = "login-password" ) var validCustomPromptSegments = []CustomPromptSegment{ From 6b3b71a53b458bfa9594cdb318e08b7bf4829e27 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 10:56:46 -0500 Subject: [PATCH 10/14] Add dots to satisfy go-lint --- management/prompt.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/management/prompt.go b/management/prompt.go index 31953fb4..917bb729 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -35,13 +35,13 @@ type CustomPrompt struct { Segment CustomPromptSegment `json:"-"` } -// MarshalJSON implements a custom Marshaler +// MarshalJSON implements a custom Marshaler. func (c *CustomPrompt) MarshalJSON() ([]byte, error) { body := map[string]CustomPrompt{string(c.Segment): *c} return json.Marshal(body) } -// UnmarshalJSON implements a custom Unmarshaler +// UnmarshalJSON implements a custom Unmarshaler. func (c *CustomPrompt) UnmarshalJSON(data []byte) error { var body map[string]map[string]string if err := json.Unmarshal(data, &body); err != nil { @@ -64,22 +64,22 @@ func (c *CustomPrompt) UnmarshalJSON(data []byte) error { type CustomPromptSegment string const ( - // CustomPromptSignup represents the signup segment + // CustomPromptSignup represents the signup segment. CustomPromptSignup CustomPromptSegment = "signup" - // CustomPromptSignupID represents the signup-id segment + // CustomPromptSignupID represents the signup-id segment. CustomPromptSignupID CustomPromptSegment = "signup-id" - // CustomPromptSignupPassword represents the signup-password segment + // CustomPromptSignupPassword represents the signup-password segment. CustomPromptSignupPassword CustomPromptSegment = "signup-password" - // CustomPromptLogin represents the login segment + // CustomPromptLogin represents the login segment. CustomPromptLogin CustomPromptSegment = "login" - // CustomPromptLoginID represents the login-id segment + // CustomPromptLoginID represents the login-id segment. CustomPromptLoginID CustomPromptSegment = "login-id" - // CustomPromptLoginPassword represents the login-password segment + // CustomPromptLoginPassword represents the login-password segment. CustomPromptLoginPassword CustomPromptSegment = "login-password" ) From bfcd6618ce8b805670c55967c230bb38034ca48a Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 11:22:28 -0500 Subject: [PATCH 11/14] Cleanup Unmarshaler for CustomPrompt --- management/prompt.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/management/prompt.go b/management/prompt.go index 917bb729..83609a05 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -43,18 +43,13 @@ func (c *CustomPrompt) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements a custom Unmarshaler. func (c *CustomPrompt) UnmarshalJSON(data []byte) error { - var body map[string]map[string]string + var body map[string]struct{ CustomPrompt } if err := json.Unmarshal(data, &body); err != nil { return err } for k, v := range body { - c.FormContentStart = v["form-content-start"] - c.FormFooterEnd = v["form-content-end"] - c.FormFooterStart = v["form-footer-start"] - c.FormFooterEnd = v["form-footer-end"] - c.SecondaryActionsStart = v["secondary-actions-start"] - c.SecondaryActionsEnd = v["secondary-actions-end"] + *c = v.CustomPrompt c.Segment = CustomPromptSegment(k) } return nil From 24a5ae6888b9732e0265fe5dade2e251dbd1a1a2 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 13:18:02 -0500 Subject: [PATCH 12/14] Rename Partials --- management/management.gen.go | 4 +- management/management.gen_test.go | 2 +- management/prompt.go | 92 +++++++++++++++---------------- management/prompt_test.go | 60 ++++++++++---------- 4 files changed, 79 insertions(+), 79 deletions(-) diff --git a/management/management.gen.go b/management/management.gen.go index 51e7d80f..b589908a 100644 --- a/management/management.gen.go +++ b/management/management.gen.go @@ -5874,8 +5874,8 @@ func (c *CustomDomainVerification) String() string { return Stringify(c) } -// String returns a string representation of CustomPrompt. -func (c *CustomPrompt) String() string { +// String returns a string representation of PartialsPrompt. +func (c *PartialsPrompt) String() string { return Stringify(c) } diff --git a/management/management.gen_test.go b/management/management.gen_test.go index 9527f98d..da895cff 100644 --- a/management/management.gen_test.go +++ b/management/management.gen_test.go @@ -7290,7 +7290,7 @@ func TestCustomDomainVerification_String(t *testing.T) { func TestCustomPrompt_String(t *testing.T) { var rawJSON json.RawMessage - v := &CustomPrompt{} + v := &PartialsPrompt{} if err := json.Unmarshal([]byte(v.String()), &rawJSON); err != nil { t.Errorf("failed to produce a valid json") } diff --git a/management/prompt.go b/management/prompt.go index 83609a05..3c464aa1 100644 --- a/management/prompt.go +++ b/management/prompt.go @@ -20,10 +20,10 @@ type Prompt struct { WebAuthnPlatformFirstFactor *bool `json:"webauthn_platform_first_factor,omitempty"` } -// CustomPrompt to be used for Custom Prompt Partials. +// PartialsPrompt to be used for Custom Prompt Partials. // // See: https://auth0.com/docs/sign-up-prompt-customizations -type CustomPrompt struct { +type PartialsPrompt struct { FormContentStart string `json:"form-content-start,omitempty"` FormContentEnd string `json:"form-content-end,omitempty"` FormFooterStart string `json:"form-footer-start,omitempty"` @@ -32,59 +32,59 @@ type CustomPrompt struct { SecondaryActionsEnd string `json:"secondary-actions-end,omitempty"` // Segment for custom prompt - Segment CustomPromptSegment `json:"-"` + Segment PartialsPromptSegment `json:"-"` } // MarshalJSON implements a custom Marshaler. -func (c *CustomPrompt) MarshalJSON() ([]byte, error) { - body := map[string]CustomPrompt{string(c.Segment): *c} +func (c *PartialsPrompt) MarshalJSON() ([]byte, error) { + body := map[string]PartialsPrompt{string(c.Segment): *c} return json.Marshal(body) } // UnmarshalJSON implements a custom Unmarshaler. -func (c *CustomPrompt) UnmarshalJSON(data []byte) error { - var body map[string]struct{ CustomPrompt } +func (c *PartialsPrompt) UnmarshalJSON(data []byte) error { + var body map[string]struct{ PartialsPrompt } if err := json.Unmarshal(data, &body); err != nil { return err } for k, v := range body { - *c = v.CustomPrompt - c.Segment = CustomPromptSegment(k) + *c = v.PartialsPrompt + c.Segment = PartialsPromptSegment(k) } return nil } -// CustomPromptSegment defines the partials segment that we are managing. -type CustomPromptSegment string +// PartialsPromptSegment defines the partials segment that we are managing. +type PartialsPromptSegment string const ( - // CustomPromptSignup represents the signup segment. - CustomPromptSignup CustomPromptSegment = "signup" + // PartialsPromptSignup represents the signup segment. + PartialsPromptSignup PartialsPromptSegment = "signup" - // CustomPromptSignupID represents the signup-id segment. - CustomPromptSignupID CustomPromptSegment = "signup-id" + // PartialsPromptSignupID represents the signup-id segment. + PartialsPromptSignupID PartialsPromptSegment = "signup-id" - // CustomPromptSignupPassword represents the signup-password segment. - CustomPromptSignupPassword CustomPromptSegment = "signup-password" + // PartialsPromptSignupPassword represents the signup-password segment. + PartialsPromptSignupPassword PartialsPromptSegment = "signup-password" - // CustomPromptLogin represents the login segment. - CustomPromptLogin CustomPromptSegment = "login" + // PartialsPromptLogin represents the login segment. + PartialsPromptLogin PartialsPromptSegment = "login" - // CustomPromptLoginID represents the login-id segment. - CustomPromptLoginID CustomPromptSegment = "login-id" + // PartialsPromptLoginID represents the login-id segment. + PartialsPromptLoginID PartialsPromptSegment = "login-id" - // CustomPromptLoginPassword represents the login-password segment. - CustomPromptLoginPassword CustomPromptSegment = "login-password" + // PartialsPromptLoginPassword represents the login-password segment. + PartialsPromptLoginPassword PartialsPromptSegment = "login-password" ) -var validCustomPromptSegments = []CustomPromptSegment{ - CustomPromptSignup, - CustomPromptSignupID, - CustomPromptSignupPassword, - CustomPromptLogin, - CustomPromptLoginID, - CustomPromptLoginPassword, +var validPartialsPromptSegments = []PartialsPromptSegment{ + PartialsPromptSignup, + PartialsPromptSignupID, + PartialsPromptSignupPassword, + PartialsPromptLogin, + PartialsPromptLoginID, + PartialsPromptLoginPassword, } // PromptManager is used for managing a Prompt. @@ -121,50 +121,50 @@ func (m *PromptManager) SetCustomText(ctx context.Context, p string, l string, b return } -// CreateCustomPartials creates new custom prompt partials for a given segment. +// CreatePartials creates new custom prompt partials for a given segment. // // See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts -func (m *PromptManager) CreateCustomPartials(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if err := validateCustomPromptSegment(c.Segment); err != nil { +func (m *PromptManager) CreatePartials(ctx context.Context, c *PartialsPrompt, opts ...RequestOption) error { + if err := validatePartialsPromptSegment(c.Segment); err != nil { return err } return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), c, opts...) } -// UpdateCustomPartials updates custom prompt partials for a given segment. +// UpdatePartials updates custom prompt partials for a given segment. // // See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts -func (m *PromptManager) UpdateCustomPartials(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if err := validateCustomPromptSegment(c.Segment); err != nil { +func (m *PromptManager) UpdatePartials(ctx context.Context, c *PartialsPrompt, opts ...RequestOption) error { + if err := validatePartialsPromptSegment(c.Segment); err != nil { return err } return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), c, opts...) } -// ReadCustomPartials reads custom prompt partials for a given segment. +// ReadPartials reads custom prompt partials for a given segment. // // See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts -func (m *PromptManager) ReadCustomPartials(ctx context.Context, segment CustomPromptSegment, opts ...RequestOption) (c *CustomPrompt, err error) { - if err := validateCustomPromptSegment(segment); err != nil { +func (m *PromptManager) ReadPartials(ctx context.Context, segment PartialsPromptSegment, opts ...RequestOption) (c *PartialsPrompt, err error) { + if err := validatePartialsPromptSegment(segment); err != nil { return nil, err } - c = &CustomPrompt{Segment: segment} + c = &PartialsPrompt{Segment: segment} err = m.management.Request(ctx, "GET", m.management.URI("prompts", string(segment), "partials"), c, opts...) return } -// DeleteCustomPartials deletes custom prompt partials for a given segment. +// DeletePartials deletes custom prompt partials for a given segment. // // See: https://auth0.com/docs/sign-up-prompt-customizations#use-the-api-to-edit-custom-prompts -func (m *PromptManager) DeleteCustomPartials(ctx context.Context, c *CustomPrompt, opts ...RequestOption) error { - if err := validateCustomPromptSegment(c.Segment); err != nil { +func (m *PromptManager) DeletePartials(ctx context.Context, c *PartialsPrompt, opts ...RequestOption) error { + if err := validatePartialsPromptSegment(c.Segment); err != nil { return err } - return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), &CustomPrompt{}, opts...) + return m.management.Request(ctx, "PUT", m.management.URI("prompts", string(c.Segment), "partials"), &PartialsPrompt{}, opts...) } -func validateCustomPromptSegment(segment CustomPromptSegment) error { - for _, p := range validCustomPromptSegments { +func validatePartialsPromptSegment(segment PartialsPromptSegment) error { + for _, p := range validPartialsPromptSegments { if p == segment { return nil } diff --git a/management/prompt_test.go b/management/prompt_test.go index caa643d2..6d5cb075 100644 --- a/management/prompt_test.go +++ b/management/prompt_test.go @@ -79,14 +79,14 @@ func TestPromptCustomText(t *testing.T) { assert.Equal(t, "Welcome", texts["login"].(map[string]interface{})["title"]) } -func TestPromptManager_ReadCustomPartials(t *testing.T) { +func TestPromptManager_ReadPartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) _ = givenAUniversalLogin(t) - prompt := CustomPromptSignup - expected := &CustomPrompt{Segment: prompt} - got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + prompt := PartialsPromptSignup + expected := &PartialsPrompt{Segment: prompt} + got, err := api.Prompt.ReadPartials(context.Background(), prompt) assert.NoError(t, err) assert.Equal(t, expected, got) @@ -97,78 +97,78 @@ func TestPromptManager_ReadCustomPartials(t *testing.T) { }) } -func TestPromptManager_CreateCustomPartials(t *testing.T) { +func TestPromptManager_CreatePartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) _ = givenAUniversalLogin(t) - prompt := CustomPromptSignup - original := &CustomPrompt{Segment: prompt} - expected := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} + prompt := PartialsPromptSignup + original := &PartialsPrompt{Segment: prompt} + expected := &PartialsPrompt{Segment: prompt, FormContentStart: `
Test Content
`} - err := api.Prompt.CreateCustomPartials(context.Background(), expected) + err := api.Prompt.CreatePartials(context.Background(), expected) assert.NoError(t, err) - got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + got, err := api.Prompt.ReadPartials(context.Background(), prompt) assert.NoError(t, err) assert.Equal(t, expected, got) assert.NotEqual(t, original, got) t.Cleanup(func() { - cleanupCustomPrompt(t, customDomain.GetID(), prompt) + cleanupPartialsPrompt(t, customDomain.GetID(), prompt) }) } -func TestPromptManager_UpdateCustomPartials(t *testing.T) { +func TestPromptManager_UpdatePartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) _ = givenAUniversalLogin(t) - prompt := CustomPromptSignup - original := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} + prompt := PartialsPromptSignup + original := &PartialsPrompt{Segment: prompt, FormContentStart: `
Test Content
`} - err := api.Prompt.CreateCustomPartials(context.Background(), original) + err := api.Prompt.CreatePartials(context.Background(), original) assert.NoError(t, err) - expected := &CustomPrompt{Segment: prompt, FormContentStart: `
Updated Test Content
`} - err = api.Prompt.UpdateCustomPartials(context.Background(), expected) + expected := &PartialsPrompt{Segment: prompt, FormContentStart: `
Updated Test Content
`} + err = api.Prompt.UpdatePartials(context.Background(), expected) assert.NoError(t, err) - got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + got, err := api.Prompt.ReadPartials(context.Background(), prompt) assert.NoError(t, err) assert.Equal(t, expected, got) assert.NotEqual(t, original, expected) t.Cleanup(func() { - cleanupCustomPrompt(t, customDomain.GetID(), prompt) + cleanupPartialsPrompt(t, customDomain.GetID(), prompt) }) } -func TestPromptManager_DeleteCustomPartials(t *testing.T) { +func TestPromptManager_DeletePartials(t *testing.T) { configureHTTPTestRecordings(t) customDomain := givenACustomDomain(t) _ = givenAUniversalLogin(t) - prompt := CustomPromptSignup - original := &CustomPrompt{Segment: prompt, FormContentStart: `
Test Content
`} + prompt := PartialsPromptSignup + original := &PartialsPrompt{Segment: prompt, FormContentStart: `
Test Content
`} - err := api.Prompt.CreateCustomPartials(context.Background(), original) + err := api.Prompt.CreatePartials(context.Background(), original) assert.NoError(t, err) - expected := &CustomPrompt{Segment: prompt} - err = api.Prompt.DeleteCustomPartials(context.Background(), expected) + expected := &PartialsPrompt{Segment: prompt} + err = api.Prompt.DeletePartials(context.Background(), expected) assert.NoError(t, err) - got, err := api.Prompt.ReadCustomPartials(context.Background(), prompt) + got, err := api.Prompt.ReadPartials(context.Background(), prompt) assert.NoError(t, err) assert.Equal(t, expected, got) assert.NotEqual(t, original, expected) t.Cleanup(func() { - cleanupCustomPrompt(t, customDomain.GetID(), prompt) + cleanupPartialsPrompt(t, customDomain.GetID(), prompt) }) } @@ -186,11 +186,11 @@ func givenAUniversalLogin(t *testing.T) *BrandingUniversalLogin { return ul } -func cleanupCustomPrompt(t *testing.T, customDomainID string, prompt CustomPromptSegment) { +func cleanupPartialsPrompt(t *testing.T, customDomainID string, prompt PartialsPromptSegment) { t.Helper() - c := &CustomPrompt{Segment: prompt} - err := api.Prompt.DeleteCustomPartials(context.Background(), c) + c := &PartialsPrompt{Segment: prompt} + err := api.Prompt.DeletePartials(context.Background(), c) assert.NoError(t, err) cleanupUniversalLogin(t) From 4b1b6d1c8a938cc56d46d2bd264451d53f4ceb44 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 13:24:55 -0500 Subject: [PATCH 13/14] Update cassettes to match partials name change --- ... => TestPromptManager_CreatePartials.yaml} | 24 ++++++++-------- ... => TestPromptManager_DeletePartials.yaml} | 26 ++++++++--------- ...ml => TestPromptManager_ReadPartials.yaml} | 28 +++++++++---------- ... => TestPromptManager_UpdatePartials.yaml} | 26 ++++++++--------- 4 files changed, 52 insertions(+), 52 deletions(-) rename test/data/recordings/{TestPromptManager_CreateCustomPartials.yaml => TestPromptManager_CreatePartials.yaml} (93%) rename test/data/recordings/{TestPromptManager_DeleteCustomPartials.yaml => TestPromptManager_DeletePartials.yaml} (93%) rename test/data/recordings/{TestPromptManager_ReadCustomPartials.yaml => TestPromptManager_ReadPartials.yaml} (90%) rename test/data/recordings/{TestPromptManager_UpdateCustomPartials.yaml => TestPromptManager_UpdatePartials.yaml} (93%) diff --git a/test/data/recordings/TestPromptManager_CreateCustomPartials.yaml b/test/data/recordings/TestPromptManager_CreatePartials.yaml similarity index 93% rename from test/data/recordings/TestPromptManager_CreateCustomPartials.yaml rename to test/data/recordings/TestPromptManager_CreatePartials.yaml index d273459a..02c1a3be 100644 --- a/test/data/recordings/TestPromptManager_CreateCustomPartials.yaml +++ b/test/data/recordings/TestPromptManager_CreatePartials.yaml @@ -13,7 +13,7 @@ interactions: remote_addr: "" request_uri: "" body: | - {"domain":"1706802462.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + {"domain":"1706811773.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} form: {} headers: Content-Type: @@ -30,13 +30,13 @@ interactions: trailer: {} content_length: 300 uncompressed: false - body: '{"custom_domain_id":"cd_zlbyQ1KRsMq1U4wU","domain":"1706802462.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-zlbyq1krsmq1u4wu.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + body: '{"custom_domain_id":"cd_w6vH7aZArojlHGcr","domain":"1706811773.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-w6vh7azarojlhgcr.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' headers: Content-Type: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 3.18294075s + duration: 3.294345708s - id: 1 request: proto: HTTP/1.1 @@ -72,7 +72,7 @@ interactions: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 2.361173625s + duration: 2.398737583s - id: 2 request: proto: HTTP/1.1 @@ -108,7 +108,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 299.663417ms + duration: 309.48275ms - id: 3 request: proto: HTTP/1.1 @@ -144,7 +144,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 204.141792ms + duration: 184.914875ms - id: 4 request: proto: HTTP/1.1 @@ -180,7 +180,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 215.597667ms + duration: 233.15025ms - id: 5 request: proto: HTTP/1.1 @@ -215,7 +215,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 388.773042ms + duration: 348.863417ms - id: 6 request: proto: HTTP/1.1 @@ -234,7 +234,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_zlbyQ1KRsMq1U4wU + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_w6vH7aZArojlHGcr method: DELETE response: proto: HTTP/2.0 @@ -250,7 +250,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 3.956540958s + duration: 5.031660792s - id: 7 request: proto: HTTP/1.1 @@ -269,7 +269,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_zlbyQ1KRsMq1U4wU + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_w6vH7aZArojlHGcr method: DELETE response: proto: HTTP/2.0 @@ -285,4 +285,4 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 208.044959ms + duration: 409.022167ms diff --git a/test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml b/test/data/recordings/TestPromptManager_DeletePartials.yaml similarity index 93% rename from test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml rename to test/data/recordings/TestPromptManager_DeletePartials.yaml index 18a6cec0..b555cff4 100644 --- a/test/data/recordings/TestPromptManager_DeleteCustomPartials.yaml +++ b/test/data/recordings/TestPromptManager_DeletePartials.yaml @@ -13,7 +13,7 @@ interactions: remote_addr: "" request_uri: "" body: | - {"domain":"1706802539.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + {"domain":"1706811812.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} form: {} headers: Content-Type: @@ -30,13 +30,13 @@ interactions: trailer: {} content_length: 300 uncompressed: false - body: '{"custom_domain_id":"cd_eCPkkLLkx69hVURg","domain":"1706802539.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-ecpkkllkx69hvurg.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + body: '{"custom_domain_id":"cd_pUC9xawVbY0ieSJR","domain":"1706811812.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-puc9xawvby0iesjr.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' headers: Content-Type: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 3.667744667s + duration: 3.707673416s - id: 1 request: proto: HTTP/1.1 @@ -72,7 +72,7 @@ interactions: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 2.452549917s + duration: 2.471086292s - id: 2 request: proto: HTTP/1.1 @@ -108,7 +108,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 208.344583ms + duration: 245.4735ms - id: 3 request: proto: HTTP/1.1 @@ -144,7 +144,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 239.583667ms + duration: 245.701042ms - id: 4 request: proto: HTTP/1.1 @@ -180,7 +180,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 196.406834ms + duration: 309.474542ms - id: 5 request: proto: HTTP/1.1 @@ -216,7 +216,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 172.103792ms + duration: 222.163708ms - id: 6 request: proto: HTTP/1.1 @@ -251,7 +251,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 319.958916ms + duration: 429.420208ms - id: 7 request: proto: HTTP/1.1 @@ -270,7 +270,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_eCPkkLLkx69hVURg + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_pUC9xawVbY0ieSJR method: DELETE response: proto: HTTP/2.0 @@ -286,7 +286,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 4.594809583s + duration: 4.483103s - id: 8 request: proto: HTTP/1.1 @@ -305,7 +305,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_eCPkkLLkx69hVURg + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_pUC9xawVbY0ieSJR method: DELETE response: proto: HTTP/2.0 @@ -321,4 +321,4 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 188.793958ms + duration: 232.467084ms diff --git a/test/data/recordings/TestPromptManager_ReadCustomPartials.yaml b/test/data/recordings/TestPromptManager_ReadPartials.yaml similarity index 90% rename from test/data/recordings/TestPromptManager_ReadCustomPartials.yaml rename to test/data/recordings/TestPromptManager_ReadPartials.yaml index ae91f698..85abbf2e 100644 --- a/test/data/recordings/TestPromptManager_ReadCustomPartials.yaml +++ b/test/data/recordings/TestPromptManager_ReadPartials.yaml @@ -13,7 +13,7 @@ interactions: remote_addr: "" request_uri: "" body: | - {"domain":"1706802441.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + {"domain":"1706811752.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} form: {} headers: Content-Type: @@ -30,13 +30,13 @@ interactions: trailer: {} content_length: 300 uncompressed: false - body: '{"custom_domain_id":"cd_L8MBSI10kuieE21s","domain":"1706802441.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-l8mbsi10kuiee21s.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + body: '{"custom_domain_id":"cd_DNA0JO1YcIxTV6a4","domain":"1706811752.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-dna0jo1ycixtv6a4.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' headers: Content-Type: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 3.884155s + duration: 3.825249709s - id: 1 request: proto: HTTP/1.1 @@ -64,15 +64,15 @@ interactions: proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 0 + content_length: 2 uncompressed: false - body: "" + body: '{}' headers: Content-Type: - application/json; charset=utf-8 - status: 204 No Content - code: 204 - duration: 6.6820935s + status: 201 Created + code: 201 + duration: 2.616763791s - id: 2 request: proto: HTTP/1.1 @@ -108,7 +108,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 207.958042ms + duration: 245.942541ms - id: 3 request: proto: HTTP/1.1 @@ -143,7 +143,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 375.053917ms + duration: 353.674791ms - id: 4 request: proto: HTTP/1.1 @@ -162,7 +162,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_L8MBSI10kuieE21s + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_DNA0JO1YcIxTV6a4 method: DELETE response: proto: HTTP/2.0 @@ -178,7 +178,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 3.897970791s + duration: 3.98614625s - id: 5 request: proto: HTTP/1.1 @@ -197,7 +197,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_L8MBSI10kuieE21s + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_DNA0JO1YcIxTV6a4 method: DELETE response: proto: HTTP/2.0 @@ -213,4 +213,4 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 209.499375ms + duration: 401.709042ms diff --git a/test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml b/test/data/recordings/TestPromptManager_UpdatePartials.yaml similarity index 93% rename from test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml rename to test/data/recordings/TestPromptManager_UpdatePartials.yaml index 1a3bd1f6..0811cb0b 100644 --- a/test/data/recordings/TestPromptManager_UpdateCustomPartials.yaml +++ b/test/data/recordings/TestPromptManager_UpdatePartials.yaml @@ -13,7 +13,7 @@ interactions: remote_addr: "" request_uri: "" body: | - {"domain":"1706802478.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} + {"domain":"1706811793.auth.uat.auth0.com","type":"auth0_managed_certs","tls_policy":"recommended"} form: {} headers: Content-Type: @@ -30,13 +30,13 @@ interactions: trailer: {} content_length: 300 uncompressed: false - body: '{"custom_domain_id":"cd_97puvOGOSkcnMuJA","domain":"1706802478.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-97puvogoskcnmuja.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' + body: '{"custom_domain_id":"cd_xYFOABHELLbnvV6G","domain":"1706811793.auth.uat.auth0.com","primary":true,"status":"pending_verification","type":"auth0_managed_certs","verification":{"methods":[{"name":"cname","record":"go-auth0-dev.eu.auth0.com-cd-xyfoabhellbnvv6g.edge.tenants.eu.auth0.com"}]},"tls_policy":"recommended"}' headers: Content-Type: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 3.875995542s + duration: 3.256333583s - id: 1 request: proto: HTTP/1.1 @@ -72,7 +72,7 @@ interactions: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 2.452238292s + duration: 2.663866s - id: 2 request: proto: HTTP/1.1 @@ -108,7 +108,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 221.358041ms + duration: 311.633375ms - id: 3 request: proto: HTTP/1.1 @@ -144,7 +144,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 189.848125ms + duration: 300.099833ms - id: 4 request: proto: HTTP/1.1 @@ -180,7 +180,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 194.394792ms + duration: 232.093667ms - id: 5 request: proto: HTTP/1.1 @@ -216,7 +216,7 @@ interactions: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 205.682291ms + duration: 243.140416ms - id: 6 request: proto: HTTP/1.1 @@ -251,7 +251,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 300.043166ms + duration: 546.529959ms - id: 7 request: proto: HTTP/1.1 @@ -270,7 +270,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_97puvOGOSkcnMuJA + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_xYFOABHELLbnvV6G method: DELETE response: proto: HTTP/2.0 @@ -286,7 +286,7 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 3.798379667s + duration: 3.995455792s - id: 8 request: proto: HTTP/1.1 @@ -305,7 +305,7 @@ interactions: - application/json User-Agent: - Go-Auth0/1.4.0 - url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_97puvOGOSkcnMuJA + url: https://go-auth0-dev.eu.auth0.com/api/v2/custom-domains/cd_xYFOABHELLbnvV6G method: DELETE response: proto: HTTP/2.0 @@ -321,4 +321,4 @@ interactions: - application/json; charset=utf-8 status: 204 No Content code: 204 - duration: 183.79625ms + duration: 305.543042ms From 3683da4a0c03a771ab33009a22f6b7a1bcb81722 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 1 Feb 2024 13:26:22 -0500 Subject: [PATCH 14/14] Regenerated management helpers --- management/management.gen.go | 10 +++++----- management/management.gen_test.go | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/management/management.gen.go b/management/management.gen.go index b589908a..31ee6ea6 100644 --- a/management/management.gen.go +++ b/management/management.gen.go @@ -5874,11 +5874,6 @@ func (c *CustomDomainVerification) String() string { return Stringify(c) } -// String returns a string representation of PartialsPrompt. -func (c *PartialsPrompt) String() string { - return Stringify(c) -} - // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (d *DailyStat) GetCreatedAt() time.Time { if d == nil || d.CreatedAt == nil { @@ -7983,6 +7978,11 @@ func (o *OrganizationMemberRoleList) String() string { return Stringify(o) } +// String returns a string representation of PartialsPrompt. +func (p *PartialsPrompt) String() string { + return Stringify(p) +} + // GetEnabled returns the Enabled field if it's non-nil, zero value otherwise. func (p *PasskeyAuthenticationMethod) GetEnabled() bool { if p == nil || p.Enabled == nil { diff --git a/management/management.gen_test.go b/management/management.gen_test.go index da895cff..33d8a7aa 100644 --- a/management/management.gen_test.go +++ b/management/management.gen_test.go @@ -7288,14 +7288,6 @@ func TestCustomDomainVerification_String(t *testing.T) { } } -func TestCustomPrompt_String(t *testing.T) { - var rawJSON json.RawMessage - v := &PartialsPrompt{} - if err := json.Unmarshal([]byte(v.String()), &rawJSON); err != nil { - t.Errorf("failed to produce a valid json") - } -} - func TestDailyStat_GetCreatedAt(tt *testing.T) { var zeroValue time.Time d := &DailyStat{CreatedAt: &zeroValue} @@ -10025,6 +10017,14 @@ func TestOrganizationMemberRoleList_String(t *testing.T) { } } +func TestPartialsPrompt_String(t *testing.T) { + var rawJSON json.RawMessage + v := &PartialsPrompt{} + if err := json.Unmarshal([]byte(v.String()), &rawJSON); err != nil { + t.Errorf("failed to produce a valid json") + } +} + func TestPasskeyAuthenticationMethod_GetEnabled(tt *testing.T) { var zeroValue bool p := &PasskeyAuthenticationMethod{Enabled: &zeroValue}