fog 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +4 -4
  3. data/benchs/fog_vs.rb +8 -37
  4. data/fog.gemspec +6 -12
  5. data/lib/fog.rb +1 -1
  6. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +4 -3
  7. data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -2
  8. data/lib/fog/aws/s3.rb +8 -4
  9. data/lib/fog/rackspace/models/servers/image.rb +5 -0
  10. data/tests/aws/helper.rb +33 -0
  11. data/tests/aws/requests/ec2/address_tests.rb +40 -47
  12. data/tests/aws/requests/ec2/availability_zone_tests.rb +23 -0
  13. data/tests/aws/requests/ec2/key_pair_tests.rb +44 -0
  14. data/tests/aws/requests/ec2/region_tests.rb +22 -0
  15. data/tests/aws/requests/ec2/security_group_tests.rb +112 -0
  16. data/tests/aws/requests/ec2/snapshot_tests.rb +14 -21
  17. data/tests/aws/requests/ec2/volume_tests.rb +26 -40
  18. data/tests/helper.rb +50 -35
  19. data/tests/rackspace/helper.rb +2 -0
  20. data/tests/rackspace/requests/servers/create_image_tests.rb +11 -13
  21. data/tests/rackspace/requests/servers/create_server_tests.rb +9 -11
  22. data/tests/rackspace/requests/servers/delete_image_tests.rb +9 -15
  23. data/tests/rackspace/requests/servers/delete_server_tests.rb +6 -10
  24. data/tests/rackspace/requests/servers/get_flavor_details_tests.rb +4 -10
  25. data/tests/rackspace/requests/servers/get_image_details_tests.rb +4 -10
  26. data/tests/rackspace/requests/servers/get_server_details_tests.rb +7 -14
  27. data/tests/rackspace/requests/servers/list_addresses_tests.rb +7 -14
  28. data/tests/rackspace/requests/servers/list_flavors_detail_tests.rb +2 -6
  29. data/tests/rackspace/requests/servers/list_flavors_tests.rb +2 -6
  30. data/tests/rackspace/requests/servers/list_images_detail_tests.rb +2 -6
  31. data/tests/rackspace/requests/servers/list_images_tests.rb +2 -6
  32. data/tests/rackspace/requests/servers/list_private_addresses_tests.rb +7 -14
  33. data/tests/rackspace/requests/servers/list_public_addresses_tests.rb +7 -14
  34. data/tests/rackspace/requests/servers/list_servers_detail_tests.rb +5 -10
  35. data/tests/rackspace/requests/servers/list_servers_tests.rb +5 -10
  36. data/tests/rackspace/requests/servers/reboot_server_tests.rb +11 -19
  37. data/tests/rackspace/requests/servers/update_server_tests.rb +7 -14
  38. data/tests/slicehost/requests/create_slice_tests.rb +6 -11
  39. data/tests/slicehost/requests/delete_slice_tests.rb +4 -9
  40. data/tests/slicehost/requests/get_backups_tests.rb +2 -6
  41. data/tests/slicehost/requests/get_flavor_tests.rb +4 -10
  42. data/tests/slicehost/requests/get_flavors_tests.rb +2 -6
  43. data/tests/slicehost/requests/get_image_tests.rb +4 -10
  44. data/tests/slicehost/requests/get_images_tests.rb +2 -6
  45. data/tests/slicehost/requests/get_slice_tests.rb +7 -15
  46. data/tests/slicehost/requests/get_slices_tests.rb +2 -6
  47. data/tests/slicehost/requests/reboot_slice_tests.rb +8 -16
  48. metadata +7 -13
  49. data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +0 -36
  50. data/spec/aws/requests/ec2/create_key_pair_spec.rb +0 -36
  51. data/spec/aws/requests/ec2/create_security_group_spec.rb +0 -34
  52. data/spec/aws/requests/ec2/delete_key_pair_spec.rb +0 -21
  53. data/spec/aws/requests/ec2/delete_security_group_spec.rb +0 -26
  54. data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +0 -23
  55. data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +0 -42
  56. data/spec/aws/requests/ec2/describe_regions_spec.rb +0 -21
  57. data/spec/aws/requests/ec2/describe_security_groups_spec.rb +0 -51
  58. data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +0 -32
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ gem 'net-ssh', ">= 0"
9
9
  gem 'nokogiri', ">= 0"
10
10
  gem 'ruby-hmac', ">= 0"
11
11
  gem 'rspec', '>= 0'
12
- gem 'shindo', '>= 0'
12
+ gem 'shindo', '>= 0.1.2'
13
13
  gem 'builder', '>= 0'
@@ -39,7 +39,7 @@ dependencies:
39
39
  shindo:
40
40
  group:
41
41
  - :default
42
- version: ">= 0"
42
+ version: ">= 0.1.2"
43
43
  nokogiri:
44
44
  group:
45
45
  - :default
@@ -54,7 +54,7 @@ specs:
54
54
  - formatador:
55
55
  version: 0.0.14
56
56
  - gestalt:
57
- version: 0.0.6
57
+ version: 0.0.11
58
58
  - json:
59
59
  version: 1.4.3
60
60
  - mime-types:
@@ -68,8 +68,8 @@ specs:
68
68
  - ruby-hmac:
69
69
  version: 0.4.0
70
70
  - shindo:
71
- version: 0.0.18
72
- hash: 9a6ccfd107913e3f8ca98af1fe437f5d2b7b112a
71
+ version: 0.1.2
72
+ hash: 4e55927c1be02ee00fc3353e71caecdebd9d4817
73
73
  sources:
74
74
  - Rubygems:
75
75
  uri: http://gemcutter.org
@@ -5,20 +5,20 @@ require 'right_aws'
5
5
 
6
6
  require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
7
7
 
8
- data = File.open(File.join(File.dirname(__FILE__), '..', 'spec', 'credentials.yml')).read
9
- config = YAML.load(data)
8
+ data = File.open(File.expand_path('~/.fog')).read
9
+ config = YAML.load(data)[:default]
10
10
  fog = Fog::AWS::S3.new(
11
- :aws_access_key_id => config['aws_access_key_id'],
12
- :aws_secret_access_key => config['aws_secret_access_key']
11
+ :aws_access_key_id => config[:aws_access_key_id],
12
+ :aws_secret_access_key => config[:aws_secret_access_key]
13
13
  )
14
14
  raws = RightAws::S3Interface.new(
15
- config['aws_access_key_id'],
16
- config['aws_secret_access_key']
15
+ config[:aws_access_key_id],
16
+ config[:aws_secret_access_key]
17
17
  )
18
18
  raws.logger.level = 3 # ERROR
19
19
  awss3 = AWS::S3::Base.establish_connection!(
20
- :access_key_id => config['aws_access_key_id'],
21
- :secret_access_key => config['aws_secret_access_key'],
20
+ :access_key_id => config[:aws_access_key_id],
21
+ :secret_access_key => config[:aws_secret_access_key],
22
22
  :persistent => true
23
23
  )
24
24
 
@@ -104,32 +104,3 @@ Benchmark.bmbm(25) do |bench|
104
104
  end
105
105
  end
106
106
  end
107
-
108
- # Rehearsal ------------------------------------------------------------
109
- # fog.put_bucket 0.010000 0.000000 0.010000 ( 4.981517)
110
- # raws.create_bucket 0.030000 0.040000 0.070000 ( 10.035029)
111
- # awss3::Bucket.create 0.020000 0.020000 0.040000 ( 7.402162)
112
- # fog.put_object 0.080000 0.080000 0.160000 ( 8.757062)
113
- # raws.put 0.180000 0.080000 0.260000 ( 12.307371)
114
- # awss3::S3Object.create 0.170000 0.070000 0.240000 ( 14.028887)
115
- # fog.delete_object 0.080000 0.050000 0.130000 ( 5.481744)
116
- # raws.delete 0.140000 0.070000 0.210000 ( 7.709116)
117
- # awss3::S3Object.delete 0.100000 0.040000 0.140000 ( 5.533884)
118
- # fog.delete_bucket 0.010000 0.010000 0.020000 ( 1.861061)
119
- # raws.delete_bucket 0.030000 0.020000 0.050000 ( 3.146836)
120
- # awss3::Bucket.delete 0.050000 0.010000 0.060000 ( 1.877064)
121
- # --------------------------------------------------- total: 1.390000sec
122
- #
123
- # user system total real
124
- # fog.put_bucket 0.010000 0.020000 0.030000 ( 1.949933)
125
- # raws.create_bucket 0.030000 0.020000 0.050000 ( 4.766058)
126
- # awss3::Bucket.create 0.010000 0.010000 0.020000 ( 2.093764)
127
- # fog.put_object 0.090000 0.080000 0.170000 ( 9.352868)
128
- # raws.put 0.150000 0.080000 0.230000 ( 12.981112)
129
- # awss3::S3Object.create 0.130000 0.070000 0.200000 ( 14.442972)
130
- # fog.delete_object 0.060000 0.060000 0.120000 ( 5.657752)
131
- # raws.delete 0.130000 0.050000 0.180000 ( 6.598221)
132
- # awss3::S3Object.delete 0.110000 0.030000 0.140000 ( 5.709799)
133
- # fog.delete_bucket 0.010000 0.010000 0.020000 ( 1.864573)
134
- # raws.delete_bucket 0.040000 0.030000 0.070000 ( 4.120572)
135
- # awss3::Bucket.delete 0.020000 0.000000 0.020000 ( 1.947711)
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.1.0'
11
- s.date = '2010-05-18'
10
+ s.version = '0.1.1'
11
+ s.date = '2010-05-23'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
@@ -388,20 +388,10 @@ Gem::Specification.new do |s|
388
388
  spec/aws/models/s3/directory_spec.rb
389
389
  spec/aws/models/s3/file_spec.rb
390
390
  spec/aws/models/s3/files_spec.rb
391
- spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb
392
- spec/aws/requests/ec2/create_key_pair_spec.rb
393
- spec/aws/requests/ec2/create_security_group_spec.rb
394
- spec/aws/requests/ec2/delete_key_pair_spec.rb
395
- spec/aws/requests/ec2/delete_security_group_spec.rb
396
- spec/aws/requests/ec2/describe_availability_zones_spec.rb
397
391
  spec/aws/requests/ec2/describe_images_spec.rb
398
392
  spec/aws/requests/ec2/describe_instances_spec.rb
399
- spec/aws/requests/ec2/describe_key_pairs_spec.rb
400
- spec/aws/requests/ec2/describe_regions_spec.rb
401
- spec/aws/requests/ec2/describe_security_groups_spec.rb
402
393
  spec/aws/requests/ec2/get_console_output_spec.rb
403
394
  spec/aws/requests/ec2/reboot_instances_spec.rb
404
- spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb
405
395
  spec/aws/requests/ec2/run_instances_spec.rb
406
396
  spec/aws/requests/ec2/terminate_instances_spec.rb
407
397
  spec/aws/requests/s3/copy_object_spec.rb
@@ -459,6 +449,10 @@ Gem::Specification.new do |s|
459
449
  spec/vcloud/vcloud_spec.rb
460
450
  tests/aws/helper.rb
461
451
  tests/aws/requests/ec2/address_tests.rb
452
+ tests/aws/requests/ec2/availability_zone_tests.rb
453
+ tests/aws/requests/ec2/key_pair_tests.rb
454
+ tests/aws/requests/ec2/region_tests.rb
455
+ tests/aws/requests/ec2/security_group_tests.rb
462
456
  tests/aws/requests/ec2/snapshot_tests.rb
463
457
  tests/aws/requests/ec2/volume_tests.rb
464
458
  tests/helper.rb
data/lib/fog.rb CHANGED
@@ -35,7 +35,7 @@ require 'fog/vcloud'
35
35
  module Fog
36
36
 
37
37
  unless const_defined?(:VERSION)
38
- VERSION = '0.1.0'
38
+ VERSION = '0.1.1'
39
39
  end
40
40
 
41
41
  module Mock
@@ -15,9 +15,10 @@ module Fog
15
15
  # * 'return'<~Boolean> - success?
16
16
  def delete_key_pair(key_name)
17
17
  request(
18
- 'Action' => 'DeleteKeyPair',
19
- 'KeyName' => key_name,
20
- :parser => Fog::Parsers::AWS::EC2::Basic.new
18
+ 'Action' => 'DeleteKeyPair',
19
+ 'KeyName' => key_name,
20
+ :idempotent => true,
21
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
21
22
  )
22
23
  end
23
24
 
@@ -50,8 +50,8 @@ module Fog
50
50
  case volume['status']
51
51
  when 'attaching'
52
52
  if Time.now - volume['attachmentSet'].first['attachTime'] > Fog::Mock.delay
53
- volume['attachmentSet'].first['status'] = 'attached'
54
- volume['status'] = 'attached'
53
+ volume['attachmentSet'].first['status'] = 'in-use'
54
+ volume['status'] = 'in-use'
55
55
  end
56
56
  when 'creating'
57
57
  if Time.now - volume['createTime'] > Fog::Mock.delay
@@ -64,7 +64,7 @@ module Fog
64
64
  unless (mime_types = MIME::Types.of(filename)).empty?
65
65
  metadata[:headers]['Content-Type'] = mime_types.first.content_type
66
66
  end
67
- metadata[:body] = data.read
67
+ metadata[:body] = data
68
68
  metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
69
69
  end
70
70
  # metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
@@ -151,12 +151,16 @@ module Fog
151
151
  end
152
152
  @port = options[:port] || 443
153
153
  @scheme = options[:scheme] || 'https'
154
+ reset
155
+ end
156
+
157
+ def reset
158
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
154
159
  end
155
160
 
156
161
  private
157
162
 
158
163
  def request(params, &block)
159
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
160
164
  params[:headers]['Date'] = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
161
165
  params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
162
166
 
@@ -181,8 +185,8 @@ DATA
181
185
  end
182
186
  end
183
187
  amz_headers = amz_headers.sort {|x, y| x[0] <=> y[0]}
184
- for pair in amz_headers
185
- canonical_amz_headers << "#{pair[0]}:#{pair[1]}\n"
188
+ for key, value in amz_headers
189
+ canonical_amz_headers << "#{key}:#{value}\n"
186
190
  end
187
191
  string_to_sign << "#{canonical_amz_headers}"
188
192
 
@@ -11,6 +11,7 @@ module Fog
11
11
  attribute :name
12
12
  attribute :created_at, 'created'
13
13
  attribute :updated_at, 'updated'
14
+ attribute :progress
14
15
  attribute :status
15
16
  attribute :server_id, 'serverId'
16
17
 
@@ -27,6 +28,10 @@ module Fog
27
28
  true
28
29
  end
29
30
 
31
+ def ready?
32
+ status == 'ACTIVE'
33
+ end
34
+
30
35
  def save
31
36
  requires :server_id
32
37
 
@@ -41,11 +41,44 @@ module AWS
41
41
  'requestId' => String
42
42
  }
43
43
 
44
+ AVAILABILITY_ZONES = {
45
+ 'availabilityZoneInfo' => [{
46
+ 'regionName' => String,
47
+ 'zoneName' => String,
48
+ 'zoneState' => String
49
+ }],
50
+ 'requestId' => String
51
+ }
52
+
44
53
  BASIC = {
45
54
  'requestId' => String,
46
55
  'return' => ::Fog::Boolean
47
56
  }
48
57
 
58
+ REGIONS = {
59
+ 'regionInfo' => [{
60
+ 'regionEndpoint' => String,
61
+ 'regionName' => String
62
+ }],
63
+ 'requestId' => String
64
+ }
65
+
66
+ SECURITY_GROUPS = {
67
+ 'requestId' => String,
68
+ 'securityGroupInfo' => [{
69
+ 'groupDescription' => String,
70
+ 'groupName' => String,
71
+ 'ipPermissions' => [{
72
+ 'fromPort' => Integer,
73
+ 'groups' => [{ 'groupName' => String, 'userId' => String }],
74
+ 'ipProtocol' => String,
75
+ 'ipRanges' => [],
76
+ 'toPort' => Integer,
77
+ }],
78
+ 'ownerId' => String
79
+ }]
80
+ }
81
+
49
82
  SNAPSHOT = {
50
83
  'description' => NilClass,
51
84
  'ownerId' => String,
@@ -8,43 +8,46 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
8
8
 
9
9
  @public_ip = nil
10
10
 
11
- test('#allocate_address') do
12
- @data = AWS[:ec2].allocate_address.body
13
- @public_ip = @data['publicIp']
14
- has_format(
15
- @data,
16
- {
17
- 'publicIp' => String,
18
- 'requestId' => String
19
- }
20
- )
11
+ tests('#allocate_address').formats({'publicIp' => String, 'requestId' => String}) do
12
+ data = AWS[:ec2].allocate_address.body
13
+ @public_ip = data['publicIp']
14
+ data
21
15
  end
22
16
 
23
- test("#describe_addresses") do
24
- @data = AWS[:ec2].describe_addresses.body
25
- has_format(@data, AWS::EC2::Formats::ADDRESSES)
17
+ tests('#describe_addresses').formats(AWS::EC2::Formats::ADDRESSES) do
18
+ AWS[:ec2].describe_addresses.body
26
19
  end
27
20
 
28
- test("#describe_addresses('#{@public_ip}')") do
29
- @data = AWS[:ec2].describe_addresses(@public_ip).body
30
- has_format(@data, AWS::EC2::Formats::ADDRESSES)
21
+ tests("#describe_addresses('#{@public_Ip}')").formats(AWS::EC2::Formats::ADDRESSES) do
22
+ AWS[:ec2].describe_addresses(@public_ip).body
31
23
  end
32
24
 
33
- test("#associate_address('#{@server.identity}', '#{@public_ip}')") do
34
- @data = AWS[:ec2].associate_address(@server.identity, @public_ip).body
35
- has_format(@data, AWS::EC2::Formats::BASIC)
36
- @server.reload.ip_address == @public_ip
25
+ tests("#associate_addresses('#{@server.identity}', '#{@public_Ip}')") do
26
+
27
+ formats(AWS::EC2::Formats::BASIC) do
28
+ AWS[:ec2].associate_address(@server.identity, @public_ip).body
29
+ end
30
+
31
+ tests('server.ip_address').returns(@public_ip) do
32
+ @server.reload.ip_address
33
+ end
34
+
37
35
  end
38
36
 
39
- test("#disassociate_address('#{@public_ip}')") do
40
- @data = AWS[:ec2].disassociate_address(@public_ip).body
41
- has_format(@data, AWS::EC2::Formats::BASIC)
42
- @server.reload.ip_address == @ip_address
37
+ tests("#dissassociate_address('#{@public_ip}')") do
38
+
39
+ formats(AWS::EC2::Formats::BASIC) do
40
+ AWS[:ec2].disassociate_address(@public_ip).body
41
+ end
42
+
43
+ test("server.ip_address is not #{@public_ip}") do
44
+ @server.reload.ip_address != @public_ip
45
+ end
46
+
43
47
  end
44
48
 
45
- test("#release_address('#{@public_ip}')") do
46
- @data = AWS[:ec2].release_address(@public_ip).body
47
- has_format(@data, AWS::EC2::Formats::BASIC)
49
+ tests("#release_address('#{@public_ip}')").formats(AWS::EC2::Formats::BASIC) do
50
+ AWS[:ec2].release_address(@public_ip).body
48
51
  end
49
52
 
50
53
  end
@@ -52,34 +55,24 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
52
55
 
53
56
  @address = AWS[:ec2].addresses.create
54
57
 
55
- test("#describe_addresses('127.0.0.1') raises BadRequest error") do
56
- has_error(Excon::Errors::BadRequest) do
57
- AWS[:ec2].describe_addresses('127.0.0.1')
58
- end
58
+ tests("#describe_addresses('127.0.0.1')").raises(Excon::Errors::BadRequest) do
59
+ AWS[:ec2].describe_addresses('127.0.0.1')
59
60
  end
60
61
 
61
- test("#associate_addresses('i-00000000', '#{@address.identity}') raises BadRequest error") do
62
- has_error(Excon::Errors::BadRequest) do
63
- AWS[:ec2].associate_address('i-00000000', @address.identity)
64
- end
62
+ tests("#associate_addresses('i-00000000', '#{@address.identity}')").raises(Excon::Errors::BadRequest) do
63
+ AWS[:ec2].associate_address('i-00000000', @address.identity)
65
64
  end
66
65
 
67
- test("#associate_addresses('#{@server.identity}', '127.0.0.1') raises BadRequest error") do
68
- has_error(Excon::Errors::BadRequest) do
69
- AWS[:ec2].associate_address(@server.identity, '127.0.0.1')
70
- end
66
+ tests("#associate_addresses('#{@server.identity}', '127.0.0.1')").raises(Excon::Errors::BadRequest) do
67
+ AWS[:ec2].associate_address(@server.identity, '127.0.0.1')
71
68
  end
72
69
 
73
- test("#disassociate_addresses('127.0.0.1') raises BadRequest error") do
74
- has_error(Excon::Errors::BadRequest) do
75
- AWS[:ec2].disassociate_address('127.0.0.1')
76
- end
70
+ tests("#disassociate_addresses('127.0.0.1') raises BadRequest error").raises(Excon::Errors::BadRequest) do
71
+ AWS[:ec2].disassociate_address('127.0.0.1')
77
72
  end
78
73
 
79
- test("#release_address('127.0.0.1') raises BadRequest error") do
80
- has_error(Excon::Errors::BadRequest) do
81
- AWS[:ec2].release_address('127.0.0.1')
82
- end
74
+ tests("#release_address('127.0.0.1')").raises(Excon::Errors::BadRequest) do
75
+ AWS[:ec2].release_address('127.0.0.1')
83
76
  end
84
77
 
85
78
  @address.destroy
@@ -0,0 +1,23 @@
1
+ Shindo.tests('AWS::EC2 | availability zone requests', ['aws']) do
2
+
3
+ tests('success') do
4
+
5
+ tests('#describe_availability_zones').formats(AWS::EC2::Formats::AVAILABILITY_ZONES) do
6
+ AWS[:ec2].describe_availability_zones.body
7
+ end
8
+
9
+ tests("#describe_availability_zones('us-east-1a')").formats(AWS::EC2::Formats::AVAILABILITY_ZONES) do
10
+ AWS[:ec2].describe_availability_zones('us-east-1a').body
11
+ end
12
+
13
+ end
14
+
15
+ tests('failure') do
16
+
17
+ tests("#describe_availability_zones('not-a-zone')").raises(Excon::Errors::BadRequest) do
18
+ AWS[:ec2].describe_availability_zones('not-a-zone')
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,44 @@
1
+ Shindo.tests('AWS::EC2 | key pair requests', ['aws']) do
2
+
3
+ tests('success') do
4
+
5
+ @key_pair_name = 'fog_key_pair'
6
+
7
+ tests("#create_key_pair('#{@key_pair_name}')").formats({ 'keyFingerprint' => String, 'keyMaterial' => String, 'keyName' => String, 'requestId' => String }) do
8
+ AWS[:ec2].create_key_pair(@key_pair_name).body
9
+ end
10
+
11
+ tests('#describe_key_pairs').formats({ 'keySet' => [{'keyFingerprint' => String, 'keyName' => String}], 'requestId' => String }) do
12
+ AWS[:ec2].describe_key_pairs.body
13
+ end
14
+
15
+ tests("#describe_key_pairs(#{@key_pair_name})").formats({ 'keySet' => [{'keyFingerprint' => String, 'keyName' => String}], 'requestId' => String }) do
16
+ AWS[:ec2].describe_key_pairs(@key_pair_name).body
17
+ end
18
+
19
+ tests("#delete_key_pair('#{@key_pair_name}')").formats(AWS::EC2::Formats::BASIC) do
20
+ AWS[:ec2].delete_key_pair(@key_pair_name).body
21
+ end
22
+
23
+ tests("#delete_key_pair('not_a_key_name')").succeeds do
24
+ AWS[:ec2].delete_key_pair('not_a_key_name')
25
+ end
26
+
27
+ end
28
+ tests('failure') do
29
+
30
+ @key_pair = AWS[:ec2].key_pairs.create(:name => 'fog_key_pair')
31
+
32
+ tests("duplicate #create_key_pair('#{@key_pair.name}')").raises(Excon::Errors::BadRequest) do
33
+ AWS[:ec2].create_key_pair(@key_pair.name)
34
+ end
35
+
36
+ tests("#describe_key_pair('not_a_key_name')").raises(Excon::Errors::BadRequest) do
37
+ AWS[:ec2].describe_key_pairs('not_a_key_name').body
38
+ end
39
+
40
+ @key_pair.destroy
41
+
42
+ end
43
+
44
+ end