diff --git a/auth0/resource_auth0_connection.go b/auth0/resource_auth0_connection.go index 6e53abad1..5caa9965f 100644 --- a/auth0/resource_auth0_connection.go +++ b/auth0/resource_auth0_connection.go @@ -13,7 +13,6 @@ import ( func newConnection() *schema.Resource { return &schema.Resource{ - Create: createConnection, Read: readConnection, Update: updateConnection, @@ -665,6 +664,11 @@ var connectionSchema = map[string]*schema.Schema{ Computed: true, Description: "Defines the realms for which the connection will be used (i.e., email domains). If not specified, the connection name is added as the realm", }, + "show_as_button": { + Type: schema.TypeBool, + Optional: true, + Description: "Display connection as a button. Only available on enterprise connections.", + }, } func connectionSchemaV0() *schema.Resource { @@ -788,6 +792,17 @@ func readConnection(d *schema.ResourceData, m interface{}) error { d.Set("options", flattenConnectionOptions(d, c.Options)) d.Set("enabled_clients", c.EnabledClients) d.Set("realms", c.Realms) + + switch *c.Strategy { + case management.ConnectionStrategyGoogleApps, + management.ConnectionStrategyOIDC, + management.ConnectionStrategyAD, + management.ConnectionStrategyAzureAD, + management.ConnectionStrategySAML, + management.ConnectionStrategyADFS: + d.Set("show_as_button", c.ShowAsButton) + } + return nil } diff --git a/auth0/resource_auth0_connection_test.go b/auth0/resource_auth0_connection_test.go index c560dbf24..c38adb1f0 100644 --- a/auth0/resource_auth0_connection_test.go +++ b/auth0/resource_auth0_connection_test.go @@ -54,7 +54,6 @@ func init() { } func TestAccConnection(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -68,6 +67,7 @@ func TestAccConnection(t *testing.T) { random.TestCheckResourceAttr("auth0_connection.my_connection", "name", "Acceptance-Test-Connection-{{.random}}", rand), resource.TestCheckResourceAttr("auth0_connection.my_connection", "is_domain_connection", "true"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "strategy", "auth0"), + resource.TestCheckNoResourceAttr("auth0_connection.my_connection", "show_as_button"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.password_policy", "fair"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.password_no_personal_info.0.enable", "true"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.password_dictionary.0.enable", "true"), @@ -99,7 +99,6 @@ func TestAccConnection(t *testing.T) { } const testAccConnectionConfig = ` - resource "auth0_connection" "my_connection" { name = "Acceptance-Test-Connection-{{.random}}" is_domain_connection = true @@ -147,7 +146,6 @@ resource "auth0_connection" "my_connection" { ` const testAccConnectionConfigUpdate = ` - resource "auth0_connection" "my_connection" { name = "Acceptance-Test-Connection-{{.random}}" is_domain_connection = true @@ -182,7 +180,6 @@ resource "auth0_connection" "my_connection" { ` func TestAccConnectionAD(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -195,6 +192,7 @@ func TestAccConnectionAD(t *testing.T) { Check: resource.ComposeTestCheckFunc( random.TestCheckResourceAttr("auth0_connection.ad", "name", "Acceptance-Test-AD-{{.random}}", rand), resource.TestCheckResourceAttr("auth0_connection.ad", "strategy", "ad"), + resource.TestCheckResourceAttr("auth0_connection.ad", "show_as_button", "true"), resource.TestCheckResourceAttr("auth0_connection.ad", "options.0.domain_aliases.#", "2"), resource.TestCheckResourceAttr("auth0_connection.ad", "options.0.tenant_domain", "example.com"), resource.TestCheckResourceAttr("auth0_connection.ad", "options.0.use_kerberos", "false"), @@ -216,6 +214,7 @@ const testAccConnectionADConfig = ` resource "auth0_connection" "ad" { name = "Acceptance-Test-AD-{{.random}}" strategy = "ad" + show_as_button = true options { tenant_domain = "example.com" domain_aliases = [ @@ -230,7 +229,6 @@ resource "auth0_connection" "ad" { ` func TestAccConnectionAzureAD(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -243,6 +241,7 @@ func TestAccConnectionAzureAD(t *testing.T) { Check: resource.ComposeTestCheckFunc( random.TestCheckResourceAttr("auth0_connection.azure_ad", "name", "Acceptance-Test-Azure-AD-{{.random}}", rand), resource.TestCheckResourceAttr("auth0_connection.azure_ad", "strategy", "waad"), + resource.TestCheckResourceAttr("auth0_connection.azure_ad", "show_as_button", "true"), resource.TestCheckResourceAttr("auth0_connection.azure_ad", "options.0.client_id", "123456"), resource.TestCheckResourceAttr("auth0_connection.azure_ad", "options.0.client_secret", "123456"), resource.TestCheckResourceAttr("auth0_connection.azure_ad", "options.0.tenant_domain", "example.onmicrosoft.com"), @@ -267,6 +266,7 @@ const testAccConnectionAzureADConfig = ` resource "auth0_connection" "azure_ad" { name = "Acceptance-Test-Azure-AD-{{.random}}" strategy = "waad" + show_as_button = true options { client_id = "123456" client_secret = "123456" @@ -292,7 +292,6 @@ resource "auth0_connection" "azure_ad" { ` func TestAccConnectionOIDC(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -305,6 +304,7 @@ func TestAccConnectionOIDC(t *testing.T) { Check: resource.ComposeTestCheckFunc( random.TestCheckResourceAttr("auth0_connection.oidc", "name", "Acceptance-Test-OIDC-{{.random}}", rand), resource.TestCheckResourceAttr("auth0_connection.oidc", "strategy", "oidc"), + resource.TestCheckResourceAttr("auth0_connection.oidc", "show_as_button", "true"), resource.TestCheckResourceAttr("auth0_connection.oidc", "options.0.client_id", "123456"), resource.TestCheckResourceAttr("auth0_connection.oidc", "options.0.client_secret", "123456"), resource.TestCheckResourceAttr("auth0_connection.oidc", "options.0.domain_aliases.#", "2"), @@ -329,6 +329,7 @@ func TestAccConnectionOIDC(t *testing.T) { { Config: random.Template(testAccConnectionOIDCConfigUpdate, rand), Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("auth0_connection.oidc", "show_as_button", "false"), resource.TestCheckResourceAttr("auth0_connection.oidc", "options.0.client_id", "1234567"), resource.TestCheckResourceAttr("auth0_connection.oidc", "options.0.client_secret", "1234567"), resource.TestCheckResourceAttr("auth0_connection.oidc", "options.0.domain_aliases.#", "1"), @@ -351,11 +352,11 @@ func TestAccConnectionOIDC(t *testing.T) { } const testAccConnectionOIDCConfig = ` - resource "auth0_connection" "oidc" { name = "Acceptance-Test-OIDC-{{.random}}" display_name = "Acceptance-Test-OIDC-{{.random}}" strategy = "oidc" + show_as_button = true options { client_id = "123456" client_secret = "123456" @@ -378,11 +379,11 @@ resource "auth0_connection" "oidc" { ` const testAccConnectionOIDCConfigUpdate = ` - resource "auth0_connection" "oidc" { name = "Acceptance-Test-OIDC-{{.random}}" display_name = "Acceptance-Test-OIDC-{{.random}}" strategy = "oidc" + show_as_button = false options { client_id = "1234567" client_secret = "1234567" @@ -403,7 +404,6 @@ resource "auth0_connection" "oidc" { ` func TestAccConnectionOAuth2(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -447,7 +447,6 @@ func TestAccConnectionOAuth2(t *testing.T) { } const testAccConnectionOAuth2Config = ` - resource "auth0_connection" "oauth2" { name = "Acceptance-Test-OAuth2-{{.random}}" strategy = "oauth2" @@ -467,7 +466,6 @@ resource "auth0_connection" "oauth2" { ` const testAccConnectionOAuth2ConfigUpdate = ` - resource "auth0_connection" "oauth2" { name = "Acceptance-Test-OAuth2-{{.random}}" strategy = "oauth2" @@ -486,8 +484,7 @@ resource "auth0_connection" "oauth2" { } ` -func TestAccConnectionWithEnbledClients(t *testing.T) { - +func TestAccConnectionWithEnabledClients(t *testing.T) { rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -507,7 +504,6 @@ func TestAccConnectionWithEnbledClients(t *testing.T) { } const testAccConnectionWithEnabledClientsConfig = ` - resource "auth0_client" "my_client_1" { name = "Application - Acceptance Test - 1 - {{.random}}" description = "Test Applications Long Description" @@ -546,7 +542,6 @@ resource "auth0_connection" "my_connection" { ` func TestAccConnectionSMS(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -571,7 +566,6 @@ func TestAccConnectionSMS(t *testing.T) { } const testAccConnectionSMSConfig = ` - resource "auth0_connection" "sms" { name = "Acceptance-Test-SMS-{{.random}}" is_domain_connection = false @@ -597,7 +591,6 @@ resource "auth0_connection" "sms" { ` func TestAccConnectionCustomSMS(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -626,7 +619,6 @@ func TestAccConnectionCustomSMS(t *testing.T) { } const testAccConnectionCustomSMSConfig = ` - resource "auth0_connection" "sms" { name = "Acceptance-Test-Custom-SMS-{{.random}}" is_domain_connection = false @@ -657,7 +649,6 @@ resource "auth0_connection" "sms" { ` func TestAccConnectionEmail(t *testing.T) { - rand := random.String(6) resource.Test(t, resource.TestCase{ @@ -690,12 +681,10 @@ func TestAccConnectionEmail(t *testing.T) { } const testAccConnectionEmailConfig = ` - resource "auth0_connection" "email" { name = "Acceptance-Test-Email-{{.random}}" is_domain_connection = false strategy = "email" - options { disable_signup = false name = "Email OTP" @@ -703,9 +692,7 @@ resource "auth0_connection" "email" { subject = "Sign in!" syntax = "liquid" template = "