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

Add support for rendering the settings of prompt-screen #1077

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ramya18101
Copy link

@ramya18101 ramya18101 commented Nov 15, 2024

🔧 Changes

Added new resources and data sources: "auth0_prompt_screen_renderer"
Added relevant expand and flatten rules.
Added relevant test cases for data_source and resource.
Added relevant docs and examples.

Example

resource "auth0_prompt_screen_renderer" "prompt_screen_renderer" {
  prompt_type                = "login-id"
  screen_name                = "login-id"
  rendering_mode             = "advanced"
  default_head_tags_disabled = false
  context_configuration = [
    "branding.settings",
    "branding.themes.default",
    "client.logo_uri",
    "client.description",
    "organization.display_name",
    "organization.branding",
    "screen.texts",
    "tenant.name",
    "tenant.friendly_name",
    "tenant.enabled_locales",
    "untrusted_data.submitted_form_data",
    "untrusted_data.authorization_params.ui_locales",
    "untrusted_data.authorization_params.login_hint",
    "untrusted_data.authorization_params.screen_hint"
  ]
  head_tags = jsonencode([
    {
      attributes : {
        "async" : true,
        "defer" : true,
        "integrity" : [
          "sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
        ],
        "src" : "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
      },
      tag : "script"
    }
  ])
}

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

2. Include unit tests, examples and docs
3. Update Go-Auth0's dependent version
@ramya18101 ramya18101 requested a review from a team as a code owner November 15, 2024 04:07
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

var (
Copy link
Contributor

@kushalshit27 kushalshit27 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use as an enum as the values are not constant

StateContext: schema.ImportStatePassthroughContext,
},
Description: "With this resource, you can Configure the render settings for a specific screen." +
"You can read more about this [here](https://auth0.com/docs/customize/universal-login-pages/.../acul).",
Copy link
Contributor

@kushalshit27 kushalshit27 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link is not valid

Computed: true,
ValidateFunc: validation.StringIsJSON,
DiffSuppressFunc: structure.SuppressJsonDiff,
Description: "An array of head tags",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add better description

func deletePromptScreenRenderer(ctx context.Context, data *schema.ResourceData, meta any) diag.Diagnostics {
api := meta.(*config.Config).GetAPI()
idComponents := strings.Split(data.Id(), ":")
promptName, screenName := idComponents[0], idComponents[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add check and validation promptName, screenName


func readPromptScreenRenderer(ctx context.Context, data *schema.ResourceData, meta any) diag.Diagnostics {
api := meta.(*config.Config).GetAPI()
promptScreenSettings, err := api.Prompt.ReadRendering(ctx, management.PromptType(strings.Split(data.Id(), ":")[0]), management.ScreenName(strings.Split(data.Id(), ":")[1]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add check and validation for [0] and [1] in case invalid

return diag.FromErr(internalError.HandleAPIError(data, err))
}

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not it call readPromptScreenRenderer() instead for return null?


const (
testAccPromptScreenRenderWithoutSettings = `
resource "auth0_prompt_screen_renderer" "prompt_screen_renderer" {
Copy link
Contributor

@kushalshit27 kushalshit27 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add cases for:


resource "auth0_prompt_screen_renderer" "prompt_screen_renderer" {
  screen_name =  "logout"
}

resource "auth0_prompt_screen_renderer" "prompt_screen_renderer" {
  prompt_type     = "logout"
}

),
},
},
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add case for testAccPromptScreenRenderDelete


# Resource: auth0_prompt_screen_renderer

With this resource, you can Configure the render settings for a specific screen.You can read more about this [here](https://auth0.com/docs/customize/universal-login-pages/.../acul).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid link

@kushalshit27
Copy link
Contributor

e2e test recordings are not available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants