-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2cc9c1
commit 13110d8
Showing
10 changed files
with
417 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package outscale | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccOthers_user_groups_basic(t *testing.T) { | ||
t.Parallel() | ||
resourceName := "data.outscale_user_groups.basicUGTest" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataUserGroupsBasicConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_groups.#"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccDataUserGroupsBasicConfig = ` | ||
resource "outscale_user_group" "uGroupData" { | ||
user_group_name = "TestACC_uGdata" | ||
path = "/" | ||
} | ||
data "outscale_user_groups" "basicUGTest" { | ||
filter { | ||
name = "user_group_ids" | ||
values = [outscale_user_group.uGroupData.user_group_id] | ||
} | ||
}` |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package outscale | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccOthers_Users_basic(t *testing.T) { | ||
t.Parallel() | ||
//resourceName := "outscale_user.basic_data_user" | ||
resourceName := "data.outscale_users.basicTestUser" //s.data_testUser" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccOutscaleDataUserBasicConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "users.#"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccOutscaleDataUserBasicConfig = ` | ||
resource "outscale_user" "basic_data_user" { | ||
user_name = "ACC_test_data1" | ||
path = "/" | ||
} | ||
data "outscale_users" "basicTestUser" { | ||
depends_on = [outscale_user.basic_data_user] | ||
}` |
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package outscale | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccOthers_user_group_basic(t *testing.T) { | ||
t.Parallel() | ||
resourceName := "outscale_user_group.basic_group" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccUserGroupBasicConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_group_name"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
func TestAccOthers_userGroup_with_user(t *testing.T) { | ||
t.Parallel() | ||
resourceName := "outscale_user_group.userGroupAcc" | ||
groupName := "groupWithUsers" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccUserGroupWithUsers(groupName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_group_name"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
resource.TestCheckResourceAttr(resourceName, "user_group_name", groupName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccOthers_userGroup_update(t *testing.T) { | ||
t.Parallel() | ||
resourceName := "outscale_user_group.userGroupTAcc1" | ||
groupName := "Gp1UpUser" | ||
userName := "userGp1" | ||
newGpName := "Gp2UpUsers" | ||
newUsName := "userGp2" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccUserGroupUpadate(groupName, userName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_group_name"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
resource.TestCheckResourceAttr(resourceName, "user_group_name", groupName), | ||
), | ||
}, | ||
{ | ||
Config: testAccUserGroupUpadate(newGpName, newUsName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_group_name"), | ||
resource.TestCheckResourceAttrSet(resourceName, "users.#"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
resource.TestCheckResourceAttr(resourceName, "user_group_name", newGpName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccUserGroupBasicConfig = ` | ||
resource "outscale_user_group" "basic_group" { | ||
user_group_name = "TestACC_group1" | ||
path = "/" | ||
}` | ||
|
||
func testAccUserGroupWithUsers(name string) string { | ||
return fmt.Sprintf(` | ||
resource "outscale_user" "userToAdd1" { | ||
user_name = "userForGp1" | ||
path = "/" | ||
} | ||
resource "outscale_user" "userToAdd2" { | ||
user_name = "userForGp2" | ||
path = "/TestPath/" | ||
} | ||
resource "outscale_user_group" "userGroupAcc" { | ||
user_group_name = "%s" | ||
path = "/" | ||
users { | ||
user_name = outscale_user.userToAdd1.user_name | ||
} | ||
users { | ||
user_name = outscale_user.userToAdd2.user_name | ||
path = "/TestPath/" | ||
} | ||
} | ||
`, name) | ||
} | ||
|
||
func testAccUserGroupUpadate(name, userName string) string { | ||
return fmt.Sprintf(` | ||
resource "outscale_user" "userUpToAdd01" { | ||
user_name = "userGp1" | ||
path = "/" | ||
} | ||
resource "outscale_user" "userUpToAdd02" { | ||
user_name = "userGp2" | ||
path = "/TestPath/" | ||
} | ||
resource "outscale_user_group" "userGroupTAcc1" { | ||
user_group_name = "%s" | ||
path = "/" | ||
users { | ||
user_name = "%s" | ||
} | ||
depends_on = [outscale_user.userUpToAdd01] | ||
} | ||
`, name, userName) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package outscale | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccOthers_User_basic(t *testing.T) { | ||
t.Parallel() | ||
resourceName := "outscale_user.basic_user" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccOutscaleUserBasicConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_name"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccOthers_User_update(t *testing.T) { | ||
t.Parallel() | ||
resourceName := "outscale_user.update_user" | ||
name := "TestACC_user1" | ||
newName := "TestACC_user2" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccOutscaleUserUpdatedConfig(name), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "user_name"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
resource.TestCheckResourceAttr(resourceName, "user_name", name), | ||
), | ||
}, | ||
{ | ||
Config: testAccOutscaleUserUpdatedConfig(newName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "path"), | ||
resource.TestCheckResourceAttrSet(resourceName, "user_name"), | ||
resource.TestCheckResourceAttr(resourceName, "path", "/"), | ||
resource.TestCheckResourceAttr(resourceName, "user_name", newName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccOutscaleUserBasicConfig = ` | ||
resource "outscale_user" "basic_user" { | ||
user_name = "ACC_test1" | ||
path = "/" | ||
}` | ||
|
||
func testAccOutscaleUserUpdatedConfig(name string) string { | ||
return fmt.Sprintf(` | ||
resource "outscale_user" "update_user" { | ||
user_name = "%s" | ||
path = "/" | ||
} | ||
`, name) | ||
} |
29 changes: 29 additions & 0 deletions
29
...er_oapi/data/user/TF-01_user_resource_attributes_ok/step1.user_resource_attributes_ok.ref
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"version": "########", | ||
"terraform_version": "########", | ||
"serial": "########", | ||
"lineage": "########", | ||
"outputs": {}, | ||
"resources": [ | ||
{ | ||
"mode": "managed", | ||
"type": "outscale_user", | ||
"name": "userInteg", | ||
"provider": "provider[\"registry.terraform.io/outscale/outscale\"]", | ||
"instances": [ | ||
{ | ||
"schema_version": 0, | ||
"attributes": { | ||
"id": "##id-0##", | ||
"path": "/", | ||
"user_id": "##id-1##", | ||
"user_name": "test_integ" | ||
}, | ||
"sensitive_attributes": [], | ||
"private": "bnVsbA==" | ||
} | ||
] | ||
} | ||
], | ||
"check_results": "########" | ||
} |
4 changes: 4 additions & 0 deletions
4
...der_oapi/data/user/TF-01_user_resource_attributes_ok/step1.user_resource_attributes_ok.tf
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "outscale_user" "userInteg" { | ||
user_name = "test_integ" | ||
path = "/" | ||
} |
29 changes: 29 additions & 0 deletions
29
...er_oapi/data/user/TF-01_user_resource_attributes_ok/step2.user_resource_attributes_ok.ref
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"version": "########", | ||
"terraform_version": "########", | ||
"serial": "########", | ||
"lineage": "########", | ||
"outputs": {}, | ||
"resources": [ | ||
{ | ||
"mode": "managed", | ||
"type": "outscale_user", | ||
"name": "userInteg", | ||
"provider": "provider[\"registry.terraform.io/outscale/outscale\"]", | ||
"instances": [ | ||
{ | ||
"schema_version": 0, | ||
"attributes": { | ||
"id": "##id-0##", | ||
"path": "/Integ/", | ||
"user_id": "##id-1##", | ||
"user_name": "test_integ_update" | ||
}, | ||
"sensitive_attributes": [], | ||
"private": "bnVsbA==" | ||
} | ||
] | ||
} | ||
], | ||
"check_results": "########" | ||
} |
4 changes: 4 additions & 0 deletions
4
...der_oapi/data/user/TF-01_user_resource_attributes_ok/step2.user_resource_attributes_ok.tf
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "outscale_user" "userInteg" { | ||
user_name = "test_integ_update" | ||
path = "/Integ/" | ||
} |
Oops, something went wrong.