@@ -50,45 +50,40 @@ resource "baremetal_core_virtual_network" "t" {
5050 compartment_id = "${var.compartment_id}"
5151 display_name = "display_name"
5252}
53-
54-
55- resource "baremetal_core_internet_gateway" "CompleteIG" {
56- compartment_id = "${var.compartment_id}"
57- display_name = "CompleteIG"
58- vcn_id = "${baremetal_core_virtual_network.t.id}"
59- }
60-
61- resource "baremetal_core_route_table" "RouteForComplete" {
62- compartment_id = "${var.compartment_id}"
63- vcn_id = "${baremetal_core_virtual_network.t.id}"
64- display_name = "RouteTableForComplete"
65- route_rules {
66- cidr_block = "0.0.0.0/0"
67- network_entity_id = "${baremetal_core_internet_gateway.CompleteIG.id}"
68- }
69- }
7053`
7154 s .SLConfig = `
7255resource "baremetal_core_security_list" "t" {
73- compartment_id = "${var.compartment_id}"
74- display_name = "Public "
75- vcn_id = "${baremetal_core_virtual_network.t.id}"
76- egress_security_rules = [{
77- destination = "0.0.0.0/0"
78- protocol = "6"
79- }]
80- ingress_security_rules = [{
81- tcp_options {
82- "max" = 80
83- "min" = 80
84- }
85- protocol = "6"
86- source = "0.0.0.0/0"
87- },
56+ compartment_id = "${var.compartment_id}"
57+ display_name = "security_list0 "
58+ vcn_id = "${baremetal_core_virtual_network.t.id}"
59+ egress_security_rules = [{
60+ destination = "0.0.0.0/0"
61+ protocol = "6"
62+ }]
63+ ingress_security_rules = [{
64+ protocol = "1"
65+ source = "0.0.0.0/0"
66+ icmp_options {
67+ "type" = 3
68+ "code" = 4
69+ }
70+ },
8871 {
89- protocol = "6"
90- source = "10.0.0.0/16"
91- }]
72+ protocol = "6"
73+ source = "0.0.0.0/0"
74+ tcp_options {
75+ "min" = 80
76+ "max" = 80
77+ }
78+ },
79+ {
80+ protocol = "17"
81+ source = "10.0.0.0/16"
82+ udp_options {
83+ "min" = 319
84+ "max" = 320
85+ }
86+ }]
9287}
9388 `
9489 s .Config += testProviderConfig ()
@@ -106,18 +101,20 @@ func (s *ResourceCoreSecurityListTestSuite) TestCreateResourceCoreSecurityList()
106101 ImportStateVerify : true ,
107102 Config : s .Config + s .SLConfig ,
108103 Check : resource .ComposeTestCheckFunc (
109- resource .TestCheckResourceAttr (s .ResourceName , "display_name" , "Public " ),
104+ resource .TestCheckResourceAttr (s .ResourceName , "display_name" , "security_list0 " ),
110105 resource .TestCheckResourceAttr (s .ResourceName , "egress_security_rules.#" , "1" ),
111- resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.#" , "2" ),
112106 resource .TestCheckResourceAttr (s .ResourceName , "egress_security_rules.0.stateless" , "false" ),
113- resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.0.tcp_options.0.max" , "80" ),
107+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.#" , "3" ),
108+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.0.icmp_options.0.type" , "3" ),
109+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.1.tcp_options.0.max" , "80" ),
110+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.2.udp_options.0.max" , "320" ),
114111 ),
115112 },
116113 },
117114 })
118115}
119116
120- func (s * ResourceCoreSecurityListTestSuite ) TestCreateResourceCoreSecurityListRemoveRules () {
117+ func (s * ResourceCoreSecurityListTestSuite ) TestCreateResourceCoreSecurityListUpdateRules () {
121118
122119 resource .UnitTest (s .T (), resource.TestCase {
123120 Providers : s .Providers ,
@@ -130,11 +127,65 @@ func (s *ResourceCoreSecurityListTestSuite) TestCreateResourceCoreSecurityListRe
130127 {
131128 Config : s .Config + `
132129 resource "baremetal_core_security_list" "t" {
133- compartment_id = "${var.compartment_id}"
134- display_name = "Public"
135- vcn_id = "${baremetal_core_virtual_network.t.id}"
136- egress_security_rules = []
137- ingress_security_rules = []
130+ compartment_id = "${var.compartment_id}"
131+ display_name = "security_list1"
132+ vcn_id = "${baremetal_core_virtual_network.t.id}"
133+ egress_security_rules = [{
134+ destination = "0.0.0.0/0"
135+ protocol = "17"
136+ stateless = true
137+ }]
138+ ingress_security_rules = [{
139+ protocol = "1"
140+ source = "0.0.0.0/0"
141+ stateless = true
142+ icmp_options {
143+ "type" = 5
144+ "code" = 0
145+ }
146+ },
147+ {
148+ protocol = "6"
149+ source = "0.0.0.0/0"
150+ stateless = true
151+ tcp_options {
152+ "min" = 80
153+ "max" = 82
154+ }
155+ },
156+ {
157+ protocol = "17"
158+ source = "10.0.0.0/16"
159+ stateless = true
160+ }]
161+ }
162+ ` ,
163+ Check : resource .ComposeTestCheckFunc (
164+ resource .TestCheckResourceAttr (s .ResourceName , "display_name" , "security_list1" ),
165+ resource .TestCheckResourceAttr (s .ResourceName , "egress_security_rules.0.protocol" , "17" ),
166+ resource .TestCheckResourceAttr (s .ResourceName , "egress_security_rules.0.stateless" , "true" ),
167+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.0.stateless" , "true" ),
168+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.0.icmp_options.0.type" , "5" ),
169+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.1.tcp_options.0.max" , "82" ),
170+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.1.stateless" , "true" ),
171+ resource .TestCheckResourceAttr (s .ResourceName , "ingress_security_rules.2.stateless" , "true" ),
172+ resource .TestCheckNoResourceAttr (s .ResourceName , "ingress_security_rules.2.udp_options" ),
173+ ),
174+ },
175+ // todo: consistent 500 error from server without this step
176+ {
177+ ImportState : true ,
178+ ImportStateVerify : true ,
179+ Config : s .Config ,
180+ },
181+ {
182+ Config : s .Config + `
183+ resource "baremetal_core_security_list" "t" {
184+ compartment_id = "${var.compartment_id}"
185+ display_name = "Public"
186+ vcn_id = "${baremetal_core_virtual_network.t.id}"
187+ egress_security_rules = []
188+ ingress_security_rules = []
138189 }
139190 ` ,
140191 Check : resource .ComposeTestCheckFunc (
0 commit comments