fog-aws 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/lib/fog/aws/compute.rb +16 -8
  4. data/lib/fog/aws/models/compute/address.rb +15 -1
  5. data/lib/fog/aws/models/compute/spot_request.rb +3 -2
  6. data/lib/fog/aws/models/compute/subnet.rb +4 -0
  7. data/lib/fog/aws/models/storage/file.rb +1 -1
  8. data/lib/fog/aws/parsers/compute/describe_route_tables.rb +3 -3
  9. data/lib/fog/aws/parsers/compute/move_address_to_vpc.rb +16 -0
  10. data/lib/fog/aws/parsers/compute/restore_address_to_classic.rb +16 -0
  11. data/lib/fog/aws/requests/compute/allocate_address.rb +2 -1
  12. data/lib/fog/aws/requests/compute/associate_address.rb +9 -1
  13. data/lib/fog/aws/requests/compute/cancel_spot_instance_requests.rb +17 -0
  14. data/lib/fog/aws/requests/compute/describe_instances.rb +1 -1
  15. data/lib/fog/aws/requests/compute/describe_network_interfaces.rb +4 -0
  16. data/lib/fog/aws/requests/compute/describe_route_tables.rb +6 -0
  17. data/lib/fog/aws/requests/compute/describe_spot_instance_requests.rb +33 -0
  18. data/lib/fog/aws/requests/compute/disassociate_address.rb +4 -1
  19. data/lib/fog/aws/requests/compute/move_address_to_vpc.rb +52 -0
  20. data/lib/fog/aws/requests/compute/request_spot_instances.rb +33 -22
  21. data/lib/fog/aws/requests/compute/restore_address_to_classic.rb +55 -0
  22. data/lib/fog/aws/requests/compute/run_instances.rb +26 -24
  23. data/lib/fog/aws/requests/compute/terminate_instances.rb +1 -1
  24. data/lib/fog/aws/requests/storage/delete_bucket_policy.rb +1 -1
  25. data/lib/fog/aws/requests/storage/get_bucket_object_versions.rb +1 -0
  26. data/lib/fog/aws/requests/storage/get_object.rb +4 -0
  27. data/lib/fog/aws/version.rb +1 -1
  28. data/tests/models/compute/address_tests.rb +20 -1
  29. data/tests/models/compute/subnet_tests.rb +9 -1
  30. data/tests/requests/compute/address_tests.rb +27 -4
  31. data/tests/requests/compute/route_tests.rb +1 -0
  32. data/tests/requests/compute/spot_instance_tests.rb +1 -3
  33. data/tests/requests/storage/object_tests.rb +72 -0
  34. data/tests/requests/storage/versioning_tests.rb +4 -0
  35. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a19f2beb9ccbc769e67d13f1439379dbe37d345
4
- data.tar.gz: d2c335bd1b9b390d49ecfc3ca651611801e1b063
3
+ metadata.gz: 5e768fc1ff288fe562ed0dd7c933c719dcdc33f4
4
+ data.tar.gz: 526f5ba1b58f9ba023ef1567b5a9cd79334f7212
5
5
  SHA512:
6
- metadata.gz: 292f539571c0e60a9cb39b999b2d3082c22dc49d664ef06aabab0adde68d6f40c8caf4a198ce1fc97ab47e77a82a564f65330c2fe7cb9525ab2134160a9fc225
7
- data.tar.gz: 124b4a4d8ea72f661e3d98cf9c215871d56b377fb7d614973a5bab32384dcdd64a8ace0a5fee6fbdcb354a6b8473d2c49c9b1052aedb8d8f8bf324cda0a69e1d
6
+ metadata.gz: 71f1af91375c2b20e8de2ca347fb5c1ae7e62f2606b5cab88813a89c3a5cdaeb41da1d30000caf47eb8e2d2e8ffe2b405a893944d23016bc5a8e085842e74a3c
7
+ data.tar.gz: 23faf3f32d79b4da048189a3e1a3261c62e30425091cc3964f467af4d3f0b12a835951a0ba56a03f18df2191086e2e94b8868616db4a39d44e5aa3e00d95f590
@@ -2,7 +2,22 @@
2
2
 
3
3
  ## [Unreleased](https://github.com/fog/fog-aws/tree/HEAD)
4
4
 
5
- [Full Changelog](https://github.com/fog/fog-aws/compare/v1.1.0...HEAD)
5
+ [Full Changelog](https://github.com/fog/fog-aws/compare/v1.2.0...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Fog mock does not mimmick real behaviour for some Excon errors [\#341](https://github.com/fog/fog-aws/issues/341)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Spot fixes [\#349](https://github.com/fog/fog-aws/pull/349) ([ehowe](https://github.com/ehowe))
14
+ - add natGatewayId to describe\_route\_tables [\#346](https://github.com/fog/fog-aws/pull/346) ([mliao2](https://github.com/mliao2))
15
+ - Fog mock accuracy, fixes \#341 [\#344](https://github.com/fog/fog-aws/pull/344) ([easkay](https://github.com/easkay))
16
+ - Subnet [\#343](https://github.com/fog/fog-aws/pull/343) ([ehowe](https://github.com/ehowe))
17
+ - Fix multipart upload [\#340](https://github.com/fog/fog-aws/pull/340) ([nobmurakita](https://github.com/nobmurakita))
18
+
19
+ ## [v1.2.0](https://github.com/fog/fog-aws/tree/v1.2.0) (2017-01-20)
20
+ [Full Changelog](https://github.com/fog/fog-aws/compare/v1.1.0...v1.2.0)
6
21
 
7
22
  **Closed issues:**
8
23
 
@@ -142,6 +142,7 @@ module Fog
142
142
  request :modify_subnet_attribute
143
143
  request :modify_volume_attribute
144
144
  request :modify_vpc_attribute
145
+ request :move_address_to_vpc
145
146
  request :purchase_reserved_instances_offering
146
147
  request :reboot_instances
147
148
  request :release_address
@@ -151,6 +152,7 @@ module Fog
151
152
  request :register_image
152
153
  request :request_spot_instances
153
154
  request :reset_network_interface_attribute
155
+ request :restore_address_to_classic
154
156
  request :revoke_security_group_egress
155
157
  request :revoke_security_group_ingress
156
158
  request :run_instances
@@ -177,13 +179,14 @@ module Fog
177
179
 
178
180
  class Mock
179
181
  MOCKED_TAG_TYPES = {
180
- 'ami' => 'image',
181
- 'i' => 'instance',
182
+ 'acl' => 'network_acl',
183
+ 'ami' => 'image',
184
+ 'igw' => 'internet_gateway',
185
+ 'i' => 'instance',
186
+ 'rtb' => 'route_table',
182
187
  'snap' => 'snapshot',
183
- 'vol' => 'volume',
184
- 'igw' => 'internet_gateway',
185
- 'acl' => 'network_acl',
186
- 'vpc' => 'vpc'
188
+ 'vol' => 'volume',
189
+ 'vpc' => 'vpc'
187
190
  }
188
191
 
189
192
  include Fog::AWS::CredentialFetcher::ConnectionMethods
@@ -285,7 +288,8 @@ module Fog
285
288
  "values" => ["5"],
286
289
  "attributeName" => "vpc-max-elastic-ips"
287
290
  }
288
- ]
291
+ ],
292
+ :spot_requests => {},
289
293
  }
290
294
  end
291
295
  end
@@ -386,6 +390,10 @@ module Fog
386
390
  if self.data[:vpcs].select {|v| v['vpcId'] == resource_id }.empty?
387
391
  raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the vpc does not exist"))
388
392
  end
393
+ when 'route_table'
394
+ unless self.data[:route_tables].detect { |r| r['routeTableId'] == resource_id }
395
+ raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the route table does not exist"))
396
+ end
389
397
  else
390
398
  unless self.data[:"#{type}s"][resource_id]
391
399
  raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the #{type} does not exist"))
@@ -459,7 +467,7 @@ module Fog
459
467
  @region = options[:region] ||= 'us-east-1'
460
468
  @instrumentor = options[:instrumentor]
461
469
  @instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute'
462
- @version = options[:version] || '2014-10-01'
470
+ @version = options[:version] || '2016-11-15'
463
471
 
464
472
  @use_iam_profile = options[:use_iam_profile]
465
473
  setup_credentials(options)
@@ -24,6 +24,16 @@ module Fog
24
24
  true
25
25
  end
26
26
 
27
+ def change_scope
28
+ if self.domain == 'standard'
29
+ service.move_address_to_vpc(self.identity)
30
+ wait_for { self.domain == 'vpc' }
31
+ else
32
+ service.restore_address_to_classic(self.identity)
33
+ wait_for { self.domain == 'standard' }
34
+ end
35
+ end
36
+
27
37
  def server=(new_server)
28
38
  if new_server
29
39
  associate(new_server)
@@ -63,7 +73,11 @@ module Fog
63
73
  @server = nil
64
74
  self.server_id = nil
65
75
  if persisted?
66
- service.disassociate_address(public_ip)
76
+ if association_id
77
+ service.disassociate_address(nil, association_id)
78
+ else
79
+ service.disassociate_address(public_ip)
80
+ end
67
81
  end
68
82
  end
69
83
  end
@@ -21,6 +21,7 @@ module Fog
21
21
 
22
22
  attribute :ebs_optimized, :aliases => 'LaunchSpecification.EbsOptimized'
23
23
  attribute :groups, :aliases => 'LaunchSpecification.SecurityGroup'
24
+ attribute :security_group_ids, :aliases => 'LaunchSpecification.SecurityGroupId'
24
25
  attribute :key_name, :aliases => 'LaunchSpecification.KeyName'
25
26
  attribute :availability_zone, :aliases => 'LaunchSpecification.Placement.AvailabilityZone'
26
27
  attribute :flavor_id, :aliases => 'LaunchSpecification.InstanceType'
@@ -37,7 +38,7 @@ module Fog
37
38
  attr_writer :iam_instance_profile_name, :iam_instance_profile_arn
38
39
 
39
40
  def initialize(attributes={})
40
- self.groups ||= ["default"]
41
+ self.groups ||= self.security_group_ids || ["default"]
41
42
  self.flavor_id ||= 't1.micro'
42
43
  self.image_id ||= begin
43
44
  self.username ||= 'ubuntu'
@@ -93,7 +94,7 @@ module Fog
93
94
  'LaunchSpecification.KeyName' => key_name,
94
95
  'LaunchSpecification.Monitoring.Enabled' => monitoring,
95
96
  'LaunchSpecification.Placement.AvailabilityZone' => availability_zone,
96
- 'LaunchSpecification.SecurityGroupId' => groups,
97
+ 'LaunchSpecification.SecurityGroupId' => security_group_ids || groups,
97
98
  'LaunchSpecification.EbsOptimized' => ebs_optimized,
98
99
  'LaunchSpecification.UserData' => user_data,
99
100
  'LaunchSpecification.SubnetId' => subnet_id,
@@ -16,6 +16,10 @@ module Fog
16
16
  state == 'available'
17
17
  end
18
18
 
19
+ def network_interfaces
20
+ service.network_interfaces.all('subnet-id' => [self.identity])
21
+ end
22
+
19
23
  # Removes an existing subnet
20
24
  #
21
25
  # subnet.destroy
@@ -210,7 +210,7 @@ module Fog
210
210
  options.merge!(encryption_headers)
211
211
 
212
212
  # With a single PUT operation you can upload objects up to 5 GB in size. Automatically set MP for larger objects.
213
- multipart_chunk_size=5242880 if !multipart_chunk_size && Fog::Storage.get_body_size(body) > 5368709120
213
+ self.multipart_chunk_size = 5242880 if !multipart_chunk_size && Fog::Storage.get_body_size(body) > 5368709120
214
214
 
215
215
  if multipart_chunk_size && Fog::Storage.get_body_size(body) >= multipart_chunk_size && body.respond_to?(:read)
216
216
  data = multipart_save(options)
@@ -7,7 +7,7 @@ module Fog
7
7
  @association = { 'routeTableAssociationId' => nil, 'routeTableId' => nil, 'subnetId' => nil, 'main' => false }
8
8
  @in_association_set = false
9
9
  @in_route_set = false
10
- @route = { 'destinationCidrBlock' => nil, 'gatewayId' => nil, 'instanceId' => nil, 'instanceOwnerId' => nil, 'networkInterfaceId' => nil, 'vpcPeeringConnectionId' => nil, 'state' => nil, 'origin' => nil }
10
+ @route = { 'destinationCidrBlock' => nil, 'gatewayId' => nil, 'instanceId' => nil, 'instanceOwnerId' => nil, 'networkInterfaceId' => nil, 'vpcPeeringConnectionId' => nil, 'natGatewayId' => nil, 'state' => nil, 'origin' => nil }
11
11
  @response = { 'routeTableSet' => [] }
12
12
  @tag = {}
13
13
  @route_table = { 'associationSet' => [], 'tagSet' => {}, 'routeSet' => [] }
@@ -54,11 +54,11 @@ module Fog
54
54
  end
55
55
  elsif @in_route_set
56
56
  case name
57
- when 'destinationCidrBlock', 'gatewayId', 'instanceId', 'instanceOwnerId', 'networkInterfaceId', 'vpcPeeringConnectionId', 'state', 'origin'
57
+ when 'destinationCidrBlock', 'gatewayId', 'instanceId', 'instanceOwnerId', 'networkInterfaceId', 'vpcPeeringConnectionId', 'natGatewayId', 'state', 'origin'
58
58
  @route[name] = value
59
59
  when 'item'
60
60
  @route_table['routeSet'] << @route
61
- @route = { 'destinationCidrBlock' => nil, 'gatewayId' => nil, 'instanceId' => nil, 'instanceOwnerId' => nil, 'networkInterfaceId' => nil, 'vpcPeeringConnectionId' => nil, 'state' => nil, 'origin' => nil }
61
+ @route = { 'destinationCidrBlock' => nil, 'gatewayId' => nil, 'instanceId' => nil, 'instanceOwnerId' => nil, 'networkInterfaceId' => nil, 'vpcPeeringConnectionId' => nil, 'natGatewayId' => nil, 'state' => nil, 'origin' => nil }
62
62
  when 'routeSet'
63
63
  @in_route_set = false
64
64
  end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Parsers
3
+ module Compute
4
+ module AWS
5
+ class MoveAddressToVpc < Fog::Parsers::Base
6
+ def end_element(name)
7
+ case name
8
+ when 'requestId', 'allocationId', 'status'
9
+ @response[name] = value
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Parsers
3
+ module Compute
4
+ module AWS
5
+ class RestoreAddressToClassic < Fog::Parsers::Base
6
+ def end_element(name)
7
+ case name
8
+ when 'requestId', 'publicIp', 'status'
9
+ @response[name] = value
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -40,7 +40,8 @@ module Fog
40
40
  data = {
41
41
  'instanceId' => nil,
42
42
  'publicIp' => public_ip,
43
- 'domain' => domain
43
+ 'domain' => domain,
44
+ :origin => domain
44
45
  }
45
46
 
46
47
  if domain == 'vpc'
@@ -80,6 +80,12 @@ module Fog
80
80
  if !allocation_ip.nil?
81
81
  public_ip = allocation_ip['publicIp']
82
82
  address = public_ip.nil? ? nil : self.data[:addresses][public_ip]
83
+
84
+ if instance['vpcId'] && vpc = self.data[:vpcs].detect { |v| v['vpcId'] == instance['vpcId'] }
85
+ if vpc['enableDnsHostnames']
86
+ instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip)
87
+ end
88
+ end
83
89
  end
84
90
  end
85
91
  if !address.nil?
@@ -103,10 +109,12 @@ module Fog
103
109
  'return' => true
104
110
  }
105
111
  elsif !params[:allocation_id].nil?
112
+ association_id = "eipassoc-#{Fog::Mock.random_hex(8)}"
113
+ address['associationId'] = association_id
106
114
  response.body = {
107
115
  'requestId' => Fog::AWS::Mock.request_id,
108
116
  'return' => true,
109
- 'associationId' => Fog::AWS::Mock.request_id
117
+ 'associationId' => association_id,
110
118
  }
111
119
  end
112
120
  response
@@ -27,6 +27,23 @@ module Fog
27
27
  }.merge!(params))
28
28
  end
29
29
  end
30
+
31
+ class Mock
32
+ def cancel_spot_instance_requests(spot_instance_request_id)
33
+ response = Excon::Response.new
34
+ spot_request = self.data[:spot_requests][spot_instance_request_id]
35
+
36
+ unless spot_request
37
+ raise Fog::Compute::AWS::NotFound.new("The spot instance request ID '#{spot_instance_request_id}' does not exist")
38
+ end
39
+
40
+ spot_request['fault']['code'] = 'request-cancelled'
41
+ spot_request['state'] = 'cancelled'
42
+
43
+ response.body = {'spotInstanceRequestSet' => [{'spotInstanceRequestId' => spot_instance_request_id, 'state' => 'cancelled'}], 'requestId' => Fog::AWS::Mock.request_id}
44
+ response
45
+ end
46
+ end
30
47
  end
31
48
  end
32
49
  end
@@ -249,7 +249,7 @@ module Fog
249
249
  'ownerId' => instance['ownerId'],
250
250
  'reservationId' => instance['reservationId']
251
251
  }
252
- reservation_set[instance['reservationId']]['instancesSet'] << instance.reject{|key,value| !['amiLaunchIndex', 'architecture', 'blockDeviceMapping', 'clientToken', 'dnsName', 'ebsOptimized', 'hypervisor', 'iamInstanceProfile', 'imageId', 'instanceId', 'instanceState', 'instanceType', 'ipAddress', 'kernelId', 'keyName', 'launchTime', 'monitoring', 'networkInterfaces', 'ownerId', 'placement', 'platform', 'privateDnsName', 'privateIpAddress', 'productCodes', 'ramdiskId', 'reason', 'rootDeviceName', 'rootDeviceType', 'stateReason', 'virtualizationType'].include?(key)}.merge('tagSet' => self.data[:tag_sets][instance['instanceId']])
252
+ reservation_set[instance['reservationId']]['instancesSet'] << instance.reject{|key,value| !['amiLaunchIndex', 'architecture', 'blockDeviceMapping', 'clientToken', 'dnsName', 'ebsOptimized', 'hypervisor', 'iamInstanceProfile', 'imageId', 'instanceId', 'instanceState', 'instanceType', 'ipAddress', 'kernelId', 'keyName', 'launchTime', 'monitoring', 'networkInterfaces', 'ownerId', 'placement', 'platform', 'privateDnsName', 'privateIpAddress', 'productCodes', 'ramdiskId', 'reason', 'rootDeviceName', 'rootDeviceType', 'spotInstanceRequestId', 'stateReason', 'subnetId', 'virtualizationType'].include?(key)}.merge('tagSet' => self.data[:tag_sets][instance['instanceId']])
253
253
  end
254
254
  end
255
255
 
@@ -68,6 +68,10 @@ module Fog
68
68
 
69
69
  network_interface_info = self.data[:network_interfaces].values
70
70
 
71
+ if subnet_filter = filters.delete('subnet-id')
72
+ filters['subnetId'] = subnet_filter
73
+ end
74
+
71
75
  for filter_key, filter_value in filters
72
76
  network_interface_info = network_interface_info.reject{|nic| ![*filter_value].include?(nic[filter_key])}
73
77
  end
@@ -24,6 +24,7 @@ module Fog
24
24
  # * 'instanceOwnerId'<~String> - The owner of the instance.
25
25
  # * 'networkInterfaceId'<~String> - The network interface ID.
26
26
  # * 'vpcPeeringConnectionId'<~String> - The peering connection ID.
27
+ # * 'natGatewayId'<~String> - The ID of a NAT gateway attached to your VPC.
27
28
  # * 'state'<~String> - The state of the route. The blackhole state indicates that the route's target isn't available.
28
29
  # * 'origin'<~String> - Describes how the route was created.
29
30
  # * 'associationSet'<~Array>:
@@ -73,6 +74,11 @@ module Fog
73
74
  end
74
75
  end
75
76
 
77
+ display_routes.each do |route|
78
+ tags = self.data[:tag_sets][route['routeTableId']]
79
+ route.merge!('tagSet' => tags) if tags
80
+ end
81
+
76
82
  Excon::Response.new(
77
83
  :status => 200,
78
84
  :body => {
@@ -41,6 +41,39 @@ module Fog
41
41
  }.merge!(params))
42
42
  end
43
43
  end
44
+
45
+ class Mock
46
+ def describe_spot_instance_requests(filters = {})
47
+ response = Excon::Response.new
48
+ spot_requests = self.data[:spot_requests].values
49
+
50
+ if id = Array(filters['spot-instance-request-id']).first
51
+ spot_requests = spot_requests.select { |r| r['spotInstanceRequestId'] == id }
52
+ end
53
+
54
+ spot_requests.select { |r| r['instanceId'].nil? }.each do |request|
55
+ run_instance_options = {
56
+ 'BlockDeviceMapping' => request['launchSpecification']['blockDeviceMapping'],
57
+ 'EbsOptimized' => request['launchSpecification']['ebsOptimized'],
58
+ 'KeyName' => request['launchSpecification']['keyName'],
59
+ 'SecurityGroupId' => request['launchSpecification']['groupSet'].first,
60
+ 'SpotInstanceRequestId' => request['spotInstanceRequestId'],
61
+ 'SubnetId' => request['launchSpecification']['subnetId']
62
+ }
63
+ instances = run_instances(request['launchSpecification']['imageId'], 1,1, run_instance_options).body['instancesSet']
64
+
65
+ request['instanceId'] = instances.first['instanceId']
66
+ request['state'] = 'active'
67
+ request['fault'] = {'code' => 'fulfilled', 'message' => 'Your Spot request is fulfilled.'}
68
+ request['launchedAvailabilityZone'] = instances.first['placement']['availabilityZone']
69
+
70
+ self.data[:spot_requests][request['spotInstanceRequestId']] = request
71
+ end
72
+
73
+ response.body = {'spotInstanceRequestSet' => spot_requests, 'requestId' => Fog::AWS::Mock.request_id}
74
+ response
75
+ end
76
+ end
44
77
  end
45
78
  end
46
79
  end
@@ -29,10 +29,13 @@ module Fog
29
29
  end
30
30
 
31
31
  class Mock
32
- def disassociate_address(public_ip)
32
+ def disassociate_address(public_ip, association_id=nil)
33
33
  response = Excon::Response.new
34
34
  response.status = 200
35
35
  if address = self.data[:addresses][public_ip]
36
+ if address['allocationId'] && association_id.nil?
37
+ raise Fog::Compute::AWS::Error.new("InvalidParameterValue => You must specify an association id when unmapping an address from a VPC instance")
38
+ end
36
39
  instance_id = address['instanceId']
37
40
  if instance = self.data[:instances][instance_id]
38
41
  instance['ipAddress'] = instance['originalIpAddress']
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Compute
3
+ class AWS
4
+ class Real
5
+ require 'fog/aws/parsers/compute/move_address_to_vpc'
6
+
7
+ # Move address to VPC scope
8
+ #
9
+ # === Returns
10
+ # * response<~Excon::Response>:
11
+ # * body<~<Hash>:
12
+ # * 'allocationId'<~String> - The allocation ID for the Elastic IP address
13
+ # * 'requestId'<~String> - Id of the request
14
+ # * 'status'<~String> - The status of the move of the IP address (MoveInProgress | InVpc | InClassic)
15
+
16
+ def move_address_to_vpc(public_ip)
17
+ request(
18
+ 'Action' => 'MoveAddressToVpc',
19
+ 'PublicIp' => public_ip,
20
+ :idempotent => true,
21
+ :parser => Fog::Parsers::Compute::AWS::MoveAddressToVpc.new
22
+ )
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def move_address_to_vpc(public_ip)
28
+ response = Excon::Response.new
29
+ allocation_id = "eip-#{Fog::Mock.random_hex(8)}"
30
+
31
+ address = self.data[:addresses][public_ip]
32
+
33
+ if address
34
+ address['domain'] = 'vpc'
35
+ address['allocationId'] = allocation_id
36
+
37
+ response.status = 200
38
+ response.body = {
39
+ 'requestId' => Fog::AWS::Mock.request_id,
40
+ 'allocationId' => allocation_id,
41
+ 'status' => "InVpc"
42
+ }
43
+
44
+ response
45
+ else
46
+ raise Fog::Compute::AWS::NotFound.new("Address does not exist")
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -71,7 +71,7 @@ module Fog
71
71
  options.merge!(Fog::AWS.indexed_param('LaunchSpecification.SecurityGroupId', [*security_group_ids]))
72
72
  end
73
73
  if options['LaunchSpecification.UserData']
74
- options['LaunchSpecification.UserData'] = Base64.encode64(options['LaunchSpecification.UserData'])
74
+ options['LaunchSpecification.UserData'] = Base64.encode64(options['LaunchSpecification.UserData']).chomp!
75
75
  end
76
76
 
77
77
  if options['ValidFrom'] && options['ValidFrom'].is_a?(Time)
@@ -95,6 +95,7 @@ module Fog
95
95
  class Mock
96
96
  def request_spot_instances(image_id, instance_type, spot_price, options = {})
97
97
  response = Excon::Response.new
98
+ id = Fog::AWS::Mock.spot_instance_request_id
98
99
 
99
100
  if (image_id && instance_type && spot_price)
100
101
  response.status = 200
@@ -139,32 +140,42 @@ module Fog
139
140
 
140
141
  launch_spec = {
141
142
  'iamInstanceProfile' => {},
142
- 'blockDeviceMapping' => [],
143
- 'groupSet' => [Fog::AWS::Mock.security_group_id],
143
+ 'blockDeviceMapping' => options['LaunchSpecification.BlockDeviceMapping'] || [],
144
+ 'groupSet' => options['LaunchSpecification.SecurityGroupId'] || ['default'],
144
145
  'imageId' => image_id,
145
146
  'instanceType' => instance_type,
146
- 'monitoring' => options['MonitoringEnabled'] || false,
147
- 'subnetId' => nil,
148
- 'ebsOptimized' => false,
149
- 'keyName' => options['KeyName'] || nil
147
+ 'monitoring' => options['LaunchSpecification.Monitoring.Enabled'] || false,
148
+ 'subnetId' => options['LaunchSpecification.SubnetId'] || nil,
149
+ 'ebsOptimized' => options['LaunchSpecification.EbsOptimized'] || false,
150
+ 'keyName' => options['LaunchSpecification.KeyName'] || nil
150
151
  }
151
152
 
153
+ if iam_arn = options['LaunchSpecification.IamInstanceProfile.Arn']
154
+ launch_spec['iamInstanceProfile'].merge!('Arn' => iam_arn)
155
+ end
156
+
157
+ if iam_name = options['LaunchSpecification.IamInstanceProfile.Name']
158
+ launch_spec['iamInstanceProfile'].merge!('Name' => iam_name)
159
+ end
160
+
161
+ spot_request = {
162
+ 'launchSpecification' => launch_spec,
163
+ 'spotInstanceRequestId' => id,
164
+ 'spotPrice' => spot_price,
165
+ 'type' => options['Type'] || 'one-time',
166
+ 'state' => 'open',
167
+ 'fault' => {
168
+ 'code' => 'pending-evaluation',
169
+ 'message' => 'Your Spot request has been submitted for review, and is pending evaluation.'
170
+ },
171
+ 'createTime' => Time.now,
172
+ 'productDescription' => 'Linux/UNIX'
173
+ }
174
+
175
+ self.data[:spot_requests][id] = spot_request
176
+
152
177
  response.body = {
153
- 'spotInstanceRequestSet' => [
154
- {
155
- 'launchSpecification' => launch_spec,
156
- 'spotInstanceRequestId' => Fog::AWS::Mock.spot_instance_request_id,
157
- 'spotPrice' => spot_price,
158
- 'type' => options['Type'] || 'one-time',
159
- 'state' => 'open',
160
- 'fault' => {
161
- 'code' => 'pending-evaluation',
162
- 'message' => 'Your Spot request has been submitted for review, and is pending evaluation.'
163
- },
164
- 'createTime' => Time.now,
165
- 'productDescription' => 'Linux/UNIX'
166
- }
167
- ],
178
+ 'spotInstanceRequestSet' => [spot_request],
168
179
  'requestId' => Fog::AWS::Mock.request_id
169
180
  }
170
181
 
@@ -0,0 +1,55 @@
1
+ module Fog
2
+ module Compute
3
+ class AWS
4
+ class Real
5
+ require 'fog/aws/parsers/compute/restore_address_to_classic'
6
+
7
+ # Move address from VPC to Classic
8
+ #
9
+ # === Returns
10
+ # * response<~Excon::Response>:
11
+ # * body<~<Hash>:
12
+ # * 'publicIp'<~String> - IP address
13
+ # * 'requestId'<~String> - Id of the request
14
+ # * 'status'<~String> - The status of the move of the IP address (MoveInProgress | InVpc | InClassic)
15
+
16
+ def restore_address_to_classic(public_ip)
17
+ request(
18
+ 'Action' => 'RestoreAddressToClassic',
19
+ 'PublicIp' => public_ip,
20
+ :idempotent => true,
21
+ :parser => Fog::Parsers::Compute::AWS::RestoreAddressToClassic.new
22
+ )
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def restore_address_to_classic(public_ip)
28
+ response = Excon::Response.new
29
+
30
+ address = self.data[:addresses][public_ip]
31
+
32
+ if address
33
+ if address[:origin] == 'vpc'
34
+ raise Fog::Compute::AWS::Error.new("InvalidState => You cannot migrate an Elastic IP address that was originally allocated for use in EC2-VPC to EC2-Classic.")
35
+ end
36
+
37
+ address['domain'] = 'standard'
38
+ address.delete("allocationId")
39
+
40
+ response.status = 200
41
+ response.body = {
42
+ 'requestId' => Fog::AWS::Mock.request_id,
43
+ 'publicIp' => public_ip,
44
+ 'status' => "InClassic"
45
+ }
46
+
47
+ response
48
+ else
49
+ raise Fog::Compute::AWS::NotFound.new("Address does not exist")
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -217,30 +217,32 @@ module Fog
217
217
  end
218
218
 
219
219
  instance = {
220
- 'amiLaunchIndex' => i,
221
- 'associatePublicIP' => options['associatePublicIP'] || false,
222
- 'architecture' => 'i386',
223
- 'blockDeviceMapping' => block_device_mapping,
224
- 'networkInterfaces' => network_interfaces,
225
- 'clientToken' => options['clientToken'],
226
- 'dnsName' => nil,
227
- 'ebsOptimized' => options['EbsOptimized'] || false,
228
- 'hypervisor' => 'xen',
229
- 'imageId' => image_id,
230
- 'instanceId' => instance_id,
231
- 'instanceState' => { 'code' => 0, 'name' => 'pending' },
232
- 'instanceType' => options['InstanceType'] || 'm1.small',
233
- 'kernelId' => options['KernelId'] || Fog::AWS::Mock.kernel_id,
234
- 'keyName' => options['KeyName'],
235
- 'launchTime' => Time.now,
236
- 'monitoring' => { 'state' => options['Monitoring.Enabled'] || false },
237
- 'placement' => { 'availabilityZone' => availability_zone, 'groupName' => nil, 'tenancy' => options['Placement.Tenancy'] || 'default' },
238
- 'privateDnsName' => nil,
239
- 'productCodes' => [],
240
- 'reason' => nil,
241
- 'rootDeviceName' => block_device_mapping.first && block_device_mapping.first["deviceName"],
242
- 'rootDeviceType' => 'instance-store',
243
- 'virtualizationType' => 'paravirtual'
220
+ 'amiLaunchIndex' => i,
221
+ 'associatePublicIP' => options['associatePublicIP'] || false,
222
+ 'architecture' => 'i386',
223
+ 'blockDeviceMapping' => block_device_mapping,
224
+ 'networkInterfaces' => network_interfaces,
225
+ 'clientToken' => options['clientToken'],
226
+ 'dnsName' => nil,
227
+ 'ebsOptimized' => options['EbsOptimized'] || false,
228
+ 'hypervisor' => 'xen',
229
+ 'imageId' => image_id,
230
+ 'instanceId' => instance_id,
231
+ 'instanceState' => { 'code' => 0, 'name' => 'pending' },
232
+ 'instanceType' => options['InstanceType'] || 'm1.small',
233
+ 'kernelId' => options['KernelId'] || Fog::AWS::Mock.kernel_id,
234
+ 'keyName' => options['KeyName'],
235
+ 'launchTime' => Time.now,
236
+ 'monitoring' => { 'state' => options['Monitoring.Enabled'] || false },
237
+ 'placement' => { 'availabilityZone' => availability_zone, 'groupName' => nil, 'tenancy' => options['Placement.Tenancy'] || 'default' },
238
+ 'privateDnsName' => nil,
239
+ 'productCodes' => [],
240
+ 'reason' => nil,
241
+ 'rootDeviceName' => block_device_mapping.first && block_device_mapping.first["deviceName"],
242
+ 'rootDeviceType' => 'instance-store',
243
+ 'spotInstanceRequestId' => options['SpotInstanceRequestId'],
244
+ 'subnetId' => options['SubnetId'],
245
+ 'virtualizationType' => 'paravirtual'
244
246
  }
245
247
  instances_set << instance
246
248
  self.data[:instances][instance_id] = instance.merge({
@@ -73,7 +73,7 @@ module Fog
73
73
 
74
74
  describe_addresses.body['addressesSet'].each do |address|
75
75
  if instance_id.include?(address['instanceId'])
76
- disassociate_address(address['publicIp'])
76
+ disassociate_address(address['publicIp'], address['associationId'])
77
77
  end
78
78
  end
79
79
 
@@ -32,7 +32,7 @@ module Fog
32
32
  response.status = 200
33
33
  end
34
34
  else
35
- raise Fog::AWS::IAM::NotFound.new("The bucket with name #{bucket_name} cannot be found.")
35
+ raise(Excon::Errors.status_error({:expects => 200}, response))
36
36
  end
37
37
  end
38
38
  end
@@ -85,6 +85,7 @@ module Fog
85
85
  'HostId' => Fog::Mock.random_base64(65)
86
86
  }
87
87
  }
88
+ raise(Excon::Errors.status_error({:expects => 200}, response))
88
89
 
89
90
  # Valid case.
90
91
  # TODO: (nirvdrum 12/15/11) It's not clear to me how to actually use version-id-marker, so I didn't implement it below.
@@ -86,12 +86,16 @@ module Fog
86
86
  if (object && !object[:delete_marker])
87
87
  if options['If-Match'] && options['If-Match'] != object['ETag']
88
88
  response.status = 412
89
+ raise(Excon::Errors.status_error({:expects => 200}, response))
89
90
  elsif options['If-Modified-Since'] && options['If-Modified-Since'] >= Time.parse(object['Last-Modified'])
90
91
  response.status = 304
92
+ raise(Excon::Errors.status_error({:expects => 200}, response))
91
93
  elsif options['If-None-Match'] && options['If-None-Match'] == object['ETag']
92
94
  response.status = 304
95
+ raise(Excon::Errors.status_error({:expects => 200}, response))
93
96
  elsif options['If-Unmodified-Since'] && options['If-Unmodified-Since'] < Time.parse(object['Last-Modified'])
94
97
  response.status = 412
98
+ raise(Excon::Errors.status_error({:expects => 200}, response))
95
99
  else
96
100
  response.status = 200
97
101
  for key, value in object
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AWS
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -16,9 +16,28 @@ Shindo.tests("Fog::Compute[:aws] | address", ['aws']) do
16
16
  end
17
17
  end
18
18
 
19
+ tests("#change_scope") do
20
+ test('to vpc') do
21
+ @instance.change_scope
22
+ @instance.domain == 'vpc'
23
+ end
24
+
25
+ test('to classic') do
26
+ @instance.change_scope
27
+ @instance.domain == 'standard'
28
+ end
29
+
30
+ # merge_attributes requires this
31
+ @instance = Fog::Compute[:aws].addresses.get(@instance.identity)
32
+ end
33
+
19
34
  @server.destroy
20
35
 
21
36
  end
22
37
 
23
- model_tests(Fog::Compute[:aws].addresses, { :domain => "vpc" }, true)
38
+ model_tests(Fog::Compute[:aws].addresses, { :domain => "vpc" }, true) do
39
+ tests("#change_scope").raises(Fog::Compute::AWS::Error) do
40
+ @instance.change_scope
41
+ end
42
+ end
24
43
  end
@@ -1,5 +1,13 @@
1
1
  Shindo.tests("Fog::Compute[:aws] | subnet", ['aws']) do
2
2
  @vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24')
3
- model_tests(Fog::Compute[:aws].subnets, {:vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28', :availability_zone => 'us-east-1b'}, true)
3
+ model_tests(Fog::Compute[:aws].subnets, {:vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28', :availability_zone => 'us-east-1b'}, true) do
4
+ @ni = Fog::Compute[:aws].network_interfaces.create(:description => 'fog eni', :name => uniq_id('fog-eni'), :subnet_id => @instance.identity)
5
+
6
+ tests("#network_interfaces") do
7
+ returns([@ni]) { @instance.network_interfaces.to_a }
8
+ end
9
+
10
+ @ni.destroy
11
+ end
4
12
  @vpc.destroy
5
13
  end
@@ -34,6 +34,15 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do
34
34
  data
35
35
  end
36
36
 
37
+ # the following 2 tests imply that your account is old enough that the tested region does not have a default VPC. These methods do not work with an ip created in a vpc. this probably means that they will probably fail if they aren't mocked
38
+ tests("#move_address_to_vpc('#{@public_ip}')").formats({'status' => String, 'allocationId' => String, 'requestId' => String}) do
39
+ compute.move_address_to_vpc(@public_ip).body
40
+ end
41
+
42
+ tests("#restore_address_to_classic('#{@public_ip}')").formats({'status' => String, 'publicIp' => String, 'requestId' => String}) do
43
+ compute.restore_address_to_classic(@public_ip).body
44
+ end
45
+
37
46
  tests('#describe_addresses').formats(@addresses_format) do
38
47
  compute.describe_addresses.body
39
48
  end
@@ -42,11 +51,11 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do
42
51
  compute.describe_addresses('public-ip' => @public_ip).body
43
52
  end
44
53
 
45
- tests("#associate_addresses('#{@server.identity}', '#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do
54
+ tests("#associate_address('#{@server.identity}', '#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do
46
55
  compute.associate_address(@server.identity, @public_ip).body
47
56
  end
48
57
 
49
- tests("#associate_addresses({:instance_id=>'#{@server.identity}', :public_ip=>'#{@public_ip}'})").formats(AWS::Compute::Formats::BASIC) do
58
+ tests("#associate_address({:instance_id=>'#{@server.identity}', :public_ip=>'#{@public_ip}'})").formats(AWS::Compute::Formats::BASIC) do
50
59
  compute.associate_address({:instance_id=>@server.identity,:public_ip=> @public_ip}).body
51
60
  end
52
61
 
@@ -54,18 +63,28 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do
54
63
  compute.disassociate_address(@public_ip).body
55
64
  end
56
65
 
57
- tests("#associate_addresses('#{@server.id}', nil, nil, '#{@vpc_allocation_id}')").formats(AWS::Compute::Formats::BASIC) do
66
+ tests("#associate_address('#{@server.id}', nil, nil, '#{@vpc_allocation_id}')").formats(AWS::Compute::Formats::BASIC) do
58
67
  compute.associate_address(@server.id, nil, nil, @vpc_allocation_id).body
59
68
  end
60
69
 
61
- tests("#associate_addresses({:instance_id=>'#{@server.id}', :allocation_id=>'#{@vpc_allocation_id}'})").formats(AWS::Compute::Formats::BASIC) do
70
+ $pry = true
71
+ tests("#associate_address({:instance_id=>'#{@server.id}', :allocation_id=>'#{@vpc_allocation_id}'})").formats(AWS::Compute::Formats::BASIC) do
62
72
  compute.associate_address({:instance_id=>@server.id, :allocation_id=>@vpc_allocation_id}).body
63
73
  end
64
74
 
75
+ tests("#disassociate_address('#{@vpc_public_ip}')").raises(Fog::Compute::AWS::Error) do
76
+ compute.disassociate_address(@vpc_public_ip)
77
+ end
78
+
65
79
  tests("#release_address('#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do
66
80
  compute.release_address(@public_ip).body
67
81
  end
68
82
 
83
+ tests("#disassociate_address('#{@vpc_public_ip}', '#{@vpc_allocation_id}')").formats(AWS::Compute::Formats::BASIC) do
84
+ address = compute.describe_addresses('public-ip' => @vpc_public_ip).body['addressesSet'].first
85
+ compute.disassociate_address(@vpc_public_ip, address['associationId']).body
86
+ end
87
+
69
88
  tests("#release_address('#{@vpc_allocation_id}')").formats(AWS::Compute::Formats::BASIC) do
70
89
  compute.release_address(@vpc_allocation_id).body
71
90
  end
@@ -88,6 +107,10 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do
88
107
  compute.associate_address({:instance_id =>'i-00000000', :public_ip =>'127.0.0.1'})
89
108
  end
90
109
 
110
+ tests("#restore_address_to_classic('#{@vpc_address.identity}')").raises(Fog::Compute::AWS::Error) do
111
+ compute.restore_address_to_classic(@vpc_address.identity)
112
+ end
113
+
91
114
  tests("#disassociate_addresses('127.0.0.1') raises BadRequest error").raises(Fog::Compute::AWS::Error) do
92
115
  compute.disassociate_address('127.0.0.1')
93
116
  end
@@ -31,6 +31,7 @@ Shindo.tests('Fog::Compute[:aws] | route table requests', ['aws']) do
31
31
  'instanceOwnerId' => Fog::Nullable::String,
32
32
  'networkInterfaceId' => Fog::Nullable::String,
33
33
  'vpcPeeringConnectionId' => Fog::Nullable::String,
34
+ 'natGatewayId' => Fog::Nullable::String,
34
35
  'state' => String,
35
36
  'origin' => String
36
37
  }],
@@ -42,10 +42,8 @@ Shindo.tests('Fog::Compute[:aws] | spot instance requests', ['aws']) do
42
42
  data
43
43
  end
44
44
 
45
- pending if Fog.mocking?
46
-
47
45
  tests("#describe_spot_instance_requests").formats(@spot_instance_requests_format) do
48
- Fog::Compute[:aws].describe_spot_instance_requests('spot-instance-request-id' => [@spot_instance_request_id]).body
46
+ data = Fog::Compute[:aws].describe_spot_instance_requests('spot-instance-request-id' => [@spot_instance_request_id]).body
49
47
  end
50
48
 
51
49
  tests("#cancel_spot_instance_requests('#{@spot_instance_request_id}')").formats(@cancel_spot_instance_request_format) do
@@ -42,6 +42,10 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
42
42
  data
43
43
  end
44
44
 
45
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Match' => Digest::MD5.hexdigest(lorem_file) })").returns(lorem_file.read) do
46
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Match' => Digest::MD5.hexdigest(lorem_file.read) }).body
47
+ end
48
+
45
49
  tests("#get_object('#{@directory.identity}', 'fog_object', {'Range' => 'bytes=0-20'})").returns(lorem_file.read[0..20]) do
46
50
  Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', {'Range' => 'bytes=0-20'}).body
47
51
  end
@@ -50,10 +54,42 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
50
54
  Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', {'Range' => 'bytes=0-0'}).body
51
55
  end
52
56
 
57
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Match' => Digest::MD5.hexdigest(lorem_file.read) })").returns(lorem_file.read) do
58
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Match' => Digest::MD5.hexdigest(lorem_file.read) }).body
59
+ end
60
+
61
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Modified-Since' => Time.now - 60 })").returns(lorem_file.read) do
62
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Modified-Since' => Time.now - 60 }).body
63
+ end
64
+
65
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-None-Match' => 'invalid_etag' })").returns(lorem_file.read) do
66
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-None-Match' => 'invalid_etag' }).body
67
+ end
68
+
69
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Unmodified-Since' => Time.now + 60 })").returns(lorem_file.read) do
70
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Unmodified-Since' => Time.now + 60 }).body
71
+ end
72
+
53
73
  tests("#head_object('#{@directory.identity}', 'fog_object')").succeeds do
54
74
  Fog::Storage[:aws].head_object(@directory.identity, 'fog_object')
55
75
  end
56
76
 
77
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-Match' => Digest::MD5.hexdigest(lorem_file.read) })").succeeds do
78
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-Match' => Digest::MD5.hexdigest(lorem_file.read) })
79
+ end
80
+
81
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-Modified-Since' => Time.now - 60 })").succeeds do
82
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-Modified-Since' => Time.now - 60 })
83
+ end
84
+
85
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-None-Match' => 'invalid_etag' })").succeeds do
86
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-None-Match' => 'invalid_etag' })
87
+ end
88
+
89
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-Unmodified-Since' => Time.now + 60 })").succeeds do
90
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-Unmodified-Since' => Time.now + 60 })
91
+ end
92
+
57
93
  tests("#post_object_restore('#{@directory.identity}', 'fog_object')").succeeds do
58
94
  pending unless Fog.mocking?
59
95
  Fog::Storage[:aws].post_object_restore(@directory.identity, 'fog_object')
@@ -168,6 +204,42 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
168
204
  Fog::Storage[:aws].get_object(@directory.identity, 'fog_non_object')
169
205
  end
170
206
 
207
+ Fog::Storage[:aws].put_object(@directory.identity, 'fog_object', lorem_file)
208
+
209
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Match' => 'invalid_etag' })").raises(Excon::Errors::PreconditionFailed) do
210
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Match' => 'invalid_etag' })
211
+ end
212
+
213
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Modified-Since' => Time.now })").raises(Excon::Errors::NotModified) do
214
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Modified-Since' => Time.now })
215
+ end
216
+
217
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-None-Match' => Digest::MD5.hexdigest(lorem_file.read) })").raises(Excon::Errors::NotModified) do
218
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-None-Match' => Digest::MD5.hexdigest(lorem_file.read) })
219
+ end
220
+
221
+ tests("#get_object('#{@directory.identity}', 'fog_object', { 'If-Unmodified-Since' => Time.now - 60 })").raises(Excon::Errors::PreconditionFailed) do
222
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object', { 'If-Unmodified-Since' => Time.now - 60 })
223
+ end
224
+
225
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-Match' => 'invalid_etag' })").raises(Excon::Errors::PreconditionFailed) do
226
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-Match' => 'invalid_etag' })
227
+ end
228
+
229
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-Modified-Since' => Time.now })").raises(Excon::Errors::NotModified) do
230
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-Modified-Since' => Time.now })
231
+ end
232
+
233
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-None-Match' => Digest::MD5.hexdigest(lorem_file.read) })").raises(Excon::Errors::NotModified) do
234
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-None-Match' => Digest::MD5.hexdigest(lorem_file.read) })
235
+ end
236
+
237
+ tests("#head_object('#{@directory.identity}', 'fog_object', { 'If-Unmodified-Since' => Time.now - 60 })").raises(Excon::Errors::PreconditionFailed) do
238
+ Fog::Storage[:aws].head_object(@directory.identity, 'fog_object', { 'If-Unmodified-Since' => Time.now - 60 })
239
+ end
240
+
241
+ Fog::Storage[:aws].delete_object(@directory.identity, 'fog_object')
242
+
171
243
  tests("#head_object(fognonbucket, 'fog_non_object')").raises(Excon::Errors::NotFound) do
172
244
  Fog::Storage[:aws].head_object(fognonbucket, 'fog_non_object')
173
245
  end
@@ -229,6 +229,10 @@ Shindo.tests('Fog::Storage[:aws] | versioning', ["aws"]) do
229
229
  Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'bad_value')
230
230
  end
231
231
 
232
+ tests("#get_bucket_object_versions('#{@aws_bucket_name}', { 'version-id-marker' => 'foo' })").raises(Excon::Errors::BadRequest) do
233
+ Fog::Storage[:aws].get_bucket_object_versions(@aws_bucket_name, { 'version-id-marker' => 'foo' })
234
+ end
235
+
232
236
  tests("#put_bucket_versioning('fognonbucket', 'Enabled')").raises(Excon::Errors::NotFound) do
233
237
  Fog::Storage[:aws].put_bucket_versioning('fognonbucket', 'Enabled')
234
238
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-20 00:00:00.000000000 Z
12
+ date: 2017-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -465,11 +465,13 @@ files:
465
465
  - lib/fog/aws/parsers/compute/import_key_pair.rb
466
466
  - lib/fog/aws/parsers/compute/modify_subnet_attribute.rb
467
467
  - lib/fog/aws/parsers/compute/monitor_unmonitor_instances.rb
468
+ - lib/fog/aws/parsers/compute/move_address_to_vpc.rb
468
469
  - lib/fog/aws/parsers/compute/network_acl_parser.rb
469
470
  - lib/fog/aws/parsers/compute/network_interface_parser.rb
470
471
  - lib/fog/aws/parsers/compute/purchase_reserved_instances_offering.rb
471
472
  - lib/fog/aws/parsers/compute/register_image.rb
472
473
  - lib/fog/aws/parsers/compute/replace_network_acl_association.rb
474
+ - lib/fog/aws/parsers/compute/restore_address_to_classic.rb
473
475
  - lib/fog/aws/parsers/compute/run_instances.rb
474
476
  - lib/fog/aws/parsers/compute/spot_datafeed_subscription.rb
475
477
  - lib/fog/aws/parsers/compute/spot_instance_requests.rb
@@ -947,6 +949,7 @@ files:
947
949
  - lib/fog/aws/requests/compute/modify_volume_attribute.rb
948
950
  - lib/fog/aws/requests/compute/modify_vpc_attribute.rb
949
951
  - lib/fog/aws/requests/compute/monitor_instances.rb
952
+ - lib/fog/aws/requests/compute/move_address_to_vpc.rb
950
953
  - lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb
951
954
  - lib/fog/aws/requests/compute/reboot_instances.rb
952
955
  - lib/fog/aws/requests/compute/register_image.rb
@@ -956,6 +959,7 @@ files:
956
959
  - lib/fog/aws/requests/compute/replace_route.rb
957
960
  - lib/fog/aws/requests/compute/request_spot_instances.rb
958
961
  - lib/fog/aws/requests/compute/reset_network_interface_attribute.rb
962
+ - lib/fog/aws/requests/compute/restore_address_to_classic.rb
959
963
  - lib/fog/aws/requests/compute/revoke_security_group_egress.rb
960
964
  - lib/fog/aws/requests/compute/revoke_security_group_ingress.rb
961
965
  - lib/fog/aws/requests/compute/run_instances.rb