@@ -301,3 +301,76 @@ resource "temporalcloud_user" "terraform" {
301301 },
302302 })
303303}
304+
305+ func TestAccBasicUserWithMultipleNamespaceAccesses (t * testing.T ) {
306+ type configArgs struct {
307+ Email string
308+ NamespaceName string
309+ }
310+
311+ emailAddr := createRandomEmail ()
312+ nsName := randomString (10 )
313+
314+ tmpl := template .Must (template .New ("config" ).Parse (`
315+ provider "temporalcloud" {
316+
317+ }
318+
319+ resource "temporalcloud_namespace" "test" {
320+ name = "{{ .NamespaceName }}"
321+ regions = ["aws-us-east-1"]
322+ api_key_auth = true
323+
324+ retention_days = 7
325+ }
326+
327+ resource "temporalcloud_namespace" "test2" {
328+ name = "{{ .NamespaceName }}2"
329+ regions = ["aws-us-east-1"]
330+ api_key_auth = true
331+
332+ retention_days = 7
333+ }
334+
335+ resource "temporalcloud_user" "terraform" {
336+ email = "{{ .Email }}"
337+ account_access = "read"
338+ namespace_accesses = [
339+ {
340+ namespace_id = temporalcloud_namespace.test.id
341+ permission = "Read"
342+ },
343+ {
344+ namespace_id = temporalcloud_namespace.test2.id
345+ permission = "Write"
346+ },
347+ ]
348+ }` ))
349+
350+ config := func (args configArgs ) string {
351+ var buf bytes.Buffer
352+ writer := bufio .NewWriter (& buf )
353+ if err := tmpl .Execute (writer , args ); err != nil {
354+ t .Errorf ("failed to execute template: %v" , err )
355+ t .FailNow ()
356+ }
357+
358+ writer .Flush ()
359+ return buf .String ()
360+ }
361+
362+ resource .ParallelTest (t , resource.TestCase {
363+ PreCheck : func () {
364+ testAccPreCheck (t )
365+ },
366+ ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
367+ Steps : []resource.TestStep {
368+ {
369+ Config : config (configArgs {
370+ Email : emailAddr ,
371+ NamespaceName : nsName ,
372+ }),
373+ },
374+ },
375+ })
376+ }
0 commit comments