diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 487a6a73..8fbc11d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,16 +28,22 @@ jobs: - name: Build run: make build + - name: Start containers + run: docker-compose up -d --build + - name: Test run: make testacc OPTS=-coverprofile=c.out env: AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }} AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} - DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - name: Send code coverage report uses: aktions/codeclimate-test-reporter@v1 with: codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }} command: after-build --prefix github.com/alexkappa/terraform-provider-auth0 + + - name: Stop containers + if: always() + run: docker-compose down diff --git a/auth0/provider_test.go b/auth0/provider_test.go index 25d817b8..956620f3 100644 --- a/auth0/provider_test.go +++ b/auth0/provider_test.go @@ -5,11 +5,49 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/terraform" "gopkg.in/auth0.v5/management" ) +func providerWithWiremock() *schema.Provider { + return &schema.Provider{ + ResourcesMap: map[string]*schema.Resource{ + "auth0_client": newClient(), + "auth0_global_client": newGlobalClient(), + "auth0_client_grant": newClientGrant(), + "auth0_connection": newConnection(), + "auth0_custom_domain": newCustomDomain(), + "auth0_custom_domain_verification": newCustomDomainVerification(), + "auth0_resource_server": newResourceServer(), + "auth0_rule": newRule(), + "auth0_rule_config": newRuleConfig(), + "auth0_hook": newHook(), + "auth0_prompt": newPrompt(), + "auth0_prompt_custom_text": newPromptCustomText(), + "auth0_email": newEmail(), + "auth0_email_template": newEmailTemplate(), + "auth0_user": newUser(), + "auth0_tenant": newTenant(), + "auth0_role": newRole(), + "auth0_log_stream": newLogStream(), + "auth0_branding": newBranding(), + "auth0_guardian": newGuardian(), + "auth0_organization": newOrganization(), + "auth0_action": newAction(), + "auth0_trigger_binding": newTriggerBinding(), + }, + ConfigureFunc: func(data *schema.ResourceData) (interface{}, error) { + return management.New( + "localhost:8080", + management.WithInsecure(), + management.WithDebug(true), + ) + }, + } +} + func Auth0() (*management.Management, error) { c := terraform.NewResourceConfigRaw(nil) p := Provider() diff --git a/auth0/resource_auth0_custom_domain_verification_test.go b/auth0/resource_auth0_custom_domain_verification_test.go index e1cc7475..d0f29e6a 100644 --- a/auth0/resource_auth0_custom_domain_verification_test.go +++ b/auth0/resource_auth0_custom_domain_verification_test.go @@ -3,54 +3,36 @@ package auth0 import ( "testing" - "github.com/alexkappa/terraform-provider-auth0/auth0/internal/digitalocean" - "github.com/alexkappa/terraform-provider-auth0/auth0/internal/random" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) func TestAccCustomDomainVerification(t *testing.T) { - - rand := random.String(6) - resource.Test(t, resource.TestCase{ Providers: map[string]terraform.ResourceProvider{ - "auth0": Provider(), - "digitalocean": digitalocean.Provider(), + "auth0": providerWithWiremock(), }, Steps: []resource.TestStep{ { - Config: random.Template(testAccCustomDomainVerification, rand), + Config: testAccCustomDomainVerification, Check: resource.ComposeTestCheckFunc( - random.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "{{.random}}.auth.uat.alexkappa.com", rand), + resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "terraform-provider.auth0.com"), resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "type", "auth0_managed_certs"), resource.TestCheckResourceAttrSet("auth0_custom_domain_verification.my_custom_domain_verification", "custom_domain_id"), ), }, - { - Config: random.Template(testAccCustomDomainVerification, rand), - }, }, }) } const testAccCustomDomainVerification = ` - -resource "digitalocean_record" "auth0_domain" { - domain = "alexkappa.com" - type = upper(auth0_custom_domain.my_custom_domain.verification[0].methods[0].name) - name = "{{.random}}.auth.uat.alexkappa.com." - value = "${auth0_custom_domain.my_custom_domain.verification[0].methods[0].record}." -} - resource "auth0_custom_domain" "my_custom_domain" { - domain = "{{.random}}.auth.uat.alexkappa.com" + domain = "terraform-provider.auth0.com" type = "auth0_managed_certs" } resource "auth0_custom_domain_verification" "my_custom_domain_verification" { custom_domain_id = auth0_custom_domain.my_custom_domain.id timeouts { create = "15m" } - depends_on = [ digitalocean_record.auth0_domain ] } `