Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix hashicorp/terraform-provider-google#17388 (only run tests in beta)" #17482

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/10111.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```release-note:none
```
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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccFirebaseAppCheckAppAttestConfig_firebaseAppCheckAppAttestConfigUpdat

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
"time": {},
Expand Down
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenUpdate(t *testi

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
"time": {},
Expand Down Expand Up @@ -60,8 +60,6 @@ func TestAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenUpdate(t *testi
func testAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenTemplate(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_firebase_web_app" "default" {
provider = google-beta

project = "%{project_id}"
display_name = "Web App for debug token"
}
Expand All @@ -74,8 +72,6 @@ resource "time_sleep" "wait_30s" {
}

resource "google_firebase_app_check_debug_token" "default" {
provider = google-beta

project = "%{project_id}"
app_id = google_firebase_web_app.default.app_id
display_name = "%{display_name}"
Expand Down
Loading
Loading