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

DXCDT-462: Adding optional display_name field to auth0_trigger_action resource #621

Merged
merged 21 commits into from
Jun 8, 2023

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Jun 7, 2023

🔧 Changes

The initial iteration of the auth0_trigger_action resource (#612) did not include a display name field. This field is used to assign a distinguishable name to a specific instance of an action within a flow. This can be useful in cases where there are multiple instances of the same action with a flow, albeit configured differently. The auth0_trigger_actions resource does include this property so for API consistency, this PR adds the display_name property too.

📚 References

🔬 Testing

Adding new test cases.

📝 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)

@willvedd willvedd requested a review from a team as a code owner June 7, 2023 12:28
Comment on lines 97 to 103
if d.GetRawConfig().GetAttr("display_name").IsNull() {
action, err := api.Action.Read(actionID)
if err != nil {
return diag.FromErr(err)
}
return diag.FromErr(err)
displayName = action.GetName()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is the most effective way of detecting an undefined display name. Open to suggestions on how to improve.

@@ -55,6 +65,15 @@ func TestAccTriggerAction(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_trigger_action.my_action_post_login", "trigger", "post-login"),
resource.TestCheckResourceAttrSet("auth0_trigger_action.my_action_post_login", "action_id"),
resource.TestCheckNoResourceAttr("auth0_trigger_action.my_action_post_login", "display_name"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wondering if there's a way to check the computed value here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well we know that it will take the name of the action by default, so we can check for that one: Test Action {{.testName}}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's in direct conflict with TestCheckNoResourceAttr.

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2023

Codecov Report

Merging #621 (1711ad4) into main (0ac7731) will decrease coverage by 0.05%.
The diff coverage is 70.31%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #621      +/-   ##
==========================================
- Coverage   86.38%   86.33%   -0.05%     
==========================================
  Files          79       79              
  Lines       12207    12259      +52     
==========================================
+ Hits        10545    10584      +39     
- Misses       1278     1287       +9     
- Partials      384      388       +4     
Impacted Files Coverage Δ
internal/auth0/action/resource_trigger_action.go 73.19% <70.31%> (+0.66%) ⬆️

Comment on lines 130 to 133
if mErr, ok := err.(management.Error); ok && mErr.Status() == http.StatusNotFound {
d.SetId("")
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.

We shouldn't ignore the 404 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you be more specific? This is consistent across the entire codebase.

Copy link
Contributor

@sergiught sergiught Jun 7, 2023

Choose a reason for hiding this comment

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

It's consistent across the entire codebase for resources that get created and get deleted. The set of triggers is static and is not something a customer can create or delete.

Comment on lines +187 to +190
err = d.Set("display_name", binding.GetDisplayName())
if err != nil {
return diag.FromErr(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err = d.Set("display_name", binding.GetDisplayName())
if err != nil {
return diag.FromErr(err)
}
return diag.FromErr(d.Set("display_name", binding.GetDisplayName()))

@@ -55,6 +65,15 @@ func TestAccTriggerAction(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_trigger_action.my_action_post_login", "trigger", "post-login"),
resource.TestCheckResourceAttrSet("auth0_trigger_action.my_action_post_login", "action_id"),
resource.TestCheckNoResourceAttr("auth0_trigger_action.my_action_post_login", "display_name"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Well we know that it will take the name of the action by default, so we can check for that one: Test Action {{.testName}}.

@willvedd willvedd requested a review from sergiught June 7, 2023 22:37
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The name for this action within the trigger. This can be useful for distinguishing between multiple instances of the same action bound to a trigger.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great to specify that this defaults to the action name if not set.

return nil
if displayName == "" {
action, err := api.Action.Read(actionID)

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@willvedd willvedd merged commit e8b26b6 into main Jun 8, 2023
@willvedd willvedd deleted the DXCDT-462-auth0-action-trigger-display-name branch June 8, 2023 16:32
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.

3 participants