From d514d4c698042ac9e9c396831f8f66c5b324157a Mon Sep 17 00:00:00 2001 From: Tujit Bora Date: Fri, 4 Oct 2024 10:41:03 +0530 Subject: [PATCH] datasource tests --- internal/datasources/data_consent_test.go | 36 ++++++ .../datasources/data_custom_provider_test.go | 36 ++++++ internal/datasources/data_group_type_test.go | 103 +++++++---------- .../datasources/data_registration_field.go | 3 +- .../data_registration_field_test.go | 73 ++++++++++++ internal/datasources/data_role_test.go | 104 +++++------------- internal/datasources/data_scope_group_test.go | 35 ++++++ internal/datasources/data_scope_test.go | 66 +++++++++++ .../datasources/data_social_provider_test.go | 41 +++++++ .../data_system_template_option_test.go | 66 +++++++++++ internal/resources/resource_app_test.go | 5 +- .../resources/resource_hosted_page_test.go | 2 +- 12 files changed, 431 insertions(+), 139 deletions(-) create mode 100644 internal/datasources/data_consent_test.go create mode 100644 internal/datasources/data_custom_provider_test.go create mode 100644 internal/datasources/data_registration_field_test.go create mode 100644 internal/datasources/data_scope_group_test.go create mode 100644 internal/datasources/data_scope_test.go create mode 100644 internal/datasources/data_social_provider_test.go create mode 100644 internal/datasources/data_system_template_option_test.go diff --git a/internal/datasources/data_consent_test.go b/internal/datasources/data_consent_test.go new file mode 100644 index 0000000..d7c20ff --- /dev/null +++ b/internal/datasources/data_consent_test.go @@ -0,0 +1,36 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceConsent_basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_consent.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_consent" "sample" { + } + `, os.Getenv("BASE_URL")), // replace with acctest.BaseURL or have a init func to set the base URL + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "consent.#"), + resource.TestCheckResourceAttrSet(resourceName, "consent.0.id"), + resource.TestCheckResourceAttrSet(resourceName, "consent.0.consent_name"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_custom_provider_test.go b/internal/datasources/data_custom_provider_test.go new file mode 100644 index 0000000..48c8fe3 --- /dev/null +++ b/internal/datasources/data_custom_provider_test.go @@ -0,0 +1,36 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceCustomProvider_basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_custom_provider.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_custom_provider" "sample" { + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "custom_provider.#"), + resource.TestCheckResourceAttrSet(resourceName, "custom_provider.0.provider_name"), + resource.TestCheckResourceAttrSet(resourceName, "custom_provider.0.standard_type"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_group_type_test.go b/internal/datasources/data_group_type_test.go index 72b4022..02ebfe5 100644 --- a/internal/datasources/data_group_type_test.go +++ b/internal/datasources/data_group_type_test.go @@ -2,86 +2,67 @@ package datasources_test import ( "fmt" - "log" - "net/http" "os" "testing" - "github.com/Cidaas/terraform-provider-cidaas/helpers/cidaas" acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" ) -var groupType = acctest.RandString(10) +func TestAccGroupTypeDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_group_type.sample" -func testGroupTypeConfig(groupType string) string { - return fmt.Sprintf(` - provider "cidaas" { - base_url = "https://kube-nightlybuild-dev.cidaas.de" - } - data "cidaas_group_type" "example" { - group_type = "%s" - }`, groupType) -} - -func TestAccGroupTypeDataSource(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.TestAccPreCheck(t) }, ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, - CheckDestroy: destroyGroupTypeIfExists, Steps: []resource.TestStep{ { - PreConfig: func() { - gt := cidaas.GroupType{ - ClientConfig: cidaas.ClientConfig{ - BaseURL: os.Getenv("BASE_URL"), - AccessToken: acctest.TestToken, - }, - } - payload := cidaas.GroupTypeData{ - RoleMode: "no_roles", - GroupType: groupType, - Description: "terraform user group type description", - } - res, _ := gt.Create(payload) - if res != nil && res.Status != http.StatusNoContent { - log.Print("failed to complete pre config") - } - }, - Config: testGroupTypeConfig(groupType), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.cidaas_group_type.example", "role_mode", "no_roles"), + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_group_type" "sample" { + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "group_type.#"), + resource.TestCheckResourceAttrSet(resourceName, "group_type.0.id"), + resource.TestCheckResourceAttrSet(resourceName, "group_type.0.group_type"), + resource.TestCheckResourceAttrSet(resourceName, "group_type.0.role_mode"), + resource.TestCheckResourceAttrSet(resourceName, "group_type.0.allowed_roles.#"), ), }, }, }) } -func destroyGroupTypeIfExists(s *terraform.State) error { - var groupTypeInState string - for _, rs := range s.RootModule().Resources { - if rs.Type != "cidaas_group_type" { - continue - } - groupTypeInState = rs.Primary.Attributes["group_type"] - } - - if groupTypeInState != groupType { - return fmt.Errorf("resource not found with by the role created in preconfig step") - } +func TestAccGroupTypeDataSource_RoleModeFilter(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_group_type.sample" - // resource found and destroy from remote - client := cidaas.GroupType{ - ClientConfig: cidaas.ClientConfig{ - BaseURL: os.Getenv("BASE_URL"), - AccessToken: acctest.TestToken, + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_group_type" "sample" { + filter { + name = "role_mode" + values = ["allowed_roles"] + } + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "group_type.#"), + resource.TestCheckResourceAttr(resourceName, "group_type.0.role_mode", "allowed_roles"), + resource.TestCheckResourceAttrSet(resourceName, "group_type.0.allowed_roles.#"), + ), + }, }, - } - - err := client.Delete(groupTypeInState) - if err != nil { - return fmt.Errorf("failed to destroy resource in remote created in the preconfig step") - } - return nil + }) } diff --git a/internal/datasources/data_registration_field.go b/internal/datasources/data_registration_field.go index b37525e..cbcf82e 100644 --- a/internal/datasources/data_registration_field.go +++ b/internal/datasources/data_registration_field.go @@ -31,7 +31,7 @@ type RegistrationField struct { IsGroup types.Bool `tfsdk:"is_group"` ParentGroupID types.String `tfsdk:"parent_group_id"` FieldType types.String `tfsdk:"field_type"` - Order types.Int32 `tfsdk:"order"` + Order types.Int64 `tfsdk:"order"` } var registrationFieldsFilter = FilterConfig{ @@ -165,5 +165,6 @@ func parseRegistrationField(rf cidaas.RegistrationFieldConfig) (result Registrat result.ReadOnly = types.BoolValue(rf.ReadOnly) result.Internal = types.BoolValue(rf.Internal) result.ParentGroupID = types.StringValue(rf.ParentGroupID) + result.Order = types.Int64Value(rf.Order) return result } diff --git a/internal/datasources/data_registration_field_test.go b/internal/datasources/data_registration_field_test.go new file mode 100644 index 0000000..ec175c3 --- /dev/null +++ b/internal/datasources/data_registration_field_test.go @@ -0,0 +1,73 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccRegFieldDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_registration_field.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_registration_field" "sample" { + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "registration_field.#"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.id"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.parent_group_id"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.field_type"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.data_type"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.field_key"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.required"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.internal"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.enabled"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.read_only"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.is_group"), + resource.TestCheckResourceAttrSet(resourceName, "registration_field.0.order"), + ), + }, + }, + }) +} + +func TestAccRegFieldDataSource_FieldTypeFilter(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_registration_field.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_registration_field" "sample" { + filter { + name = "field_type" + values = ["CUSTOM"] + } + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "registration_field.0.field_type", "CUSTOM"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_role_test.go b/internal/datasources/data_role_test.go index da2973d..8b46e5d 100644 --- a/internal/datasources/data_role_test.go +++ b/internal/datasources/data_role_test.go @@ -1,79 +1,35 @@ package datasources_test -// import ( -// "fmt" -// "testing" +import ( + "fmt" + "os" + "testing" -// acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" -// "github.com/hashicorp/terraform-plugin-testing/helper/resource" -// "github.com/hashicorp/terraform-plugin-testing/terraform" -// ) + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) -// // to test data sources, existing role in cidaas must be provided -// // this can be tested by creating a role prior to the test run and cleaning up after the test -// // here test_role12 is an existing cidaas_role -// // TODO: implement presetup & cleanup -// func testAccDataSourceRoleConfig(role string) string { -// return fmt.Sprintf(` -// provider "cidaas" { -// base_url = "https://automation-test.dev.cidaas.eu" -// } -// data "cidaas_role" "example" { -// role = "%s" -// }`, role) -// } +func TestAccRoleDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_role.sample" -// func TestAccRoleDataSource(t *testing.T) { -// role := "test_role12" -// resource.Test(t, resource.TestCase{ -// PreCheck: func() { acctest.TestAccPreCheck(t) }, -// ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, -// Steps: []resource.TestStep{ -// // Read testing -// { -// Config: testAccDataSourceRoleConfig(role), -// Check: resource.ComposeAggregateTestCheckFunc( -// resource.TestCheckResourceAttr("data.cidaas_role.example", "id", role), -// ), -// }, -// }, -// }) -// } - -// func TestAccRoleDataSource_validateAttrSet(t *testing.T) { -// role := "test_role12" -// resource.Test(t, resource.TestCase{ -// ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, -// PreCheck: func() { acctest.TestAccPreCheck(t) }, -// Steps: []resource.TestStep{ -// { -// Config: testAccDataSourceRoleConfig(role), -// Check: resource.ComposeTestCheckFunc( -// resource.TestCheckResourceAttrSet("data.cidaas_role.example", "role"), -// resource.TestCheckResourceAttrSet("data.cidaas_role.example", "id"), -// testAccRoleData(t, "data.cidaas_role.example"), -// ), -// }, -// }, -// }) -// } - -// func testAccRoleData(t *testing.T, resourceName string) resource.TestCheckFunc { -// // just a sample demo for reference -// t.Run("A sample test", func(t *testing.T) { -// if resourceName != "data.cidaas_role.example" { -// t.Errorf("invalid resource name %s", resourceName) -// } -// }) -// return func(s *terraform.State) error { -// rs, ok := s.RootModule().Resources[resourceName] -// if !ok { -// return fmt.Errorf("Not found: %s", resourceName) -// } -// _, ok = rs.Primary.Attributes["role"] -// if !ok { -// return fmt.Errorf("Resource %s has no role set", resourceName) -// } -// return nil -// } -// } + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_role" "sample" { + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "role.#"), + resource.TestCheckResourceAttrSet(resourceName, "role.0.role"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_scope_group_test.go b/internal/datasources/data_scope_group_test.go new file mode 100644 index 0000000..7635f1b --- /dev/null +++ b/internal/datasources/data_scope_group_test.go @@ -0,0 +1,35 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccScopeGroupDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_scope_group.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_scope_group" "sample" {} + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "scope_group.#"), + resource.TestCheckResourceAttrSet(resourceName, "scope_group.0.id"), + resource.TestCheckResourceAttrSet(resourceName, "scope_group.0.group_name"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_scope_test.go b/internal/datasources/data_scope_test.go new file mode 100644 index 0000000..61cd085 --- /dev/null +++ b/internal/datasources/data_scope_test.go @@ -0,0 +1,66 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccScopeDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_scope.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_scope" "sample" {} + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "scope.#"), + resource.TestCheckResourceAttrSet(resourceName, "scope.0.security_level"), + resource.TestCheckResourceAttrSet(resourceName, "scope.0.scope_key"), + resource.TestCheckResourceAttrSet(resourceName, "scope.0.required_user_consent"), + resource.TestCheckResourceAttrSet(resourceName, "scope.0.localized_descriptions.#"), + ), + }, + }, + }) +} + +func TestAccScopeDataSource_SecurityLevelFilter(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_scope.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_scope" "sample" { + filter { + name = "security_level" + values = ["PUBLIC"] + } + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "scope.#"), + resource.TestCheckResourceAttr(resourceName, "scope.0.security_level", "PUBLIC"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_social_provider_test.go b/internal/datasources/data_social_provider_test.go new file mode 100644 index 0000000..50a4f64 --- /dev/null +++ b/internal/datasources/data_social_provider_test.go @@ -0,0 +1,41 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccSocialProviderDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_social_provider.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_social_provider" "sample" {} + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "social_provider.#"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.id"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.name"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.provider_name"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.enabled"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.client_id"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.client_secret"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.enabled_for_admin_portal"), + resource.TestCheckResourceAttrSet(resourceName, "social_provider.0.scopes.#"), + ), + }, + }, + }) +} diff --git a/internal/datasources/data_system_template_option_test.go b/internal/datasources/data_system_template_option_test.go new file mode 100644 index 0000000..5cb87c2 --- /dev/null +++ b/internal/datasources/data_system_template_option_test.go @@ -0,0 +1,66 @@ +package datasources_test + +import ( + "fmt" + "os" + "testing" + + acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccSysTemplateOptionDataSource_Basic(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_system_template_option.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_system_template_option" "sample" {} + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "system_template_option.#"), + resource.TestCheckResourceAttrSet(resourceName, "system_template_option.0.template_key"), + resource.TestCheckResourceAttrSet(resourceName, "system_template_option.0.enabled"), + resource.TestCheckResourceAttrSet(resourceName, "system_template_option.0.template_types.#"), + resource.TestCheckResourceAttrSet(resourceName, "system_template_option.0.template_types.0.template_type"), + ), + }, + }, + }) +} + +func TestAccSysTemplateOptionDataSource_TemplateKeyFilter(t *testing.T) { + t.Parallel() + resourceName := "data.cidaas_system_template_option.sample" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "cidaas" { + base_url = "%s" + } + data "cidaas_system_template_option" "sample" { + filter { + name = "template_key" + values = ["UN_REGISTER_USER_ALERT"] + } + } + `, os.Getenv("BASE_URL")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(resourceName, "system_template_option.#"), + resource.TestCheckResourceAttr(resourceName, "system_template_option.0.template_key", "UN_REGISTER_USER_ALERT"), + ), + }, + }, + }) +} diff --git a/internal/resources/resource_app_test.go b/internal/resources/resource_app_test.go index 2688fbd..09e54f2 100644 --- a/internal/resources/resource_app_test.go +++ b/internal/resources/resource_app_test.go @@ -2,6 +2,7 @@ package resources_test import ( "fmt" + "os" "testing" acctest "github.com/Cidaas/terraform-provider-cidaas/internal/test" @@ -40,7 +41,7 @@ func TestApp_Basic(t *testing.T) { func testAppConfig(clientName, companyWebsite string) string { return fmt.Sprintf(` provider "cidaas" { - base_url = "https://automation-test.dev.cidaas.eu" + base_url = "%s" } # The config below has the list of common config and main config resource "cidaas_app" "example" { @@ -219,7 +220,7 @@ resource "cidaas_app" "example" { pending_scopes = ["sample"] } } - `, clientName, companyWebsite) + `, os.Getenv("BASE_URL"), clientName, companyWebsite) } func TestApp_CommonConfig(t *testing.T) { diff --git a/internal/resources/resource_hosted_page_test.go b/internal/resources/resource_hosted_page_test.go index 669494d..549d1d3 100644 --- a/internal/resources/resource_hosted_page_test.go +++ b/internal/resources/resource_hosted_page_test.go @@ -197,7 +197,7 @@ func TestAccHostedPageResource_MissingRequiredFields(t *testing.T) { // validation where hosted_page_id and url is required // config4 := ` // provider "cidaas" { - // base_url = "https://automation-test.dev.cidaas.eu" + // base_url = "%s" // } // resource "cidaas_hosted_page" "example" { // hosted_page_group_name = ""