fog-core 2.1.0 → 2.6.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.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/ci.yml +32 -0
- data/.rubocop.yml +16 -12
- data/.rubocop_todo.yml +724 -0
- data/CONTRIBUTING.md +5 -1
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/Rakefile +2 -14
- data/SECURITY.md +6 -0
- data/changelog.md +241 -141
- data/fog-core.gemspec +13 -9
- data/lib/fog/account.rb +0 -16
- data/lib/fog/billing.rb +0 -11
- data/lib/fog/compute/models/server.rb +7 -3
- data/lib/fog/compute.rb +3 -25
- data/lib/fog/core/association.rb +1 -0
- data/lib/fog/core/attributes/default.rb +7 -0
- data/lib/fog/core/attributes.rb +42 -5
- data/lib/fog/core/cache.rb +58 -55
- data/lib/fog/core/collection.rb +9 -3
- data/lib/fog/core/connection.rb +4 -6
- data/lib/fog/core/current_machine.rb +1 -1
- data/lib/fog/core/errors.rb +1 -1
- data/lib/fog/core/logger.rb +5 -2
- data/lib/fog/core/mock.rb +7 -2
- data/lib/fog/core/model.rb +34 -5
- data/lib/fog/core/provider.rb +37 -4
- data/lib/fog/core/scp.rb +16 -11
- data/lib/fog/core/service.rb +5 -5
- data/lib/fog/core/services_mixin.rb +62 -10
- data/lib/fog/core/ssh.rb +49 -25
- data/lib/fog/core/stringify_keys.rb +0 -2
- data/lib/fog/core/time.rb +2 -2
- data/lib/fog/core/uuid.rb +2 -8
- data/lib/fog/core/version.rb +3 -1
- data/lib/fog/core/wait_for.rb +2 -1
- data/lib/fog/core/wait_for_defaults.rb +2 -0
- data/lib/fog/core.rb +57 -59
- data/lib/fog/dns.rb +0 -11
- data/lib/fog/formatador.rb +9 -8
- data/lib/fog/monitoring.rb +0 -11
- data/lib/fog/network.rb +0 -12
- data/lib/fog/schema/data_validator.rb +1 -0
- data/lib/fog/storage.rb +15 -30
- data/lib/fog/support.rb +0 -12
- data/lib/fog/test_helpers/collection_helper.rb +2 -0
- data/lib/fog/test_helpers/formats_helper.rb +2 -2
- data/lib/fog/test_helpers/helper.rb +3 -3
- data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
- data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
- data/lib/fog/test_helpers/mock_helper.rb +84 -84
- data/lib/fog/test_helpers/succeeds_helper.rb +2 -2
- data/lib/fog/test_helpers/types_helper.rb +1 -0
- data/lib/fog/vpn.rb +0 -12
- data/lib/tasks/test_task.rb +4 -5
- metadata +58 -85
- data/.travis.yml +0 -39
- data/spec/compute/models/server_spec.rb +0 -229
- data/spec/compute_spec.rb +0 -95
- data/spec/connection_spec.rb +0 -105
- data/spec/core/cache_spec.rb +0 -191
- data/spec/core/model_spec.rb +0 -36
- data/spec/core/stringify_keys_spec.rb +0 -38
- data/spec/core/whitelist_keys_spec.rb +0 -36
- data/spec/credentials_spec.rb +0 -88
- data/spec/current_machine_spec.rb +0 -36
- data/spec/fake_app/fake_service.rb +0 -18
- data/spec/fake_app/models/collection.rb +0 -5
- data/spec/fake_app/models/model.rb +0 -2
- data/spec/fake_app/requests/request.rb +0 -11
- data/spec/fog_attribute_spec.rb +0 -549
- data/spec/formatador_spec.rb +0 -154
- data/spec/identity_spec.rb +0 -95
- data/spec/mocking_spec.rb +0 -84
- data/spec/service_spec.rb +0 -201
- data/spec/spec_helper.rb +0 -19
- data/spec/storage_spec.rb +0 -114
- data/spec/test_helpers/formats_helper_spec.rb +0 -121
- data/spec/test_helpers/schema_validator_spec.rb +0 -101
- data/spec/timeout_spec.rb +0 -20
- data/spec/utils_spec.rb +0 -29
- data/spec/uuid_spec.rb +0 -11
- data/spec/wait_for_spec.rb +0 -30
@@ -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
|
data/spec/wait_for_spec.rb
DELETED
@@ -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 = 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
|