diff --git a/docs/data-sources/self_service_profile.md b/docs/data-sources/self_service_profile.md new file mode 100644 index 00000000..133b6980 --- /dev/null +++ b/docs/data-sources/self_service_profile.md @@ -0,0 +1,60 @@ +--- +page_title: "Data Source: auth0_self_service_profile" +description: |- + Data source to retrieve a specific Auth0 Self-Service Profile by id +--- + +# Data Source: auth0_self_service_profile + +Data source to retrieve a specific Auth0 Self-Service Profile by `id` + +## Example Usage + +```terraform +# An Auth0 Self-Service- Profile loaded using it's ID. +data "auth0_self_service_profile" "auth0_self_service_profile" { + id = "some-profile-id" +} +``` + + +## Schema + +### Required + +- `id` (String) The id of the Self Service Profile + +### Read-Only + +- `branding` (List of Object) Field can be used to customize the look and feel of the wizard. (see [below for nested schema](#nestedatt--branding)) +- `created_at` (String) The ISO 8601 formatted date the profile was created. +- `updated_at` (String) The ISO 8601 formatted date the profile was updated. +- `user_attributes` (List of Object) This array stores the mapping information that will be shown to the user during the SS-SSO flow. The user will be prompted to map the attributes on their identity provider to ensure the specified attributes get passed to Auth0. (see [below for nested schema](#nestedatt--user_attributes)) + + +### Nested Schema for `branding` + +Read-Only: + +- `colors` (List of Object) (see [below for nested schema](#nestedobjatt--branding--colors)) +- `logo_url` (String) + + +### Nested Schema for `branding.colors` + +Read-Only: + +- `primary` (String) + + + + +### Nested Schema for `user_attributes` + +Read-Only: + +- `description` (String) +- `is_optional` (Boolean) +- `name` (String) + + diff --git a/docs/resources/self_service_profile.md b/docs/resources/self_service_profile.md new file mode 100644 index 00000000..1531256f --- /dev/null +++ b/docs/resources/self_service_profile.md @@ -0,0 +1,77 @@ +--- +page_title: "Resource: auth0_self_service_profile" +description: |- + With this resource, you can create and manage Self-Service Profile for a tenant. +--- + +# Resource: auth0_self_service_profile + +With this resource, you can create and manage Self-Service Profile for a tenant. + +## Example Usage + +```terraform +resource "auth0_self_service_profile" "my_self_service_profile" { + user_attributes { + name = "sample-name" + description = "sample-description" + is_optional = true + } + branding { + logo_url = "https://mycompany.org/v2/logo.png" + colors { + primary = "#0059d6" + } + } +} +``` + + +## Schema + +### Optional + +- `branding` (Block List, Max: 1) Field can be used to customize the look and feel of the wizard. (see [below for nested schema](#nestedblock--branding)) +- `user_attributes` (Block List, Max: 20) This array stores the mapping information that will be shown to the user during the SS-SSO flow. The user will be prompted to map the attributes on their identity provider to ensure the specified attributes get passed to Auth0. (see [below for nested schema](#nestedblock--user_attributes)) + +### Read-Only + +- `created_at` (String) The ISO 8601 formatted date the profile was created. +- `id` (String) The ID of this resource. +- `updated_at` (String) The ISO 8601 formatted date the profile was updated. + + +### Nested Schema for `branding` + +Optional: + +- `colors` (Block List, Max: 1) Configuration settings for colors for branding. (see [below for nested schema](#nestedblock--branding--colors)) +- `logo_url` (String) URL of logo to display on login page. + + +### Nested Schema for `branding.colors` + +Optional: + +- `primary` (String) Primary button background color in hexadecimal. + + + + +### Nested Schema for `user_attributes` + +Required: + +- `description` (String) A human readable description of the attribute. +- `is_optional` (Boolean) Indicates if this attribute is optional or if it has to be provided by the customer for the application to function. +- `name` (String) Attribute’s name on Auth0 side + +## Import + +Import is supported using the following syntax: + +```shell +# This resource can be imported using the id +# Example: +terraform import auth0_self_service_profile.id "ssp_32oi5unksja93124" +``` diff --git a/examples/data-sources/auth0_self_service_profile/data-source.tf b/examples/data-sources/auth0_self_service_profile/data-source.tf new file mode 100644 index 00000000..c6c5a3e1 --- /dev/null +++ b/examples/data-sources/auth0_self_service_profile/data-source.tf @@ -0,0 +1,4 @@ +# An Auth0 Self-Service- Profile loaded using it's ID. +data "auth0_self_service_profile" "auth0_self_service_profile" { + id = "some-profile-id" +} diff --git a/examples/resources/auth0_self_service_profile/import.sh b/examples/resources/auth0_self_service_profile/import.sh new file mode 100644 index 00000000..b5d5af73 --- /dev/null +++ b/examples/resources/auth0_self_service_profile/import.sh @@ -0,0 +1,3 @@ +# This resource can be imported using the id +# Example: +terraform import auth0_self_service_profile.id "ssp_32oi5unksja93124" diff --git a/examples/resources/auth0_self_service_profile/resource.tf b/examples/resources/auth0_self_service_profile/resource.tf new file mode 100644 index 00000000..d42e3d1e --- /dev/null +++ b/examples/resources/auth0_self_service_profile/resource.tf @@ -0,0 +1,14 @@ +resource "auth0_self_service_profile" "my_self_service_profile" { + user_attributes { + name = "sample-name" + description = "sample-description" + is_optional = true + } + branding { + logo_url = "https://mycompany.org/v2/logo.png" + colors { + primary = "#0059d6" + } + } +} + diff --git a/internal/auth0/selfserviceprofile/data_source.go b/internal/auth0/selfserviceprofile/data_source.go new file mode 100644 index 00000000..19c50a2c --- /dev/null +++ b/internal/auth0/selfserviceprofile/data_source.go @@ -0,0 +1,43 @@ +package selfserviceprofile + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/auth0/terraform-provider-auth0/internal/config" + internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema" +) + +// NewDataSource will return a new auth0_self_service_profile data source. +func NewDataSource() *schema.Resource { + return &schema.Resource{ + ReadContext: readSelfServiceProfileForDataSource, + Description: "Data source to retrieve a specific Auth0 Self-Service Profile by `id`", + Schema: dataSourceSchema(), + } +} + +func dataSourceSchema() map[string]*schema.Schema { + dataSourceSchema := internalSchema.TransformResourceToDataSource(NewResource().Schema) + dataSourceSchema["id"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The ID of the Self Service Profile.", + } + dataSourceSchema["id"].Description = "The id of the Self Service Profile " + return dataSourceSchema +} + +func readSelfServiceProfileForDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { + api := meta.(*config.Config).GetAPI() + id := data.Get("id").(string) + data.SetId(id) + ssp, err := api.SelfServiceProfile.Read(ctx, data.Id()) + if err != nil { + return diag.FromErr(err) + } + err = flattenSelfServiceProfile(data, ssp) + return diag.FromErr(err) +} diff --git a/internal/auth0/selfserviceprofile/data_source_test.go b/internal/auth0/selfserviceprofile/data_source_test.go new file mode 100644 index 00000000..c9385375 --- /dev/null +++ b/internal/auth0/selfserviceprofile/data_source_test.go @@ -0,0 +1,99 @@ +package selfserviceprofile_test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + + "github.com/auth0/terraform-provider-auth0/internal/acctest" +) + +const testAGivenSelfServiceProfile = ` +resource "auth0_self_service_profile" "my_self_service_profile" { + user_attributes { + name = "sample-name-{{.testName}}" + description = "sample-description" + is_optional = true + } + branding { + logo_url = "https://mycompany.org/v2/logo.png" + colors { + primary = "#0059d6" + } + } +} +` + +const testDataResourceWithoutID = testAGivenSelfServiceProfile + ` +data "auth0_self_service_profile" "my_profile" { + depends_on = [ auth0_self_service_profile.my_self_service_profile ] +}` + +const testDataResourceWithValidID = testAGivenSelfServiceProfile + ` +data "auth0_self_service_profile" "my_profile" { + depends_on = [ auth0_self_service_profile.my_self_service_profile ] + id = auth0_self_service_profile.my_self_service_profile.id +} +` + +const testDataResourceWithInvalidID = testAGivenSelfServiceProfile + ` +data "auth0_self_service_profile" "my_profile" { + depends_on = [ auth0_self_service_profile.my_self_service_profile ] + id = "ssp_bskks8aGbiq7qS13umnuvX" +} +` + +func TestSelfServiceDataSourceResourceRequiredId(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: acctest.TestFactories(), + Steps: []resource.TestStep{ + { + Config: testDataResourceWithoutID, + ExpectError: regexp.MustCompile("The argument \"id\" is required, but no definition was found."), + }, + }, + }) +} + +func TestSelfServiceDataSourceResource(t *testing.T) { + acctest.Test(t, resource.TestCase{ + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testDataResourceWithInvalidID, t.Name()), + ExpectError: regexp.MustCompile( + `Error: 404 Not Found`, + ), + }, + { + Config: acctest.ParseTestName(testDataResourceWithValidID, t.Name()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckTypeSetElemNestedAttrs( + "data.auth0_self_service_profile.my_profile", + "user_attributes.*", + map[string]string{ + "name": fmt.Sprintf("sample-name-%s", t.Name()), + "description": "sample-description", + "is_optional": "true", + }, + ), + resource.TestCheckTypeSetElemNestedAttrs( + "data.auth0_self_service_profile.my_profile", + "branding.*", + map[string]string{ + "logo_url": "https://mycompany.org/v2/logo.png", + }, + ), + resource.TestCheckTypeSetElemNestedAttrs( + "data.auth0_self_service_profile.my_profile", + "branding.*.colors.*", + map[string]string{ + "primary": "#0059d6", + }, + ), + ), + }, + }, + }) +} diff --git a/internal/auth0/selfserviceprofile/expand.go b/internal/auth0/selfserviceprofile/expand.go new file mode 100644 index 00000000..b592c155 --- /dev/null +++ b/internal/auth0/selfserviceprofile/expand.go @@ -0,0 +1,68 @@ +package selfserviceprofile + +import ( + "github.com/auth0/go-auth0/management" + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/auth0/terraform-provider-auth0/internal/value" +) + +func expandSelfServiceProfiles(data *schema.ResourceData) *management.SelfServiceProfile { + cfg := data.GetRawConfig() + + return &management.SelfServiceProfile{ + UserAttributes: expandSelfServiceProfileUserAttributes(cfg.GetAttr("user_attributes")), + Branding: expandBranding(cfg.GetAttr("branding")), + } +} + +func expandSelfServiceProfileUserAttributes(userAttr cty.Value) []*management.SelfServiceProfileUserAttributes { + if userAttr.IsNull() { + return nil + } + + SelfServiceProfileUserAttributes := make([]*management.SelfServiceProfileUserAttributes, 0) + + userAttr.ForEachElement(func(_ cty.Value, attr cty.Value) (stop bool) { + SelfServiceProfileUserAttributes = append(SelfServiceProfileUserAttributes, &management.SelfServiceProfileUserAttributes{ + Name: value.String(attr.GetAttr("name")), + Description: value.String(attr.GetAttr("description")), + IsOptional: value.Bool(attr.GetAttr("is_optional")), + }) + return stop + }) + + return SelfServiceProfileUserAttributes +} + +func expandBranding(config cty.Value) *management.Branding { + var branding management.Branding + + config.ForEachElement(func(_ cty.Value, b cty.Value) (stop bool) { + branding.LogoURL = value.String(b.GetAttr("logo_url")) + branding.Colors = expandBrandingColors(b.GetAttr("colors")) + return stop + }) + + if branding == (management.Branding{}) { + return nil + } + + return &branding +} + +func expandBrandingColors(config cty.Value) *management.BrandingColors { + var brandingColors management.BrandingColors + + config.ForEachElement(func(_ cty.Value, colors cty.Value) (stop bool) { + brandingColors.Primary = value.String(colors.GetAttr("primary")) + return stop + }) + + if brandingColors == (management.BrandingColors{}) { + return nil + } + + return &brandingColors +} diff --git a/internal/auth0/selfserviceprofile/flatten.go b/internal/auth0/selfserviceprofile/flatten.go new file mode 100644 index 00000000..eb0f834e --- /dev/null +++ b/internal/auth0/selfserviceprofile/flatten.go @@ -0,0 +1,56 @@ +package selfserviceprofile + +import ( + "github.com/auth0/go-auth0/management" + "github.com/hashicorp/go-multierror" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func flattenSelfServiceProfile(data *schema.ResourceData, selfServiceProfile *management.SelfServiceProfile) error { + result := multierror.Append( + data.Set("user_attributes", flattenUserAttributes(selfServiceProfile.UserAttributes)), + data.Set("branding", flattenBranding(selfServiceProfile.GetBranding())), + data.Set("created_at", selfServiceProfile.GetCreatedAt().String()), + data.Set("updated_at", selfServiceProfile.GetUpdatedAt().String()), + ) + + return result.ErrorOrNil() +} + +func flattenUserAttributes(userAttributes []*management.SelfServiceProfileUserAttributes) []interface{} { + var result []interface{} + + for _, userAttribute := range userAttributes { + result = append(result, map[string]interface{}{ + "name": userAttribute.GetName(), + "description": userAttribute.GetDescription(), + "is_optional": userAttribute.GetIsOptional(), + }) + } + + return result +} + +func flattenBranding(branding *management.Branding) []interface{} { + if branding == nil { + return nil + } + return []interface{}{ + map[string]interface{}{ + "logo_url": branding.GetLogoURL(), + "colors": flattenBrandingColors(branding.GetColors()), + }, + } +} + +func flattenBrandingColors(brandingColors *management.BrandingColors) []interface{} { + if brandingColors == nil { + return nil + } + + return []interface{}{ + map[string]interface{}{ + "primary": brandingColors.GetPrimary(), + }, + } +} diff --git a/internal/auth0/selfserviceprofile/resource.go b/internal/auth0/selfserviceprofile/resource.go new file mode 100644 index 00000000..15751b2d --- /dev/null +++ b/internal/auth0/selfserviceprofile/resource.go @@ -0,0 +1,148 @@ +package selfserviceprofile + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + + "github.com/auth0/terraform-provider-auth0/internal/config" + internalError "github.com/auth0/terraform-provider-auth0/internal/error" +) + +// NewResource will return a new auth0_self_service_profile resource. +func NewResource() *schema.Resource { + return &schema.Resource{ + CreateContext: createSelfServiceProfile, + ReadContext: readSelfServiceProfile, + UpdateContext: updateSelfServiceProfile, + DeleteContext: deleteSelfServiceProfile, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Description: "With this resource, you can create and manage Self-Service Profile for a tenant.", + Schema: map[string]*schema.Schema{ + "user_attributes": { + Type: schema.TypeList, + Optional: true, + MaxItems: 20, + Description: "This array stores the mapping information that will be shown to the user during " + + "the SS-SSO flow. The user will be prompted to map the attributes on their identity provider " + + "to ensure the specified attributes get passed to Auth0.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + Description: "Attribute’s name on Auth0 side", + }, + "description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + Description: " A human readable description of the attribute.", + }, + "is_optional": { + Type: schema.TypeBool, + Required: true, + Description: "Indicates if this attribute is optional or if it has to be provided " + + "by the customer for the application to function.", + }, + }, + }, + }, + "branding": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Description: "Field can be used to customize the look and feel of the wizard.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "logo_url": { + Type: schema.TypeString, + Optional: true, + Description: "URL of logo to display on login page.", + }, + "colors": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Description: "Configuration settings for colors for branding.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "primary": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Primary button background color in hexadecimal.", + }, + }, + }, + }, + }, + }, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "The ISO 8601 formatted date the profile was created.", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "The ISO 8601 formatted date the profile was updated.", + }, + }, + } +} + +func createSelfServiceProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { + api := meta.(*config.Config).GetAPI() + + ssp := expandSelfServiceProfiles(data) + + if err := api.SelfServiceProfile.Create(ctx, ssp); err != nil { + return diag.FromErr(err) + } + + data.SetId(ssp.GetID()) + + return readSelfServiceProfile(ctx, data, meta) +} + +func readSelfServiceProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { + api := meta.(*config.Config).GetAPI() + + ssp, err := api.SelfServiceProfile.Read(ctx, data.Id()) + if err != nil { + return diag.FromErr(internalError.HandleAPIError(data, err)) + } + + return diag.FromErr(flattenSelfServiceProfile(data, ssp)) +} + +func updateSelfServiceProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { + api := meta.(*config.Config).GetAPI() + + ssp := expandSelfServiceProfiles(data) + + if err := api.SelfServiceProfile.Update(ctx, data.Id(), ssp); err != nil { + return diag.FromErr(internalError.HandleAPIError(data, err)) + } + + return readSelfServiceProfile(ctx, data, meta) +} + +func deleteSelfServiceProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { + api := meta.(*config.Config).GetAPI() + + if err := api.SelfServiceProfile.Delete(ctx, data.Id()); err != nil { + return diag.FromErr(internalError.HandleAPIError(data, err)) + } + + return nil +} diff --git a/internal/auth0/selfserviceprofile/resource_test.go b/internal/auth0/selfserviceprofile/resource_test.go new file mode 100644 index 00000000..048efbd8 --- /dev/null +++ b/internal/auth0/selfserviceprofile/resource_test.go @@ -0,0 +1,69 @@ +package selfserviceprofile_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + + "github.com/auth0/terraform-provider-auth0/internal/acctest" +) + +const testSelfServiceProfileCreate = ` +resource "auth0_self_service_profile" "my_self_service_profile" { + user_attributes { + name = "sample-name-{{.testName}}" + description = "sample-description" + is_optional = true + } + branding { + logo_url = "https://mycompany.org/v2/logo.png" + colors { + primary = "#0059d6" + } + } +} +` + +const testSelfServiceProfileUpdate = ` +resource "auth0_self_service_profile" "my_self_service_profile" { + user_attributes { + name = "updated-sample-name-{{.testName}}" + description = "updated-sample-description" + is_optional = true + } + branding { + logo_url = "https://newcompany.org/v2/logo.png" + colors { + primary = "#000000" + } + } +} +` + +func TestSelfServiceProfile(t *testing.T) { + acctest.Test(t, resource.TestCase{ + Steps: []resource.TestStep{ + { + Config: acctest.ParseTestName(testSelfServiceProfileCreate, t.Name()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "user_attributes.0.name", fmt.Sprintf("sample-name-%s", t.Name())), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "user_attributes.0.description", "sample-description"), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "user_attributes.0.is_optional", "true"), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "branding.0.logo_url", "https://mycompany.org/v2/logo.png"), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "branding.0.colors.0.primary", "#0059d6"), + ), + }, + { + Config: acctest.ParseTestName(testSelfServiceProfileUpdate, t.Name()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "user_attributes.0.name", fmt.Sprintf("updated-sample-name-%s", t.Name())), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "user_attributes.0.description", "updated-sample-description"), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "user_attributes.0.is_optional", "true"), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "branding.0.logo_url", "https://newcompany.org/v2/logo.png"), + resource.TestCheckResourceAttr("auth0_self_service_profile.my_self_service_profile", "branding.0.colors.0.primary", "#000000"), + ), + }, + }, + }) +} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index a6246435..1103d595 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -3,6 +3,8 @@ package provider import ( "os" + selfserviceprofile "github.com/auth0/terraform-provider-auth0/internal/auth0/selfserviceprofile" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/auth0/terraform-provider-auth0/internal/auth0/action" @@ -133,6 +135,7 @@ func New() *schema.Provider { "auth0_user_permissions": user.NewPermissionsResource(), "auth0_user_role": user.NewRoleResource(), "auth0_user_roles": user.NewRolesResource(), + "auth0_self_service_profile": selfserviceprofile.NewResource(), }, DataSourcesMap: map[string]*schema.Resource{ "auth0_attack_protection": attackprotection.NewDataSource(), @@ -149,6 +152,7 @@ func New() *schema.Provider { "auth0_signing_keys": signingkey.NewDataSource(), "auth0_tenant": tenant.NewDataSource(), "auth0_user": user.NewDataSource(), + "auth0_self_service_profile": selfserviceprofile.NewDataSource(), }, } diff --git a/test/data/recordings/TestSelfServiceDataSourceResource.yaml b/test/data/recordings/TestSelfServiceDataSourceResource.yaml new file mode 100644 index 00000000..786c7c9e --- /dev/null +++ b/test/data/recordings/TestSelfServiceDataSourceResource.yaml @@ -0,0 +1,319 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 224 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"branding":{"colors":{"primary":"#0059d6"},"logo_url":"https://mycompany.org/v2/logo.png"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 337 + uncompressed: false + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 379.807291ms + - id: 1 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 357.008ms + - id: 2 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_bskks8aGbiq7qS13umnuvX + 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":"Profile with ID: ssp_bskks8aGbiq7qS13umnuvX not found"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 404 Not Found + code: 404 + duration: 353.041541ms + - 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 345.169042ms + - id: 4 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 313.995208ms + - id: 5 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 331.157916ms + - id: 6 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 331.689167ms + - id: 7 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_hcfmRKDq1o8P3eBFGBmc4y","user_attributes":[{"name":"sample-name-TestSelfServiceDataSourceResource","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T20:57:45.382Z","updated_at":"2024-08-22T20:57:45.382Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 328.803167ms + - id: 8 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_hcfmRKDq1o8P3eBFGBmc4y + 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: 331.205458ms diff --git a/test/data/recordings/TestSelfServiceProfile.yaml b/test/data/recordings/TestSelfServiceProfile.yaml new file mode 100644 index 00000000..c2700157 --- /dev/null +++ b/test/data/recordings/TestSelfServiceProfile.yaml @@ -0,0 +1,285 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 213 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"user_attributes":[{"name":"sample-name-TestSelfServiceProfile","description":"sample-description","is_optional":true}],"branding":{"colors":{"primary":"#0059d6"},"logo_url":"https://mycompany.org/v2/logo.png"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 326 + uncompressed: false + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"sample-name-TestSelfServiceProfile","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:09.230Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 425.205083ms + - id: 1 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"sample-name-TestSelfServiceProfile","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:09.230Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 337.79425ms + - id: 2 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"sample-name-TestSelfServiceProfile","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:09.230Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 323.154917ms + - 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"sample-name-TestSelfServiceProfile","description":"sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:09.230Z","branding":{"logo_url":"https://mycompany.org/v2/logo.png","colors":{"primary":"#0059d6"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 347.216417ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 230 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"user_attributes":[{"name":"updated-sample-name-TestSelfServiceProfile","description":"updated-sample-description","is_optional":true}],"branding":{"colors":{"primary":"#000000"},"logo_url":"https://newcompany.org/v2/logo.png"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + method: PATCH + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"updated-sample-name-TestSelfServiceProfile","description":"updated-sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:12.155Z","branding":{"logo_url":"https://newcompany.org/v2/logo.png","colors":{"primary":"#000000"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 357.310042ms + - id: 5 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"updated-sample-name-TestSelfServiceProfile","description":"updated-sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:12.155Z","branding":{"logo_url":"https://newcompany.org/v2/logo.png","colors":{"primary":"#000000"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 329.831375ms + - id: 6 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"ssp_mCuWk3TvhEQDk1f6oovKod","user_attributes":[{"name":"updated-sample-name-TestSelfServiceProfile","description":"updated-sample-description","is_optional":true}],"created_at":"2024-08-22T21:01:09.230Z","updated_at":"2024-08-22T21:01:12.155Z","branding":{"logo_url":"https://newcompany.org/v2/logo.png","colors":{"primary":"#000000"}}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 317.670291ms + - id: 7 + 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.9.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/self-service-profiles/ssp_mCuWk3TvhEQDk1f6oovKod + 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: 335.627375ms