-
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
DXCDT-94 Stop ignoring errors when setting resource data within the client #94
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,10 @@ func TestAccDataClientByName(t *testing.T) { | |
PreventPostDestroyRefresh: true, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: random.Template(testAccClientConfig, rand), // must initialize resource before reading with data source | ||
Config: random.Template(testAccClientConfig, rand), | ||
Check: resource.ComposeTestCheckFunc( | ||
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. After initializing the resource we just wanna make extra sure the client got created correctly so we can fetch it within the client data source below. |
||
resource.TestCheckResourceAttr("auth0_client.my_client", "name", fmt.Sprintf("Acceptance Test - %v", rand)), | ||
), // check that the client got created correctly before using the data source | ||
}, | ||
{ | ||
Config: random.Template(fmt.Sprintf(testAccDataClientConfigByName, testAccClientConfig), rand), | ||
|
@@ -44,7 +47,6 @@ func TestAccDataClientByName(t *testing.T) { | |
resource.TestCheckResourceAttr("data.auth0_client.test", "name", fmt.Sprintf("Acceptance Test - %v", rand)), | ||
resource.TestCheckResourceAttr("data.auth0_client.test", "app_type", "non_interactive"), // Arbitrary property selection | ||
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret_rotation_trigger"), | ||
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret"), | ||
), | ||
}, | ||
}, | ||
|
@@ -62,6 +64,9 @@ func TestAccDataClientById(t *testing.T) { | |
Steps: []resource.TestStep{ | ||
{ | ||
Config: random.Template(testAccClientConfig, rand), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("auth0_client.my_client", "name", fmt.Sprintf("Acceptance Test - %v", rand)), | ||
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. After initializing the resource we just wanna make extra sure the client got created correctly so we can fetch it within the client data source below. |
||
), // check that the client got created correctly before using the data source | ||
}, | ||
{ | ||
Config: random.Template(fmt.Sprintf(testAccDataClientConfigById, testAccClientConfig), rand), | ||
|
@@ -70,7 +75,6 @@ func TestAccDataClientById(t *testing.T) { | |
resource.TestCheckResourceAttrSet("data.auth0_client.test", "name"), | ||
resource.TestCheckResourceAttr("data.auth0_client.test", "signing_keys.#", "1"), // checks that signing_keys is set, and it includes 1 element | ||
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret_rotation_trigger"), | ||
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret"), | ||
), | ||
}, | ||
}, | ||
|
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.
Because we are reusing the same schema as the client resource, if we delete the
client_secret
from here, when reading an entire client we will be getting an error when settingclient_secret
within thereadClient()
func as it's not present in the schema any more.This should have never been deleted here because of this reason.
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 had originally agreed to omit
client_secret
from the data source. Unless I'm missing it down below, this change appears to repeal that decision (confirmed by the change in the test). I see that this method of deletion is problematic but it would be wise to scrub the client secret some other way.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.
That's indeed true, however at the time we weren't aware that this would lead to an unsurfaced error. Considering the resource already has the
client_secret
and this is something that the API simply returns, if not using the data_source we always have access to it through the resource. Having the client_secret will also help a lot with passing that information to other providers / resources for configuration purposes.