diff --git a/builtin/providers/google/data_source_storage_object_signed_url.go b/builtin/providers/google/data_source_storage_object_signed_url.go index 10a03ff07..fced990cf 100644 --- a/builtin/providers/google/data_source_storage_object_signed_url.go +++ b/builtin/providers/google/data_source_storage_object_signed_url.go @@ -20,8 +20,6 @@ import ( "sort" - "regexp" - "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform/helper/pathorcontents" "github.com/hashicorp/terraform/helper/schema" @@ -98,7 +96,7 @@ func validateExtensionHeaders(v interface{}, k string) (ws []string, errors []er func validateHttpMethod(v interface{}, k string) (ws []string, errs []error) { value := v.(string) value = strings.ToUpper(value) - if !regexp.MustCompile(`^(GET|HEAD|PUT|DELETE)$`).MatchString(value) { + if value != "GET" && value != "HEAD" && value != "PUT" && value != "DELETE" { errs = append(errs, errors.New("http_method must be one of [GET|HEAD|PUT|DELETE]")) } return @@ -149,14 +147,7 @@ func dataSourceGoogleSignedUrlRead(d *schema.ResourceData, meta interface{}) err } } - // object path - path := []string{ - "", - d.Get("bucket").(string), - d.Get("path").(string), - } - objectPath := strings.Join(path, "/") - urlData.Path = objectPath + urlData.Path = fmt.Sprintf("/%s/%s", d.Get("bucket").(string), d.Get("path").(string)) // Load JWT Config from Google Credentials jwtConfig, err := loadJwtConfig(d, config) diff --git a/builtin/providers/google/data_source_storage_object_signed_url_test.go b/builtin/providers/google/data_source_storage_object_signed_url_test.go index b59b5a7a5..03912216c 100644 --- a/builtin/providers/google/data_source_storage_object_signed_url_test.go +++ b/builtin/providers/google/data_source_storage_object_signed_url_test.go @@ -99,7 +99,7 @@ func TestUrlData_SignedUrl(t *testing.T) { } } -func TestDatasourceSignedUrl_basic(t *testing.T) { +func TestAccStorageSignedUrl_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -114,7 +114,7 @@ func TestDatasourceSignedUrl_basic(t *testing.T) { }) } -func TestDatasourceSignedUrl_accTest(t *testing.T) { +func TestAccStorageSignedUrl_accTest(t *testing.T) { bucketName := fmt.Sprintf("tf-test-bucket-%d", acctest.RandInt()) headers := map[string]string{ @@ -127,7 +127,7 @@ func TestDatasourceSignedUrl_accTest(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccTestGoogleStorageObjectSingedUrl(bucketName), + Config: testAccTestGoogleStorageObjectSignedURL(bucketName), Check: resource.ComposeTestCheckFunc( testAccGoogleSignedUrlRetrieval("data.google_storage_object_signed_url.story_url", nil), testAccGoogleSignedUrlRetrieval("data.google_storage_object_signed_url.story_url_w_headers", headers), @@ -168,7 +168,10 @@ func testAccGoogleSignedUrlRetrieval(n string, headers map[string]string) resour // create HTTP request url := a["signed_url"] method := a["http_method"] - req, _ := http.NewRequest(method, url, nil) + req, err := http.NewRequest(method, url, nil) + if err != nil { + return err + } // Add extension headers to request, if provided for k, v := range headers { @@ -216,7 +219,7 @@ data "google_storage_object_signed_url" "blerg" { } ` -func testAccTestGoogleStorageObjectSingedUrl(bucketName string) string { +func testAccTestGoogleStorageObjectSignedURL(bucketName string) string { return fmt.Sprintf(` resource "google_storage_bucket" "bucket" { name = "%s"