Skip to content

Commit

Permalink
Deprecate enabled_clients on the auth0_connection resource
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Dec 20, 2022
1 parent 3ca221f commit 17d8077
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 1,578 deletions.
2 changes: 1 addition & 1 deletion docs/resources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ resource "auth0_connection" "okta" {
### Optional

- `display_name` (String) Name used in login screen.
- `enabled_clients` (Set of String) IDs of the clients for which the connection is enabled.
- `enabled_clients` (Set of String, Deprecated) IDs of the clients for which the connection is enabled. This has been deprecated in favor of the `auth0_connection_client` resource.
- `is_domain_connection` (Boolean) Indicates whether the connection is domain level.
- `metadata` (Map of String) Metadata associated with the connection, in the form of a map of string values (max 255 chars). Maximum of 10 metadata properties allowed.
- `options` (Block List, Max: 1) Configuration settings for connection options. (see [below for nested schema](#nestedblock--options))
Expand Down
15 changes: 9 additions & 6 deletions internal/provider/resource_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,15 @@ var connectionSchema = map[string]*schema.Schema{
},
},
"enabled_clients": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
Description: "IDs of the clients for which the connection is enabled.",
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
Description: "IDs of the clients for which the connection is enabled. " +
"This has been deprecated in favor of the `auth0_connection_client` resource.",
Deprecated: "Management of enabled clients on a connection through this property has been deprecated in " +
"favor of the `auth0_connection_client` resource. Please migrate all managed enabled clients of the " +
"connection to the new resource type.",
},
"realms": {
Type: schema.TypeList,
Expand Down Expand Up @@ -924,7 +928,6 @@ func readConnection(ctx context.Context, d *schema.ResourceData, m interface{})
d.Set("is_domain_connection", connection.GetIsDomainConnection()),
d.Set("strategy", connection.GetStrategy()),
d.Set("options", connectionOptions),
d.Set("enabled_clients", connection.GetEnabledClients()),
d.Set("realms", connection.GetRealms()),
d.Set("metadata", connection.GetMetadata()),
)
Expand Down
12 changes: 0 additions & 12 deletions internal/provider/resource_auth0_connection_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ func TestAccConnectionClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_connection_client.my_conn_client_assoc-2", "name", fmt.Sprintf("Acceptance-Test-Connection-%s", t.Name())),
),
},
{
RefreshState: true,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.my_conn", "enabled_clients.#", "2"),
),
},
{
Config: template.ParseTestName(testAccDeleteConnectionClient, t.Name()),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -106,12 +100,6 @@ func TestAccConnectionClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_connection_client.my_conn_client_assoc-2", "name", fmt.Sprintf("Acceptance-Test-Connection-%s", t.Name())),
),
},
{
RefreshState: true,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.my_conn", "enabled_clients.#", "1"),
),
},
},
})
}
Expand Down
74 changes: 0 additions & 74 deletions internal/provider/resource_auth0_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,80 +645,6 @@ resource "auth0_connection" "oauth2" {
}
`

func TestAccConnectionWithEnabledClients(t *testing.T) {
httpRecorder := recorder.New(t)

resource.Test(t, resource.TestCase{
ProviderFactories: testProviders(httpRecorder),
Steps: []resource.TestStep{
{
Config: template.ParseTestName(testAccConnectionWithEnabledClientsConfig, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.my_connection", "name", fmt.Sprintf("Acceptance-Test-Connection-%s", t.Name())),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "enabled_clients.#", "4"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.#", "1"), // Gets computed with defaults by the API.
),
},
{
Config: template.ParseTestName(testAccConnectionWithEmptyEnabledClientsConfig, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.my_connection", "enabled_clients.#", "0"),
),
},
},
})
}

const testAccConnectionWithEnabledClientsConfig = `
resource "auth0_client" "my_client_1" {
name = "Application - Acceptance Test - 1 - {{.testName}}"
description = "Test Applications Long Description"
app_type = "non_interactive"
}
resource "auth0_client" "my_client_2" {
depends_on = [auth0_client.my_client_1]
name = "Application - Acceptance Test - 2 - {{.testName}}"
description = "Test Applications Long Description"
app_type = "non_interactive"
}
resource "auth0_client" "my_client_3" {
depends_on = [auth0_client.my_client_2]
name = "Application - Acceptance Test - 3 - {{.testName}}"
description = "Test Applications Long Description"
app_type = "non_interactive"
}
resource "auth0_client" "my_client_4" {
depends_on = [auth0_client.my_client_3]
name = "Application - Acceptance Test - 4 - {{.testName}}"
description = "Test Applications Long Description"
app_type = "non_interactive"
}
resource "auth0_connection" "my_connection" {
name = "Acceptance-Test-Connection-{{.testName}}"
is_domain_connection = true
strategy = "auth0"
enabled_clients = [
auth0_client.my_client_1.id,
auth0_client.my_client_2.id,
auth0_client.my_client_3.id,
auth0_client.my_client_4.id,
]
}
`

const testAccConnectionWithEmptyEnabledClientsConfig = `
resource "auth0_connection" "my_connection" {
name = "Acceptance-Test-Connection-{{.testName}}"
is_domain_connection = true
strategy = "auth0"
enabled_clients = []
}
`

func TestAccConnectionSMS(t *testing.T) {
httpRecorder := recorder.New(t)

Expand Down
1 change: 0 additions & 1 deletion internal/provider/structure_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ func expandConnection(d *schema.ResourceData) (*management.Connection, diag.Diag
connection := &management.Connection{
DisplayName: value.String(config.GetAttr("display_name")),
IsDomainConnection: value.Bool(config.GetAttr("is_domain_connection")),
EnabledClients: value.Strings(config.GetAttr("enabled_clients")),
Metadata: value.MapOfStrings(config.GetAttr("metadata")),
}

Expand Down
Loading

0 comments on commit 17d8077

Please sign in to comment.