conjur-api 4.10.0 → 4.10.1
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 +4 -4
- data/Gemfile +2 -0
- data/conjur-api.gemspec +1 -1
- data/lib/conjur-api/version.rb +1 -1
- data/lib/conjur/configuration.rb +29 -5
- data/lib/conjur/exists.rb +2 -0
- data/spec/api/hosts_spec.rb +0 -1
- data/spec/lib/configuration_spec.rb +61 -1
- data/spec/lib/exists_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8082f753ddebe272f08498fb3e144dcd5477cc57
|
4
|
+
data.tar.gz: 1de7d39d363c091712b8d73add7cf7d87b952ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28727a8a68e30751fc2234329ceee61857d02fc6fbb41d8f51e1997523b66b21146d740f2af6577160a4d8aebc2f4026994a03fb20542750bb299a251deb80d1
|
7
|
+
data.tar.gz: 93e98f2269bd14ac60e4e3cd7ff8b6453aca5b0f7e4c2cc77da8e2e5736ed035a2712c460874f2ec72f467fd844ccbf9a41ec9b1db9d141bfda4476dd470a5a5
|
data/Gemfile
CHANGED
data/conjur-api.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_development_dependency 'spork'
|
27
27
|
gem.add_development_dependency 'rspec', '>= 2.14', '< 3.0'
|
28
28
|
gem.add_development_dependency 'webmock'
|
29
|
-
gem.add_development_dependency '
|
29
|
+
gem.add_development_dependency 'ci_reporter_rspec'
|
30
30
|
gem.add_development_dependency 'simplecov'
|
31
31
|
gem.add_development_dependency 'io-grab'
|
32
32
|
gem.add_development_dependency 'yard'
|
data/lib/conjur-api/version.rb
CHANGED
data/lib/conjur/configuration.rb
CHANGED
@@ -21,16 +21,38 @@
|
|
21
21
|
module Conjur
|
22
22
|
|
23
23
|
class << self
|
24
|
+
# Sets the Configuration for the current thread, yields the block, then resets the thread-local variable.
|
25
|
+
def with_configuration(config, &block)
|
26
|
+
oldvalue = Thread.current[:conjur_configuration]
|
27
|
+
Thread.current[:conjur_configuration] = config
|
28
|
+
yield
|
29
|
+
ensure
|
30
|
+
Thread.current[:conjur_configuration] = oldvalue
|
31
|
+
end
|
32
|
+
|
33
|
+
# Gets the current thread-local or global configuration.
|
24
34
|
def configuration
|
25
|
-
@config ||= Configuration.new
|
35
|
+
Thread.current[:conjur_configuration] || (@config ||= Configuration.new)
|
26
36
|
end
|
27
37
|
|
38
|
+
# Sets the global configuration.
|
28
39
|
def configuration=(config)
|
29
40
|
@config = config
|
30
41
|
end
|
31
42
|
end
|
32
43
|
|
33
44
|
class Configuration
|
45
|
+
# All explicit values.
|
46
|
+
attr_reader :explicit
|
47
|
+
|
48
|
+
# All explicit and cached values.
|
49
|
+
attr_reader :supplied
|
50
|
+
|
51
|
+
def initialize explicit = {}
|
52
|
+
@explicit = explicit.dup
|
53
|
+
@supplied = explicit.dup
|
54
|
+
end
|
55
|
+
|
34
56
|
class << self
|
35
57
|
# @api private
|
36
58
|
def accepted_options
|
@@ -94,9 +116,15 @@ module Conjur
|
|
94
116
|
alias_method("#{name}?", name) if options[:boolean]
|
95
117
|
end
|
96
118
|
end
|
119
|
+
|
120
|
+
# Copies the current configuration, except a set of overridden options.
|
121
|
+
def clone override_options
|
122
|
+
self.class.new self.explicit.dup.merge(override_options)
|
123
|
+
end
|
97
124
|
|
98
125
|
def set(key, value)
|
99
126
|
if self.class.accepted_options.include?(key.to_sym)
|
127
|
+
explicit[key.to_sym] = value
|
100
128
|
supplied[key.to_sym] = value
|
101
129
|
end
|
102
130
|
end
|
@@ -176,9 +204,5 @@ module Conjur
|
|
176
204
|
def herokuize name
|
177
205
|
name.downcase.gsub(/[^a-z0-9\-]/, '-')
|
178
206
|
end
|
179
|
-
|
180
|
-
def supplied
|
181
|
-
@supplied ||= {}
|
182
|
-
end
|
183
207
|
end
|
184
208
|
end
|
data/lib/conjur/exists.rb
CHANGED
data/spec/api/hosts_spec.rb
CHANGED
@@ -4,7 +4,67 @@ describe Conjur::Configuration do
|
|
4
4
|
before {
|
5
5
|
Conjur.configuration = Conjur::Configuration.new
|
6
6
|
}
|
7
|
-
|
7
|
+
let(:configuration) { Conjur.configuration }
|
8
|
+
subject { configuration }
|
9
|
+
context "thread-local behavior" do
|
10
|
+
it "can swap the Configuration in a new thread" do
|
11
|
+
original = Conjur.configuration
|
12
|
+
c = Conjur::Configuration.new
|
13
|
+
Thread.new do
|
14
|
+
Thread.current[:conjur_configuration] = :foo
|
15
|
+
Conjur.with_configuration c do
|
16
|
+
Conjur.configuration.should == c
|
17
|
+
end
|
18
|
+
Thread.current[:conjur_configuration].should == :foo
|
19
|
+
end.join
|
20
|
+
Conjur.configuration.should == original
|
21
|
+
end
|
22
|
+
end
|
23
|
+
context "with various options" do
|
24
|
+
before {
|
25
|
+
configuration.account = "the-account"
|
26
|
+
configuration.appliance_url = "https://conjur/api"
|
27
|
+
}
|
28
|
+
it "core_url is not pre-cached" do
|
29
|
+
configuration.supplied[:core_url].should_not be
|
30
|
+
end
|
31
|
+
it "core_url is cached after use" do
|
32
|
+
configuration.core_url
|
33
|
+
configuration.supplied[:core_url].should == configuration.core_url
|
34
|
+
end
|
35
|
+
context "and core_url fetched" do
|
36
|
+
before {
|
37
|
+
configuration.core_url
|
38
|
+
}
|
39
|
+
context "and duplicated" do
|
40
|
+
subject { configuration.clone override_options }
|
41
|
+
let(:override_options) { Hash.new }
|
42
|
+
its(:account) { should == configuration.account }
|
43
|
+
its(:appliance_url) { should == configuration.appliance_url }
|
44
|
+
its(:core_url) { should == configuration.appliance_url }
|
45
|
+
context "core_url fetched" do
|
46
|
+
it "is then cached in the original" do
|
47
|
+
configuration.supplied[:core_url].should be
|
48
|
+
end
|
49
|
+
it "is not cached in the copy" do
|
50
|
+
subject.supplied[:core_url].should_not be
|
51
|
+
end
|
52
|
+
end
|
53
|
+
context "appliance_url overridden" do
|
54
|
+
let(:override_options) {
|
55
|
+
{ :appliance_url => "https://example/api" }
|
56
|
+
}
|
57
|
+
it "is ignored by the configuration core_url" do
|
58
|
+
configuration.core_url.should == "https://conjur/api"
|
59
|
+
end
|
60
|
+
it "is reflected in the copy core_url" do
|
61
|
+
subject.core_url.should == "https://example/api"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
8
68
|
context "CONJUR_ENV unspecified" do
|
9
69
|
before {
|
10
70
|
ENV.delete('CONJUR_ENV')
|
data/spec/lib/exists_spec.rb
CHANGED
@@ -10,8 +10,8 @@ describe Conjur::Exists do
|
|
10
10
|
|
11
11
|
context "when forbidden" do
|
12
12
|
before { subject.stub(:head) { raise RestClient::Forbidden }}
|
13
|
-
it "
|
14
|
-
|
13
|
+
it "returns true" do
|
14
|
+
subject.exists?.should be_truthy
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.10.
|
4
|
+
version: 4.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Rzepecki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: ci_reporter_rspec
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '>='
|