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

Adding IncludeEmailInRedirect field for email templates #90

Merged
merged 4 commits into from
Jul 12, 2022

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Jul 8, 2022

Description

This PR adds the includeEmailInRedirect boolean field for email templates. This comes per a request in the Terraform provider.

Additionally, included are some minor testing changes to the email templates testing to improve assertions and repeatability. These testing changes are only somewhat related to the core change here, but somewhat messy to separate while ensuring testing on this feature; willing to separate if requested.

References

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have read and agreed to the terms within the Auth0 Code of Conduct.
  • I have read the Auth0 General Contribution Guidelines.
  • I have reviewed my own code beforehand.
  • I have added documentation for new/changed functionality in this PR.
  • All active GitHub checks for tests, formatting, and security are passing.
  • The correct base branch is being used, if not main.

@willvedd willvedd requested a review from a team as a code owner July 8, 2022 19:49
Subject: auth0.String("Verify your email"),
Syntax: auth0.String("liquid"),
Enabled: auth0.Bool(true),
IncludeEmailInRedirect: auth0.Bool(true),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only change is here.

Comment on lines 75 to 76
err := m.Email.Delete()
assert.NoError(t, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting the email provider is necessary for repeatability. Otherwise, this will fail with a 409 when attempting to instantiate an email provider in givenAnEmailProvider(t) when one already exists.

I chose to run in this test only to limit the blast radius of the change, but it may also reside in the givenAnEmailProvider helper function to help ensure the repeatability of other tests too.

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 := m.Email.Delete()
assert.NoError(t, err)

The email provider already gets deleted after the test: line 78 calls "givenAnEmailProvider" which calls the delete after the test:

t.Cleanup(func() {
cleanupEmailProvider(t)
})

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 works before the test, but if an email provider already exists, it also needs to occur before a test is run. Otherwise it will perpetually fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

t.Cleanup() registers a function to be called when the test finishes, which means the email provider will get deleted after the tests either passes or fails. So when we restart the test, there won't be any email provider to delete, as it was already deleted. :)

Copy link
Contributor

@sergiught sergiught Jul 11, 2022

Choose a reason for hiding this comment

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

Ah, I think I get your point now. Let's do it differently tho, let's modify the givenAnEmailProvider() func to not error if there's already an email provider, but use that instead. Wdyt?

Comment on lines +93 to +97
assert.Equal(t, actualTemplate.GetBody(), template.GetBody())
assert.Equal(t, actualTemplate.GetSubject(), template.GetSubject())
assert.Equal(t, actualTemplate.GetFrom(), template.GetFrom())
assert.Equal(t, actualTemplate.GetTemplate(), template.GetTemplate())
assert.Equal(t, actualTemplate.GetIncludeEmailInRedirect(), template.GetIncludeEmailInRedirect())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding actual assertions that the replaced template is as expected.

Comment on lines 75 to 76
err := m.Email.Delete()
assert.NoError(t, 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 := m.Email.Delete()
assert.NoError(t, err)

The email provider already gets deleted after the test: line 78 calls "givenAnEmailProvider" which calls the delete after the test:

t.Cleanup(func() {
cleanupEmailProvider(t)
})

@willvedd willvedd requested a review from sergiught July 11, 2022 13:21
@willvedd willvedd merged commit f00bc6f into main Jul 12, 2022
@willvedd willvedd deleted the add-include-email-in-redirect branch July 12, 2022 14:20
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