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,29 @@
1
+ def model_tests(collection, params = {}, mocks_implemented = true)
2
+ tests("success") do
3
+ @instance = collection.new(params)
4
+
5
+ tests("#save").succeeds do
6
+ pending if Fog.mocking? && !mocks_implemented
7
+ @instance.save
8
+ end
9
+
10
+ if block_given?
11
+ yield(@instance)
12
+ end
13
+
14
+ tests("#destroy").succeeds do
15
+ pending if Fog.mocking? && !mocks_implemented
16
+ @instance.destroy
17
+ end
18
+ end
19
+ end
20
+
21
+ # Generates a unique identifier with a random differentiator.
22
+ # Useful when rapidly re-running tests, so we don't have to wait
23
+ # serveral minutes for deleted objects to disappear from the API
24
+ # E.g. 'fog-test-1234'
25
+ def uniq_id(base_name = "fog-test")
26
+ # random_differentiator
27
+ suffix = rand(65_536).to_s(16).rjust(4, "0")
28
+ [base_name, suffix].join("-")
29
+ end
@@ -0,0 +1,11 @@
1
+ module Shindo
2
+ class Tests
3
+ def responds_to(method_names)
4
+ for method_name in [*method_names]
5
+ tests("#respond_to?(:#{method_name})").returns(true) do
6
+ @instance.respond_to?(method_name)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,101 @@
1
+ Shindo.tests("Fog::Schema::DataValidator", "meta") do
2
+ validator = Fog::Schema::DataValidator.new
3
+
4
+ tests('#validate') do
5
+ tests("returns true") do
6
+ returns(true, "when value matches schema expectation") do
7
+ validator.validate({ "key" => "Value" }, "key" => String)
8
+ end
9
+
10
+ returns(true, "when values within an array all match schema expectation") do
11
+ validator.validate({ "key" => [1, 2] }, "key" => [Integer])
12
+ end
13
+
14
+ returns(true, "when nested values match schema expectation") do
15
+ validator.validate({ "key" => { :nested_key => "Value" } }, "key" => { :nested_key => String })
16
+ end
17
+
18
+ returns(true, "when collection of values all match schema expectation") do
19
+ validator.validate([{ "key" => "Value" }, { "key" => "Value" }], [{ "key" => String }])
20
+ end
21
+
22
+ returns(true, "when collection is empty although schema covers optional members") do
23
+ validator.validate([], [{ "key" => String }])
24
+ end
25
+
26
+ returns(true, "when additional keys are passed and not strict") do
27
+ validator.validate({ "key" => "Value", :extra => "Bonus" }, { "key" => String }, :allow_extra_keys => true)
28
+ end
29
+
30
+ returns(true, "when value is nil and schema expects NilClass") do
31
+ validator.validate({ "key" => nil }, "key" => NilClass)
32
+ end
33
+
34
+ returns(true, "when value and schema match as hashes") do
35
+ validator.validate({}, {})
36
+ end
37
+
38
+ returns(true, "when value and schema match as arrays") do
39
+ validator.validate([], [])
40
+ end
41
+
42
+ returns(true, "when value is a Time") do
43
+ validator.validate({ "time" => Time.now }, "time" => Time)
44
+ end
45
+
46
+ returns(true, 'when key is missing but value should be NilClass (#1477)') do
47
+ validator.validate({}, { "key" => NilClass }, :allow_optional_rules => true)
48
+ end
49
+
50
+ returns(true, 'when key is missing but value is nullable (#1477)') do
51
+ validator.validate({}, { "key" => Fog::Nullable::String }, :allow_optional_rules => true)
52
+ end
53
+ end
54
+
55
+ tests("returns false") do
56
+ returns(false, "when value does not match schema expectation") do
57
+ validator.validate({ "key" => nil }, { "key" => String })
58
+ end
59
+
60
+ returns(false, "when key formats do not match") do
61
+ validator.validate({ "key" => "Value" }, :key => String)
62
+ end
63
+
64
+ returns(false, "when additional keys are passed and strict") do
65
+ validator.validate({ "key" => "Missing" }, {})
66
+ end
67
+
68
+ returns(false, "when some keys do not appear") do
69
+ validator.validate({}, "key" => String)
70
+ end
71
+
72
+ returns(false, "when collection contains a member that does not match schema") do
73
+ validator.validate([{ "key" => "Value" }, { "key" => 5 }], [{ "key" => String }])
74
+ end
75
+
76
+ returns(false, "when collection has multiple schema patterns") do
77
+ validator.validate([{ "key" => "Value" }], [{ "key" => Integer }, { "key" => String }])
78
+ end
79
+
80
+ returns(false, "when hash and array are compared") do
81
+ validator.validate({}, [])
82
+ end
83
+
84
+ returns(false, "when array and hash are compared") do
85
+ validator.validate([], {})
86
+ end
87
+
88
+ returns(false, "when a hash is expected but another data type is found") do
89
+ validator.validate({ "key" => { :nested_key => [] } }, "key" => { :nested_key => {} })
90
+ end
91
+
92
+ returns(false, 'when key is missing but value should be NilClass (#1477)') do
93
+ validator.validate({}, { "key" => NilClass }, :allow_optional_rules => false)
94
+ end
95
+
96
+ returns(false, 'when key is missing but value is nullable (#1477)') do
97
+ validator.validate({}, { "key" => Fog::Nullable::String }, :allow_optional_rules => false)
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,9 @@
1
+ module Shindo
2
+ class Tests
3
+ def succeeds
4
+ test("succeeds") do
5
+ !!instance_eval(&Proc.new)
6
+ end
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-brightbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Thornthwaite
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: shindo
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: webmock
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -350,6 +364,11 @@ files:
350
364
  - spec/fog/brightbox/compute/config_spec.rb
351
365
  - spec/fog/brightbox/config_spec.rb
352
366
  - spec/fog/brightbox/link_helper_spec.rb
367
+ - spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb
368
+ - spec/fog/brightbox/oauth2/credential_set_spec.rb
369
+ - spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb
370
+ - spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb
371
+ - spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb
353
372
  - spec/fog/brightbox/storage/authentication_request_spec.rb
354
373
  - spec/fog/brightbox/storage/config_spec.rb
355
374
  - spec/fog/brightbox/storage/connection_errors_spec.rb
@@ -378,6 +397,48 @@ files:
378
397
  - spec/spec_helper.rb
379
398
  - spec/stock_storage_responses.rb
380
399
  - spec/supports_resource_locking.rb
400
+ - tests/brightbox/compute/helper.rb
401
+ - tests/brightbox/compute/schema.rb
402
+ - tests/brightbox/compute_tests.rb
403
+ - tests/brightbox/helper.rb
404
+ - tests/brightbox/models/compute/account_tests.rb
405
+ - tests/brightbox/models/compute/cloud_ip_tests.rb
406
+ - tests/brightbox/models/compute/database_server_tests.rb
407
+ - tests/brightbox/models/compute/database_snapshot_tests.rb
408
+ - tests/brightbox/models/compute/database_type_tests.rb
409
+ - tests/brightbox/models/compute/server_tests.rb
410
+ - tests/brightbox/requests/compute/account_tests.rb
411
+ - tests/brightbox/requests/compute/api_client_tests.rb
412
+ - tests/brightbox/requests/compute/application_test.rb
413
+ - tests/brightbox/requests/compute/cloud_ip_tests.rb
414
+ - tests/brightbox/requests/compute/collaboration_tests.rb
415
+ - tests/brightbox/requests/compute/database_server_tests.rb
416
+ - tests/brightbox/requests/compute/database_snapsnot_tests.rb
417
+ - tests/brightbox/requests/compute/database_type_tests.rb
418
+ - tests/brightbox/requests/compute/firewall_policy_tests.rb
419
+ - tests/brightbox/requests/compute/firewall_rule_tests.rb
420
+ - tests/brightbox/requests/compute/helper.rb
421
+ - tests/brightbox/requests/compute/image_tests.rb
422
+ - tests/brightbox/requests/compute/interface_tests.rb
423
+ - tests/brightbox/requests/compute/load_balancer_tests.rb
424
+ - tests/brightbox/requests/compute/server_group_tests.rb
425
+ - tests/brightbox/requests/compute/server_tests.rb
426
+ - tests/brightbox/requests/compute/server_type_tests.rb
427
+ - tests/brightbox/requests/compute/user_collaboration_tests.rb
428
+ - tests/brightbox/requests/compute/user_tests.rb
429
+ - tests/brightbox/requests/compute/zone_tests.rb
430
+ - tests/helper.rb
431
+ - tests/helpers/collection_helper.rb
432
+ - tests/helpers/compute/flavors_helper.rb
433
+ - tests/helpers/compute/server_helper.rb
434
+ - tests/helpers/compute/servers_helper.rb
435
+ - tests/helpers/formats_helper.rb
436
+ - tests/helpers/formats_helper_tests.rb
437
+ - tests/helpers/mock_helper.rb
438
+ - tests/helpers/model_helper.rb
439
+ - tests/helpers/responds_to_helper.rb
440
+ - tests/helpers/schema_validator_tests.rb
441
+ - tests/helpers/succeeds_helper.rb
381
442
  homepage: ''
382
443
  licenses:
383
444
  - MIT
@@ -407,6 +468,11 @@ test_files:
407
468
  - spec/fog/brightbox/compute/config_spec.rb
408
469
  - spec/fog/brightbox/config_spec.rb
409
470
  - spec/fog/brightbox/link_helper_spec.rb
471
+ - spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb
472
+ - spec/fog/brightbox/oauth2/credential_set_spec.rb
473
+ - spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb
474
+ - spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb
475
+ - spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb
410
476
  - spec/fog/brightbox/storage/authentication_request_spec.rb
411
477
  - spec/fog/brightbox/storage/config_spec.rb
412
478
  - spec/fog/brightbox/storage/connection_errors_spec.rb