fog-core 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +2 -0
  3. data/.github/dependabot.yml +2 -4
  4. data/.github/workflows/ci.yml +32 -0
  5. data/.rubocop.yml +1 -1
  6. data/README.md +2 -1
  7. data/SECURITY.md +6 -0
  8. data/changelog.md +12 -0
  9. data/fog-core.gemspec +1 -1
  10. data/lib/fog/compute.rb +1 -1
  11. data/lib/fog/core/mock.rb +1 -1
  12. data/lib/fog/core/provider.rb +1 -1
  13. data/lib/fog/core/service.rb +1 -1
  14. data/lib/fog/core/version.rb +1 -1
  15. data/lib/fog/core.rb +0 -1
  16. data/lib/fog/formatador.rb +3 -3
  17. data/lib/fog/storage.rb +0 -1
  18. data/lib/tasks/test_task.rb +2 -3
  19. metadata +5 -31
  20. data/.github/workflows/ruby.yml +0 -18
  21. data/.github/workflows/stale.yml +0 -9
  22. data/spec/compute/models/server_spec.rb +0 -229
  23. data/spec/compute_spec.rb +0 -95
  24. data/spec/connection_spec.rb +0 -107
  25. data/spec/core/cache_spec.rb +0 -227
  26. data/spec/core/collection_spec.rb +0 -24
  27. data/spec/core/model_spec.rb +0 -69
  28. data/spec/core/stringify_keys_spec.rb +0 -38
  29. data/spec/core/whitelist_keys_spec.rb +0 -36
  30. data/spec/credentials_spec.rb +0 -88
  31. data/spec/current_machine_spec.rb +0 -36
  32. data/spec/fake_app/fake_service.rb +0 -18
  33. data/spec/fake_app/models/collection.rb +0 -5
  34. data/spec/fake_app/models/model.rb +0 -2
  35. data/spec/fake_app/requests/request.rb +0 -11
  36. data/spec/fog_attribute_spec.rb +0 -569
  37. data/spec/formatador_spec.rb +0 -154
  38. data/spec/identity_spec.rb +0 -95
  39. data/spec/mocking_spec.rb +0 -84
  40. data/spec/service_spec.rb +0 -201
  41. data/spec/spec_helper.rb +0 -14
  42. data/spec/storage_spec.rb +0 -112
  43. data/spec/test_helpers/formats_helper_spec.rb +0 -121
  44. data/spec/test_helpers/schema_validator_spec.rb +0 -101
  45. data/spec/timeout_spec.rb +0 -20
  46. data/spec/utils_spec.rb +0 -29
  47. data/spec/uuid_spec.rb +0 -11
  48. data/spec/wait_for_spec.rb +0 -30
@@ -1,121 +0,0 @@
1
- require "spec_helper"
2
- require "fog/test_helpers/formats_helper"
3
- require "fog/test_helpers/types_helper"
4
-
5
- module Shindo
6
- class Tests
7
- def test(_str, &_block)
8
- yield
9
- end
10
- end
11
- end
12
-
13
- describe "formats_helper" do
14
- let(:shindo) { Shindo::Tests.new }
15
-
16
- it "comparing welcome data against schema" do
17
- data = { welcome: "Hello" }
18
- assert shindo.data_matches_schema(welcome: String) { data }
19
- end
20
-
21
- describe "#data_matches_schema" do
22
- it "when value matches schema expectation" do
23
- assert shindo.data_matches_schema("key" => String) { { "key" => "Value" } }
24
- end
25
-
26
- it "when values within an array all match schema expectation" do
27
- assert shindo.data_matches_schema("key" => [Integer]) { { "key" => [1, 2] } }
28
- end
29
-
30
- it "when nested values match schema expectation" do
31
- assert shindo.data_matches_schema("key" => { nested_key: String }) { { "key" => { nested_key: "Value" } } }
32
- end
33
-
34
- it "when collection of values all match schema expectation" do
35
- assert shindo.data_matches_schema([{ "key" => String }]) { [{ "key" => "Value" }, { "key" => "Value" }] }
36
- end
37
-
38
- it "when collection is empty although schema covers optional members" do
39
- assert shindo.data_matches_schema([{ "key" => String }], allow_optional_rules: true) { [] }
40
- end
41
-
42
- it "when additional keys are passed and not strict" do
43
- assert shindo.data_matches_schema({ "key" => String }, { allow_extra_keys: true }) { { "key" => "Value", :extra => "Bonus" } }
44
- end
45
-
46
- it "when value is nil and schema expects NilClass" do
47
- assert shindo.data_matches_schema("key" => NilClass) { { "key" => nil } }
48
- end
49
-
50
- it "when value and schema match as hashes" do
51
- assert shindo.data_matches_schema({}) { {} }
52
- end
53
-
54
- it "when value and schema match as arrays" do
55
- assert shindo.data_matches_schema([]) { [] }
56
- end
57
-
58
- it "when value is a Time" do
59
- assert shindo.data_matches_schema("time" => Time) { { "time" => Time.now } }
60
- end
61
-
62
- it "when key is missing but value should be NilClass (#1477)" do
63
- assert shindo.data_matches_schema({ "key" => NilClass }, { allow_optional_rules: true }) { {} }
64
- end
65
-
66
- it "when key is missing but value is nullable (#1477)" do
67
- assert shindo.data_matches_schema({ "key" => Fog::Nullable::String }, { allow_optional_rules: true }) { {} }
68
- end
69
- end
70
-
71
- describe "#formats backwards compatible changes" do
72
-
73
- it "when value matches schema expectation" do
74
- assert shindo.formats("key" => String) { { "key" => "Value" } }
75
- end
76
-
77
- it "when values within an array all match schema expectation" do
78
- assert shindo.formats("key" => [Integer]) { { "key" => [1, 2] } }
79
- end
80
-
81
- it "when nested values match schema expectation" do
82
- assert shindo.formats("key" => { nested_key: String }) { { "key" => { nested_key: "Value" } } }
83
- end
84
-
85
- it "when collection of values all match schema expectation" do
86
- assert shindo.formats([{ "key" => String }]) { [{ "key" => "Value" }, { "key" => "Value" }] }
87
- end
88
-
89
- it "when collection is empty although schema covers optional members" do
90
- assert shindo.formats([{ "key" => String }]) { [] }
91
- end
92
-
93
- it "when additional keys are passed and not strict" do
94
- assert shindo.formats({ "key" => String }, false) { { "key" => "Value", :extra => "Bonus" } }
95
- end
96
-
97
- it "when value is nil and schema expects NilClass" do
98
- assert shindo.formats("key" => NilClass) { { "key" => nil } }
99
- end
100
-
101
- it "when value and schema match as hashes" do
102
- assert shindo.formats({}) { {} }
103
- end
104
-
105
- it "when value and schema match as arrays" do
106
- assert shindo.formats([]) { [] }
107
- end
108
-
109
- it "when value is a Time" do
110
- assert shindo.formats("time" => Time) { { "time" => Time.now } }
111
- end
112
-
113
- it "when key is missing but value should be NilClass (#1477)" do
114
- assert shindo.formats("key" => NilClass) { {} }
115
- end
116
-
117
- it "when key is missing but value is nullable (#1477)" do
118
- assert shindo.formats("key" => Fog::Nullable::String) { {} }
119
- end
120
- end
121
- end
@@ -1,101 +0,0 @@
1
- require "spec_helper"
2
- require "fog/test_helpers/formats_helper"
3
- require "fog/schema/data_validator"
4
-
5
- describe "SchemaValidator" do
6
- let(:validator) { Fog::Schema::DataValidator.new }
7
-
8
- describe "#validate" do
9
- it "returns true when value matches schema expectation" do
10
- assert validator.validate({ "key" => "Value" }, { "key" => String })
11
- end
12
-
13
- it "returns true when values within an array all match schema expectation" do
14
- assert validator.validate({ "key" => [1, 2] }, { "key" => [Integer] })
15
- end
16
-
17
- it "returns true when nested values match schema expectation" do
18
- assert validator.validate({ "key" => { nested_key: "Value" } }, { "key" => { nested_key: String } })
19
- end
20
-
21
- it "returns true when collection of values all match schema expectation" do
22
- assert validator.validate([{ "key" => "Value" }, { "key" => "Value" }], [{ "key" => String }])
23
- end
24
-
25
- it "returns true when collection is empty although schema covers optional members" do
26
- assert validator.validate([], [{ "key" => String }])
27
- end
28
-
29
- it "returns true when additional keys are passed and not strict" do
30
- assert validator.validate({ "key" => "Value", :extra => "Bonus" }, { "key" => String }, { allow_extra_keys: true })
31
- end
32
-
33
- it "returns true when value is nil and schema expects NilClass" do
34
- assert validator.validate({ "key" => nil }, { "key" => NilClass })
35
- end
36
-
37
- it "returns true when value and schema match as hashes" do
38
- assert validator.validate({}, {})
39
- end
40
-
41
- it "returns true when value and schema match as arrays" do
42
- assert validator.validate([], [])
43
- end
44
-
45
- it "returns true when value is a Time" do
46
- assert validator.validate({ "time" => Time.now }, { "time" => Time })
47
- end
48
-
49
- it "returns true when key is missing but value should be NilClass (#1477)" do
50
- assert validator.validate({}, { "key" => NilClass }, { allow_optional_rules: true })
51
- end
52
-
53
- it "returns true when key is missing but value is nullable (#1477)" do
54
- assert validator.validate({}, { "key" => Fog::Nullable::String }, { allow_optional_rules: true })
55
- end
56
-
57
- it "returns false when value does not match schema expectation" do
58
- refute validator.validate({ "key" => nil }, { "key" => String })
59
- end
60
-
61
- it "returns false when key formats do not match" do
62
- refute validator.validate({ "key" => "Value" }, { key: String })
63
- end
64
-
65
- it "returns false when additional keys are passed and strict" do
66
- refute validator.validate({ "key" => "Missing" }, {})
67
- end
68
-
69
- it "returns false when some keys do not appear" do
70
- refute validator.validate({}, { "key" => String })
71
- end
72
-
73
- it "returns false when collection contains a member that does not match schema" do
74
- refute validator.validate([{ "key" => "Value" }, { "key" => 5 }], [{ "key" => String }])
75
- end
76
-
77
- it "returns false when collection has multiple schema patterns" do
78
- refute validator.validate([{ "key" => "Value" }], [{ "key" => Integer }, { "key" => String }])
79
- end
80
-
81
- it "returns false when hash and array are compared" do
82
- refute validator.validate({}, [])
83
- end
84
-
85
- it "returns false when array and hash are compared" do
86
- refute validator.validate([], {})
87
- end
88
-
89
- it "returns false when a hash is expected but another data type is found" do
90
- refute validator.validate({ "key" => { nested_key: [] } }, { "key" => { nested_key: {} } })
91
- end
92
-
93
- it "returns false when key is missing but value should be NilClass (#1477)" do
94
- refute validator.validate({}, { "key" => NilClass }, { allow_optional_rules: false })
95
- end
96
-
97
- it "returns false when key is missing but value is nullable (#1477)" do
98
- refute validator.validate({}, { "key" => Fog::Nullable::String }, { allow_optional_rules: false })
99
- end
100
- end
101
- end
data/spec/timeout_spec.rb DELETED
@@ -1,20 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Fog#timeout" do
4
- before do
5
- @old_timeout = Fog.timeout
6
- end
7
-
8
- after do
9
- Fog.timeout = @old_timeout
10
- end
11
-
12
- it "defaults to 600" do
13
- assert_equal 600, Fog.timeout
14
- end
15
-
16
- it "can be reassigned through Fog#timeout=" do
17
- Fog.timeout = 300
18
- assert_equal 300, Fog.timeout
19
- end
20
- end
data/spec/utils_spec.rb DELETED
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Fog::Core::Utils do
4
- describe "prepare_service_settings" do
5
- it "changes String keys to be Symbols" do
6
- settings = { "a" => 3 }
7
- expected = { a: 3 }
8
- assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
9
- end
10
-
11
- it "leaves Symbol keys unchanged" do
12
- settings = { something: 2 }
13
- expected = { something: 2 }
14
- assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
15
- end
16
-
17
- it "changes nested String keys to Symbols" do
18
- settings = { "connection_options" => { "val" => 5 } }
19
- expected = { connection_options: { val: 5 } }
20
- assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
21
- end
22
-
23
- it "does not change the :header key or contents" do
24
- settings = { headers: { "User-Agent" => "my user agent" } }
25
- expected = { headers: { "User-Agent" => "my user agent" } }
26
- assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
27
- end
28
- end
29
- end
data/spec/uuid_spec.rb DELETED
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Fog::UUID" do
4
- it "#supported?" do
5
- Fog::UUID.supported? == SecureRandom.respond_to?(:uuid)
6
- end
7
-
8
- it "generates a valid UUID" do
9
- Fog::UUID.uuid =~ /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Fog#wait_for" do
4
- it "returns a Hash indicating the wait duration if successful" do
5
- assert_equal({ duration: 0 }, Fog.wait_for(1) { true })
6
- end
7
-
8
- it "raises if the wait timeout is exceeded" do
9
- assert_raises(Fog::Errors::TimeoutError) do
10
- Fog.wait_for(2) { false }
11
- end
12
- end
13
-
14
- it "does not raise if successful when the wait timeout is exceeded" do
15
- timeout = 2
16
- i = 0
17
- ret = Fog.wait_for(timeout) { i += 1; i > 2 }
18
- assert_operator(ret[:duration], :>, timeout)
19
- end
20
-
21
- it "accepts a proc to determine the sleep interval" do
22
- i = 0
23
- ret = Fog.wait_for(1, lambda { |_t| 1 }) do
24
- i += 1
25
- i > 1
26
- end
27
- assert(1 <= ret[:duration])
28
- assert(ret[:duration] < 2)
29
- end
30
- end