LEFT | RIGHT |
(no file at all) | |
1 package ec2_test | 1 package ec2_test |
2 | 2 |
3 import ( | 3 import ( |
4 "launchpad.net/goamz/aws" | 4 "launchpad.net/goamz/aws" |
5 "launchpad.net/goamz/ec2" | 5 "launchpad.net/goamz/ec2" |
6 . "launchpad.net/gocheck" | 6 . "launchpad.net/gocheck" |
7 ) | 7 ) |
8 | 8 |
9 var _ = Suite(&S{}) | 9 var _ = Suite(&S{}) |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 PlacementGroupName: "group", | 78 PlacementGroupName: "group", |
79 Monitoring: true, | 79 Monitoring: true, |
80 SubnetId: "subnet-id", | 80 SubnetId: "subnet-id", |
81 DisableAPITermination: true, | 81 DisableAPITermination: true, |
82 ShutdownBehavior: "terminate", | 82 ShutdownBehavior: "terminate", |
83 PrivateIPAddress: "10.0.0.25", | 83 PrivateIPAddress: "10.0.0.25", |
84 } | 84 } |
85 resp, err := s.ec2.RunInstances(&options) | 85 resp, err := s.ec2.RunInstances(&options) |
86 | 86 |
87 req := testServer.WaitRequest() | 87 req := testServer.WaitRequest() |
88 » c.Assert(req.Form["Action"], Equals, []string{"RunInstances"}) | 88 » c.Assert(req.Form["Action"], DeepEquals, []string{"RunInstances"}) |
89 » c.Assert(req.Form["ImageId"], Equals, []string{"image-id"}) | 89 » c.Assert(req.Form["ImageId"], DeepEquals, []string{"image-id"}) |
90 » c.Assert(req.Form["MinCount"], Equals, []string{"1"}) | 90 » c.Assert(req.Form["MinCount"], DeepEquals, []string{"1"}) |
91 » c.Assert(req.Form["MaxCount"], Equals, []string{"1"}) | 91 » c.Assert(req.Form["MaxCount"], DeepEquals, []string{"1"}) |
92 » c.Assert(req.Form["KeyName"], Equals, []string{"my-keys"}) | 92 » c.Assert(req.Form["KeyName"], DeepEquals, []string{"my-keys"}) |
93 » c.Assert(req.Form["InstanceType"], Equals, []string{"inst-type"}) | 93 » c.Assert(req.Form["InstanceType"], DeepEquals, []string{"inst-type"}) |
94 » c.Assert(req.Form["SecurityGroup.1"], Equals, []string{"g1"}) | 94 » c.Assert(req.Form["SecurityGroup.1"], DeepEquals, []string{"g1"}) |
95 » c.Assert(req.Form["SecurityGroup.2"], Equals, []string{"g3"}) | 95 » c.Assert(req.Form["SecurityGroup.2"], DeepEquals, []string{"g3"}) |
96 » c.Assert(req.Form["SecurityGroupId.1"], Equals, []string{"g2"}) | 96 » c.Assert(req.Form["SecurityGroupId.1"], DeepEquals, []string{"g2"}) |
97 » c.Assert(req.Form["SecurityGroupId.2"], Equals, []string{"g4"}) | 97 » c.Assert(req.Form["SecurityGroupId.2"], DeepEquals, []string{"g4"}) |
98 » c.Assert(req.Form["UserData"], Equals, []string{"MTIzNA=="}) | 98 » c.Assert(req.Form["UserData"], DeepEquals, []string{"MTIzNA=="}) |
99 » c.Assert(req.Form["KernelId"], Equals, []string{"kernel-id"}) | 99 » c.Assert(req.Form["KernelId"], DeepEquals, []string{"kernel-id"}) |
100 » c.Assert(req.Form["RamdiskId"], Equals, []string{"ramdisk-id"}) | 100 » c.Assert(req.Form["RamdiskId"], DeepEquals, []string{"ramdisk-id"}) |
101 » c.Assert(req.Form["Placement.AvailabilityZone"], Equals, []string{"zone"
}) | 101 » c.Assert(req.Form["Placement.AvailabilityZone"], DeepEquals, []string{"z
one"}) |
102 » c.Assert(req.Form["Placement.GroupName"], Equals, []string{"group"}) | 102 » c.Assert(req.Form["Placement.GroupName"], DeepEquals, []string{"group"}) |
103 » c.Assert(req.Form["Monitoring.Enabled"], Equals, []string{"true"}) | 103 » c.Assert(req.Form["Monitoring.Enabled"], DeepEquals, []string{"true"}) |
104 » c.Assert(req.Form["SubnetId"], Equals, []string{"subnet-id"}) | 104 » c.Assert(req.Form["SubnetId"], DeepEquals, []string{"subnet-id"}) |
105 » c.Assert(req.Form["DisableApiTermination"], Equals, []string{"true"}) | 105 » c.Assert(req.Form["DisableApiTermination"], DeepEquals, []string{"true"}
) |
106 » c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], Equals, []string
{"terminate"}) | 106 » c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], DeepEquals, []st
ring{"terminate"}) |
107 » c.Assert(req.Form["PrivateIpAddress"], Equals, []string{"10.0.0.25"}) | 107 » c.Assert(req.Form["PrivateIpAddress"], DeepEquals, []string{"10.0.0.25"}
) |
108 | 108 |
109 c.Assert(err, IsNil) | 109 c.Assert(err, IsNil) |
110 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 110 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
111 c.Assert(resp.ReservationId, Equals, "r-47a5402e") | 111 c.Assert(resp.ReservationId, Equals, "r-47a5402e") |
112 c.Assert(resp.OwnerId, Equals, "999988887777") | 112 c.Assert(resp.OwnerId, Equals, "999988887777") |
113 » c.Assert(resp.SecurityGroups, Equals, []ec2.SecurityGroup{{Name: "defaul
t", Id: "sg-67ad940e"}}) | 113 » c.Assert(resp.SecurityGroups, DeepEquals, []ec2.SecurityGroup{{Name: "de
fault", Id: "sg-67ad940e"}}) |
114 » c.Assert(len(resp.Instances), Equals, 3) | 114 » c.Assert(resp.Instances, HasLen, 3) |
115 | 115 |
116 i0 := resp.Instances[0] | 116 i0 := resp.Instances[0] |
117 c.Assert(i0.InstanceId, Equals, "i-2ba64342") | 117 c.Assert(i0.InstanceId, Equals, "i-2ba64342") |
118 c.Assert(i0.InstanceType, Equals, "m1.small") | 118 c.Assert(i0.InstanceType, Equals, "m1.small") |
119 c.Assert(i0.ImageId, Equals, "ami-60a54009") | 119 c.Assert(i0.ImageId, Equals, "ami-60a54009") |
120 c.Assert(i0.Monitoring, Equals, "enabled") | 120 c.Assert(i0.Monitoring, Equals, "enabled") |
121 c.Assert(i0.KeyName, Equals, "example-key-name") | 121 c.Assert(i0.KeyName, Equals, "example-key-name") |
122 c.Assert(i0.AMILaunchIndex, Equals, 0) | 122 c.Assert(i0.AMILaunchIndex, Equals, 0) |
123 c.Assert(i0.VirtType, Equals, "paravirtual") | 123 c.Assert(i0.VirtType, Equals, "paravirtual") |
124 c.Assert(i0.Hypervisor, Equals, "xen") | 124 c.Assert(i0.Hypervisor, Equals, "xen") |
(...skipping 18 matching lines...) Expand all Loading... |
143 c.Assert(i2.VirtType, Equals, "paravirtual") | 143 c.Assert(i2.VirtType, Equals, "paravirtual") |
144 c.Assert(i2.Hypervisor, Equals, "xen") | 144 c.Assert(i2.Hypervisor, Equals, "xen") |
145 } | 145 } |
146 | 146 |
147 func (s *S) TestTerminateInstancesExample(c *C) { | 147 func (s *S) TestTerminateInstancesExample(c *C) { |
148 testServer.PrepareResponse(200, nil, TerminateInstancesExample) | 148 testServer.PrepareResponse(200, nil, TerminateInstancesExample) |
149 | 149 |
150 resp, err := s.ec2.TerminateInstances([]string{"i-1", "i-2"}) | 150 resp, err := s.ec2.TerminateInstances([]string{"i-1", "i-2"}) |
151 | 151 |
152 req := testServer.WaitRequest() | 152 req := testServer.WaitRequest() |
153 » c.Assert(req.Form["Action"], Equals, []string{"TerminateInstances"}) | 153 » c.Assert(req.Form["Action"], DeepEquals, []string{"TerminateInstances"}) |
154 » c.Assert(req.Form["InstanceId.1"], Equals, []string{"i-1"}) | 154 » c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"}) |
155 » c.Assert(req.Form["InstanceId.2"], Equals, []string{"i-2"}) | 155 » c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"}) |
156 c.Assert(req.Form["UserData"], IsNil) | 156 c.Assert(req.Form["UserData"], IsNil) |
157 c.Assert(req.Form["KernelId"], IsNil) | 157 c.Assert(req.Form["KernelId"], IsNil) |
158 c.Assert(req.Form["RamdiskId"], IsNil) | 158 c.Assert(req.Form["RamdiskId"], IsNil) |
159 c.Assert(req.Form["Placement.AvailabilityZone"], IsNil) | 159 c.Assert(req.Form["Placement.AvailabilityZone"], IsNil) |
160 c.Assert(req.Form["Placement.GroupName"], IsNil) | 160 c.Assert(req.Form["Placement.GroupName"], IsNil) |
161 c.Assert(req.Form["Monitoring.Enabled"], IsNil) | 161 c.Assert(req.Form["Monitoring.Enabled"], IsNil) |
162 c.Assert(req.Form["SubnetId"], IsNil) | 162 c.Assert(req.Form["SubnetId"], IsNil) |
163 c.Assert(req.Form["DisableApiTermination"], IsNil) | 163 c.Assert(req.Form["DisableApiTermination"], IsNil) |
164 c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], IsNil) | 164 c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], IsNil) |
165 c.Assert(req.Form["PrivateIpAddress"], IsNil) | 165 c.Assert(req.Form["PrivateIpAddress"], IsNil) |
166 | 166 |
167 c.Assert(err, IsNil) | 167 c.Assert(err, IsNil) |
168 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 168 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
169 » c.Assert(len(resp.StateChanges), Equals, 1) | 169 » c.Assert(resp.StateChanges, HasLen, 1) |
170 c.Assert(resp.StateChanges[0].InstanceId, Equals, "i-3ea74257") | 170 c.Assert(resp.StateChanges[0].InstanceId, Equals, "i-3ea74257") |
171 c.Assert(resp.StateChanges[0].CurrentState.Code, Equals, 32) | 171 c.Assert(resp.StateChanges[0].CurrentState.Code, Equals, 32) |
172 c.Assert(resp.StateChanges[0].CurrentState.Name, Equals, "shutting-down"
) | 172 c.Assert(resp.StateChanges[0].CurrentState.Name, Equals, "shutting-down"
) |
173 c.Assert(resp.StateChanges[0].PreviousState.Code, Equals, 16) | 173 c.Assert(resp.StateChanges[0].PreviousState.Code, Equals, 16) |
174 c.Assert(resp.StateChanges[0].PreviousState.Name, Equals, "running") | 174 c.Assert(resp.StateChanges[0].PreviousState.Name, Equals, "running") |
175 } | 175 } |
176 | 176 |
177 func (s *S) TestDescribeInstancesExample1(c *C) { | 177 func (s *S) TestDescribeInstancesExample1(c *C) { |
178 testServer.PrepareResponse(200, nil, DescribeInstancesExample1) | 178 testServer.PrepareResponse(200, nil, DescribeInstancesExample1) |
179 | 179 |
180 filter := ec2.NewFilter() | 180 filter := ec2.NewFilter() |
181 filter.Add("key1", "value1") | 181 filter.Add("key1", "value1") |
182 filter.Add("key2", "value2", "value3") | 182 filter.Add("key2", "value2", "value3") |
183 | 183 |
184 resp, err := s.ec2.Instances([]string{"i-1", "i-2"}, nil) | 184 resp, err := s.ec2.Instances([]string{"i-1", "i-2"}, nil) |
185 | 185 |
186 req := testServer.WaitRequest() | 186 req := testServer.WaitRequest() |
187 » c.Assert(req.Form["Action"], Equals, []string{"DescribeInstances"}) | 187 » c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstances"}) |
188 » c.Assert(req.Form["InstanceId.1"], Equals, []string{"i-1"}) | 188 » c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"}) |
189 » c.Assert(req.Form["InstanceId.2"], Equals, []string{"i-2"}) | 189 » c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"}) |
190 | 190 |
191 c.Assert(err, IsNil) | 191 c.Assert(err, IsNil) |
192 c.Assert(resp.RequestId, Equals, "98e3c9a4-848c-4d6d-8e8a-b1bdEXAMPLE") | 192 c.Assert(resp.RequestId, Equals, "98e3c9a4-848c-4d6d-8e8a-b1bdEXAMPLE") |
193 » c.Assert(len(resp.Reservations), Equals, 2) | 193 » c.Assert(resp.Reservations, HasLen, 2) |
194 | 194 |
195 r0 := resp.Reservations[0] | 195 r0 := resp.Reservations[0] |
196 c.Assert(r0.ReservationId, Equals, "r-b27e30d9") | 196 c.Assert(r0.ReservationId, Equals, "r-b27e30d9") |
197 c.Assert(r0.OwnerId, Equals, "999988887777") | 197 c.Assert(r0.OwnerId, Equals, "999988887777") |
198 c.Assert(r0.RequesterId, Equals, "854251627541") | 198 c.Assert(r0.RequesterId, Equals, "854251627541") |
199 » c.Assert(r0.SecurityGroups, Equals, []ec2.SecurityGroup{{Name: "default"
, Id: "sg-67ad940e"}}) | 199 » c.Assert(r0.SecurityGroups, DeepEquals, []ec2.SecurityGroup{{Name: "defa
ult", Id: "sg-67ad940e"}}) |
200 » c.Assert(len(r0.Instances), Equals, 1) | 200 » c.Assert(r0.Instances, HasLen, 1) |
201 | 201 |
202 r0i := r0.Instances[0] | 202 r0i := r0.Instances[0] |
203 c.Assert(r0i.InstanceId, Equals, "i-c5cd56af") | 203 c.Assert(r0i.InstanceId, Equals, "i-c5cd56af") |
204 c.Assert(r0i.PrivateDNSName, Equals, "domU-12-31-39-10-56-34.compute-1.i
nternal") | 204 c.Assert(r0i.PrivateDNSName, Equals, "domU-12-31-39-10-56-34.compute-1.i
nternal") |
205 c.Assert(r0i.DNSName, Equals, "ec2-174-129-165-232.compute-1.amazonaws.c
om") | 205 c.Assert(r0i.DNSName, Equals, "ec2-174-129-165-232.compute-1.amazonaws.c
om") |
206 c.Assert(r0i.AvailZone, Equals, "us-east-1b") | 206 c.Assert(r0i.AvailZone, Equals, "us-east-1b") |
207 } | 207 } |
208 | 208 |
209 func (s *S) TestDescribeInstancesExample2(c *C) { | 209 func (s *S) TestDescribeInstancesExample2(c *C) { |
210 testServer.PrepareResponse(200, nil, DescribeInstancesExample2) | 210 testServer.PrepareResponse(200, nil, DescribeInstancesExample2) |
211 | 211 |
212 filter := ec2.NewFilter() | 212 filter := ec2.NewFilter() |
213 filter.Add("key1", "value1") | 213 filter.Add("key1", "value1") |
214 filter.Add("key2", "value2", "value3") | 214 filter.Add("key2", "value2", "value3") |
215 | 215 |
216 resp, err := s.ec2.Instances([]string{"i-1", "i-2"}, filter) | 216 resp, err := s.ec2.Instances([]string{"i-1", "i-2"}, filter) |
217 | 217 |
218 req := testServer.WaitRequest() | 218 req := testServer.WaitRequest() |
219 » c.Assert(req.Form["Action"], Equals, []string{"DescribeInstances"}) | 219 » c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstances"}) |
220 » c.Assert(req.Form["InstanceId.1"], Equals, []string{"i-1"}) | 220 » c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"}) |
221 » c.Assert(req.Form["InstanceId.2"], Equals, []string{"i-2"}) | 221 » c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"}) |
222 » c.Assert(req.Form["Filter.1.Name"], Equals, []string{"key1"}) | 222 » c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"}) |
223 » c.Assert(req.Form["Filter.1.Value.1"], Equals, []string{"value1"}) | 223 » c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"}) |
224 c.Assert(req.Form["Filter.1.Value.2"], IsNil) | 224 c.Assert(req.Form["Filter.1.Value.2"], IsNil) |
225 » c.Assert(req.Form["Filter.2.Name"], Equals, []string{"key2"}) | 225 » c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"}) |
226 » c.Assert(req.Form["Filter.2.Value.1"], Equals, []string{"value2"}) | 226 » c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"}) |
227 » c.Assert(req.Form["Filter.2.Value.2"], Equals, []string{"value3"}) | 227 » c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"}) |
228 | 228 |
229 » c.Assert(err, IsNil) | 229 » c.Assert(err, IsNil) |
230 » c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 230 » c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
231 » c.Assert(len(resp.Reservations), Equals, 1) | 231 » c.Assert(resp.Reservations, HasLen, 1) |
232 | 232 |
233 r0 := resp.Reservations[0] | 233 r0 := resp.Reservations[0] |
234 r0i := r0.Instances[0] | 234 r0i := r0.Instances[0] |
235 c.Assert(r0i.State.Code, Equals, 16) | 235 c.Assert(r0i.State.Code, Equals, 16) |
236 c.Assert(r0i.State.Name, Equals, "running") | 236 c.Assert(r0i.State.Name, Equals, "running") |
237 | 237 |
238 r0t0 := r0i.Tags[0] | 238 r0t0 := r0i.Tags[0] |
239 r0t1 := r0i.Tags[1] | 239 r0t1 := r0i.Tags[1] |
240 c.Assert(r0t0.Key, Equals, "webserver") | 240 c.Assert(r0t0.Key, Equals, "webserver") |
241 c.Assert(r0t0.Value, Equals, "") | 241 c.Assert(r0t0.Value, Equals, "") |
242 c.Assert(r0t1.Key, Equals, "stack") | 242 c.Assert(r0t1.Key, Equals, "stack") |
243 c.Assert(r0t1.Value, Equals, "Production") | 243 c.Assert(r0t1.Value, Equals, "Production") |
244 } | 244 } |
245 | 245 |
246 func (s *S) TestCreateSecurityGroupExample(c *C) { | 246 func (s *S) TestCreateSecurityGroupExample(c *C) { |
247 testServer.PrepareResponse(200, nil, CreateSecurityGroupExample) | 247 testServer.PrepareResponse(200, nil, CreateSecurityGroupExample) |
248 | 248 |
249 resp, err := s.ec2.CreateSecurityGroup("websrv", "Web Servers") | 249 resp, err := s.ec2.CreateSecurityGroup("websrv", "Web Servers") |
250 | 250 |
251 req := testServer.WaitRequest() | 251 req := testServer.WaitRequest() |
252 » c.Assert(req.Form["Action"], Equals, []string{"CreateSecurityGroup"}) | 252 » c.Assert(req.Form["Action"], DeepEquals, []string{"CreateSecurityGroup"}
) |
253 » c.Assert(req.Form["GroupName"], Equals, []string{"websrv"}) | 253 » c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"}) |
254 » c.Assert(req.Form["GroupDescription"], Equals, []string{"Web Servers"}) | 254 » c.Assert(req.Form["GroupDescription"], DeepEquals, []string{"Web Servers
"}) |
255 | 255 |
256 c.Assert(err, IsNil) | 256 c.Assert(err, IsNil) |
257 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 257 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
258 c.Assert(resp.Name, Equals, "websrv") | 258 c.Assert(resp.Name, Equals, "websrv") |
259 c.Assert(resp.Id, Equals, "sg-67ad940e") | 259 c.Assert(resp.Id, Equals, "sg-67ad940e") |
260 } | 260 } |
261 | 261 |
262 func (s *S) TestDescribeSecurityGroupsExample(c *C) { | 262 func (s *S) TestDescribeSecurityGroupsExample(c *C) { |
263 testServer.PrepareResponse(200, nil, DescribeSecurityGroupsExample) | 263 testServer.PrepareResponse(200, nil, DescribeSecurityGroupsExample) |
264 | 264 |
265 resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{{Name: "WebServers
"}, {Name: "RangedPortsBySource"}}, nil) | 265 resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{{Name: "WebServers
"}, {Name: "RangedPortsBySource"}}, nil) |
266 | 266 |
267 req := testServer.WaitRequest() | 267 req := testServer.WaitRequest() |
268 » c.Assert(req.Form["Action"], Equals, []string{"DescribeSecurityGroups"}) | 268 » c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroup
s"}) |
269 » c.Assert(req.Form["GroupName.1"], Equals, []string{"WebServers"}) | 269 » c.Assert(req.Form["GroupName.1"], DeepEquals, []string{"WebServers"}) |
270 » c.Assert(req.Form["GroupName.2"], Equals, []string{"RangedPortsBySource"
}) | 270 » c.Assert(req.Form["GroupName.2"], DeepEquals, []string{"RangedPortsBySou
rce"}) |
271 | 271 |
272 » c.Assert(err, IsNil) | 272 » c.Assert(err, IsNil) |
273 » c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 273 » c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
274 » c.Assert(len(resp.Groups), Equals, 2) | 274 » c.Assert(resp.Groups, HasLen, 2) |
275 | 275 |
276 g0 := resp.Groups[0] | 276 g0 := resp.Groups[0] |
277 c.Assert(g0.OwnerId, Equals, "999988887777") | 277 c.Assert(g0.OwnerId, Equals, "999988887777") |
278 c.Assert(g0.Name, Equals, "WebServers") | 278 c.Assert(g0.Name, Equals, "WebServers") |
279 c.Assert(g0.Id, Equals, "sg-67ad940e") | 279 c.Assert(g0.Id, Equals, "sg-67ad940e") |
280 c.Assert(g0.Description, Equals, "Web Servers") | 280 c.Assert(g0.Description, Equals, "Web Servers") |
281 » c.Assert(len(g0.IPPerms), Equals, 1) | 281 » c.Assert(g0.IPPerms, HasLen, 1) |
282 | 282 |
283 g0ipp := g0.IPPerms[0] | 283 g0ipp := g0.IPPerms[0] |
284 c.Assert(g0ipp.Protocol, Equals, "tcp") | 284 c.Assert(g0ipp.Protocol, Equals, "tcp") |
285 c.Assert(g0ipp.FromPort, Equals, 80) | 285 c.Assert(g0ipp.FromPort, Equals, 80) |
286 c.Assert(g0ipp.ToPort, Equals, 80) | 286 c.Assert(g0ipp.ToPort, Equals, 80) |
287 » c.Assert(g0ipp.SourceIPs, Equals, []string{"0.0.0.0/0"}) | 287 » c.Assert(g0ipp.SourceIPs, DeepEquals, []string{"0.0.0.0/0"}) |
288 | 288 |
289 g1 := resp.Groups[1] | 289 g1 := resp.Groups[1] |
290 c.Assert(g1.OwnerId, Equals, "999988887777") | 290 c.Assert(g1.OwnerId, Equals, "999988887777") |
291 c.Assert(g1.Name, Equals, "RangedPortsBySource") | 291 c.Assert(g1.Name, Equals, "RangedPortsBySource") |
292 c.Assert(g1.Id, Equals, "sg-76abc467") | 292 c.Assert(g1.Id, Equals, "sg-76abc467") |
293 c.Assert(g1.Description, Equals, "Group A") | 293 c.Assert(g1.Description, Equals, "Group A") |
294 » c.Assert(len(g1.IPPerms), Equals, 1) | 294 » c.Assert(g1.IPPerms, HasLen, 1) |
295 | 295 |
296 g1ipp := g1.IPPerms[0] | 296 g1ipp := g1.IPPerms[0] |
297 c.Assert(g1ipp.Protocol, Equals, "tcp") | 297 c.Assert(g1ipp.Protocol, Equals, "tcp") |
298 c.Assert(g1ipp.FromPort, Equals, 6000) | 298 c.Assert(g1ipp.FromPort, Equals, 6000) |
299 c.Assert(g1ipp.ToPort, Equals, 7000) | 299 c.Assert(g1ipp.ToPort, Equals, 7000) |
300 c.Assert(g1ipp.SourceIPs, IsNil) | 300 c.Assert(g1ipp.SourceIPs, IsNil) |
301 } | 301 } |
302 | 302 |
303 func (s *S) TestDescribeSecurityGroupsExampleWithFilter(c *C) { | 303 func (s *S) TestDescribeSecurityGroupsExampleWithFilter(c *C) { |
304 testServer.PrepareResponse(200, nil, DescribeSecurityGroupsExample) | 304 testServer.PrepareResponse(200, nil, DescribeSecurityGroupsExample) |
305 | 305 |
306 filter := ec2.NewFilter() | 306 filter := ec2.NewFilter() |
307 filter.Add("ip-permission.protocol", "tcp") | 307 filter.Add("ip-permission.protocol", "tcp") |
308 filter.Add("ip-permission.from-port", "22") | 308 filter.Add("ip-permission.from-port", "22") |
309 filter.Add("ip-permission.to-port", "22") | 309 filter.Add("ip-permission.to-port", "22") |
310 filter.Add("ip-permission.group-name", "app_server_group", "database_gro
up") | 310 filter.Add("ip-permission.group-name", "app_server_group", "database_gro
up") |
311 | 311 |
312 _, err := s.ec2.SecurityGroups(nil, filter) | 312 _, err := s.ec2.SecurityGroups(nil, filter) |
313 | 313 |
314 req := testServer.WaitRequest() | 314 req := testServer.WaitRequest() |
315 » c.Assert(req.Form["Action"], Equals, []string{"DescribeSecurityGroups"}) | 315 » c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroup
s"}) |
316 » c.Assert(req.Form["Filter.1.Name"], Equals, []string{"ip-permission.from
-port"}) | 316 » c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"ip-permission.
from-port"}) |
317 » c.Assert(req.Form["Filter.1.Value.1"], Equals, []string{"22"}) | 317 » c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"22"}) |
318 » c.Assert(req.Form["Filter.2.Name"], Equals, []string{"ip-permission.grou
p-name"}) | 318 » c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"ip-permission.
group-name"}) |
319 » c.Assert(req.Form["Filter.2.Value.1"], Equals, []string{"app_server_grou
p"}) | 319 » c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"app_server_
group"}) |
320 » c.Assert(req.Form["Filter.2.Value.2"], Equals, []string{"database_group"
}) | 320 » c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"database_gr
oup"}) |
321 » c.Assert(req.Form["Filter.3.Name"], Equals, []string{"ip-permission.prot
ocol"}) | 321 » c.Assert(req.Form["Filter.3.Name"], DeepEquals, []string{"ip-permission.
protocol"}) |
322 » c.Assert(req.Form["Filter.3.Value.1"], Equals, []string{"tcp"}) | 322 » c.Assert(req.Form["Filter.3.Value.1"], DeepEquals, []string{"tcp"}) |
323 » c.Assert(req.Form["Filter.4.Name"], Equals, []string{"ip-permission.to-p
ort"}) | 323 » c.Assert(req.Form["Filter.4.Name"], DeepEquals, []string{"ip-permission.
to-port"}) |
324 » c.Assert(req.Form["Filter.4.Value.1"], Equals, []string{"22"}) | 324 » c.Assert(req.Form["Filter.4.Value.1"], DeepEquals, []string{"22"}) |
325 | 325 |
326 c.Assert(err, IsNil) | 326 c.Assert(err, IsNil) |
327 } | 327 } |
328 | 328 |
329 func (s *S) TestDescribeSecurityGroupsDumpWithGroup(c *C) { | 329 func (s *S) TestDescribeSecurityGroupsDumpWithGroup(c *C) { |
330 testServer.PrepareResponse(200, nil, DescribeSecurityGroupsDump) | 330 testServer.PrepareResponse(200, nil, DescribeSecurityGroupsDump) |
331 | 331 |
332 resp, err := s.ec2.SecurityGroups(nil, nil) | 332 resp, err := s.ec2.SecurityGroups(nil, nil) |
333 | 333 |
334 req := testServer.WaitRequest() | 334 req := testServer.WaitRequest() |
335 » c.Assert(req.Form["Action"], Equals, []string{"DescribeSecurityGroups"}) | 335 » c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroup
s"}) |
336 » c.Assert(err, IsNil) | 336 » c.Assert(err, IsNil) |
337 » c.Check(len(resp.Groups), Equals, 1) | 337 » c.Check(resp.Groups, HasLen, 1) |
338 » c.Check(len(resp.Groups[0].IPPerms), Equals, 2) | 338 » c.Check(resp.Groups[0].IPPerms, HasLen, 2) |
339 | 339 |
340 ipp0 := resp.Groups[0].IPPerms[0] | 340 ipp0 := resp.Groups[0].IPPerms[0] |
341 c.Assert(ipp0.SourceIPs, IsNil) | 341 c.Assert(ipp0.SourceIPs, IsNil) |
342 c.Check(ipp0.Protocol, Equals, "icmp") | 342 c.Check(ipp0.Protocol, Equals, "icmp") |
343 » c.Assert(len(ipp0.SourceGroups), Equals, 1) | 343 » c.Assert(ipp0.SourceGroups, HasLen, 1) |
344 c.Check(ipp0.SourceGroups[0].OwnerId, Equals, "12345") | 344 c.Check(ipp0.SourceGroups[0].OwnerId, Equals, "12345") |
345 c.Check(ipp0.SourceGroups[0].Name, Equals, "default") | 345 c.Check(ipp0.SourceGroups[0].Name, Equals, "default") |
346 c.Check(ipp0.SourceGroups[0].Id, Equals, "sg-67ad940e") | 346 c.Check(ipp0.SourceGroups[0].Id, Equals, "sg-67ad940e") |
347 | 347 |
348 ipp1 := resp.Groups[0].IPPerms[1] | 348 ipp1 := resp.Groups[0].IPPerms[1] |
349 c.Check(ipp1.Protocol, Equals, "tcp") | 349 c.Check(ipp1.Protocol, Equals, "tcp") |
350 c.Assert(ipp0.SourceIPs, IsNil) | 350 c.Assert(ipp0.SourceIPs, IsNil) |
351 » c.Assert(len(ipp0.SourceGroups), Equals, 1) | 351 » c.Assert(ipp0.SourceGroups, HasLen, 1) |
352 c.Check(ipp1.SourceGroups[0].Id, Equals, "sg-76abc467") | 352 c.Check(ipp1.SourceGroups[0].Id, Equals, "sg-76abc467") |
353 c.Check(ipp1.SourceGroups[0].OwnerId, Equals, "12345") | 353 c.Check(ipp1.SourceGroups[0].OwnerId, Equals, "12345") |
354 c.Check(ipp1.SourceGroups[0].Name, Equals, "other") | 354 c.Check(ipp1.SourceGroups[0].Name, Equals, "other") |
355 } | 355 } |
356 | 356 |
357 func (s *S) TestDeleteSecurityGroupExample(c *C) { | 357 func (s *S) TestDeleteSecurityGroupExample(c *C) { |
358 testServer.PrepareResponse(200, nil, DeleteSecurityGroupExample) | 358 testServer.PrepareResponse(200, nil, DeleteSecurityGroupExample) |
359 | 359 |
360 resp, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: "websrv"}
) | 360 resp, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: "websrv"}
) |
361 req := testServer.WaitRequest() | 361 req := testServer.WaitRequest() |
362 | 362 |
363 » c.Assert(req.Form["Action"], Equals, []string{"DeleteSecurityGroup"}) | 363 » c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteSecurityGroup"}
) |
364 » c.Assert(req.Form["GroupName"], Equals, []string{"websrv"}) | 364 » c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"}) |
365 c.Assert(req.Form["GroupId"], IsNil) | 365 c.Assert(req.Form["GroupId"], IsNil) |
366 c.Assert(err, IsNil) | 366 c.Assert(err, IsNil) |
367 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 367 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
368 } | 368 } |
369 | 369 |
370 func (s *S) TestDeleteSecurityGroupExampleWithId(c *C) { | 370 func (s *S) TestDeleteSecurityGroupExampleWithId(c *C) { |
371 testServer.PrepareResponse(200, nil, DeleteSecurityGroupExample) | 371 testServer.PrepareResponse(200, nil, DeleteSecurityGroupExample) |
372 | 372 |
373 // ignore return and error - we're only want to check the parameter hand
ling. | 373 // ignore return and error - we're only want to check the parameter hand
ling. |
374 s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ig
nored"}) | 374 s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ig
nored"}) |
375 req := testServer.WaitRequest() | 375 req := testServer.WaitRequest() |
376 | 376 |
377 c.Assert(req.Form["GroupName"], IsNil) | 377 c.Assert(req.Form["GroupName"], IsNil) |
378 » c.Assert(req.Form["GroupId"], Equals, []string{"sg-67ad940e"}) | 378 » c.Assert(req.Form["GroupId"], DeepEquals, []string{"sg-67ad940e"}) |
379 } | 379 } |
380 | 380 |
381 func (s *S) TestAuthorizeSecurityGroupExample1(c *C) { | 381 func (s *S) TestAuthorizeSecurityGroupExample1(c *C) { |
382 testServer.PrepareResponse(200, nil, AuthorizeSecurityGroupIngressExampl
e) | 382 testServer.PrepareResponse(200, nil, AuthorizeSecurityGroupIngressExampl
e) |
383 | 383 |
384 perms := []ec2.IPPerm{{ | 384 perms := []ec2.IPPerm{{ |
385 Protocol: "tcp", | 385 Protocol: "tcp", |
386 FromPort: 80, | 386 FromPort: 80, |
387 ToPort: 80, | 387 ToPort: 80, |
388 SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"}, | 388 SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"}, |
389 }} | 389 }} |
390 resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websr
v"}, perms) | 390 resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websr
v"}, perms) |
391 | 391 |
392 req := testServer.WaitRequest() | 392 req := testServer.WaitRequest() |
393 | 393 |
394 » c.Assert(req.Form["Action"], Equals, []string{"AuthorizeSecurityGroupIng
ress"}) | 394 » c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGrou
pIngress"}) |
395 » c.Assert(req.Form["GroupName"], Equals, []string{"websrv"}) | 395 » c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"}) |
396 » c.Assert(req.Form["IpPermissions.1.IpProtocol"], Equals, []string{"tcp"}
) | 396 » c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"t
cp"}) |
397 » c.Assert(req.Form["IpPermissions.1.FromPort"], Equals, []string{"80"}) | 397 » c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"
}) |
398 » c.Assert(req.Form["IpPermissions.1.ToPort"], Equals, []string{"80"}) | 398 » c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"80"}) |
399 » c.Assert(req.Form["IpPermissions.1.IpRanges.1.CidrIp"], Equals, []string
{"205.192.0.0/16"}) | 399 » c.Assert(req.Form["IpPermissions.1.IpRanges.1.CidrIp"], DeepEquals, []st
ring{"205.192.0.0/16"}) |
400 » c.Assert(req.Form["IpPermissions.1.IpRanges.2.CidrIp"], Equals, []string
{"205.159.0.0/16"}) | 400 » c.Assert(req.Form["IpPermissions.1.IpRanges.2.CidrIp"], DeepEquals, []st
ring{"205.159.0.0/16"}) |
401 | 401 |
402 c.Assert(err, IsNil) | 402 c.Assert(err, IsNil) |
403 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 403 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
404 } | 404 } |
405 | 405 |
406 func (s *S) TestAuthorizeSecurityGroupExample1WithId(c *C) { | 406 func (s *S) TestAuthorizeSecurityGroupExample1WithId(c *C) { |
407 testServer.PrepareResponse(200, nil, AuthorizeSecurityGroupIngressExampl
e) | 407 testServer.PrepareResponse(200, nil, AuthorizeSecurityGroupIngressExampl
e) |
408 | 408 |
409 perms := []ec2.IPPerm{{ | 409 perms := []ec2.IPPerm{{ |
410 Protocol: "tcp", | 410 Protocol: "tcp", |
411 FromPort: 80, | 411 FromPort: 80, |
412 ToPort: 80, | 412 ToPort: 80, |
413 SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"}, | 413 SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"}, |
414 }} | 414 }} |
415 // ignore return and error - we're only want to check the parameter hand
ling. | 415 // ignore return and error - we're only want to check the parameter hand
ling. |
416 s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name:
"ignored"}, perms) | 416 s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name:
"ignored"}, perms) |
417 | 417 |
418 req := testServer.WaitRequest() | 418 req := testServer.WaitRequest() |
419 | 419 |
420 c.Assert(req.Form["GroupName"], IsNil) | 420 c.Assert(req.Form["GroupName"], IsNil) |
421 » c.Assert(req.Form["GroupId"], Equals, []string{"sg-67ad940e"}) | 421 » c.Assert(req.Form["GroupId"], DeepEquals, []string{"sg-67ad940e"}) |
422 } | 422 } |
423 | 423 |
424 func (s *S) TestAuthorizeSecurityGroupExample2(c *C) { | 424 func (s *S) TestAuthorizeSecurityGroupExample2(c *C) { |
425 testServer.PrepareResponse(200, nil, AuthorizeSecurityGroupIngressExampl
e) | 425 testServer.PrepareResponse(200, nil, AuthorizeSecurityGroupIngressExampl
e) |
426 | 426 |
427 perms := []ec2.IPPerm{{ | 427 perms := []ec2.IPPerm{{ |
428 Protocol: "tcp", | 428 Protocol: "tcp", |
429 FromPort: 80, | 429 FromPort: 80, |
430 ToPort: 81, | 430 ToPort: 81, |
431 SourceGroups: []ec2.UserSecurityGroup{ | 431 SourceGroups: []ec2.UserSecurityGroup{ |
432 {OwnerId: "999988887777", Name: "OtherAccountGroup"}, | 432 {OwnerId: "999988887777", Name: "OtherAccountGroup"}, |
433 {Id: "sg-67ad940e"}, | 433 {Id: "sg-67ad940e"}, |
434 }, | 434 }, |
435 }} | 435 }} |
436 resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websr
v"}, perms) | 436 resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websr
v"}, perms) |
437 | 437 |
438 req := testServer.WaitRequest() | 438 req := testServer.WaitRequest() |
439 | 439 |
440 » c.Assert(req.Form["Action"], Equals, []string{"AuthorizeSecurityGroupIng
ress"}) | 440 » c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGrou
pIngress"}) |
441 » c.Assert(req.Form["GroupName"], Equals, []string{"websrv"}) | 441 » c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"}) |
442 » c.Assert(req.Form["IpPermissions.1.IpProtocol"], Equals, []string{"tcp"}
) | 442 » c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"t
cp"}) |
443 » c.Assert(req.Form["IpPermissions.1.FromPort"], Equals, []string{"80"}) | 443 » c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"
}) |
444 » c.Assert(req.Form["IpPermissions.1.ToPort"], Equals, []string{"81"}) | 444 » c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"81"}) |
445 » c.Assert(req.Form["IpPermissions.1.Groups.1.UserId"], Equals, []string{"
999988887777"}) | 445 » c.Assert(req.Form["IpPermissions.1.Groups.1.UserId"], DeepEquals, []stri
ng{"999988887777"}) |
446 » c.Assert(req.Form["IpPermissions.1.Groups.1.GroupName"], Equals, []strin
g{"OtherAccountGroup"}) | 446 » c.Assert(req.Form["IpPermissions.1.Groups.1.GroupName"], DeepEquals, []s
tring{"OtherAccountGroup"}) |
447 c.Assert(req.Form["IpPermissions.1.Groups.2.UserId"], IsNil) | 447 c.Assert(req.Form["IpPermissions.1.Groups.2.UserId"], IsNil) |
448 c.Assert(req.Form["IpPermissions.1.Groups.2.GroupName"], IsNil) | 448 c.Assert(req.Form["IpPermissions.1.Groups.2.GroupName"], IsNil) |
449 » c.Assert(req.Form["IpPermissions.1.Groups.2.GroupId"], Equals, []string{
"sg-67ad940e"}) | 449 » c.Assert(req.Form["IpPermissions.1.Groups.2.GroupId"], DeepEquals, []str
ing{"sg-67ad940e"}) |
450 | 450 |
451 c.Assert(err, IsNil) | 451 c.Assert(err, IsNil) |
452 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 452 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
453 } | 453 } |
454 | 454 |
455 func (s *S) TestRevokeSecurityGroupExample(c *C) { | 455 func (s *S) TestRevokeSecurityGroupExample(c *C) { |
456 // RevokeSecurityGroup is implemented by the same code as AuthorizeSecur
ityGroup | 456 // RevokeSecurityGroup is implemented by the same code as AuthorizeSecur
ityGroup |
457 // so there's no need to duplicate all the tests. | 457 // so there's no need to duplicate all the tests. |
458 testServer.PrepareResponse(200, nil, RevokeSecurityGroupIngressExample) | 458 testServer.PrepareResponse(200, nil, RevokeSecurityGroupIngressExample) |
459 | 459 |
460 resp, err := s.ec2.RevokeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}
, nil) | 460 resp, err := s.ec2.RevokeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}
, nil) |
461 | 461 |
462 req := testServer.WaitRequest() | 462 req := testServer.WaitRequest() |
463 | 463 |
464 » c.Assert(req.Form["Action"], Equals, []string{"RevokeSecurityGroupIngres
s"}) | 464 » c.Assert(req.Form["Action"], DeepEquals, []string{"RevokeSecurityGroupIn
gress"}) |
465 » c.Assert(req.Form["GroupName"], Equals, []string{"websrv"}) | 465 » c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"}) |
466 c.Assert(err, IsNil) | 466 c.Assert(err, IsNil) |
467 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 467 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
468 } | 468 } |
469 | 469 |
470 func (s *S) TestCreateTags(c *C) { | 470 func (s *S) TestCreateTags(c *C) { |
471 testServer.PrepareResponse(200, nil, CreateTagsExample) | 471 testServer.PrepareResponse(200, nil, CreateTagsExample) |
472 | 472 |
473 resp, err := s.ec2.CreateTags([]string{"ami-1a2b3c4d", "i-7f4d3a2b"}, []
ec2.Tag{{"webserver", ""}, {"stack", "Production"}}) | 473 resp, err := s.ec2.CreateTags([]string{"ami-1a2b3c4d", "i-7f4d3a2b"}, []
ec2.Tag{{"webserver", ""}, {"stack", "Production"}}) |
474 | 474 |
475 req := testServer.WaitRequest() | 475 req := testServer.WaitRequest() |
476 » c.Assert(req.Form["ResourceId.1"], Equals, []string{"ami-1a2b3c4d"}) | 476 » c.Assert(req.Form["ResourceId.1"], DeepEquals, []string{"ami-1a2b3c4d"}) |
477 » c.Assert(req.Form["ResourceId.2"], Equals, []string{"i-7f4d3a2b"}) | 477 » c.Assert(req.Form["ResourceId.2"], DeepEquals, []string{"i-7f4d3a2b"}) |
478 » c.Assert(req.Form["Tag.1.Key"], Equals, []string{"webserver"}) | 478 » c.Assert(req.Form["Tag.1.Key"], DeepEquals, []string{"webserver"}) |
479 » c.Assert(req.Form["Tag.1.Value"], Equals, []string{""}) | 479 » c.Assert(req.Form["Tag.1.Value"], DeepEquals, []string{""}) |
480 » c.Assert(req.Form["Tag.2.Key"], Equals, []string{"stack"}) | 480 » c.Assert(req.Form["Tag.2.Key"], DeepEquals, []string{"stack"}) |
481 » c.Assert(req.Form["Tag.2.Value"], Equals, []string{"Production"}) | 481 » c.Assert(req.Form["Tag.2.Value"], DeepEquals, []string{"Production"}) |
482 | 482 |
483 c.Assert(err, IsNil) | 483 c.Assert(err, IsNil) |
484 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 484 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
485 } | 485 } |
486 | 486 |
487 func (s *S) TestStartInstances(c *C) { | 487 func (s *S) TestStartInstances(c *C) { |
488 testServer.PrepareResponse(200, nil, StartInstancesExample) | 488 testServer.PrepareResponse(200, nil, StartInstancesExample) |
489 | 489 |
490 resp, err := s.ec2.StartInstances("i-10a64379") | 490 resp, err := s.ec2.StartInstances("i-10a64379") |
491 req := testServer.WaitRequest() | 491 req := testServer.WaitRequest() |
492 | 492 |
493 » c.Assert(req.Form["Action"], Equals, []string{"StartInstances"}) | 493 » c.Assert(req.Form["Action"], DeepEquals, []string{"StartInstances"}) |
494 » c.Assert(req.Form["InstanceId.1"], Equals, []string{"i-10a64379"}) | 494 » c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"}) |
495 | 495 |
496 c.Assert(err, IsNil) | 496 c.Assert(err, IsNil) |
497 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 497 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
498 | 498 |
499 s0 := resp.StateChanges[0] | 499 s0 := resp.StateChanges[0] |
500 c.Assert(s0.InstanceId, Equals, "i-10a64379") | 500 c.Assert(s0.InstanceId, Equals, "i-10a64379") |
501 c.Assert(s0.CurrentState.Code, Equals, 0) | 501 c.Assert(s0.CurrentState.Code, Equals, 0) |
502 c.Assert(s0.CurrentState.Name, Equals, "pending") | 502 c.Assert(s0.CurrentState.Name, Equals, "pending") |
503 c.Assert(s0.PreviousState.Code, Equals, 80) | 503 c.Assert(s0.PreviousState.Code, Equals, 80) |
504 c.Assert(s0.PreviousState.Name, Equals, "stopped") | 504 c.Assert(s0.PreviousState.Name, Equals, "stopped") |
505 } | 505 } |
506 | 506 |
507 func (s *S) TestStopInstances(c *C) { | 507 func (s *S) TestStopInstances(c *C) { |
508 testServer.PrepareResponse(200, nil, StopInstancesExample) | 508 testServer.PrepareResponse(200, nil, StopInstancesExample) |
509 | 509 |
510 resp, err := s.ec2.StopInstances("i-10a64379") | 510 resp, err := s.ec2.StopInstances("i-10a64379") |
511 req := testServer.WaitRequest() | 511 req := testServer.WaitRequest() |
512 | 512 |
513 » c.Assert(req.Form["Action"], Equals, []string{"StopInstances"}) | 513 » c.Assert(req.Form["Action"], DeepEquals, []string{"StopInstances"}) |
514 » c.Assert(req.Form["InstanceId.1"], Equals, []string{"i-10a64379"}) | 514 » c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"}) |
515 | 515 |
516 c.Assert(err, IsNil) | 516 c.Assert(err, IsNil) |
517 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 517 c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
518 | 518 |
519 s0 := resp.StateChanges[0] | 519 s0 := resp.StateChanges[0] |
520 c.Assert(s0.InstanceId, Equals, "i-10a64379") | 520 c.Assert(s0.InstanceId, Equals, "i-10a64379") |
521 c.Assert(s0.CurrentState.Code, Equals, 64) | 521 c.Assert(s0.CurrentState.Code, Equals, 64) |
522 c.Assert(s0.CurrentState.Name, Equals, "stopping") | 522 c.Assert(s0.CurrentState.Name, Equals, "stopping") |
523 c.Assert(s0.PreviousState.Code, Equals, 16) | 523 c.Assert(s0.PreviousState.Code, Equals, 16) |
524 c.Assert(s0.PreviousState.Name, Equals, "running") | 524 c.Assert(s0.PreviousState.Name, Equals, "running") |
525 } | 525 } |
526 | 526 |
527 func (s *S) TestRebootInstances(c *C) { | 527 func (s *S) TestRebootInstances(c *C) { |
528 testServer.PrepareResponse(200, nil, RebootInstancesExample) | 528 testServer.PrepareResponse(200, nil, RebootInstancesExample) |
529 | 529 |
530 resp, err := s.ec2.RebootInstances("i-10a64379") | 530 resp, err := s.ec2.RebootInstances("i-10a64379") |
531 req := testServer.WaitRequest() | 531 req := testServer.WaitRequest() |
532 | 532 |
533 » c.Assert(req.Form["Action"], Equals, []string{"RebootInstances"}) | 533 » c.Assert(req.Form["Action"], DeepEquals, []string{"RebootInstances"}) |
534 » c.Assert(req.Form["InstanceId.1"], Equals, []string{"i-10a64379"}) | 534 » c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"}) |
535 | 535 |
536 » c.Assert(err, IsNil) | 536 » c.Assert(err, IsNil) |
537 » c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") | 537 » c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE") |
538 } | 538 } |
LEFT | RIGHT |