-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[azurerm_security_center_contact] Security center contacts opti… (#3761)
* Make phone optional in azurerm_security_center_contact * Edit documentation that phone is now optional in security center contact
- Loading branch information
1 parent
b7a1058
commit 2ef8c65
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ func TestAccAzureRMSecurityCenter_contact(t *testing.T) { | |
"basic": testAccAzureRMSecurityCenterContact_basic, | ||
"update": testAccAzureRMSecurityCenterContact_update, | ||
"requiresImport": testAccAzureRMSecurityCenterContact_requiresImport, | ||
"phoneOptional": testAccAzureRMSecurityCenterContact_phoneOptional, | ||
}, | ||
} | ||
|
||
|
@@ -127,6 +128,33 @@ func testAccAzureRMSecurityCenterContact_update(t *testing.T) { | |
}) | ||
} | ||
|
||
func testAccAzureRMSecurityCenterContact_phoneOptional(t *testing.T) { | ||
resourceName := "azurerm_security_center_contact.test" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMSecurityCenterContactDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAzureRMSecurityCenterContact_templateWithoutPhone("[email protected]", true, true), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMSecurityCenterContactExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "email", "[email protected]"), | ||
resource.TestCheckResourceAttr(resourceName, "phone", ""), | ||
resource.TestCheckResourceAttr(resourceName, "alert_notifications", "true"), | ||
resource.TestCheckResourceAttr(resourceName, "alerts_to_admins", "true"), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testCheckAzureRMSecurityCenterContactExists(resourceName string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
client := testAccProvider.Meta().(*ArmClient).securityCenter.ContactsClient | ||
|
@@ -183,6 +211,17 @@ resource "azurerm_security_center_contact" "test" { | |
`, email, phone, notifications, adminAlerts) | ||
} | ||
|
||
func testAccAzureRMSecurityCenterContact_templateWithoutPhone(email string, notifications, adminAlerts bool) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_security_center_contact" "test" { | ||
email = "%s" | ||
alert_notifications = %t | ||
alerts_to_admins = %t | ||
} | ||
`, email, notifications, adminAlerts) | ||
} | ||
|
||
func testAccAzureRMSecurityCenterContact_requiresImportCfg(email, phone string, notifications, adminAlerts bool) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters