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-95 Stop ignoring errors when setting resource data within the connection #97

Merged
merged 2 commits into from
Mar 30, 2022

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Mar 28, 2022

Description

This PR stops ignoring errors when setting resource data within the connection.

            * options.0.password_dictionary: '': source data must be an array or slice, got map
            * options.0.password_history: '': source data must be an array or slice, got map
            * options.0.totp: '': source data must be an array or slice, got map
            * options.0.gateway_authentication: '': source data must be an array or slice, got map
            * options.0.idp_initiated: '': source data must be an array or slice, got map
            * options.0.validation: '': source data must be an array or slice, got map
            * options.0.mfa: '': source data must be an array or slice, got map
            * options.0.password_no_personal_info: '': source data must be an array or slice, got map
            * options.0.password_complexity_options: '': source data must be an array or slice, got map
        Error: 400 Bad Request: options.set_user_root_attributes can be set only for enterprise connections, social connections or custom database connections (using external users store)

Ultimately fixing these fixes several issues we have on github:

Checklist

Note: Checklist required to be completed before a PR is considered to be reviewable.

Auth0 Code of Conduct

Auth0 General Contribution Guidelines

Changes include test coverage?

  • Yes
  • Not needed

Does the description provide the correct amount of context?

  • Yes, the description provides enough context for the reviewer to understand what these changes accomplish

Have you updated the documentation?

  • Yes, I've updated the appropriate docs
  • Not needed

Is this code ready for production?

  • Yes, all code changes are intentional and no debugging calls are left over

@sergiught sergiught self-assigned this Mar 28, 2022
@sergiught sergiught changed the base branch from main to patch/DXCDT-80-client March 28, 2022 09:11
@sergiught sergiught marked this pull request as ready for review March 28, 2022 09:25
@sergiught sergiught requested a review from a team as a code owner March 28, 2022 09:25
Copy link
Contributor Author

@sergiught sergiught left a comment

Choose a reason for hiding this comment

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

Adding a few comments to aid with reviewing.

@@ -243,6 +218,7 @@ var connectionSchema = map[string]*schema.Schema{
},
"allowed_audiences": {
Type: schema.TypeSet,
Computed: 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.

The issue here is that we define all possible parameters of the options object for all the different connection types and with the legacy SDK (v1) if we don't set something up for a TypeSet initially it will be read as "" but then after a state update it will be automatically set to an empty []string making the tests fail cuz there's an unexpected plan change. To fix this we need to set computed on this property and several others.

@@ -77,7 +77,6 @@ func TestAccConnection(t *testing.T) {
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.import_mode", "false"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.disable_signup", "false"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.requires_username", "true"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.set_user_root_attributes", "on_each_login"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually not allowed and it was never set within the flatten for the Auth0 connection type. This property only works for enterprise connections.

@@ -216,6 +212,7 @@ resource "auth0_connection" "ad" {
strategy = "ad"
show_as_button = true
options {
brute_force_protection = 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.

The default by the API is to set brute force conection as enabled. Like this we remove the hack we introduced here https://github.com/auth0/terraform-provider-auth0/pull/97/files#diff-f2cec8e18d10bdff521bfda90a79b3154d267cccd5925b7ec9393cf7eeec7726L662-L666

"non_persistent_attrs": o.GetNonPersistentAttrs(),
"scopes": o.Scopes(),
}
func optionsBlockIsNotDefined(d ResourceData) bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This now allows to have a connection without options block defined in the terraform config.

Base automatically changed from patch/DXCDT-80-client to main March 30, 2022 13:09
@sergiught sergiught merged commit c982218 into main Mar 30, 2022
@sergiught sergiught deleted the patch/DXCDT-95-connection branch March 30, 2022 13:21
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