-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix user creation with special chars (#292)
* Tests fixed * Fix account user API with special chars --------- Co-authored-by: Raphael Attal <[email protected]>
- Loading branch information
1 parent
832587a
commit 25da2da
Showing
2 changed files
with
29 additions
and
8 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 |
---|---|---|
|
@@ -13,7 +13,8 @@ import ( | |
const accountResourceUserType = "incapsula_account_user" | ||
const accountResourceUserName = "test-terraform-account-user" | ||
const accountResourceUserTypeName = accountResourceUserType + "." + accountResourceUserName | ||
const accountUserEmail = "[email protected]" | ||
const accountUserEmail = "[email protected]" | ||
const accountUserEmailSpecialChar = "[email protected]" | ||
const accountUserFirstName = "First" | ||
const accountUserLastName = "Last" | ||
|
||
|
@@ -24,7 +25,7 @@ func TestIncapsulaAccountUser_Basic(t *testing.T) { | |
CheckDestroy: testCheckIncapsulaAccountUserDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t), | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t, accountUserEmail), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckIncapsulaAccountUserExists(accountResourceUserTypeName), | ||
resource.TestCheckResourceAttr(accountResourceUserTypeName, "email", accountUserEmail), | ||
|
@@ -36,14 +37,33 @@ func TestIncapsulaAccountUser_Basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestIncapsulaAccountUser_BasicWithSpecialChar(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckIncapsulaAccountUserDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t, accountUserEmailSpecialChar), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckIncapsulaAccountUserExists(accountResourceUserTypeName), | ||
resource.TestCheckResourceAttr(accountResourceUserTypeName, "email", accountUserEmailSpecialChar), | ||
resource.TestCheckResourceAttr(accountResourceUserTypeName, "first_name", accountUserFirstName), | ||
resource.TestCheckResourceAttr(accountResourceUserTypeName, "last_name", accountUserLastName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestIncapsulaAccountUser_Update(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckIncapsulaAccountUserDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t), | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t, accountUserEmail), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckIncapsulaAccountUserExists(accountResourceUserTypeName), | ||
resource.TestCheckResourceAttr(accountResourceUserTypeName, "email", accountUserEmail), | ||
|
@@ -69,7 +89,7 @@ func TestIncapsulaAccountUser_ImportBasic(t *testing.T) { | |
CheckDestroy: testCheckIncapsulaAccountUserDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t), | ||
Config: testCheckIncapsulaAccountUserConfigBasic(t, accountUserEmail), | ||
}, | ||
{ | ||
ResourceName: accountResourceUserTypeName, | ||
|
@@ -186,7 +206,7 @@ func testCheckIncapsulaAccountUserExists(name string) resource.TestCheckFunc { | |
} | ||
} | ||
|
||
func testCheckIncapsulaAccountUserConfigBasic(t *testing.T) string { | ||
func testCheckIncapsulaAccountUserConfigBasic(t *testing.T, email string) string { | ||
return fmt.Sprintf(` | ||
data "incapsula_account_data" "account_data" {} | ||
|
@@ -196,7 +216,7 @@ func testCheckIncapsulaAccountUserConfigBasic(t *testing.T) string { | |
first_name = "%s" | ||
last_name = "%s" | ||
}`, | ||
accountResourceUserType, accountResourceUserName, accountUserEmail, accountUserFirstName, accountUserLastName, | ||
accountResourceUserType, accountResourceUserName, email, accountUserFirstName, accountUserLastName, | ||
) | ||
} | ||
|
||
|