Skip to content

Commit

Permalink
Remove remaining deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jul 17, 2023
1 parent d1ac049 commit ead685f
Show file tree
Hide file tree
Showing 20 changed files with 1,122 additions and 2,261 deletions.
1 change: 0 additions & 1 deletion docs/resources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ resource "auth0_connection" "okta" {

### Read-Only

- `enabled_clients` (Set of String) IDs of the clients for which the connection is enabled. Reading the enabled clients through this attribute is deprecated and it will be removed in a future major version. Use the `auth0_connection` data source instead.
- `id` (String) The ID of this resource.

<a id="nestedblock--options"></a>
Expand Down
1 change: 0 additions & 1 deletion docs/resources/email.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Optional:

- `access_key_id` (String, Sensitive) AWS Access Key ID. Used only for AWS.
- `api_key` (String, Sensitive) API Key for your email service. Will always be encrypted in our database.
- `api_user` (String, Deprecated) API User for your email service. This field is not accepted by the API any more so it will be removed in a future major version.
- `domain` (String) Domain name.
- `region` (String) Default region. Used only for AWS, Mailgun, and SparkPost.
- `secret_access_key` (String, Sensitive) AWS Secret Key. Will always be encrypted in our database. Used only for AWS.
Expand Down
3 changes: 0 additions & 3 deletions docs/resources/hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ Hooks are secure, self-contained functions that allow you to customize the behav

!> This resource is deprecated. Refer to the [guide on how to migrate from hooks to actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-hooks-to-actions) and manage your actions using the `auth0_action` resource.

!> This resource is deprecated. Refer to the [guide on how to migrate from rules to actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions)
and manage your actions using the `auth0_action` resource.

## Example Usage

```terraform
Expand Down
3 changes: 0 additions & 3 deletions docs/resources/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ With Auth0, you can create custom Javascript snippets that run in a secure, isol

!> This resource is deprecated. Refer to the [guide on how to migrate from rules to actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions) and manage your actions using the `auth0_action` resource.

!> This resource is deprecated. Refer to the [guide on how to migrate from hooks to actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-hooks-to-actions)
and manage your actions using the `auth0_action` resource.

## Example Usage

```terraform
Expand Down
91 changes: 0 additions & 91 deletions docs/resources/trigger_binding.md

This file was deleted.

16 changes: 0 additions & 16 deletions internal/auth0/action/resource_trigger_binding.go

This file was deleted.

30 changes: 19 additions & 11 deletions internal/auth0/connection/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/auth0/terraform-provider-auth0/internal/auth0"
"github.com/auth0/terraform-provider-auth0/internal/config"
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema"
)
Expand All @@ -34,36 +33,45 @@ func dataSourceSchema() map[string]*schema.Schema {
dataSourceSchema["name"].Description = "The name of the connection. If not provided, `connection_id` must be set."
dataSourceSchema["name"].AtLeastOneOf = []string{"connection_id", "name"}

dataSourceSchema["enabled_clients"].Deprecated = ""
dataSourceSchema["enabled_clients"].Description = "IDs of the clients for which the connection is enabled."
dataSourceSchema["enabled_clients"] = &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Computed: true,
Description: "IDs of the clients for which the connection is enabled.",
}

return dataSourceSchema
}

func readConnectionForDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
api := meta.(*config.Config).GetAPI()

connectionID := data.Get("connection_id").(string)
if connectionID != "" {
connection, err := api.Connection.Read(ctx, connectionID)
if err != nil {
return diag.FromErr(err)
}

data.SetId(connectionID)
return auth0.CheckFor404Error(ctx, readConnection, data, meta)

return flattenConnectionForDataSource(data, connection)
}

api := meta.(*config.Config).GetAPI()
name := data.Get("name").(string)
page := 0
for {
connections, err := api.Connection.List(
ctx,
management.IncludeFields("id", "name"),
management.Page(page),
)
connections, err := api.Connection.List(ctx, management.Page(page))
if err != nil {
return diag.FromErr(err)
}

for _, connection := range connections.Connections {
if connection.GetName() == name {
data.SetId(connection.GetID())
return auth0.CheckFor404Error(ctx, readConnection, data, meta)
return flattenConnectionForDataSource(data, connection)
}
}

Expand Down
38 changes: 11 additions & 27 deletions internal/auth0/connection/data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
"github.com/auth0/terraform-provider-auth0/internal/acctest"
)

const testAccDataConnectionNonExistentID = `
data "auth0_connection" "test" {
connection_id = "con_xxxxxxxxxxxxxxxx"
}
`

const testAccGivenAConnection = `
resource "auth0_connection" "my_connection" {
name = "Acceptance-Test-Connection-{{.testName}}"
Expand Down Expand Up @@ -59,9 +65,13 @@ func TestAccDataSourceConnectionRequiredArguments(t *testing.T) {
})
}

func TestAccDataSourceConnectionByName(t *testing.T) {
func TestAccDataSourceConnection(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
Config: acctest.ParseTestName(testAccDataConnectionNonExistentID, t.Name()),
ExpectError: regexp.MustCompile("404 Not Found: The connection does not exist"),
},
{
Config: acctest.ParseTestName(testAccDataConnectionConfigByName, t.Name()),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -77,13 +87,6 @@ func TestAccDataSourceConnectionByName(t *testing.T) {
resource.TestCheckResourceAttr("data.auth0_connection.test", "enabled_clients.#", "1"),
),
},
},
})
}

func TestAccDataSourceConnectionByID(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
Config: acctest.ParseTestName(testAccDataConnectionConfigByID, t.Name()),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -102,22 +105,3 @@ func TestAccDataSourceConnectionByID(t *testing.T) {
},
})
}

const testAccDataConnectionNonexistentID = `
data "auth0_connection" "test" {
connection_id = "con_xxxxxxxxxxxxxxxx"
}
`

func TestAccDataSourceConnectionNonexistentID(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
Config: acctest.ParseTestName(testAccDataConnectionNonexistentID, t.Name()),
ExpectError: regexp.MustCompile(
`no resource found with that identifier \((404\))`,
),
},
},
})
}
4 changes: 0 additions & 4 deletions internal/auth0/connection/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ func expandConnection(ctx context.Context, d *schema.ResourceData, api *manageme
connection.Realms = value.Strings(config.GetAttr("realms"))
}

if d.HasChange("enabled_clients") {
connection.EnabledClients = value.Strings(config.GetAttr("enabled_clients"))
}

var diagnostics diag.Diagnostics
strategy := d.Get("strategy").(string)
showAsButton := value.Bool(config.GetAttr("show_as_button"))
Expand Down
11 changes: 10 additions & 1 deletion internal/auth0/connection/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func flattenConnection(data *schema.ResourceData, connection *management.Connect
data.Set("options", connectionOptions),
data.Set("realms", connection.GetRealms()),
data.Set("metadata", connection.GetMetadata()),
data.Set("enabled_clients", connection.GetEnabledClients()),
)

switch connection.GetStrategy() {
Expand All @@ -41,6 +40,16 @@ func flattenConnection(data *schema.ResourceData, connection *management.Connect
return diag.FromErr(result.ErrorOrNil())
}

func flattenConnectionForDataSource(data *schema.ResourceData, connection *management.Connection) diag.Diagnostics {
diags := flattenConnection(data, connection)

err := data.Set("enabled_clients", connection.GetEnabledClients())

diags = append(diags, diag.FromErr(err)...)

return diags
}

func flattenConnectionOptions(d *schema.ResourceData, options interface{}) ([]interface{}, diag.Diagnostics) {
if options == nil {
return nil, nil
Expand Down
3 changes: 1 addition & 2 deletions internal/auth0/connection/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func NewResource() *schema.Resource {
"which may include identity providers (such as Google or LinkedIn), databases, or " +
"passwordless authentication methods. This resource allows you to configure " +
"and manage connections to be used with your clients and users.",
Schema: resourceSchema,
SchemaVersion: 0,
Schema: resourceSchema,
}
}

Expand Down
9 changes: 0 additions & 9 deletions internal/auth0/connection/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,4 @@ var resourceSchema = map[string]*schema.Schema{
Optional: true,
Description: "Display connection as a button. Only available on enterprise connections.",
},
"enabled_clients": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Computed: true,
Description: "IDs of the clients for which the connection is enabled. " +
"Reading the enabled clients through this attribute is deprecated and it will be removed in a future major version. Use the `auth0_connection` data source instead.",
},
}
6 changes: 0 additions & 6 deletions internal/auth0/email/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ func NewResource() *schema.Resource {
Description: "Configuration settings for the credentials for the email provider.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_user": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field is not accepted by the API any more so it will be removed soon.",
Description: "API User for your email service. This field is not accepted by the API any more so it will be removed in a future major version.",
},
"api_key": {
Type: schema.TypeString,
Optional: true,
Expand Down
1 change: 0 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func New() *schema.Provider {
},
ResourcesMap: map[string]*schema.Resource{
"auth0_action": action.NewResource(),
"auth0_trigger_binding": action.NewTriggerBindingResource(),
"auth0_trigger_actions": action.NewTriggerActionsResource(),
"auth0_trigger_action": action.NewTriggerActionResource(),
"auth0_attack_protection": attackprotection.NewResource(),
Expand Down
32 changes: 0 additions & 32 deletions templates/resources/hook.md.tmpl

This file was deleted.

Loading

0 comments on commit ead685f

Please sign in to comment.