fog-brightbox 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +18 -0
  5. data/fog-brightbox.gemspec +1 -0
  6. data/lib/fog/brightbox/compute/shared.rb +1 -1
  7. data/lib/fog/brightbox/oauth2.rb +16 -13
  8. data/lib/fog/brightbox/version.rb +1 -1
  9. data/spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb +30 -0
  10. data/spec/fog/brightbox/oauth2/credential_set_spec.rb +86 -0
  11. data/spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb +24 -0
  12. data/spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb +33 -0
  13. data/spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb +40 -0
  14. data/spec/fog/compute/brightbox/database_server_spec.rb +3 -3
  15. data/spec/fog/compute/brightbox/server_spec.rb +3 -3
  16. data/tests/brightbox/compute/helper.rb +1 -0
  17. data/tests/brightbox/compute/schema.rb +794 -0
  18. data/tests/brightbox/compute_tests.rb +98 -0
  19. data/tests/brightbox/helper.rb +1 -0
  20. data/tests/brightbox/models/compute/account_tests.rb +15 -0
  21. data/tests/brightbox/models/compute/cloud_ip_tests.rb +32 -0
  22. data/tests/brightbox/models/compute/database_server_tests.rb +78 -0
  23. data/tests/brightbox/models/compute/database_snapshot_tests.rb +26 -0
  24. data/tests/brightbox/models/compute/database_type_tests.rb +27 -0
  25. data/tests/brightbox/models/compute/server_tests.rb +19 -0
  26. data/tests/brightbox/requests/compute/account_tests.rb +59 -0
  27. data/tests/brightbox/requests/compute/api_client_tests.rb +59 -0
  28. data/tests/brightbox/requests/compute/application_test.rb +58 -0
  29. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +79 -0
  30. data/tests/brightbox/requests/compute/collaboration_tests.rb +36 -0
  31. data/tests/brightbox/requests/compute/database_server_tests.rb +53 -0
  32. data/tests/brightbox/requests/compute/database_snapsnot_tests.rb +46 -0
  33. data/tests/brightbox/requests/compute/database_type_tests.rb +16 -0
  34. data/tests/brightbox/requests/compute/firewall_policy_tests.rb +39 -0
  35. data/tests/brightbox/requests/compute/firewall_rule_tests.rb +42 -0
  36. data/tests/brightbox/requests/compute/helper.rb +42 -0
  37. data/tests/brightbox/requests/compute/image_tests.rb +54 -0
  38. data/tests/brightbox/requests/compute/interface_tests.rb +30 -0
  39. data/tests/brightbox/requests/compute/load_balancer_tests.rb +116 -0
  40. data/tests/brightbox/requests/compute/server_group_tests.rb +91 -0
  41. data/tests/brightbox/requests/compute/server_tests.rb +93 -0
  42. data/tests/brightbox/requests/compute/server_type_tests.rb +28 -0
  43. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +65 -0
  44. data/tests/brightbox/requests/compute/user_tests.rb +32 -0
  45. data/tests/brightbox/requests/compute/zone_tests.rb +28 -0
  46. data/tests/helper.rb +8 -0
  47. data/tests/helpers/collection_helper.rb +91 -0
  48. data/tests/helpers/compute/flavors_helper.rb +28 -0
  49. data/tests/helpers/compute/server_helper.rb +23 -0
  50. data/tests/helpers/compute/servers_helper.rb +8 -0
  51. data/tests/helpers/formats_helper.rb +98 -0
  52. data/tests/helpers/formats_helper_tests.rb +106 -0
  53. data/tests/helpers/mock_helper.rb +98 -0
  54. data/tests/helpers/model_helper.rb +29 -0
  55. data/tests/helpers/responds_to_helper.rb +11 -0
  56. data/tests/helpers/schema_validator_tests.rb +101 -0
  57. data/tests/helpers/succeeds_helper.rb +9 -0
  58. metadata +68 -2
@@ -0,0 +1,98 @@
1
+ Shindo.tests("Fog::Compute[:brightbox]", ["brightbox"]) do
2
+ @test_service = Fog::Compute[:brightbox]
3
+
4
+ tests("#respond_to? :default_image").returns(true) do
5
+ @test_service.respond_to?(:default_image)
6
+ end
7
+ end
8
+
9
+ Shindo.tests("Fog::Compute.new", ["brightbox"]) do
10
+ tests("service options") do
11
+ {
12
+ :brightbox_api_url => "https://example.com",
13
+ :brightbox_auth_url => "https://example.com",
14
+ :brightbox_client_id => "app-12345",
15
+ :brightbox_secret => "12345abdef6789",
16
+ :brightbox_username => "user-12345",
17
+ :brightbox_password => "password1234",
18
+ :brightbox_account => "acc-12345",
19
+ :brightbox_access_token => "12345abdef6789",
20
+ :brightbox_refresh_token => "12345abdef6789",
21
+ :brightbox_token_management => false
22
+ }.each_pair do |option, sample|
23
+ tests("recognises :#{option}").returns(true) do
24
+ options = { :provider => "Brightbox" }
25
+ options[option] = sample
26
+ begin
27
+ Fog::Compute.new(options)
28
+ true
29
+ rescue ArgumentError
30
+ false
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ tests("automatic token management") do
37
+ service_options = { :provider => "Brightbox" }
38
+
39
+ tests("when enabled (default)") do
40
+ service_options[:brightbox_token_management] = true
41
+
42
+ tests("using bad token") do
43
+ service_options[:brightbox_access_token] = "bad-token"
44
+
45
+ tests("#request").returns(true, "returns a Hash") do
46
+ pending if Fog.mocking?
47
+ service = Fog::Compute.new(service_options)
48
+ response = service.get_authenticated_user
49
+ response.is_a?(Hash) # This is an outstanding issue, should be Excon::Response
50
+ end
51
+ end
52
+ end
53
+
54
+ tests("when disabled") do
55
+ service_options[:brightbox_token_management] = false
56
+
57
+ tests("using bad token") do
58
+ service_options[:brightbox_access_token] = "bad-token"
59
+
60
+ tests("#request").raises(Excon::Errors::Unauthorized) do
61
+ pending if Fog.mocking?
62
+ service = Fog::Compute.new(service_options)
63
+ service.get_authenticated_user
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ tests("account scoping") do
70
+ service = Fog::Compute.new(:provider => "Brightbox")
71
+ configured_account = Fog.credentials[:brightbox_account]
72
+ tests("when Fog.credentials are #{configured_account}") do
73
+ test("#scoped_account == #{configured_account}") { service.scoped_account == configured_account }
74
+ end
75
+
76
+ set_account = "acc-35791"
77
+ tests("when Compute instance is updated to #{set_account}") do
78
+ service.scoped_account = set_account
79
+ test("#scoped_account == #{set_account}") { service.scoped_account == set_account }
80
+ end
81
+
82
+ tests("when Compute instance is reset") do
83
+ service.scoped_account_reset
84
+ test("#scoped_account == #{configured_account}") { service.scoped_account == configured_account }
85
+ end
86
+
87
+ optioned_account = "acc-56789"
88
+ tests("when Compute instance created with :brightbox_account => #{optioned_account}") do
89
+ service = Fog::Compute.new(:provider => "Brightbox", :brightbox_account => optioned_account)
90
+ test("#scoped_account == #{optioned_account}") { service.scoped_account == optioned_account }
91
+ end
92
+
93
+ request_account = "acc-24680"
94
+ tests("when requested with #{request_account}") do
95
+ test("#scoped_account(#{request_account}) == #{request_account}") { service.scoped_account(request_account) == request_account }
96
+ end
97
+ end
98
+ end
@@ -0,0 +1 @@
1
+ Excon.defaults[:ssl_verify_peer] = false
@@ -0,0 +1,15 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | Account model", ["brightbox"]) do
2
+ pending if Fog.mocking?
3
+
4
+ @account = Fog::Compute[:brightbox].account
5
+
6
+ tests("success") do
7
+ tests("#reset_ftp_password") do
8
+ pending if Fog.mocking?
9
+ test("original ftp password is blanked") { @account.library_ftp_password.nil? }
10
+ @new_password = @account.reset_ftp_password
11
+ test("new ftp password was not nil") { !@new_password.nil? }
12
+ test("new ftp password is set") { @account.library_ftp_password == @new_password }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | CloudIp model", ["brightbox"]) do
2
+ pending if Fog.mocking?
3
+
4
+ @test_service = Fog::Compute[:brightbox]
5
+
6
+ tests("success") do
7
+ @server = Brightbox::Compute::TestSupport.get_test_server
8
+ server_id = @server.id
9
+
10
+ @cip = @test_service.cloud_ips.allocate
11
+
12
+ tests("#destination_id") do
13
+ returns(true) do
14
+ @cip.respond_to?(:destination_id)
15
+ end
16
+
17
+ @cip.map(@server)
18
+ @cip.wait_for { mapped? }
19
+
20
+ returns(server_id) do
21
+ @cip.destination_id
22
+ end
23
+
24
+ @cip.unmap
25
+ @cip.wait_for { !mapped? }
26
+ end
27
+
28
+ @cip.destroy
29
+
30
+ @server.destroy
31
+ end
32
+ end
@@ -0,0 +1,78 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | DatabaseServer model", ["brightbox"]) do
2
+ pending if Fog.mocking?
3
+
4
+ @service = Fog::Compute[:brightbox]
5
+
6
+ tests("success") do
7
+ tests("#create") do
8
+ test("a new database server is returned") do
9
+ @database_server = @service.database_servers.create
10
+ !@database_server.nil?
11
+ end
12
+
13
+ test("state is not nil") do
14
+ !@database_server.state.nil?
15
+ end
16
+
17
+ test("database_version is not nil") do
18
+ !@database_server.database_version.nil?
19
+ end
20
+
21
+ test("admin_username is not nil") do
22
+ !@database_server.admin_username.nil?
23
+ end
24
+
25
+ test("admin_password is not nil") do
26
+ !@database_server.admin_password.nil?
27
+ end
28
+ end
29
+
30
+ @sample_identifier = @database_server.id
31
+ pending if @sample_identifier.nil?
32
+
33
+ tests("#all") do
34
+ test("returns results") do
35
+ @database_servers = @service.database_servers.all
36
+ @database_servers.any? do |dbs|
37
+ dbs.identity == @database_server.identity
38
+ end
39
+ end
40
+ end
41
+
42
+ tests("#get('#{@sample_identifier}')") do
43
+ @database_server = @service.database_servers.get(@sample_identifier)
44
+
45
+ @database_server.wait_for { ready? }
46
+
47
+ test("admin_username is not nil") do
48
+ !@database_server.admin_username.nil?
49
+ end
50
+
51
+ test("admin_password is nil") do
52
+ @database_server.admin_password.nil?
53
+ end
54
+ end
55
+
56
+ @database_server.wait_for { ready? }
57
+
58
+ tests("#snapshot") do
59
+ # Very messy but there is no feedback about if snapshotting or what the ID will be
60
+ existing_snapshots = @service.database_snapshots.all.map(&:identity)
61
+ test do
62
+ @database_server.snapshot
63
+ end
64
+
65
+ current_snapshots = @service.database_snapshots.all.map(&:identity)
66
+ snapshot_id = (current_snapshots - existing_snapshots).last
67
+
68
+ @snapshot = @service.database_snapshots.get(snapshot_id)
69
+ @snapshot.wait_for { ready? }
70
+ @snapshot.destroy
71
+ end
72
+
73
+ # Can no longer destroy when snapshotting
74
+ tests("#destroy") do
75
+ @database_server.destroy
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,26 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | DatabaseSnapshot model", ["brightbox"]) do
2
+ pending if Fog.mocking?
3
+
4
+ @service = Fog::Compute[:brightbox]
5
+
6
+ tests("success") do
7
+ tests("#all") do
8
+ test("returns results") do
9
+ @database_snapshots = @service.database_snapshots.all
10
+ !@database_snapshots.empty?
11
+ end
12
+ end
13
+
14
+ pending if @database_snapshots.empty?
15
+ @sample_identifier = @database_snapshots.first.identity
16
+ tests("#get('#{@sample_identifier}')") do
17
+ @database_snapshot = @service.database_snapshots.get(@sample_identifier)
18
+ end
19
+
20
+ # @database_snapshot.wait_for { ready? }
21
+
22
+ # tests("#destroy") do
23
+ # @database_snapshot.destroy
24
+ # end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | DatabaseType model", ["brightbox"]) do
2
+ pending if Fog.mocking?
3
+
4
+ @service = Fog::Compute[:brightbox]
5
+
6
+ tests("success") do
7
+ tests("#all") do
8
+ @database_types = @service.database_types.all
9
+ test("returns results") { !@database_types.empty? }
10
+ end
11
+
12
+ @sample_identifier = @database_types.first.id
13
+ pending if @sample_identifier.nil?
14
+
15
+ tests("#get(#{@sample_identifier})") do
16
+ @database_type = @service.database_types.get(@sample_identifier)
17
+
18
+ test("disk is not nil") do
19
+ !@database_type.disk.nil?
20
+ end
21
+
22
+ test("ram is not nil") do
23
+ !@database_type.ram.nil?
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | Server model", ["brightbox"]) do
2
+ pending if Fog.mocking?
3
+
4
+ tests("success") do
5
+ @server = Brightbox::Compute::TestSupport.get_test_server
6
+ server_id = @server.id
7
+
8
+ tests("#dns_name") do
9
+ returns("public.#{@server.fqdn}") { @server.dns_name }
10
+ end
11
+
12
+ tests("#mapping_identity") do
13
+ first_interface_id = @server.interfaces.first["id"]
14
+ returns(first_interface_id) { @server.mapping_identity }
15
+ end
16
+
17
+ @server.destroy
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | account requests", ["brightbox"]) do
2
+ tests("success") do
3
+ tests("#list_accounts") do
4
+ pending if Fog.mocking?
5
+ result = Fog::Compute[:brightbox].list_accounts
6
+ data_matches_schema(Brightbox::Compute::Formats::Collection::ACCOUNTS, :allow_extra_keys => true) { result }
7
+ end
8
+
9
+ tests("#get_scoped_account") do
10
+ pending if Fog.mocking?
11
+ result = Fog::Compute[:brightbox].get_scoped_account
12
+ @scoped_account_identifier = result["id"]
13
+ data_matches_schema(Brightbox::Compute::Formats::Full::ACCOUNT, :allow_extra_keys => true) { result }
14
+ test("ftp password is blanked") { result["library_ftp_password"].nil? }
15
+ end
16
+
17
+ tests("#get_account(#{@scoped_account_identifier}") do
18
+ pending if Fog.mocking?
19
+ result = Fog::Compute[:brightbox].get_account(@scoped_account_identifier)
20
+ @current_name = result["name"]
21
+ data_matches_schema(Brightbox::Compute::Formats::Full::ACCOUNT, :allow_extra_keys => true) { result }
22
+ test("ftp password is blanked") { result["library_ftp_password"].nil? }
23
+ end
24
+
25
+ update_options = { :name => @current_name }
26
+ tests("#update_scoped_account(#{update_options.inspect})") do
27
+ pending if Fog.mocking?
28
+ result = Fog::Compute[:brightbox].update_scoped_account(update_options)
29
+ data_matches_schema(Brightbox::Compute::Formats::Full::ACCOUNT, :allow_extra_keys => true) { result }
30
+ end
31
+
32
+ tests("#update_account(#{@scoped_account_identifier}, #{update_options.inspect})") do
33
+ pending if Fog.mocking?
34
+ result = Fog::Compute[:brightbox].update_account(@scoped_account_identifier, update_options)
35
+ data_matches_schema(Brightbox::Compute::Formats::Full::ACCOUNT, :allow_extra_keys => true) { result }
36
+ end
37
+
38
+ tests("#reset_ftp_password_scoped_account") do
39
+ pending if Fog.mocking?
40
+ result = Fog::Compute[:brightbox].reset_ftp_password_scoped_account
41
+ data_matches_schema(Brightbox::Compute::Formats::Full::ACCOUNT, :allow_extra_keys => true) { result }
42
+ test("new ftp password is visible") { !result["library_ftp_password"].nil? }
43
+ end
44
+
45
+ tests("#reset_ftp_password_account(#{@scoped_account_identifier})") do
46
+ pending if Fog.mocking?
47
+ result = Fog::Compute[:brightbox].reset_ftp_password_account(@scoped_account_identifier)
48
+ data_matches_schema(Brightbox::Compute::Formats::Full::ACCOUNT, :allow_extra_keys => true) { result }
49
+ test("new ftp password is visible") { !result["library_ftp_password"].nil? }
50
+ end
51
+ end
52
+
53
+ tests("failure") do
54
+ tests("#update_account").raises(ArgumentError) do
55
+ pending if Fog.mocking?
56
+ Fog::Compute[:brightbox].update_account
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,59 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | api client requests", ["brightbox"]) do
2
+ tests("success") do
3
+ create_options = {
4
+ :name => "Fog@#{Time.now.iso8601}",
5
+ :description => "Description from Fog test"
6
+ }
7
+
8
+ tests("#create_api_client(#{create_options.inspect})") do
9
+ pending if Fog.mocking?
10
+ result = Fog::Compute[:brightbox].create_api_client(create_options)
11
+ @api_client_id = result["id"]
12
+ data_matches_schema(Brightbox::Compute::Formats::Full::API_CLIENT, :allow_extra_keys => true) { result }
13
+ end
14
+
15
+ tests("#list_api_clients") do
16
+ pending if Fog.mocking?
17
+ result = Fog::Compute[:brightbox].list_api_clients
18
+ data_matches_schema(Brightbox::Compute::Formats::Collection::API_CLIENTS, :allow_extra_keys => true) { result }
19
+ end
20
+
21
+ tests("#get_api_client('#{@api_client_id}')") do
22
+ pending if Fog.mocking?
23
+ result = Fog::Compute[:brightbox].get_api_client(@api_client_id)
24
+ data_matches_schema(Brightbox::Compute::Formats::Full::API_CLIENT, :allow_extra_keys => true) { result }
25
+ end
26
+
27
+ update_options = { :name => "Fog@#{Time.now.iso8601}" }
28
+ tests("#update_api_client('#{@api_client_id}', #{update_options.inspect})") do
29
+ pending if Fog.mocking?
30
+ result = Fog::Compute[:brightbox].update_api_client(@api_client_id, update_options)
31
+ data_matches_schema(Brightbox::Compute::Formats::Full::API_CLIENT, :allow_extra_keys => true) { result }
32
+ end
33
+
34
+ tests("#reset_secret_api_client('#{@api_client_id}')") do
35
+ pending if Fog.mocking?
36
+ result = Fog::Compute[:brightbox].reset_secret_api_client(@api_client_id)
37
+ data_matches_schema(Brightbox::Compute::Formats::Full::API_CLIENT, :allow_extra_keys => true) { result }
38
+ test("new secret is visible") { !result["secret"].nil? }
39
+ end
40
+
41
+ tests("#destroy_api_client('#{@api_client_id}')") do
42
+ pending if Fog.mocking?
43
+ result = Fog::Compute[:brightbox].destroy_api_client(@api_client_id)
44
+ data_matches_schema(Brightbox::Compute::Formats::Full::API_CLIENT, :allow_extra_keys => true) { result }
45
+ end
46
+ end
47
+
48
+ tests("failure") do
49
+ tests("#get_api_client('cli-00000')").raises(Excon::Errors::NotFound) do
50
+ pending if Fog.mocking?
51
+ Fog::Compute[:brightbox].get_api_client("cli-00000")
52
+ end
53
+
54
+ tests("#get_api_client").raises(ArgumentError) do
55
+ pending if Fog.mocking?
56
+ Fog::Compute[:brightbox].get_api_client
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | api client requests", ["brightbox"]) do
2
+ tests("success") do
3
+ create_options = {
4
+ :name => "Fog@#{Time.now.iso8601}"
5
+ }
6
+
7
+ tests("#create_application(#{create_options.inspect})") do
8
+ pending if Fog.mocking?
9
+ result = Fog::Compute[:brightbox].create_application(create_options)
10
+ @application_id = result["id"]
11
+ data_matches_schema(Brightbox::Compute::Formats::Full::APPLICATION, :allow_extra_keys => true) { result }
12
+ end
13
+
14
+ tests("#list_applications") do
15
+ pending if Fog.mocking?
16
+ result = Fog::Compute[:brightbox].list_applications
17
+ data_matches_schema(Brightbox::Compute::Formats::Collection::APPLICATION, :allow_extra_keys => true) { result }
18
+ end
19
+
20
+ tests("#get_application('#{@application_id}')") do
21
+ pending if Fog.mocking?
22
+ result = Fog::Compute[:brightbox].get_application(@application_id)
23
+ data_matches_schema(Brightbox::Compute::Formats::Full::APPLICATION, :allow_extra_keys => true) { result }
24
+ end
25
+
26
+ update_options = { :name => "Fog@#{Time.now.iso8601}" }
27
+ tests("#update_application('#{@application_id}', #{update_options.inspect})") do
28
+ pending if Fog.mocking?
29
+ result = Fog::Compute[:brightbox].update_application(@application_id, update_options)
30
+ data_matches_schema(Brightbox::Compute::Formats::Full::APPLICATION, :allow_extra_keys => true) { result }
31
+ end
32
+
33
+ tests("#reset_secret_application('#{@application_id}')") do
34
+ pending if Fog.mocking?
35
+ result = Fog::Compute[:brightbox].reset_secret_application(@application_id)
36
+ data_matches_schema(Brightbox::Compute::Formats::Full::APPLICATION, :allow_extra_keys => true) { result }
37
+ test("new secret is visible") { !result["secret"].nil? }
38
+ end
39
+
40
+ tests("#destroy_application('#{@application_id}')") do
41
+ pending if Fog.mocking?
42
+ result = Fog::Compute[:brightbox].destroy_application(@application_id)
43
+ data_matches_schema(Brightbox::Compute::Formats::Full::APPLICATION, :allow_extra_keys => true) { result }
44
+ end
45
+ end
46
+
47
+ tests("failure") do
48
+ tests("#get_api_client('app-00000')").raises(Excon::Errors::NotFound) do
49
+ pending if Fog.mocking?
50
+ Fog::Compute[:brightbox].get_application("app-00000")
51
+ end
52
+
53
+ tests("#get_api_client").raises(ArgumentError) do
54
+ pending if Fog.mocking?
55
+ Fog::Compute[:brightbox].get_application
56
+ end
57
+ end
58
+ end