-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
This reverts commit ae819d0. [upstream:712cce7da0b4d17e9ee5295c2df2ae67df9d4118] Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
6ee28e2
commit 4aa87bb
Showing
16 changed files
with
608 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
```release-note:none | ||
``` |
153 changes: 153 additions & 0 deletions
153
...services/firebaseappcheck/resource_firebase_app_check_app_attest_config_generated_test.go
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,153 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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 firebaseappcheck_test | ||
|
||
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 TestAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigMinimalExample(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"project_id": envvar.GetTestProjectFromEnv(), | ||
"team_id": "9987654321", | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
ExternalProviders: map[string]resource.ExternalProvider{ | ||
"random": {}, | ||
"time": {}, | ||
}, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigMinimalExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_app_check_app_attest_config.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"app_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigMinimalExample(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_firebase_apple_app" "default" { | ||
project = "%{project_id}" | ||
display_name = "Apple app" | ||
bundle_id = "bundle.id.appattest%{random_suffix}" | ||
team_id = "%{team_id}" | ||
} | ||
# It takes a while for App Check to recognize the new app | ||
# If your app already exists, you don't have to wait 30 seconds. | ||
resource "time_sleep" "wait_30s" { | ||
depends_on = [google_firebase_apple_app.default] | ||
create_duration = "30s" | ||
} | ||
resource "google_firebase_app_check_app_attest_config" "default" { | ||
project = "%{project_id}" | ||
app_id = google_firebase_apple_app.default.app_id | ||
depends_on = [time_sleep.wait_30s] | ||
lifecycle { | ||
precondition { | ||
condition = google_firebase_apple_app.default.team_id != "" | ||
error_message = "Provide a Team ID on the Apple App to use App Check" | ||
} | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func TestAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigFullExample(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"project_id": envvar.GetTestProjectFromEnv(), | ||
"team_id": "9987654321", | ||
"token_ttl": "7200s", | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
ExternalProviders: map[string]resource.ExternalProvider{ | ||
"random": {}, | ||
"time": {}, | ||
}, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigFullExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_app_check_app_attest_config.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"app_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigFullExample(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_firebase_apple_app" "default" { | ||
project = "%{project_id}" | ||
display_name = "Apple app" | ||
bundle_id = "bundle.id.appattest%{random_suffix}" | ||
team_id = "%{team_id}" | ||
} | ||
# It takes a while for App Check to recognize the new app | ||
# If your app already exists, you don't have to wait 30 seconds. | ||
resource "time_sleep" "wait_30s" { | ||
depends_on = [google_firebase_apple_app.default] | ||
create_duration = "30s" | ||
} | ||
resource "google_firebase_app_check_app_attest_config" "default" { | ||
project = "%{project_id}" | ||
app_id = google_firebase_apple_app.default.app_id | ||
token_ttl = "%{token_ttl}" | ||
depends_on = [time_sleep.wait_30s] | ||
lifecycle { | ||
precondition { | ||
condition = google_firebase_apple_app.default.team_id != "" | ||
error_message = "Provide a Team ID on the Apple App to use App Check" | ||
} | ||
} | ||
} | ||
`, context) | ||
} |
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
127 changes: 127 additions & 0 deletions
127
google/services/firebaseappcheck/resource_firebase_app_check_debug_token_generated_test.go
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,127 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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 firebaseappcheck_test | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
"github.com/hashicorp/terraform-provider-google/google/envvar" | ||
"github.com/hashicorp/terraform-provider-google/google/tpgresource" | ||
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" | ||
) | ||
|
||
func TestAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenBasicExample(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"project_id": envvar.GetTestProjectFromEnv(), | ||
"token": "5E728315-E121-467F-BCA1-1FE71130BB98", | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
ExternalProviders: map[string]resource.ExternalProvider{ | ||
"random": {}, | ||
"time": {}, | ||
}, | ||
CheckDestroy: testAccCheckFirebaseAppCheckDebugTokenDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenBasicExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_app_check_debug_token.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"token", "app_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenBasicExample(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_firebase_web_app" "default" { | ||
project = "%{project_id}" | ||
display_name = "Web App for debug token" | ||
} | ||
# It takes a while for App Check to recognize the new app | ||
# If your app already exists, you don't have to wait 30 seconds. | ||
resource "time_sleep" "wait_30s" { | ||
depends_on = [google_firebase_web_app.default] | ||
create_duration = "30s" | ||
} | ||
resource "google_firebase_app_check_debug_token" "default" { | ||
project = "%{project_id}" | ||
app_id = google_firebase_web_app.default.app_id | ||
display_name = "Debug Token%{random_suffix}" | ||
token = "%{token}" | ||
depends_on = [time_sleep.wait_30s] | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccCheckFirebaseAppCheckDebugTokenDestroyProducer(t *testing.T) func(s *terraform.State) error { | ||
return func(s *terraform.State) error { | ||
for name, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_firebase_app_check_debug_token" { | ||
continue | ||
} | ||
if strings.HasPrefix(name, "data.") { | ||
continue | ||
} | ||
|
||
config := acctest.GoogleProviderConfig(t) | ||
|
||
url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{FirebaseAppCheckBasePath}}projects/{{project}}/apps/{{app_id}}/debugTokens/{{debug_token_id}}") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
billingProject := "" | ||
|
||
if config.BillingProject != "" { | ||
billingProject = config.BillingProject | ||
} | ||
|
||
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ | ||
Config: config, | ||
Method: "GET", | ||
Project: billingProject, | ||
RawURL: url, | ||
UserAgent: config.UserAgent, | ||
}) | ||
if err == nil { | ||
return fmt.Errorf("FirebaseAppCheckDebugToken still exists at %s", url) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} |
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
Oops, something went wrong.