fog-core 2.3.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +2 -2
- data/.github/workflows/ci.yml +32 -0
- data/.rubocop.yml +16 -12
- data/.rubocop_todo.yml +724 -0
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/Rakefile +2 -14
- data/SECURITY.md +6 -0
- data/changelog.md +26 -0
- data/fog-core.gemspec +11 -8
- data/lib/fog/compute/models/server.rb +7 -3
- data/lib/fog/compute.rb +3 -3
- data/lib/fog/core/association.rb +1 -0
- data/lib/fog/core/attributes/default.rb +7 -0
- data/lib/fog/core/attributes.rb +28 -3
- data/lib/fog/core/cache.rb +58 -55
- data/lib/fog/core/collection.rb +9 -3
- data/lib/fog/core/connection.rb +1 -1
- data/lib/fog/core/current_machine.rb +1 -1
- data/lib/fog/core/errors.rb +1 -1
- data/lib/fog/core/logger.rb +2 -2
- data/lib/fog/core/mock.rb +7 -2
- data/lib/fog/core/model.rb +34 -5
- data/lib/fog/core/provider.rb +7 -7
- data/lib/fog/core/scp.rb +15 -11
- data/lib/fog/core/service.rb +5 -5
- data/lib/fog/core/services_mixin.rb +9 -9
- data/lib/fog/core/ssh.rb +3 -2
- 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 +1 -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/formatador.rb +9 -8
- data/lib/fog/schema/data_validator.rb +1 -0
- data/lib/fog/storage.rb +15 -16
- 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/types_helper.rb +1 -0
- data/lib/tasks/test_task.rb +4 -5
- metadata +46 -81
- data/.github/workflows/ruby.yml +0 -18
- data/.github/workflows/stale.yml +0 -9
- 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 -112
- 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,36 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Fog::WhitelistKeys" do
|
4
|
-
describe ".whitelist" do
|
5
|
-
describe "when other keys are present" do
|
6
|
-
it "returns Hash with only allowed keys" do
|
7
|
-
input = { :name => "name", :type => "type", :size => 80 }
|
8
|
-
valid_keys = %w(name size)
|
9
|
-
|
10
|
-
output = Fog::WhitelistKeys.whitelist(input, valid_keys)
|
11
|
-
|
12
|
-
expected = { "name" => "name", "size" => 80 }
|
13
|
-
assert_equal(expected, output)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "when key is a Symbol" do
|
18
|
-
it "returns a String" do
|
19
|
-
input = { :name => "name" }
|
20
|
-
valid_keys = %w(name)
|
21
|
-
|
22
|
-
output = Fog::WhitelistKeys.whitelist(input, valid_keys)
|
23
|
-
|
24
|
-
expected = { "name" => "name" }
|
25
|
-
assert(expected, output)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "when Hash is empty" do
|
30
|
-
it "returns empty Hash" do
|
31
|
-
output = Fog::WhitelistKeys.whitelist({}, [])
|
32
|
-
assert_equal({}, output)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/spec/credentials_spec.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "credentials" do
|
4
|
-
before do
|
5
|
-
@old_home = ENV["HOME"]
|
6
|
-
@old_rc = ENV["FOG_RC"]
|
7
|
-
@old_credential = ENV["FOG_CREDENTIAL"]
|
8
|
-
@old_credentials = Fog.credentials
|
9
|
-
Fog.instance_variable_set("@credential_path", nil) # kill memoization
|
10
|
-
Fog.instance_variable_set("@credential", nil) # kill memoization
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
ENV["HOME"] = @old_home
|
15
|
-
ENV["FOG_RC"] = @old_rc
|
16
|
-
ENV["FOG_CREDENTIAL"] = @old_credential
|
17
|
-
Fog.credentials = @old_credentials
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "credential" do
|
21
|
-
it "returns :default for default credentials" do
|
22
|
-
assert_equal :default, Fog.credential
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns the to_sym of the assigned value" do
|
26
|
-
Fog.credential = "foo"
|
27
|
-
assert_equal :foo, Fog.credential
|
28
|
-
end
|
29
|
-
|
30
|
-
it "can set credentials throught the FOG_CREDENTIAL env va" do
|
31
|
-
ENV["FOG_CREDENTIAL"] = "bar"
|
32
|
-
assert_equal :bar, Fog.credential
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "credentials_path" do
|
37
|
-
it "has FOG_RC takes precedence over HOME" do
|
38
|
-
ENV["HOME"] = "/home/path"
|
39
|
-
ENV["FOG_RC"] = "/rc/path"
|
40
|
-
|
41
|
-
assert_equal "/rc/path", Fog.credentials_path
|
42
|
-
end
|
43
|
-
|
44
|
-
it "properly expands paths" do
|
45
|
-
ENV["FOG_RC"] = "/expanded/subdirectory/../path"
|
46
|
-
assert_equal "/expanded/path", Fog.credentials_path
|
47
|
-
end
|
48
|
-
|
49
|
-
it "falls back to home path if FOG_RC not set" do
|
50
|
-
ENV.delete("FOG_RC")
|
51
|
-
assert_equal File.join(ENV["HOME"], ".fog"), Fog.credentials_path
|
52
|
-
end
|
53
|
-
|
54
|
-
it "ignores home path if it does not exist" do
|
55
|
-
ENV.delete("FOG_RC")
|
56
|
-
ENV["HOME"] = "/no/such/path"
|
57
|
-
assert_nil Fog.credentials_path
|
58
|
-
end
|
59
|
-
|
60
|
-
it "File.expand_path raises because of non-absolute path" do
|
61
|
-
ENV.delete("FOG_RC")
|
62
|
-
ENV["HOME"] = "."
|
63
|
-
|
64
|
-
if RUBY_PLATFORM == "java"
|
65
|
-
Fog::Logger.warning("Stubbing out non-absolute path credentials test due to JRuby bug: https://github.com/jruby/jruby/issues/1163")
|
66
|
-
else
|
67
|
-
assert_nil Fog.credentials_path
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns nil when neither FOG_RC or HOME are set" do
|
72
|
-
ENV.delete("HOME")
|
73
|
-
ENV.delete("FOG_RC")
|
74
|
-
assert_nil Fog.credentials_path
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "symbolize_credential?" do
|
79
|
-
it "returns false if the value is :headers" do
|
80
|
-
refute Fog.symbolize_credential?(:headers)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "returns true if the value is not :headers" do
|
84
|
-
assert Fog.symbolize_credential?(:foo)
|
85
|
-
assert Fog.symbolize_credential?(:liberate_me_ex_inheris)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fog::CurrentMachine do
|
4
|
-
before do
|
5
|
-
@was_mocking = Fog.mock?
|
6
|
-
Fog.mock!
|
7
|
-
|
8
|
-
@old_excon_defaults_mock = Excon.defaults[:mock]
|
9
|
-
Excon.defaults[:mock] = true
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
Fog.unmock! unless @was_mocking
|
14
|
-
|
15
|
-
Fog::CurrentMachine.ip_address = nil
|
16
|
-
Excon.stubs.clear
|
17
|
-
Excon.defaults[:mock] = @old_excon_defaults_mock
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "ip_address" do
|
21
|
-
it "should be thread safe" do
|
22
|
-
|
23
|
-
(1..10).map do
|
24
|
-
Thread.new do
|
25
|
-
Excon.stub({ :method => :get, :path => "/" }, { :body => "" })
|
26
|
-
Fog::CurrentMachine.ip_address
|
27
|
-
end
|
28
|
-
end.each(&:join)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should remove trailing endline characters" do
|
32
|
-
Excon.stub({ :method => :get, :path => "/" }, { :body => "192.168.0.1\n" })
|
33
|
-
assert_equal "192.168.0.1", Fog::CurrentMachine.ip_address
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class FakeService < Fog::Service
|
2
|
-
class Real
|
3
|
-
def initialize(_options)
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
class Mock
|
8
|
-
def initialize(_options)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
model_path File.join(File.dirname(__FILE__), "models")
|
13
|
-
model :model
|
14
|
-
collection :collection
|
15
|
-
|
16
|
-
request_path File.join(File.dirname(__FILE__), "requests")
|
17
|
-
request :request
|
18
|
-
end
|