forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
b6ae45c
commit bd1aa6b
Showing
3 changed files
with
137 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
...ty/terraform/services/firebaseappcheck/resource_firebase_app_check_service_config_test.go
This file was deleted.
Oops, something went wrong.
135 changes: 135 additions & 0 deletions
135
...erraform/services/firebaseappcheck/resource_firebase_app_check_service_config_test.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
<% autogen_exception -%> | ||
package firebaseappcheck_test | ||
<% unless version == 'ga' -%> | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
"github.com/hashicorp/terraform-provider-google/google/envvar" | ||
) | ||
|
||
func TestAccFirebaseAppCheckServiceConfig_firebaseAppCheckServiceConfigUpdate(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"org_id": envvar.GetTestOrgFromEnv(t), | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), | ||
CheckDestroy: testAccCheckFirebaseAppCheckServiceConfigDestroyProducer(t), | ||
ExternalProviders: map[string]resource.ExternalProvider{ | ||
"random": {}, | ||
"time": {}, | ||
}, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFirebaseAppCheckServiceConfig_firebaseAppCheckServiceConfigUpdate(context, "UNENFORCED"), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_app_check_service_config.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseAppCheckServiceConfig_firebaseAppCheckServiceConfigUpdate(context, "ENFORCED"), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_app_check_service_config.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseAppCheckServiceConfig_firebaseAppCheckServiceConfigUpdate(context, ""), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_app_check_service_config.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFirebaseAppCheckServiceConfig_firebaseAppCheckServiceConfigUpdate(context map[string]interface{}, enforcementMode string) string { | ||
context["enforcement_mode"] = enforcementMode | ||
return acctest.Nprintf(` | ||
resource "google_project" "default" { | ||
provider = google-beta | ||
project_id = "tf-test-appcheck%{random_suffix}" | ||
name = "tf-test-appcheck%{random_suffix}" | ||
org_id = "%{org_id}" | ||
labels = { | ||
"firebase" = "enabled" | ||
} | ||
} | ||
|
||
resource "google_project_service" "firebase" { | ||
provider = google-beta | ||
project = google_project.default.project_id | ||
service = "firebase.googleapis.com" | ||
disable_on_destroy = false | ||
} | ||
|
||
resource "google_project_service" "database" { | ||
provider = google-beta | ||
project = google_project.default.project_id | ||
service = "firebasedatabase.googleapis.com" | ||
disable_on_destroy = false | ||
} | ||
|
||
resource "google_project_service" "appcheck" { | ||
provider = google-beta | ||
project = google_project.default.project_id | ||
service = "firebaseappcheck.googleapis.com" | ||
disable_on_destroy = false | ||
} | ||
|
||
resource "google_firebase_project" "default" { | ||
provider = google-beta | ||
project = google_project.default.project_id | ||
|
||
depends_on = [ | ||
google_project_service.firebase, | ||
google_project_service.database, | ||
google_project_service.appcheck, | ||
] | ||
} | ||
|
||
# It takes a while for the new project to be ready for a database | ||
resource "time_sleep" "wait_30s" { | ||
depends_on = [google_firebase_project.default] | ||
create_duration = "30s" | ||
} | ||
|
||
resource "google_firebase_database_instance" "default" { | ||
provider = google-beta | ||
project = google_firebase_project.default.project | ||
region = "us-central1" | ||
instance_id = "tf-test-appcheck%{random_suffix}-default-rtdb" | ||
type = "DEFAULT_DATABASE" | ||
|
||
depends_on = [time_sleep.wait_30s] | ||
} | ||
|
||
resource "google_firebase_app_check_service_config" "default" { | ||
provider = google-beta | ||
project = google_firebase_project.default.project | ||
service_id = "firebasedatabase.googleapis.com" | ||
enforcement_mode = "%{enforcement_mode}" | ||
|
||
depends_on = [google_firebase_database_instance.default] | ||
} | ||
`, context) | ||
} | ||
<% end -%> |