mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-16 08:10:02 +00:00
89 lines
2.5 KiB
Go
89 lines
2.5 KiB
Go
|
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
||
|
//
|
||
|
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// This file is automatically generated by Magic Modules and manual
|
||
|
// changes will be clobbered when the file is regenerated.
|
||
|
//
|
||
|
// Please read more about how to change this file in
|
||
|
// .github/CONTRIBUTING.md.
|
||
|
//
|
||
|
// ----------------------------------------------------------------------------
|
||
|
|
||
|
package google
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||
|
"github.com/hashicorp/terraform/helper/resource"
|
||
|
"github.com/hashicorp/terraform/terraform"
|
||
|
)
|
||
|
|
||
|
func TestAccStorageObjectAccessControl_StorageObjectAccessControlPublicObjectExample(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
CheckDestroy: testAccCheckStorageObjectAccessControlDestroy,
|
||
|
Steps: []resource.TestStep{
|
||
|
{
|
||
|
Config: testAccStorageObjectAccessControl_StorageObjectAccessControlPublicObjectExample(acctest.RandString(10)),
|
||
|
},
|
||
|
{
|
||
|
ResourceName: "google_storage_object_access_control.public_rule",
|
||
|
ImportState: true,
|
||
|
ImportStateVerify: true,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccStorageObjectAccessControl_StorageObjectAccessControlPublicObjectExample(val string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
resource "google_storage_object_access_control" "public_rule" {
|
||
|
object = "${google_storage_bucket_object.object.name}"
|
||
|
bucket = "${google_storage_bucket.bucket.name}"
|
||
|
role = "READER"
|
||
|
entity = "allUsers"
|
||
|
}
|
||
|
|
||
|
resource "google_storage_bucket" "bucket" {
|
||
|
name = "static-content-bucket-%s"
|
||
|
}
|
||
|
|
||
|
resource "google_storage_bucket_object" "object" {
|
||
|
name = "public-object-%s"
|
||
|
bucket = "${google_storage_bucket.bucket.name}"
|
||
|
source = "test-fixtures/header-logo.png"
|
||
|
}
|
||
|
`, val, val,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func testAccCheckStorageObjectAccessControlDestroy(s *terraform.State) error {
|
||
|
for _, rs := range s.RootModule().Resources {
|
||
|
if rs.Type != "google_storage_object_access_control" {
|
||
|
continue
|
||
|
}
|
||
|
|
||
|
config := testAccProvider.Meta().(*Config)
|
||
|
|
||
|
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/storage/v1/b/{{bucket}}/o/{{object}}/acl/{{entity}}")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
_, err = sendRequest(config, "GET", url, nil)
|
||
|
if err == nil {
|
||
|
return fmt.Errorf("StorageObjectAccessControl still exists at %s", url)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|