Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Dec 11, 2023
1 parent 13691c7 commit e4751de
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 4 deletions.
44 changes: 44 additions & 0 deletions outscale/resource_outscale_security_group_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ func TestAccOthers_SecurityGroupRule_basic(t *testing.T) {
}
}

func TestAccNet_AddSecurityGroupRuleMembersWithSgName(t *testing.T) {

rInt := acctest.RandInt()
accountID := os.Getenv("OUTSCALE_ACCOUNT")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAddSecurityGroupRuleMembersWithSgName(rInt, accountID),
},
},
})
}

func TestAccOthers_SecurityGroupRule_withSecurityGroupMember(t *testing.T) {
t.Parallel()
rInt := acctest.RandInt()
Expand Down Expand Up @@ -296,3 +312,31 @@ func testAccOutscaleOAPISecurityGroupRuleWithGroupMembers(rInt int, accountID st
}
`, accountID, rInt)
}

func testAccAddSecurityGroupRuleMembersWithSgName(rInt int, accountID string) string {
return fmt.Sprintf(`
resource "outscale_net" "netSgtest" {
ip_range = "10.0.0.0/16"
}
resource "outscale_security_group" "security_group" {
description = "testing security group"
security_group_name = "terraform-test_%[2]d"
net_id = outscale_net.netSgtest.net_id
}
resource "outscale_security_group_rule" "rule_group" {
security_group_id = outscale_security_group.security_group.security_group_id
flow = "Inbound"
rules {
from_port_range = 22
to_port_range = 22
ip_protocol = "tcp"
security_groups_members {
account_id = "%[1]s"
security_group_name = outscale_security_group.security_group.security_group_name
}
}
}
`, accountID, rInt)
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_sg",
"outscale_subnet.outscale_subnet"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group",
"outscale_security_group.outscale_security_group2"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group",
"outscale_security_group.outscale_security_group2"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
"security_groups_members": [
{
"account_id": "##id-2##",
"security_group_id": "##id-4##",
"security_group_name": ""
"security_group_id": "",
"security_group_name": "sg2-terraform-test"
}
],
"service_ids": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resource "outscale_security_group_rule" "outscale_security_group_rule-3_2" {
ip_protocol = "tcp"
security_groups_members {
account_id = outscale_security_group.outscale_security_group2.account_id
security_group_id = outscale_security_group.outscale_security_group2.id
security_group_name = outscale_security_group.outscale_security_group2.security_group_name
}
}
depends_on = [outscale_security_group.outscale_security_group2, outscale_security_group_rule.outscale_security_group_rule-3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
"security_group_name": ""
}
],
"service_ids": [],
"service_ids": null,
"to_port_range": 22
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group",
"outscale_security_group.outscale_security_group2"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group",
"outscale_security_group.outscale_security_group2"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"outscale_net.outscale_net",
"outscale_security_group.outscale_security_group",
"outscale_security_group.outscale_security_group-2",
"outscale_subnet.subnet-1"
Expand Down

0 comments on commit e4751de

Please sign in to comment.