fog 0.0.91 → 0.0.92

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +39 -39
  3. data/fog.gemspec +17 -16
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/elb.rb +4 -0
  6. data/lib/fog/aws/models/ec2/snapshot.rb +3 -0
  7. data/lib/fog/aws/parsers/ec2/create_snapshot.rb +5 -1
  8. data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +5 -1
  9. data/lib/fog/aws/parsers/elb/create_load_balancer.rb +26 -0
  10. data/lib/fog/aws/parsers/elb/delete_load_balancer.rb +24 -0
  11. data/lib/fog/aws/parsers/s3/access_control_list.rb +46 -0
  12. data/lib/fog/aws/requests/ec2/create_snapshot.rb +11 -7
  13. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +3 -0
  14. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +0 -1
  15. data/lib/fog/aws/requests/ec2/run_instances.rb +0 -2
  16. data/lib/fog/aws/requests/ec2/terminate_instances.rb +0 -1
  17. data/lib/fog/aws/requests/elb/create_load_balancer.rb +57 -0
  18. data/lib/fog/aws/requests/elb/delete_load_balancer.rb +40 -0
  19. data/lib/fog/aws/requests/s3/copy_object.rb +0 -1
  20. data/lib/fog/aws/requests/s3/get_bucket.rb +2 -3
  21. data/lib/fog/aws/requests/s3/get_bucket_acl.rb +53 -0
  22. data/lib/fog/aws/requests/s3/get_object.rb +1 -31
  23. data/lib/fog/aws/requests/s3/get_object_acl.rb +58 -0
  24. data/lib/fog/aws/requests/s3/get_object_torrent.rb +55 -0
  25. data/lib/fog/aws/requests/s3/get_object_url.rb +54 -0
  26. data/lib/fog/aws/requests/s3/put_bucket_acl.rb +80 -0
  27. data/lib/fog/aws/s3.rb +8 -2
  28. data/lib/fog/collection.rb +1 -1
  29. data/lib/fog/connection.rb +7 -5
  30. data/lib/fog/model.rb +5 -2
  31. data/lib/fog/rackspace/files.rb +2 -2
  32. data/lib/fog/rackspace/requests/files/get_object.rb +1 -1
  33. data/lib/fog/terremark/parsers/shared/get_internet_services.rb +2 -2
  34. data/lib/fog/terremark/parsers/shared/get_node_services.rb +3 -0
  35. data/lib/fog/terremark/parsers/shared/vapp.rb +33 -3
  36. data/lib/fog/terremark/requests/shared/delete_internet_service.rb +0 -12
  37. data/lib/fog/terremark/requests/shared/delete_node_service.rb +0 -12
  38. data/lib/fog/terremark/requests/shared/delete_vapp.rb +0 -12
  39. data/lib/fog/terremark/shared.rb +0 -1
  40. data/spec/aws/models/s3/file_spec.rb +2 -2
  41. data/spec/aws/models/s3/files_spec.rb +2 -2
  42. data/spec/aws/requests/ec2/get_console_output_spec.rb +4 -4
  43. data/spec/aws/requests/s3/get_bucket_spec.rb +9 -9
  44. data/tests/aws/helper.rb +105 -0
  45. data/tests/aws/requests/ec2/address_tests.rb +88 -0
  46. data/tests/aws/requests/ec2/snapshot_tests.rb +50 -0
  47. data/tests/aws/requests/ec2/volume_tests.rb +84 -0
  48. data/tests/helper.rb +21 -6
  49. data/tests/helper_tests.rb +38 -7
  50. data/tests/rackspace/requests/servers/create_image_tests.rb +1 -1
  51. data/tests/rackspace/requests/servers/create_server_tests.rb +1 -1
  52. data/tests/rackspace/requests/servers/delete_image_tests.rb +1 -4
  53. data/tests/rackspace/requests/servers/delete_server_tests.rb +1 -4
  54. data/tests/rackspace/requests/servers/get_flavor_details_tests.rb +2 -5
  55. data/tests/rackspace/requests/servers/get_image_details_tests.rb +2 -5
  56. data/tests/rackspace/requests/servers/get_server_details_tests.rb +2 -5
  57. data/tests/rackspace/requests/servers/list_addresses_tests.rb +2 -5
  58. data/tests/rackspace/requests/servers/list_flavors_detail_tests.rb +1 -1
  59. data/tests/rackspace/requests/servers/list_flavors_tests.rb +1 -1
  60. data/tests/rackspace/requests/servers/list_images_detail_tests.rb +1 -1
  61. data/tests/rackspace/requests/servers/list_images_tests.rb +1 -1
  62. data/tests/rackspace/requests/servers/list_private_addresses_tests.rb +2 -5
  63. data/tests/rackspace/requests/servers/list_public_addresses_tests.rb +2 -5
  64. data/tests/rackspace/requests/servers/list_servers_detail_tests.rb +1 -1
  65. data/tests/rackspace/requests/servers/list_servers_tests.rb +1 -1
  66. data/tests/rackspace/requests/servers/reboot_server_tests.rb +1 -4
  67. data/tests/rackspace/requests/servers/update_server_tests.rb +2 -5
  68. data/tests/slicehost/requests/create_slice_tests.rb +1 -1
  69. data/tests/slicehost/requests/delete_slice_tests.rb +1 -4
  70. data/tests/slicehost/requests/get_backups_tests.rb +1 -2
  71. data/tests/slicehost/requests/get_flavor_tests.rb +2 -5
  72. data/tests/slicehost/requests/get_flavors_tests.rb +1 -1
  73. data/tests/slicehost/requests/get_image_tests.rb +2 -5
  74. data/tests/slicehost/requests/get_images_tests.rb +1 -1
  75. data/tests/slicehost/requests/get_slice_tests.rb +2 -5
  76. data/tests/slicehost/requests/get_slices_tests.rb +1 -1
  77. data/tests/slicehost/requests/reboot_slice_tests.rb +2 -5
  78. metadata +19 -18
  79. data/spec/aws/requests/ec2/allocate_address_spec.rb +0 -18
  80. data/spec/aws/requests/ec2/associate_address_spec.rb +0 -43
  81. data/spec/aws/requests/ec2/attach_volume_spec.rb +0 -51
  82. data/spec/aws/requests/ec2/create_snapshot_spec.rb +0 -36
  83. data/spec/aws/requests/ec2/create_volume_spec.rb +0 -23
  84. data/spec/aws/requests/ec2/delete_snapshot_spec.rb +0 -34
  85. data/spec/aws/requests/ec2/delete_volume_spec.rb +0 -26
  86. data/spec/aws/requests/ec2/describe_addresses_spec.rb +0 -38
  87. data/spec/aws/requests/ec2/describe_snapshots_spec.rb +0 -50
  88. data/spec/aws/requests/ec2/describe_volumes_spec.rb +0 -50
  89. data/spec/aws/requests/ec2/detach_volume_spec.rb +0 -41
  90. data/spec/aws/requests/ec2/disassociate_address_spec.rb +0 -36
  91. data/spec/aws/requests/ec2/release_address_spec.rb +0 -26
@@ -0,0 +1,88 @@
1
+ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
2
+
3
+ @server = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
4
+ @server.wait_for { ready? }
5
+
6
+ tests('success') do
7
+
8
+ @public_ip = nil
9
+
10
+ test('#allocate_address') do
11
+ @data = AWS[:ec2].allocate_address.body
12
+ @public_ip = @data['publicIp']
13
+ has_format(
14
+ @data,
15
+ {
16
+ 'publicIp' => String,
17
+ 'requestId' => String
18
+ }
19
+ )
20
+ end
21
+
22
+ test("#describe_addresses") do
23
+ @data = AWS[:ec2].describe_addresses.body
24
+ has_format(@data, AWS::EC2::Formats::ADDRESSES)
25
+ end
26
+
27
+ test("#describe_addresses('#{@public_ip}')") do
28
+ @data = AWS[:ec2].describe_addresses(@public_ip).body
29
+ has_format(@data, AWS::EC2::Formats::ADDRESSES)
30
+ end
31
+
32
+ test("#associate_address('#{@server.identity}', '#{@public_ip}')") do
33
+ @data = AWS[:ec2].associate_address(@server.identity, @public_ip).body
34
+ has_format(@data, AWS::EC2::Formats::BASIC)
35
+ end
36
+
37
+ test("#disassociate_address('#{@public_ip}')") do
38
+ @data = AWS[:ec2].disassociate_address(@public_ip).body
39
+ has_format(@data, AWS::EC2::Formats::BASIC)
40
+ end
41
+
42
+ test("#release_address('#{@public_ip}')") do
43
+ @data = AWS[:ec2].release_address(@public_ip).body
44
+ has_format(@data, AWS::EC2::Formats::BASIC)
45
+ end
46
+
47
+ end
48
+ tests ('failure') do
49
+
50
+ @address = AWS[:ec2].addresses.create
51
+
52
+ test("#describe_addresses('127.0.0.1') raises BadRequest error") do
53
+ has_error(Excon::Errors::BadRequest) do
54
+ AWS[:ec2].describe_addresses('127.0.0.1')
55
+ end
56
+ end
57
+
58
+ test("#associate_addresses('i-00000000', '#{@address.identity}') raises BadRequest error") do
59
+ has_error(Excon::Errors::BadRequest) do
60
+ AWS[:ec2].associate_address('i-00000000', @address.identity)
61
+ end
62
+ end
63
+
64
+ test("#associate_addresses('#{@server.identity}', '127.0.0.1') raises BadRequest error") do
65
+ has_error(Excon::Errors::BadRequest) do
66
+ AWS[:ec2].associate_address(@server.identity, '127.0.0.1')
67
+ end
68
+ end
69
+
70
+ test("#disassociate_addresses('127.0.0.1') raises BadRequest error") do
71
+ has_error(Excon::Errors::BadRequest) do
72
+ AWS[:ec2].disassociate_address('127.0.0.1')
73
+ end
74
+ end
75
+
76
+ test("#release_address('127.0.0.1') raises BadRequest error") do
77
+ has_error(Excon::Errors::BadRequest) do
78
+ AWS[:ec2].release_address('127.0.0.1')
79
+ end
80
+ end
81
+
82
+ @address.destroy
83
+
84
+ end
85
+
86
+ @server.destroy
87
+
88
+ end
@@ -0,0 +1,50 @@
1
+ Shindo.tests('AWS::EC2 | snapshot requests', ['aws']) do
2
+
3
+ @volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1)
4
+
5
+ tests('success') do
6
+
7
+ @snapshot_id = nil
8
+
9
+ test("#create_snapshot(#{@volume.identity})") do
10
+ @data = AWS[:ec2].create_snapshot(@volume.identity).body
11
+ @snapshot_id = @data['snapshotId']
12
+ has_format(@data, AWS::EC2::Formats::SNAPSHOT.merge('progress' => NilClass, 'requestId' => String))
13
+ end
14
+
15
+ test("#describe_snapshots") do
16
+ AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
17
+ @data = AWS[:ec2].describe_snapshots.body
18
+ has_format(@data, AWS::EC2::Formats::SNAPSHOTS)
19
+ end
20
+
21
+ test("#describe_snapshots('#{@snapshot_id}')") do
22
+ @data = AWS[:ec2].describe_snapshots(@snapshot_id).body
23
+ has_format(@data, AWS::EC2::Formats::SNAPSHOTS)
24
+ end
25
+
26
+ test("#delete_snapshots(#{@snapshot_id})") do
27
+ @data = AWS[:ec2].delete_snapshot(@snapshot_id).body
28
+ has_format(@data, AWS::EC2::Formats::BASIC)
29
+ end
30
+
31
+ end
32
+ tests ('failure') do
33
+
34
+ test("#describe_snapshot('snap-00000000') raises BadRequest error") do
35
+ has_error(Excon::Errors::BadRequest) do
36
+ AWS[:ec2].describe_snapshots('snap-00000000')
37
+ end
38
+ end
39
+
40
+ test("#delete_snapshot('snap-00000000') raises BadRequest error") do
41
+ has_error(Excon::Errors::BadRequest) do
42
+ AWS[:ec2].delete_snapshot('snap-00000000')
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ @volume.destroy
49
+
50
+ end
@@ -0,0 +1,84 @@
1
+ Shindo.tests('AWS::EC2 | volume requests', ['aws']) do
2
+
3
+ @server = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
4
+ @server.wait_for { ready? }
5
+
6
+ tests('success') do
7
+
8
+ @volume_id = nil
9
+
10
+ test('#create_volume') do
11
+ @data = AWS[:ec2].create_volume(@server.availability_zone, 1).body
12
+ @volume_id = @data['volumeId']
13
+ has_format(@data, AWS::EC2::Formats::VOLUME)
14
+ end
15
+
16
+ test('#describe_volumes') do
17
+ @data = AWS[:ec2].describe_volumes.body
18
+ has_format(@data, AWS::EC2::Formats::VOLUMES)
19
+ end
20
+
21
+ test("#describe_volumes(#{@volume_id})") do
22
+ @data = AWS[:ec2].describe_volumes.body
23
+ has_format(@data, AWS::EC2::Formats::VOLUMES)
24
+ end
25
+
26
+ test("#attach_volume(#{@server.identity}, #{@volume_id}, '/dev/sdh')") do
27
+ @data = AWS[:ec2].attach_volume(@server.identity, @volume_id, '/dev/sdh').body
28
+ has_format(@data, AWS::EC2::Formats::VOLUME_ATTACHMENT)
29
+ end
30
+
31
+ test("#detach_volume('#{@volume_id}')") do
32
+ AWS[:ec2].volumes.get(@volume_id).wait_for { state == 'attached' }
33
+ @data = AWS[:ec2].detach_volume(@volume_id).body
34
+ has_format(@data, AWS::EC2::Formats::VOLUME_ATTACHMENT)
35
+ end
36
+
37
+ test("#delete_volume('#{@volume_id}')") do
38
+ AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
39
+ @data = AWS[:ec2].delete_volume(@volume_id).body
40
+ has_format(@data, AWS::EC2::Formats::BASIC)
41
+ end
42
+
43
+ end
44
+ tests ('failure') do
45
+
46
+ @volume = AWS[:ec2].volumes.create(:availability_zone => @server.availability_zone, :size => 1)
47
+
48
+ test("#describe_volume('vol-00000000') raises BadRequest error") do
49
+ has_error(Excon::Errors::BadRequest) do
50
+ AWS[:ec2].describe_volumes('vol-00000000')
51
+ end
52
+ end
53
+
54
+ test("#attach_volume('i-00000000', '#{@volume.identity}', '/dev/sdh') raises BadRequest error") do
55
+ has_error(Excon::Errors::BadRequest) do
56
+ AWS[:ec2].attach_volume('i-00000000', @volume.identity, '/dev/sdh')
57
+ end
58
+ end
59
+
60
+ test("#attach_volume('#{@server.identity}', 'vol-00000000', '/dev/sdh') raises BadRequest error") do
61
+ has_error(Excon::Errors::BadRequest) do
62
+ AWS[:ec2].attach_volume(@server.identity, 'vol-00000000', '/dev/sdh')
63
+ end
64
+ end
65
+
66
+ test("#detach_volume('vol-00000000') raises BadRequest error") do
67
+ has_error(Excon::Errors::BadRequest) do
68
+ AWS[:ec2].detach_volume('vol-00000000')
69
+ end
70
+ end
71
+
72
+ test("#delete_volume('vol-00000000') raises BadRequest error") do
73
+ has_error(Excon::Errors::BadRequest) do
74
+ AWS[:ec2].delete_volume('vol-00000000')
75
+ end
76
+ end
77
+
78
+ @volume.destroy
79
+
80
+ end
81
+
82
+ @server.destroy
83
+
84
+ end
data/tests/helper.rb CHANGED
@@ -1,34 +1,49 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog', 'bin'))
3
3
 
4
- # TODO: Currently is true even if some of the keys in format do not appear
5
- def validate_format(original_data, format)
4
+ if ENV["FOG_MOCK"] == "true"
5
+ Fog.mock!
6
+ end
7
+
8
+ def has_error(error, &block)
9
+ begin
10
+ yield
11
+ @formatador.display_line("[red]did not raise #{error}[/]")
12
+ false
13
+ rescue error
14
+ true
15
+ end
16
+ end
17
+
18
+ def has_format(original_data, original_format)
6
19
  valid = true
7
20
  data = original_data.dup
21
+ format = original_format.dup
8
22
  for key, value in format
9
23
  valid &&= data.has_key?(key)
10
24
  datum = data.delete(key)
25
+ format.delete(key)
11
26
  case value
12
27
  when Array
13
28
  valid &&= datum.is_a?(Array)
14
29
  for element in datum
15
30
  type = value.first
16
31
  if type.is_a?(Hash)
17
- valid &&= validate_format({:element => element}, {:element => type})
32
+ valid &&= has_format({:element => element}, {:element => type})
18
33
  else
19
34
  valid &&= element.is_a?(type)
20
35
  end
21
36
  end
22
37
  when Hash
23
38
  valid &&= datum.is_a?(Hash)
24
- valid &&= validate_format(datum, value)
39
+ valid &&= has_format(datum, value)
25
40
  else
26
41
  valid &&= datum.is_a?(value)
27
42
  end
28
43
  end
29
- valid &&= data.empty?
44
+ valid &&= data.empty? && format.empty?
30
45
  unless valid
31
- @formatador.display_line("[red]#{original_data.inspect} does not match #{format.inspect}[/]")
46
+ @formatador.display_line("[red]#{original_data.inspect} does not match #{original_format.inspect}[/]")
32
47
  end
33
48
  valid
34
49
  end
@@ -1,18 +1,48 @@
1
1
  Shindo.tests('test_helper', 'meta') do
2
- tests('#validate_data_format') do
2
+
3
+ tests('#has_error') do
4
+
5
+ tests('returns true') do
6
+
7
+ test('when expected error is raised') do
8
+ has_error(StandardError) { raise StandardError.new }
9
+ end
10
+
11
+ end
12
+
13
+ tests('returns false') do
14
+
15
+ test('when no error is raised') do
16
+ !has_error(StandardError) {}
17
+ end
18
+
19
+ test('when a different error is raised') do
20
+ begin
21
+ !has_error(StandardError) { raise Interrupt.new }
22
+ false
23
+ rescue Interrupt
24
+ true
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ tests('#has_format') do
3
33
 
4
34
  tests('returns true') do
5
35
 
6
36
  test('when format of value matches') do
7
- validate_format({:a => :b}, {:a => Symbol})
37
+ has_format({:a => :b}, {:a => Symbol})
8
38
  end
9
39
 
10
40
  test('when format of nested array elements matches') do
11
- validate_format({:a => [:b, :c]}, {:a => [Symbol]})
41
+ has_format({:a => [:b, :c]}, {:a => [Symbol]})
12
42
  end
13
43
 
14
44
  test('when format of nested hash matches') do
15
- validate_format({:a => {:b => :c}}, {:a => {:b => Symbol}})
45
+ has_format({:a => {:b => :c}}, {:a => {:b => Symbol}})
16
46
  end
17
47
 
18
48
  end
@@ -20,18 +50,19 @@ Shindo.tests('test_helper', 'meta') do
20
50
  tests('returns false') do
21
51
 
22
52
  test('when format of value does not match') do
23
- !validate_format({:a => :b}, {:a => String})
53
+ !has_format({:a => :b}, {:a => String})
24
54
  end
25
55
 
26
56
  test('when not all keys are checked') do
27
- !validate_format({:a => :b}, {})
57
+ !has_format({:a => :b}, {})
28
58
  end
29
59
 
30
60
  test('when some keys do not appear') do
31
- !validate_format({}, {:a => String})
61
+ !has_format({}, {:a => String})
32
62
  end
33
63
 
34
64
  end
35
65
 
36
66
  end
67
+
37
68
  end
@@ -15,7 +15,7 @@ Shindo.tests('Rackspace::Servers#create_image', 'rackspace') do
15
15
  end
16
16
 
17
17
  test('has proper output format') do
18
- validate_format(@data, Rackspace::Servers::Formats::IMAGE)
18
+ has_format(@data, Rackspace::Servers::Formats::IMAGE)
19
19
  end
20
20
 
21
21
  end
@@ -13,7 +13,7 @@ Shindo.tests('Rackspace::Servers#create_server', 'rackspace') do
13
13
  end
14
14
 
15
15
  test('has proper output format') do
16
- validate_format(@data, Rackspace::Servers::Formats::SERVER.merge('adminPass' => String))
16
+ has_format(@data, Rackspace::Servers::Formats::SERVER.merge('adminPass' => String))
17
17
  end
18
18
 
19
19
  end
@@ -20,11 +20,8 @@ Shindo.tests('Rackspace::Servers#delete_image', 'rackspace') do
20
20
  tests('failure') do
21
21
 
22
22
  test('raises NotFound error if image does not exist') do
23
- begin
23
+ has_error(Excon::Errors::NotFound) do
24
24
  Rackspace[:servers].delete_image(0)
25
- false
26
- rescue Excon::Errors::NotFound
27
- true
28
25
  end
29
26
  end
30
27
 
@@ -14,11 +14,8 @@ Shindo.tests('Rackspace::Servers#delete_server', 'rackspace') do
14
14
  tests('failure') do
15
15
 
16
16
  test('raises NotFound error if server does not exist') do
17
- begin
17
+ has_error(Excon::Errors::NotFound) do
18
18
  Rackspace[:servers].delete_server(0)
19
- false
20
- rescue Excon::Errors::NotFound
21
- true
22
19
  end
23
20
  end
24
21
 
@@ -6,18 +6,15 @@ Shindo.tests('Rackspace::Servers#get_flavor_details', 'rackspace') do
6
6
  end
7
7
 
8
8
  test('has proper output format') do
9
- validate_format(@data, Rackspace::Servers::Formats::FLAVOR)
9
+ has_format(@data, Rackspace::Servers::Formats::FLAVOR)
10
10
  end
11
11
 
12
12
  end
13
13
  tests('failure') do
14
14
 
15
15
  test('raises NotFound error if flavor does not exist') do
16
- begin
16
+ has_error(Excon::Errors::NotFound) do
17
17
  Rackspace[:servers].get_flavor_details(0)
18
- false
19
- rescue Excon::Errors::NotFound
20
- true
21
18
  end
22
19
  end
23
20
 
@@ -6,18 +6,15 @@ Shindo.tests('Rackspace::Servers#get_image_details', 'rackspace') do
6
6
  end
7
7
 
8
8
  test('has proper output format') do
9
- validate_format(@data, Rackspace::Servers::Formats::IMAGE)
9
+ has_format(@data, Rackspace::Servers::Formats::IMAGE)
10
10
  end
11
11
 
12
12
  end
13
13
  tests('failure') do
14
14
 
15
15
  test('raises NotFound error if image does not exist') do
16
- begin
16
+ has_error(Excon::Errors::NotFound) do
17
17
  Rackspace[:servers].get_image_details(0)
18
- false
19
- rescue Excon::Errors::NotFound
20
- true
21
18
  end
22
19
  end
23
20