Skip to content

Commit

Permalink
Merge branch 'main' into fix_breaking_unit_test
Browse files Browse the repository at this point in the history
  • Loading branch information
duedares-rvj authored Nov 27, 2024
2 parents 3baf8d4 + 720d7a0 commit 011be43
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 89 deletions.
5 changes: 5 additions & 0 deletions docs/resources/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ resource "auth0_form" "my_form" {
}
})
messages {
errors = jsonencode({
ERR_REQUIRED_PROPERTY = "This field is required for user kyc."
})
}
languages {
default = "en"
primary = "en"
Expand Down
5 changes: 5 additions & 0 deletions examples/resources/auth0_form/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ resource "auth0_form" "my_form" {
}
})

messages {
errors = jsonencode({
ERR_REQUIRED_PROPERTY = "This field is required for user kyc."
})
}
languages {
default = "en"
primary = "en"
Expand Down
20 changes: 12 additions & 8 deletions internal/auth0/client/data_source_clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ func TestAccDataClients(t *testing.T) {
{
Config: acctest.ParseTestName(testAccGivenSomeClients+testAccDataClientsWithNameFilter, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "id"),
resource.TestCheckResourceAttr("data.auth0_clients.test", "clients.#", "2"),
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "clients.0.name"),
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "clients.0.app_type"),
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "clients.0.is_first_party"),
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "clients.1.name"),
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "clients.1.app_type"),
resource.TestCheckResourceAttrSet("data.auth0_clients.test", "clients.1.is_first_party"),
resource.TestCheckTypeSetElemNestedAttrs("data.auth0_clients.test", "clients.*", map[string]string{
"name": fmt.Sprintf("Acceptance Test 1 - %s", t.Name()),
"app_type": "non_interactive",
"is_first_party": "true",
"description": fmt.Sprintf("Description for client 1 %s", t.Name()),
}),
resource.TestCheckTypeSetElemNestedAttrs("data.auth0_clients.test", "clients.*", map[string]string{
"name": fmt.Sprintf("Acceptance Test 2 - %s", t.Name()),
"app_type": "spa",
"is_first_party": "false",
"description": fmt.Sprintf("Description for client 2 %s", t.Name()),
}),
),
},
{
Expand Down
15 changes: 8 additions & 7 deletions internal/auth0/form/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ func expandForm(data *schema.ResourceData) (*management.Form, error) {

form.Name = value.String(cfg.GetAttr("name"))
form.Languages = expandFomLanguages(cfg.GetAttr("languages"))
form.Messages = expandFomMessages(cfg.GetAttr("messages"))

if data.HasChange("messages") {
form.Messages = expandFomMessages(cfg.GetAttr("messages"))
}

if data.HasChange("translations") {
translations, err := expandStringInterfaceMap(data, "translations")
Expand Down Expand Up @@ -157,16 +160,14 @@ func expandStringInterfaceMap(data *schema.ResourceData, key string) (map[string
}

func convertToInterfaceMap(rawValue cty.Value) *map[string]interface{} {
if rawValue.IsNull() || !rawValue.CanIterateElements() {
if rawValue.IsNull() {
return nil
}

m := make(map[string]interface{})
for key, value := range rawValue.AsValueMap() {
if value.IsNull() {
continue
}
m[key] = value
m, err := structure.ExpandJsonFromString(rawValue.AsString())
if err != nil {
return &m
}

return &m
Expand Down
Loading

0 comments on commit 011be43

Please sign in to comment.