Skip to content

Commit

Permalink
azurerm_api_management_named_value - fix the non empty plan when `sec…
Browse files Browse the repository at this point in the history
…ret` is true (#6834)

Fix #6688
  • Loading branch information
yupwei68 committed May 12, 2020
1 parent cf5b326 commit 3828e74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
Expand Up @@ -149,7 +149,10 @@ func resourceArmApiManagementNamedValueRead(d *schema.ResourceData, meta interfa
if properties := resp.NamedValueContractProperties; properties != nil {
d.Set("display_name", properties.DisplayName)
d.Set("secret", properties.Secret)
d.Set("value", properties.Value)
// API will not return `value` when `secret` is `true`, in which case we shall not set the `value`. Refer to the issue : #6688
if properties.Secret != nil && !*properties.Secret {
d.Set("value", properties.Value)
}
d.Set("tags", properties.Tags)
}

Expand Down
Expand Up @@ -23,10 +23,6 @@ func TestAccAzureRMAPIManagementNamedValue_basic(t *testing.T) {
Config: testAccAzureRMAPIManagementNamedValue_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementNamedValueExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "display_name", fmt.Sprintf("TestProperty%d", data.RandomInteger)),
resource.TestCheckResourceAttr(data.ResourceName, "value", "Test Value"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.0", "tag1"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.1", "tag2"),
),
},
data.ImportStep(),
Expand All @@ -46,24 +42,16 @@ func TestAccAzureRMAPIManagementNamedValue_update(t *testing.T) {
Config: testAccAzureRMAPIManagementNamedValue_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementNamedValueExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "display_name", fmt.Sprintf("TestProperty%d", data.RandomInteger)),
resource.TestCheckResourceAttr(data.ResourceName, "value", "Test Value"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.0", "tag1"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.1", "tag2"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMAPIManagementNamedValue_update(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementNamedValueExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "display_name", fmt.Sprintf("TestProperty2%d", data.RandomInteger)),
resource.TestCheckResourceAttr(data.ResourceName, "value", "Test Value2"),
resource.TestCheckResourceAttr(data.ResourceName, "secret", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.0", "tag3"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.1", "tag4"),
),
},
data.ImportStep(),
data.ImportStep("value"),
},
})
}
Expand Down

0 comments on commit 3828e74

Please sign in to comment.