@@ -102,7 +102,7 @@ func TestAccBigQuerySourceResourceCreateUpdateDelete(t *testing.T) {
102102 ConfigDirectory : config .TestNameDirectory (),
103103 ConfigVariables : config.Variables {
104104 "source_label" : config .StringVariable ("Test Source" ),
105- "source_credentials" : config .MapVariable (map [string ]config.Variable {
105+ "source_credentials" : config .ObjectVariable (map [string ]config.Variable {
106106 "project_id" : config .StringVariable ("project-id" ),
107107 "location" : config .StringVariable ("US" ),
108108 }),
@@ -125,9 +125,16 @@ func TestAccBigQuerySourceResourceCreateUpdateDelete(t *testing.T) {
125125 ConfigDirectory : config .TestNameDirectory (),
126126 ConfigVariables : config.Variables {
127127 "source_label" : config .StringVariable ("Test Source (updated)" ),
128- "source_credentials" : config .MapVariable (map [string ]config.Variable {
128+ "source_credentials" : config .ObjectVariable (map [string ]config.Variable {
129129 "project_id" : config .StringVariable ("project-id" ),
130130 "location" : config .StringVariable ("US" ),
131+ "service_account_key" : config .ObjectVariable (map [string ]config.Variable {
132+ "project_id" : config .StringVariable ("project-id" ),
133+ "private_key_id" : config .StringVariable ("private-key-id" ),
134+ "private_key" : config .StringVariable ("private-key" ),
135+ "client_id" : config .StringVariable ("client-id" ),
136+ "client_email" : config .StringVariable ("client-email" ),
137+ }),
131138 }),
132139 },
133140 ConfigPlanChecks : resource.ConfigPlanChecks {
@@ -197,3 +204,65 @@ func TestAccBigQuerySourceResourceMovedFromSource(t *testing.T) {
197204 },
198205 })
199206}
207+
208+ //nolint:paralleltest
209+ func TestAccBigQuerySourceResourceMovedFromSourceWithServiceAccountKey (t * testing.T ) {
210+ server , err := cmt .NewCensusManagementServer ()
211+ require .NoError (t , err )
212+
213+ configVariables := config.Variables {
214+ "source_label" : config .StringVariable ("Test Source" ),
215+ "source_credentials" : config .ObjectVariable (map [string ]config.Variable {
216+ "project_id" : config .StringVariable ("project-id" ),
217+ "location" : config .StringVariable ("US" ),
218+ "service_account_key" : config .ObjectVariable (map [string ]config.Variable {
219+ "project_id" : config .StringVariable ("project-id" ),
220+ "private_key_id" : config .StringVariable ("private-key-id" ),
221+ "private_key" : config .StringVariable ("private-key" ),
222+ "client_id" : config .StringVariable ("client-id" ),
223+ "client_email" : config .StringVariable ("client-email" ),
224+ }),
225+ }),
226+ }
227+
228+ ProviderMockedResourceTest (t , server , resource.TestCase {
229+ Steps : []resource.TestStep {
230+ {
231+ ConfigDirectory : config .TestStepDirectory (),
232+ ConfigVariables : configVariables ,
233+ ConfigPlanChecks : resource.ConfigPlanChecks {
234+ PreApply : []plancheck.PlanCheck {
235+ plancheck .ExpectResourceAction ("censusworkspace_source.test" , plancheck .ResourceActionCreate ),
236+ plancheck .ExpectUnknownValue ("censusworkspace_source.test" , tfjsonpath .New ("id" )),
237+ plancheck .ExpectKnownValue ("censusworkspace_source.test" , tfjsonpath .New ("label" ), knownvalue .StringExact ("Test Source" )),
238+ },
239+ PostApplyPostRefresh : []plancheck.PlanCheck {
240+ plancheck .ExpectKnownValue ("censusworkspace_source.test" , tfjsonpath .New ("last_test_succeeded" ), knownvalue .Null ()),
241+ },
242+ },
243+ },
244+ {
245+ ConfigDirectory : config .TestStepDirectory (),
246+ ConfigVariables : configVariables ,
247+
248+ ConfigPlanChecks : resource.ConfigPlanChecks {
249+ PreApply : []plancheck.PlanCheck {
250+ plancheck .ExpectEmptyPlan (),
251+ plancheck .ExpectResourceAction ("censusworkspace_big_query_source.test" , plancheck .ResourceActionNoop ),
252+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("id" ), knownvalue .NotNull ()),
253+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("label" ), knownvalue .StringExact ("Test Source" )),
254+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("name" ), knownvalue .NotNull ()),
255+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("credentials" ).AtMapKey ("project_id" ), knownvalue .StringExact ("project-id" )),
256+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("credentials" ).AtMapKey ("location" ), knownvalue .StringExact ("US" )),
257+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("credentials" ).AtMapKey ("service_account_key" ).AtMapKey ("private_key_id" ), knownvalue .StringExact ("private-key-id" )),
258+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("credentials" ).AtMapKey ("service_account_key" ).AtMapKey ("client_email" ), knownvalue .StringExact ("client-email" )),
259+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("connection_details" ), knownvalue .NotNull ()),
260+ },
261+ PostApplyPostRefresh : []plancheck.PlanCheck {
262+ plancheck .ExpectKnownValue ("censusworkspace_big_query_source.test" , tfjsonpath .New ("last_test_succeeded" ), knownvalue .Null ()),
263+ },
264+ },
265+ },
266+ },
267+ })
268+ }
0 commit comments