Skip to content

Commit

Permalink
Refactor schema and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnellis committed Dec 11, 2024
1 parent 9de3712 commit bcc6a84
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
14 changes: 3 additions & 11 deletions internal/auth0/connection/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2693,19 +2693,11 @@ func TestAuthenticationMethods(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
Config: acctest.ParseTestName(testConnectionPingFederateConfigCreate, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.#", "1"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.authentication_methods.passkey.enabled", true),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.authentication_methods.password.enabled", true),
),
},
{
Config: acctest.ParseTestName(testConnectionPingFederateConfigUpdate, t.Name()),
Config: acctest.ParseTestName(testConnectionAuthenticationMethods, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.#", "1"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.authentication_methods.passkey.enabled", true),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.authentication_methods.password.enabled", true),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.authentication_methods.passkey.enabled", "true"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.authentication_methods.password.enabled", "true"),
),
},
},
Expand Down
35 changes: 29 additions & 6 deletions internal/auth0/connection/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,35 @@ var optionsSchema = &schema.Schema{
},
"authentication_methods": {
Type: schema.TypeMap,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"passkey": {
Type: schema.TypeList,
Elem: &schema.Resource{Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Default: false,
},
}},
Required: true,
MaxItems: 1,
},
"password": {
Type: schema.TypeList,
Elem: &schema.Resource{Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Default: true,
},
}},
Required: true,
MaxItems: 1,
},
},
},
},
Expand Down

0 comments on commit bcc6a84

Please sign in to comment.