mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-03 08:42:39 +00:00
org policy test fixes (#1059)
This commit is contained in:
parent
5db0c53f32
commit
e48f247196
|
@ -3,6 +3,7 @@ package google
|
|||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
|
@ -194,6 +195,8 @@ func testAccCheckGoogleFolderOrganizationListPolicyAllowedValues(n string, value
|
|||
return err
|
||||
}
|
||||
|
||||
sort.Strings(policy.ListPolicy.AllowedValues)
|
||||
sort.Strings(values)
|
||||
if !reflect.DeepEqual(policy.ListPolicy.AllowedValues, values) {
|
||||
return fmt.Errorf("Expected the list policy to allow '%s', instead allowed '%s'", values, policy.ListPolicy.AllowedValues)
|
||||
}
|
||||
|
@ -209,6 +212,8 @@ func testAccCheckGoogleFolderOrganizationListPolicyDeniedValues(n string, values
|
|||
return err
|
||||
}
|
||||
|
||||
sort.Strings(policy.ListPolicy.DeniedValues)
|
||||
sort.Strings(values)
|
||||
if !reflect.DeepEqual(policy.ListPolicy.DeniedValues, values) {
|
||||
return fmt.Errorf("Expected the list policy to deny '%s', instead denied '%s'", values, policy.ListPolicy.DeniedValues)
|
||||
}
|
||||
|
@ -303,14 +308,14 @@ resource "google_folder" "orgpolicy" {
|
|||
}
|
||||
|
||||
resource "google_folder_organization_policy" "list" {
|
||||
folder = "${google_folder.orgpolicy.name}"
|
||||
folder = "${google_folder.orgpolicy.name}"
|
||||
constraint = "serviceuser.services"
|
||||
|
||||
list_policy {
|
||||
deny {
|
||||
values = [
|
||||
"maps-ios-backend.googleapis.com",
|
||||
"placesios.googleapis.com",
|
||||
"doubleclicksearch.googleapis.com",
|
||||
"replicapoolupdater.googleapis.com",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,24 @@ package google
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"google.golang.org/api/cloudresourcemanager/v1"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var DENIED_ORG_POLICIES = []string{
|
||||
"maps-ios-backend.googleapis.com",
|
||||
"placesios.googleapis.com",
|
||||
"doubleclicksearch.googleapis.com",
|
||||
"replicapoolupdater.googleapis.com",
|
||||
}
|
||||
|
||||
func TestAccGoogleOrganizationPolicy_boolean(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Since each test here is acting on the same organization, run the tests serially to
|
||||
// avoid race conditions and aborted operations.
|
||||
|
||||
func TestAccGoogleOrganizationPolicy_boolean(t *testing.T) {
|
||||
org := getTestOrgFromEnv(t)
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -58,8 +61,6 @@ func TestAccGoogleOrganizationPolicy_boolean(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccGoogleOrganizationPolicy_list_allowAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
org := getTestOrgFromEnv(t)
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -80,8 +81,6 @@ func TestAccGoogleOrganizationPolicy_list_allowAll(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccGoogleOrganizationPolicy_list_allowSome(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
org := getTestOrgFromEnv(t)
|
||||
project := getTestProjectFromEnv()
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
@ -103,8 +102,6 @@ func TestAccGoogleOrganizationPolicy_list_allowSome(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccGoogleOrganizationPolicy_list_denySome(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
org := getTestOrgFromEnv(t)
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -125,8 +122,6 @@ func TestAccGoogleOrganizationPolicy_list_denySome(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccGoogleOrganizationPolicy_list_update(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
org := getTestOrgFromEnv(t)
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -216,6 +211,8 @@ func testAccCheckGoogleOrganizationListPolicyAllowedValues(n string, values []st
|
|||
return err
|
||||
}
|
||||
|
||||
sort.Strings(policy.ListPolicy.AllowedValues)
|
||||
sort.Strings(values)
|
||||
if !reflect.DeepEqual(policy.ListPolicy.AllowedValues, values) {
|
||||
return fmt.Errorf("Expected the list policy to allow '%s', instead allowed '%s'", values, policy.ListPolicy.AllowedValues)
|
||||
}
|
||||
|
@ -231,6 +228,8 @@ func testAccCheckGoogleOrganizationListPolicyDeniedValues(n string, values []str
|
|||
return err
|
||||
}
|
||||
|
||||
sort.Strings(policy.ListPolicy.DeniedValues)
|
||||
sort.Strings(values)
|
||||
if !reflect.DeepEqual(policy.ListPolicy.DeniedValues, values) {
|
||||
return fmt.Errorf("Expected the list policy to deny '%s', instead denied '%s'", values, policy.ListPolicy.DeniedValues)
|
||||
}
|
||||
|
@ -306,13 +305,13 @@ func testAccGoogleOrganizationPolicy_list_denySome(org string) string {
|
|||
return fmt.Sprintf(`
|
||||
resource "google_organization_policy" "list" {
|
||||
org_id = "%s"
|
||||
constraint = "serviceuser.services"
|
||||
constraint = "serviceuser.services"
|
||||
|
||||
list_policy {
|
||||
deny {
|
||||
values = [
|
||||
"maps-ios-backend.googleapis.com",
|
||||
"placesios.googleapis.com",
|
||||
"doubleclicksearch.googleapis.com",
|
||||
"replicapoolupdater.googleapis.com",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user