Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PATCH: Ensure Removal of Insertion Points in auth0_prompt_screen_partial Resource #1043

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/auth0/prompt/resource_screen_partial.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ func updatePromptScreenPartial(ctx context.Context, data *schema.ResourceData, m
promptPartial := expandPromptScreenPartial(data)
for screenName, insertionPoints := range *promptPartial {
if existingInsertionPoints, exists := (*existingPromptScreenPartial)[screenName]; exists {
for insertionPoint := range existingInsertionPoints {
if _, found := insertionPoints[insertionPoint]; !found {
delete(existingInsertionPoints, insertionPoint)
}
}
for insertionPoint, content := range insertionPoints {
existingInsertionPoints[insertionPoint] = content
}
Expand Down
40 changes: 39 additions & 1 deletion internal/auth0/prompt/resource_screen_partial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,21 @@ resource "auth0_prompt_screen_partial" "login" {
}
}
`
const testAccPromptScreenPartialUpdate = testAccPromptScreenPartialCreate + testAccPromptScreenPartialCreate2

const testAccPromptScreenPartialRemoveInsertionPoint = testAccPromptScreenPartialWithoutScreenPartial + `
resource "auth0_prompt_screen_partial" "login_passwordless_email_code" {
depends_on = [ auth0_branding.my_brand ]
prompt_type = "login-passwordless"
screen_name = "login-passwordless-email-code"
insertion_points {
form_content_start = "<div>Form Content Start</div>"
form_content_end = "<div>Form Content End</div>"
}
}
`

const testAccPromptScreenPartialUpdate = testAccPromptScreenPartialCreate + testAccPromptScreenPartialCreate2
const testAccPromptScreenPartialRemoveInsertionPoints = testAccPromptScreenPartialRemoveInsertionPoint + testAccPromptScreenPartialCreate2
const testAccPromptScreenPartialDelete = testAccGivenACustomDomain + testGivenABrandingTemplate + testAccPromptScreenPartialCreate2

const testAccPromptScreenPartialData = `
Expand Down Expand Up @@ -93,6 +106,31 @@ func TestAccPromptScreenPartial(t *testing.T) {
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "screen_name", "login-passwordless-email-code"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_content_start", "<div>Form Content Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_content_end", "<div>Form Content End</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_footer_start", "<div>Form Footer Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_footer_end", "<div>Form Footer End</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "prompt_type", "login-passwordless"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "screen_name", "login-passwordless-sms-otp"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "insertion_points.0.form_content_start", "<div>Form Content Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "insertion_points.0.form_content_end", "<div>Form Content End</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "prompt_type", "login"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "screen_name", "login"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "insertion_points.0.form_content_start", "<div>Form Content Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "insertion_points.0.form_content_end", "<div>Form Content End</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "insertion_points.0.form_footer_start", "<div>Form Footer Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "insertion_points.0.form_footer_end", "<div>Form Footer End</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "insertion_points.0.secondary_actions_start", "<div>Secondary Actions Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login", "insertion_points.0.secondary_actions_end", "<div>Secondary Actions End</div>"),
),
},
{
Config: testAccPromptScreenPartialRemoveInsertionPoints,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "prompt_type", "login-passwordless"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "screen_name", "login-passwordless-email-code"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_content_start", "<div>Form Content Start</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_content_end", "<div>Form Content End</div>"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_footer_start", ""),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_email_code", "insertion_points.0.form_footer_end", ""),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "prompt_type", "login-passwordless"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "screen_name", "login-passwordless-sms-otp"),
resource.TestCheckResourceAttr("auth0_prompt_screen_partial.login_passwordless_sms_otp", "insertion_points.0.form_content_start", "<div>Form Content Start</div>"),
Expand Down
Loading
Loading