diff --git a/internal/auth0/404check.go b/internal/auth0/404check.go new file mode 100644 index 000000000..18b4a3402 --- /dev/null +++ b/internal/auth0/404check.go @@ -0,0 +1,22 @@ +package auth0 + +import ( + "context" + "errors" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +// CheckFor404Error accepts and executes a resource's read function within the context +// of a data source and will appropriately error when a resource is not found. +func CheckFor404Error(ctx context.Context, readFunc func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics, d *schema.ResourceData, m interface{}) diag.Diagnostics { + diags := readFunc(ctx, d, m) + if diags != nil { + return diags + } + if d.Id() == "" { + return diag.FromErr(errors.New("no resource found with that identifier (404)")) + } + return nil +} diff --git a/internal/auth0/client/data_source.go b/internal/auth0/client/data_source.go index cccacd85a..c0afc8bbd 100644 --- a/internal/auth0/client/data_source.go +++ b/internal/auth0/client/data_source.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + auth0 "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" ) @@ -37,7 +38,7 @@ func readClientForDataSource(ctx context.Context, d *schema.ResourceData, m inte clientID := d.Get("client_id").(string) if clientID != "" { d.SetId(clientID) - return readClient(ctx, d, m) + return auth0.CheckFor404Error(ctx, readClient, d, m) } name := d.Get("name").(string) @@ -61,7 +62,7 @@ func readClientForDataSource(ctx context.Context, d *schema.ResourceData, m inte for _, client := range clients.Clients { if client.GetName() == name { d.SetId(client.GetClientID()) - return readClient(ctx, d, m) + return auth0.CheckFor404Error(ctx, readClient, d, m) } } diff --git a/internal/auth0/client/data_source_test.go b/internal/auth0/client/data_source_test.go index 38fb070ca..eb8b62919 100644 --- a/internal/auth0/client/data_source_test.go +++ b/internal/auth0/client/data_source_test.go @@ -2,6 +2,7 @@ package client_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -64,3 +65,22 @@ func TestAccDataClientById(t *testing.T) { }, }) } + +const testAccDataSourceClientNonexistentID = ` +data "auth0_client" "test" { + client_id = "this-client-does-not-exist" +} +` + +func TestAccDataSourceClientNonexistentID(t *testing.T) { + acctest.Test(t, resource.TestCase{ + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testAccDataSourceClientNonexistentID, t.Name()), + ExpectError: regexp.MustCompile( + `no resource found with that identifier \((404\))`, + ), + }, + }, + }) +} diff --git a/internal/auth0/connection/data_source.go b/internal/auth0/connection/data_source.go index 1e4542cbf..aaa6ae956 100644 --- a/internal/auth0/connection/data_source.go +++ b/internal/auth0/connection/data_source.go @@ -7,6 +7,7 @@ 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" ) @@ -40,7 +41,7 @@ func readConnectionForDataSource(ctx context.Context, data *schema.ResourceData, connectionID := data.Get("connection_id").(string) if connectionID != "" { data.SetId(connectionID) - return readConnection(ctx, data, meta) + return auth0.CheckFor404Error(ctx, readConnection, data, meta) } api := meta.(*config.Config).GetAPI() @@ -59,7 +60,7 @@ func readConnectionForDataSource(ctx context.Context, data *schema.ResourceData, for _, connection := range connections.Connections { if connection.GetName() == name { data.SetId(connection.GetID()) - return readConnection(ctx, data, meta) + return auth0.CheckFor404Error(ctx, readConnection, data, meta) } } diff --git a/internal/auth0/connection/data_source_test.go b/internal/auth0/connection/data_source_test.go index 27ef8a232..129e53157 100644 --- a/internal/auth0/connection/data_source_test.go +++ b/internal/auth0/connection/data_source_test.go @@ -102,3 +102,22 @@ 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\))`, + ), + }, + }, + }) +} diff --git a/internal/auth0/organization/data_source.go b/internal/auth0/organization/data_source.go index b1030968b..064150af5 100644 --- a/internal/auth0/organization/data_source.go +++ b/internal/auth0/organization/data_source.go @@ -2,7 +2,6 @@ package organization import ( "context" - "net/http" "github.com/auth0/go-auth0/management" "github.com/hashicorp/go-multierror" @@ -79,10 +78,6 @@ func readOrganizationForDataSource(ctx context.Context, data *schema.ResourceDat if organizationID != "" { foundOrganization, err = api.Organization.Read(ctx, organizationID) if err != nil { - if mErr, ok := err.(management.Error); ok && mErr.Status() == http.StatusNotFound { - data.SetId("") - return nil - } return diag.FromErr(err) } } else { diff --git a/internal/auth0/organization/data_source_test.go b/internal/auth0/organization/data_source_test.go index 41071c6c0..f59067870 100644 --- a/internal/auth0/organization/data_source_test.go +++ b/internal/auth0/organization/data_source_test.go @@ -133,3 +133,22 @@ func TestAccDataSourceOrganizationByID(t *testing.T) { }, }) } + +const testAccDataSourceOrganizationNonexistentID = testAccGivenAnOrganizationWithConnectionsAndMembers + ` +data "auth0_organization" "test" { + organization_id = "org_XXXXXXXXXXXXXXXX" +} +` + +func TestAccDataSourceOrganizationNonexistentID(t *testing.T) { + acctest.Test(t, resource.TestCase{ + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testAccDataSourceOrganizationNonexistentID, t.Name()), + ExpectError: regexp.MustCompile( + "404 Not Found: No organization found by that id or name", + ), + }, + }, + }) +} diff --git a/internal/auth0/resourceserver/data_source.go b/internal/auth0/resourceserver/data_source.go index 9746a406f..e85654ce3 100644 --- a/internal/auth0/resourceserver/data_source.go +++ b/internal/auth0/resourceserver/data_source.go @@ -2,10 +2,8 @@ package resourceserver import ( "context" - "net/http" "net/url" - "github.com/auth0/go-auth0/management" "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,10 +47,6 @@ func readResourceServerForDataSource(ctx context.Context, data *schema.ResourceD api := meta.(*config.Config).GetAPI() resourceServer, err := api.ResourceServer.Read(ctx, resourceServerID) if err != nil { - if mErr, ok := err.(management.Error); ok && mErr.Status() == http.StatusNotFound { - data.SetId("") - return nil - } return diag.FromErr(err) } diff --git a/internal/auth0/resourceserver/data_source_test.go b/internal/auth0/resourceserver/data_source_test.go index 41de00445..720e353a4 100644 --- a/internal/auth0/resourceserver/data_source_test.go +++ b/internal/auth0/resourceserver/data_source_test.go @@ -232,3 +232,24 @@ func TestAccDataResourceServerAuth0APIManagement(t *testing.T) { }, }) } + +const testAccDataResourceServerNonexistentIdentifier = testAccGivenAResourceServer + ` +data "auth0_resource_server" "test" { + depends_on = [ auth0_resource_server.my_api ] + + identifier = "this-resource-server-does-not-exist" +} +` + +func TestAccDataSourceResourceServerNonexistentIdentifier(t *testing.T) { + acctest.Test(t, resource.TestCase{ + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testAccDataResourceServerNonexistentIdentifier, t.Name()), + ExpectError: regexp.MustCompile( + `404 Not Found: The resource server does not exist`, + ), + }, + }, + }) +} diff --git a/internal/auth0/role/data_source.go b/internal/auth0/role/data_source.go index 430ffc6d8..b7cab1006 100644 --- a/internal/auth0/role/data_source.go +++ b/internal/auth0/role/data_source.go @@ -7,6 +7,7 @@ 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" ) @@ -40,7 +41,7 @@ func readRoleForDataSource(ctx context.Context, data *schema.ResourceData, meta roleID := data.Get("role_id").(string) if roleID != "" { data.SetId(roleID) - return readRole(ctx, data, meta) + return auth0.CheckFor404Error(ctx, readRole, data, meta) } api := meta.(*config.Config).GetAPI() @@ -60,7 +61,7 @@ func readRoleForDataSource(ctx context.Context, data *schema.ResourceData, meta for _, role := range roles.Roles { if role.GetName() == name { data.SetId(role.GetID()) - return readRole(ctx, data, meta) + return auth0.CheckFor404Error(ctx, readRole, data, meta) } } diff --git a/internal/auth0/role/data_source_test.go b/internal/auth0/role/data_source_test.go index 1c3f6256a..a99fdc9c2 100644 --- a/internal/auth0/role/data_source_test.go +++ b/internal/auth0/role/data_source_test.go @@ -101,3 +101,23 @@ func TestAccDataSourceRoleByID(t *testing.T) { }, }) } + +const testAccDataSourceNonexistentRole = testAccGivenAResourceServer + ` +data "auth0_role" "test" { + name = "this-role-does-not-exist" +} +` + +func TestAccDataSourceRoleDoesNotExist(t *testing.T) { + acctest.Test(t, resource.TestCase{ + PreventPostDestroyRefresh: true, + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testAccDataSourceNonexistentRole, t.Name()), + ExpectError: regexp.MustCompile( + `No role found with "name" = "this-role-does-not-exist"`, + ), + }, + }, + }) +} diff --git a/internal/auth0/tenant/data_source.go b/internal/auth0/tenant/data_source.go index e9e7123db..b89ed1eaf 100644 --- a/internal/auth0/tenant/data_source.go +++ b/internal/auth0/tenant/data_source.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "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" ) @@ -59,5 +60,5 @@ func readTenantForDataSource(ctx context.Context, data *schema.ResourceData, met return diag.FromErr(result.ErrorOrNil()) } - return readTenant(ctx, data, meta) + return auth0.CheckFor404Error(ctx, readTenant, data, meta) } diff --git a/internal/auth0/user/data_source.go b/internal/auth0/user/data_source.go index c8bf091e6..ebb5a7b7b 100644 --- a/internal/auth0/user/data_source.go +++ b/internal/auth0/user/data_source.go @@ -6,6 +6,7 @@ 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" internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema" ) @@ -32,5 +33,5 @@ func dataSourceSchema() map[string]*schema.Schema { func readUserForDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { userID := data.Get("user_id").(string) data.SetId(userID) - return readUser(ctx, data, meta) + return auth0.CheckFor404Error(ctx, readUser, data, meta) } diff --git a/internal/auth0/user/data_source_test.go b/internal/auth0/user/data_source_test.go index a71ecc83c..838104c0b 100644 --- a/internal/auth0/user/data_source_test.go +++ b/internal/auth0/user/data_source_test.go @@ -2,6 +2,7 @@ package user_test import ( "fmt" + "regexp" "strings" "testing" @@ -80,3 +81,24 @@ func TestAccDataSourceUser(t *testing.T) { }, }) } + +const testAccDataSourceUserDoesNotExist = ` +data "auth0_user" "test" { + user_id = "auth0|this-user-id-does-not-exist" +} +` + +func TestAccDataSourceUserDoesNotExist(t *testing.T) { + testName := strings.ToLower(t.Name()) + + acctest.Test(t, resource.TestCase{ + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testAccDataSourceUserDoesNotExist, testName), + ExpectError: regexp.MustCompile( + `no resource found with that identifier \((404\))`, + ), + }, + }, + }) +} diff --git a/test/data/recordings/TestAccDataSourceClientNonexistentID.yaml b/test/data/recordings/TestAccDataSourceClientNonexistentID.yaml new file mode 100644 index 000000000..4bb39368b --- /dev/null +++ b/test/data/recordings/TestAccDataSourceClientNonexistentID.yaml @@ -0,0 +1,39 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/clients/this-client-does-not-exist + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"signing_keys":[{"cert":"[REDACTED]"}]}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 404 Not Found + code: 404 + duration: 138.304ms diff --git a/test/data/recordings/TestAccDataSourceConnectionNonexistentID.yaml b/test/data/recordings/TestAccDataSourceConnectionNonexistentID.yaml new file mode 100644 index 000000000..3c6cea0f4 --- /dev/null +++ b/test/data/recordings/TestAccDataSourceConnectionNonexistentID.yaml @@ -0,0 +1,39 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_xxxxxxxxxxxxxxxx + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"statusCode":404,"error":"Not Found","message":"The connection does not exist","errorCode":"inexistent_connection"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 404 Not Found + code: 404 + duration: 69.484125ms diff --git a/test/data/recordings/TestAccDataSourceOrganizationNonexistentID.yaml b/test/data/recordings/TestAccDataSourceOrganizationNonexistentID.yaml new file mode 100644 index 000000000..623c36208 --- /dev/null +++ b/test/data/recordings/TestAccDataSourceOrganizationNonexistentID.yaml @@ -0,0 +1,39 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/organizations/org_XXXXXXXXXXXXXXXX + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"statusCode":404,"error":"Not Found","message":"No organization found by that id or name"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 404 Not Found + code: 404 + duration: 108.996333ms diff --git a/test/data/recordings/TestAccDataSourceResourceServerNonexistentIdentifier.yaml b/test/data/recordings/TestAccDataSourceResourceServerNonexistentIdentifier.yaml new file mode 100644 index 000000000..b3d522fcc --- /dev/null +++ b/test/data/recordings/TestAccDataSourceResourceServerNonexistentIdentifier.yaml @@ -0,0 +1,146 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 489 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"name":"Acceptance Test - TestAccDataSourceResourceServerNonexistentIdentifier","identifier":"https://uat.api.terraform-provider-auth0.com/TestAccDataSourceResourceServerNonexistentIdentifier","scopes":[{"value":"create:bar","description":"Create bars"},{"value":"create:foo","description":"Create foos"}],"signing_alg":"RS256","allow_offline_access":true,"token_lifetime":7200,"token_lifetime_for_web":3600,"skip_consent_for_verifiable_first_party_clients":true,"enforce_policies":true} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/resource-servers + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 520 + uncompressed: false + body: '{"id":"64a8817dbede92adc4d8c5ea","name":"Acceptance Test - TestAccDataSourceResourceServerNonexistentIdentifier","identifier":"https://uat.api.terraform-provider-auth0.com/TestAccDataSourceResourceServerNonexistentIdentifier","allow_offline_access":true,"skip_consent_for_verifiable_first_party_clients":true,"token_lifetime":7200,"token_lifetime_for_web":3600,"signing_alg":"RS256","scopes":[{"value":"create:bar","description":"Create bars"},{"value":"create:foo","description":"Create foos"}],"enforce_policies":true}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 73.736041ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/resource-servers/64a8817dbede92adc4d8c5ea + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"64a8817dbede92adc4d8c5ea","name":"Acceptance Test - TestAccDataSourceResourceServerNonexistentIdentifier","identifier":"https://uat.api.terraform-provider-auth0.com/TestAccDataSourceResourceServerNonexistentIdentifier","allow_offline_access":true,"skip_consent_for_verifiable_first_party_clients":true,"token_lifetime":7200,"token_lifetime_for_web":3600,"signing_alg":"RS256","scopes":[{"value":"create:bar","description":"Create bars"},{"value":"create:foo","description":"Create foos"}],"enforce_policies":true}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 122.176166ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/resource-servers/this-resource-server-does-not-exist + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"statusCode":404,"error":"Not Found","message":"The resource server does not exist","errorCode":"inexistent_resource_server"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 404 Not Found + code: 404 + duration: 121.253667ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/resource-servers/64a8817dbede92adc4d8c5ea + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/json; charset=utf-8 + status: 204 No Content + code: 204 + duration: 152.911875ms diff --git a/test/data/recordings/TestAccDataSourceRoleDoesNotExist.yaml b/test/data/recordings/TestAccDataSourceRoleDoesNotExist.yaml new file mode 100644 index 000000000..db1e6f6ce --- /dev/null +++ b/test/data/recordings/TestAccDataSourceRoleDoesNotExist.yaml @@ -0,0 +1,39 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/roles?include_totals=true&name_filter=this-role-does-not-exist&page=0&per_page=100 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"roles":[],"start":0,"limit":100,"total":0}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 111.366125ms diff --git a/test/data/recordings/TestAccDataSourceUserDoesNotExist.yaml b/test/data/recordings/TestAccDataSourceUserDoesNotExist.yaml new file mode 100644 index 000000000..97a3bd1c0 --- /dev/null +++ b/test/data/recordings/TestAccDataSourceUserDoesNotExist.yaml @@ -0,0 +1,39 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.0.0-beta.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/users/auth0%7Cthis-user-id-does-not-exist + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"statusCode":404,"error":"Not Found","message":"The user does not exist.","errorCode":"inexistent_user"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 404 Not Found + code: 404 + duration: 139.946625ms