Add tests around how plugin framework provider configuration code handles credentials values#8801
Conversation
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 10 files changed, 161 insertions(+), 158 deletions(-)) |
| // LoadAndValidateFramework handles the bulk of configuring the provider | ||
| // it is pulled out so that we can manually call this from our testing provider as well | ||
| func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, data fwmodels.ProviderModel, tfVersion string, diags *diag.Diagnostics, providerversion string) { | ||
| func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, data *fwmodels.ProviderModel, tfVersion string, diags *diag.Diagnostics, providerversion string) { |
There was a problem hiding this comment.
This PR isn't ready for full review yet, but flagging this change.
Currently the data about the provider's configuration in the config (ie provider block) is received by the provider code and used to populate the data *fwmodels.ProviderModel struct in this code. The data struct is only used by passing it into LoadAndValidateFramework, and isn't used elsewhere. Because it's only got this one use, I think this change doesn't have much risk associated with it.
Making the function take a pointer instead of a copied value allows the test to see how the data model struct is mutated inside this function.
Tests analyticsTotal tests: Action takenFound 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccDataprocJobIamPolicy|TestAccProjectIamPolicy_invalidMembers |
|
Rerun these tests in REPLAYING mode to catch issues
|
… by inaccessible functions
…ig struct after `LoadAndValidateFramework` runs
…ing test case that fails
…ata model, so mutations to the data within the function change the original struct This enables tests to track how the data is mutated
a450ef8 to
8b1f805
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…` now taking a pointer as an argument
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 6 files changed, 407 insertions(+), 11 deletions(-)) |
Tests analyticsTotal tests:
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 6 files changed, 407 insertions(+), 11 deletions(-)) |
Tests analyticsTotal tests:
|
There was a problem hiding this comment.
When the file was called mmv1/third_party/terraform/fwtransport/framework_config_test.erb it didn't get generated in the downstream at all. I totally blanked this in my PR that first introduced the file to MM, but there aren't any negative consequences beyond my tests not being present in the downstream yet.
| // Handling empty strings in config | ||
| // TODO(SarahFrench) make these tests pass to address: https://github.com/hashicorp/terraform-provider-google/issues/14255 | ||
| // "when project is set as an empty string the field is treated as if it's unset, without error": { | ||
| // ConfigValues: fwmodels.ProviderModel{ | ||
| // Project: types.StringValue(""), | ||
| // }, | ||
| // ExpectedDataModelValue: types.StringNull(), | ||
| // ExpectedConfigStructValue: types.StringNull(), | ||
| // }, | ||
| // "when project is set as an empty string an environment variable will be used": { | ||
| // ConfigValues: fwmodels.ProviderModel{ | ||
| // Project: types.StringValue(""), | ||
| // }, | ||
| // EnvVariables: map[string]string{ | ||
| // "GOOGLE_PROJECT": "project-from-GOOGLE_PROJECT", | ||
| // }, | ||
| // ExpectedDataModelValue: types.StringNull(), | ||
| // ExpectedConfigStructValue: types.StringValue("project-from-GOOGLE_PROJECT"), | ||
| // }, | ||
| // Handling unknown values | ||
| // TODO(SarahFrench) make these tests pass to address: https://github.com/hashicorp/terraform-provider-google/issues/14444 | ||
| // "when project is an unknown value, the provider treats it as if it's unset (align to SDK behaviour)": { | ||
| // ConfigValues: fwmodels.ProviderModel{ | ||
| // Project: types.StringUnknown(), | ||
| // }, | ||
| // ExpectedDataModelValue: types.StringNull(), | ||
| // ExpectedConfigStructValue: types.StringNull(), | ||
| // }, |
There was a problem hiding this comment.
I'll make these tests pass in a subsequent PR, for ease of review and to ensure that all these 'fixes' can be done at once later in a single PR instead of across multiple PRs
…o.erb Co-authored-by: Riley Karson <rileykarson@google.com>
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 6 files changed, 407 insertions(+), 11 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccDataprocClusterIamPolicy |
|
Rerun these tests in REPLAYING mode to catch issues
|
…dles `credentials` values (GoogleCloudPlatform#8801) * Add initial version of plugin framework provider config test affected by inaccessible functions * Refactor provider config tests to use plugin-framework types * Add test case about handling of Unknown values for `project` * Update tests to check values in BOTH the data model and provider config struct after `LoadAndValidateFramework` runs * Add some tests for `credentials` in plugin framework provider, including test case that fails * Update `LoadAndValidateFramework` to take a pointer to the provider data model, so mutations to the data within the function change the original struct This enables tests to track how the data is mutated * Add remaining `credentials` test cases to check PF/SDK config parity * Make tests unset ADC ENV automatically, update comments to tests setting ADC ENV * Add test for behaviour when credentials value is unknown * Add comment referring devs to where unknown value test is implemented * Remove duplicated test case * Fix filename so it's generated correctly * Remove fmt line * Update `project` tests that are affected by `LoadAndValidateFramework` now taking a pointer as an argument * Update mmv1/third_party/terraform/fwtransport/framework_config_test.go.erb Co-authored-by: Riley Karson <rileykarson@google.com> --------- Co-authored-by: Riley Karson <rileykarson@google.com>
…dles `credentials` values (GoogleCloudPlatform#8801) * Add initial version of plugin framework provider config test affected by inaccessible functions * Refactor provider config tests to use plugin-framework types * Add test case about handling of Unknown values for `project` * Update tests to check values in BOTH the data model and provider config struct after `LoadAndValidateFramework` runs * Add some tests for `credentials` in plugin framework provider, including test case that fails * Update `LoadAndValidateFramework` to take a pointer to the provider data model, so mutations to the data within the function change the original struct This enables tests to track how the data is mutated * Add remaining `credentials` test cases to check PF/SDK config parity * Make tests unset ADC ENV automatically, update comments to tests setting ADC ENV * Add test for behaviour when credentials value is unknown * Add comment referring devs to where unknown value test is implemented * Remove duplicated test case * Fix filename so it's generated correctly * Remove fmt line * Update `project` tests that are affected by `LoadAndValidateFramework` now taking a pointer as an argument * Update mmv1/third_party/terraform/fwtransport/framework_config_test.go.erb Co-authored-by: Riley Karson <rileykarson@google.com> --------- Co-authored-by: Riley Karson <rileykarson@google.com>
…dles `credentials` values (GoogleCloudPlatform#8801) * Add initial version of plugin framework provider config test affected by inaccessible functions * Refactor provider config tests to use plugin-framework types * Add test case about handling of Unknown values for `project` * Update tests to check values in BOTH the data model and provider config struct after `LoadAndValidateFramework` runs * Add some tests for `credentials` in plugin framework provider, including test case that fails * Update `LoadAndValidateFramework` to take a pointer to the provider data model, so mutations to the data within the function change the original struct This enables tests to track how the data is mutated * Add remaining `credentials` test cases to check PF/SDK config parity * Make tests unset ADC ENV automatically, update comments to tests setting ADC ENV * Add test for behaviour when credentials value is unknown * Add comment referring devs to where unknown value test is implemented * Remove duplicated test case * Fix filename so it's generated correctly * Remove fmt line * Update `project` tests that are affected by `LoadAndValidateFramework` now taking a pointer as an argument * Update mmv1/third_party/terraform/fwtransport/framework_config_test.go.erb Co-authored-by: Riley Karson <rileykarson@google.com> --------- Co-authored-by: Riley Karson <rileykarson@google.com>
…dles `credentials` values (GoogleCloudPlatform#8801) * Add initial version of plugin framework provider config test affected by inaccessible functions * Refactor provider config tests to use plugin-framework types * Add test case about handling of Unknown values for `project` * Update tests to check values in BOTH the data model and provider config struct after `LoadAndValidateFramework` runs * Add some tests for `credentials` in plugin framework provider, including test case that fails * Update `LoadAndValidateFramework` to take a pointer to the provider data model, so mutations to the data within the function change the original struct This enables tests to track how the data is mutated * Add remaining `credentials` test cases to check PF/SDK config parity * Make tests unset ADC ENV automatically, update comments to tests setting ADC ENV * Add test for behaviour when credentials value is unknown * Add comment referring devs to where unknown value test is implemented * Remove duplicated test case * Fix filename so it's generated correctly * Remove fmt line * Update `project` tests that are affected by `LoadAndValidateFramework` now taking a pointer as an argument * Update mmv1/third_party/terraform/fwtransport/framework_config_test.go.erb Co-authored-by: Riley Karson <rileykarson@google.com> --------- Co-authored-by: Riley Karson <rileykarson@google.com>
This PR adds tests for how the plugin framework config code handles the
credentialsfield's value.These tests either:
Note: in this PR I changed the function signature for LoadAndValidateFramework (see comment here) to enable proper testing of the function
TODOs:
If this PR is for Terraform, I acknowledge that I have:
make testandmake lintin the generated providers to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)