-
Notifications
You must be signed in to change notification settings - Fork 89
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 session_cookie
to tenant
#220
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c7a0190
Adding support for session_cookie management including documentation …
efa5671
Adding to example
89e2de0
Simplifying flattenTenantSessionCookie logic
541f4db
Removing extra Computed property, adding test to ensure that clearing…
6fa3663
Updating to use Go SDK v0.9.0
63c54ee
Merge branch 'main' into add-tenant-session-cookie
willvedd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -93,6 +93,13 @@ func flattenTenantUniversalLogin(universalLogin *management.TenantUniversalLogin | |||||||||||||||||||||||||||||||||||||
return []interface{}{m} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
func flattenTenantSessionCookie(sessionCookie *management.TenantSessionCookie) []interface{} { | ||||||||||||||||||||||||||||||||||||||
m := make(map[string]interface{}) | ||||||||||||||||||||||||||||||||||||||
m["mode"] = sessionCookie.GetMode() | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return []interface{}{m} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
func expandTenantChangePassword(d ResourceData) *management.TenantChangePassword { | ||||||||||||||||||||||||||||||||||||||
var changePassword management.TenantChangePassword | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
@@ -176,3 +183,13 @@ func expandTenantUniversalLogin(d ResourceData) *management.TenantUniversalLogin | |||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return &universalLogin | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
func expandTenantSessionCookie(d ResourceData) *management.TenantSessionCookie { | ||||||||||||||||||||||||||||||||||||||
var sessionCookie management.TenantSessionCookie | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
List(d, "session_cookie").Elem(func(d ResourceData) { | ||||||||||||||||||||||||||||||||||||||
sessionCookie.Mode = String(d, "mode") | ||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return &sessionCookie | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+187
to
+195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need computed both here and on the mode? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, do we? Frankly, it's a confusing property that possesses unintuitive behavior; I'm seeing that we set many things to
Computed: true
so I'm just following a precedent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we can do is try first the parameters without the computed property. The computed is usually needed if there are weird diffs constantly showing whenever terraform performs a refresh, that have no explanation (my personal heuristic on when to use computed or not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out the computed property only needs to be enabled on the root object, not necessarily the children, or at least for this example. However, enabling for the child too did not alter behavior.
I'd prefer to not require manual verification testing for these types of additions, so I added a third stage for the
TestAccTenant
test. It attempts to apply an empty tenant resource block to see if it triggers any odd behavior from Terraform or the Management API. Specifically for this case, it caught a 400 error that occurred when Terrafrom attempted to set thesession_cookie
to an empty object, something that the Management API prohibits.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're sending an empty object because the expand func is flawed. We can remove the Computed property and refactor the expand as follows:
This will make it so that sessionCookie is nil in case it's not present in the config so it will get omitted from the payload because of the omitempty tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested change to refactor
expandTenantSessionCookie
works, but it does not enable us to remove theComputed
property because it fails the "reset" test stage. The plan is not empty afterwards. I'm going to opt to keep it as-is because there is no discernible change in code. Further, the code for that expand function matches the existing precedent set byexpandTenantChangePassword
,expandTenantGuardianMFAPage
,expandTenantErrorPage
andexpandTenantUniversalLogin
.