11package instance
22
33import (
4+ "net"
45 "testing"
56
67 "github.com/scaleway/scaleway-sdk-go/internal/testhelpers"
@@ -91,15 +92,15 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
9192 })
9293
9394 testhelpers .AssertNoError (t , err )
94-
95+ _ , ipNet , _ := net . ParseCIDR ( "8.8.8.8/32" )
9596 createRuleResponse , err := instanceAPI .CreateSecurityGroupRule (& CreateSecurityGroupRuleRequest {
9697 Zone : zone ,
9798 SecurityGroupID : createSecurityGroupResponse .SecurityGroup .ID ,
9899 Direction : SecurityGroupRuleDirectionInbound ,
99100 Protocol : SecurityGroupRuleProtocolTCP ,
100101 DestPortFrom : scw .Uint32Ptr (1 ),
101102 DestPortTo : scw .Uint32Ptr (1024 ),
102- IPRange : "8.8.8.8/32" ,
103+ IPRange : scw. IPNet { IPNet : * ipNet } ,
103104 Action : SecurityGroupRuleActionAccept ,
104105 Position : 1 ,
105106 })
@@ -121,13 +122,13 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
121122 action := SecurityGroupRuleActionDrop
122123 protocol := SecurityGroupRuleProtocolUDP
123124 direction := SecurityGroupRuleDirectionOutbound
124-
125+ _ , ipNet , _ := net . ParseCIDR ( "1.1.1.1/32" )
125126 updateResponse , err := instanceAPI .UpdateSecurityGroupRule (& UpdateSecurityGroupRuleRequest {
126127 Zone : zone ,
127128 SecurityGroupID : group .ID ,
128129 SecurityGroupRuleID : rule .ID ,
129130 Action : & action ,
130- IPRange : scw .StringPtr ( "1.1.1.1/32" ) ,
131+ IPRange : & scw.IPNet { IPNet : * ipNet } ,
131132 DestPortFrom : scw .Uint32Ptr (1 ),
132133 DestPortTo : scw .Uint32Ptr (2048 ),
133134 Protocol : & protocol ,
@@ -136,7 +137,7 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
136137
137138 testhelpers .AssertNoError (t , err )
138139 testhelpers .Equals (t , SecurityGroupRuleActionDrop , updateResponse .Rule .Action )
139- testhelpers .Equals (t , "1.1.1.1" , updateResponse .Rule .IPRange )
140+ testhelpers .Equals (t , scw. IPNet { IPNet : net. IPNet { IP : net. IP { 0x1 , 0x1 , 0x1 , 0x1 }, Mask : net. IPMask { 0xff , 0xff , 0xff , 0xff }}} , updateResponse .Rule .IPRange )
140141 testhelpers .Equals (t , scw .Uint32Ptr (1 ), updateResponse .Rule .DestPortFrom )
141142 testhelpers .Equals (t , scw .Uint32Ptr (2048 ), updateResponse .Rule .DestPortTo )
142143 testhelpers .Equals (t , SecurityGroupRuleProtocolUDP , updateResponse .Rule .Protocol )
@@ -151,12 +152,13 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
151152 protocol := SecurityGroupRuleProtocolUDP
152153 direction := SecurityGroupRuleDirectionOutbound
153154
155+ _ , ipNet , _ := net .ParseCIDR ("1.1.1.1/32" )
154156 updateResponse , err := instanceAPI .UpdateSecurityGroupRule (& UpdateSecurityGroupRuleRequest {
155157 Zone : zone ,
156158 SecurityGroupID : group .ID ,
157159 SecurityGroupRuleID : rule .ID ,
158160 Action : & action ,
159- IPRange : scw .StringPtr ( "1.1.1.1/32" ) ,
161+ IPRange : & scw.IPNet { IPNet : * ipNet } ,
160162 DestPortFrom : scw .Uint32Ptr (22 ),
161163 DestPortTo : scw .Uint32Ptr (22 ),
162164 Protocol : & protocol ,
@@ -165,7 +167,7 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
165167
166168 testhelpers .AssertNoError (t , err )
167169 testhelpers .Equals (t , SecurityGroupRuleActionDrop , updateResponse .Rule .Action )
168- testhelpers .Equals (t , "1.1.1.1" , updateResponse .Rule .IPRange )
170+ testhelpers .Equals (t , scw. IPNet { IPNet : net. IPNet { IP : net. IP { 0x1 , 0x1 , 0x1 , 0x1 }, Mask : net. IPMask { 0xff , 0xff , 0xff , 0xff }}} , updateResponse .Rule .IPRange )
169171 testhelpers .Equals (t , uint32 (22 ), * updateResponse .Rule .DestPortFrom )
170172 testhelpers .Equals (t , (* uint32 )(nil ), updateResponse .Rule .DestPortTo )
171173 testhelpers .Equals (t , SecurityGroupRuleProtocolUDP , updateResponse .Rule .Protocol )
@@ -187,7 +189,7 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
187189
188190 testhelpers .AssertNoError (t , err )
189191 testhelpers .Equals (t , SecurityGroupRuleActionAccept , updateResponse .Rule .Action )
190- testhelpers .Equals (t , "8.8.8.8" , updateResponse .Rule .IPRange )
192+ testhelpers .Equals (t , scw. IPNet { IPNet : net. IPNet { IP : net. IP { 0x8 , 0x8 , 0x8 , 0x8 }, Mask : net. IPMask { 0xff , 0xff , 0xff , 0xff }}} , updateResponse .Rule .IPRange )
191193 testhelpers .Equals (t , (* uint32 )(nil ), updateResponse .Rule .DestPortFrom )
192194 testhelpers .Equals (t , (* uint32 )(nil ), updateResponse .Rule .DestPortTo )
193195 testhelpers .Equals (t , SecurityGroupRuleProtocolICMP , updateResponse .Rule .Protocol )
@@ -208,7 +210,7 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) {
208210
209211 testhelpers .AssertNoError (t , err )
210212 testhelpers .Equals (t , SecurityGroupRuleActionAccept , updateResponse .Rule .Action )
211- testhelpers .Equals (t , "8.8.8.8" , updateResponse .Rule .IPRange )
213+ testhelpers .Equals (t , scw. IPNet { IPNet : net. IPNet { IP : net. IP { 0x8 , 0x8 , 0x8 , 0x8 }, Mask : net. IPMask { 0xff , 0xff , 0xff , 0xff }}} , updateResponse .Rule .IPRange )
212214 testhelpers .Equals (t , (* uint32 )(nil ), updateResponse .Rule .DestPortFrom )
213215 testhelpers .Equals (t , (* uint32 )(nil ), updateResponse .Rule .DestPortTo )
214216 testhelpers .Equals (t , SecurityGroupRuleProtocolTCP , updateResponse .Rule .Protocol )
0 commit comments