terraform-provider-google/google/import_google_organization_iam_test.go
Nathan McKinley ced8cb506c
Consistent IAM resource imports. (#835)
Add consistency for for IAM imports.
- Adds imports for projects, folders, crypto keys, organizations, and key rings.
- Anything else with IAM can implement a simple method and begin working immediately.
- Add tests for all the IAM imports.
- Import documentation for IAM resources.
2017-12-11 10:24:53 -08:00

58 lines
1.5 KiB
Go

package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccGoogleOrganizationIamMember_importBasic(t *testing.T) {
t.Parallel()
orgId := getTestOrgFromEnv(t)
account := acctest.RandomWithPrefix("tf-test")
projectId := getTestProjectFromEnv()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccGoogleOrganizationIamMember_basic(account, orgId),
},
resource.TestStep{
ResourceName: "google_organization_iam_member.foo",
ImportStateId: fmt.Sprintf("%s roles/browser serviceAccount:%s@%s.iam.gserviceaccount.com", orgId, account, projectId),
ImportState: true,
},
},
})
}
func TestAccGoogleOrganizationIamBinding_importBasic(t *testing.T) {
t.Parallel()
orgId := getTestOrgFromEnv(t)
account := acctest.RandomWithPrefix("tf-test")
roleId := "tfIamTest" + acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccGoogleOrganizationIamBinding_basic(account, roleId, orgId),
},
resource.TestStep{
ResourceName: "google_organization_iam_binding.foo",
ImportStateId: fmt.Sprintf("%s organizations/%s/roles/%s", orgId, orgId, roleId),
ImportState: true,
},
},
})
}