foreplay 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/foreplay/engine/secrets.rb +1 -3
- data/lib/foreplay/version.rb +1 -1
- data/lib/string.rb +4 -0
- data/spec/lib/foreplay/secrets_spec.rb +58 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1a465561829258d5e0b9df51f30105c29a77176
|
4
|
+
data.tar.gz: 6a14c037d84c88ce58c43daaeda788fd959013e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb510cd1560115068df1197db21bf6b734fc1e25a9e8e4e9937a075eca3405949db739a4547fba4ed732dc630dd6c27ec4efcc6cb14410a3feb6c71a9c0d749b
|
7
|
+
data.tar.gz: 58c9c5292ad36dc9366ee34771dbe1f13af30f2ce7ef791506a0fcb04405e6463f376b0fbf52bd8ac80f61afc26e67c23c253ca7b273b6afdb788861de901d68
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pp' # debug
|
2
|
-
|
3
1
|
class Foreplay::Engine::Secrets
|
4
2
|
attr_reader :environment, :secret_locations
|
5
3
|
|
@@ -25,7 +23,7 @@ class Foreplay::Engine::Secrets
|
|
25
23
|
|
26
24
|
headers = secret_location['headers']
|
27
25
|
header_string = headers.map { |k, v| " -H \"#{k}: #{v}\"" }.join if headers.is_a? Hash
|
28
|
-
command = "curl -k -L#{header_string} #{url}"
|
26
|
+
command = "curl -k -L#{header_string} #{url}".fake_erb
|
29
27
|
secrets_all = YAML.load(`#{command}`)
|
30
28
|
secrets = secrets_all[environment]
|
31
29
|
|
data/lib/foreplay/version.rb
CHANGED
data/lib/string.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foreplay'
|
3
|
+
|
4
|
+
describe Foreplay::Engine::Secrets do
|
5
|
+
context '#fetch' do
|
6
|
+
it 'returns nil if there is no secret location' do
|
7
|
+
expect(Foreplay::Engine::Secrets.new('x', nil).fetch).to be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'fails if the secret location is not a hash' do
|
11
|
+
expect { Foreplay::Engine::Secrets.new('x', 'y').fetch } .to raise_error(NoMethodError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns an empty hash if the secret location has no url' do
|
15
|
+
expect(Foreplay::Engine::Secrets.new('x', []).fetch).to eq({})
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns an empty hash if the secret location does not return valid YAML' do
|
19
|
+
expect(Foreplay::Engine::Secrets.new('x', [{ 'url' => 'http://iana.org' }]).fetch).to eq({})
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns an empty hash if the secret location does not exist' do
|
23
|
+
expect(Foreplay::Engine::Secrets.new('x', [{ 'url' => 'http://iana.org/404' }]).fetch).to eq({})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context '#fetch successful' do
|
28
|
+
let(:secrets) { { 'a' => 'x', 'b' => 'y', 'c' => 'z' } }
|
29
|
+
let(:secret) { Foreplay::Engine::Secrets.new('', ['x']) }
|
30
|
+
|
31
|
+
before :each do
|
32
|
+
allow(secret).to receive(:fetch_from).and_return(secrets)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does what it is told' do
|
36
|
+
expect(secret.fetch_from).to eq(secrets)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns a hash of secrets' do
|
40
|
+
expect(secret.fetch).to eq(secrets)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context '#fetch successful with merge' do
|
45
|
+
let(:secrets1) { { 'a' => 'x', 'b' => 'f' } }
|
46
|
+
let(:secrets2) { { 'b' => 'y', 'c' => 'z' } }
|
47
|
+
let(:secrets) { { 'a' => 'x', 'b' => 'y', 'c' => 'z' } }
|
48
|
+
let(:secret) { Foreplay::Engine::Secrets.new('', %w(x x)) }
|
49
|
+
|
50
|
+
before :each do
|
51
|
+
allow(secret).to receive(:fetch_from).and_return(secrets1, secrets2)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns a hash of secrets' do
|
55
|
+
expect(secret.fetch).to eq(secrets)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreplay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xenapto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- lib/string.rb
|
239
239
|
- spec/lib/foreplay/deploy_spec.rb
|
240
240
|
- spec/lib/foreplay/engine_spec.rb
|
241
|
+
- spec/lib/foreplay/secrets_spec.rb
|
241
242
|
- spec/lib/foreplay/setup_spec.rb
|
242
243
|
- spec/spec_helper.rb
|
243
244
|
homepage: https://github.com/Xenapto/foreplay
|
@@ -271,5 +272,6 @@ test_files:
|
|
271
272
|
- features/support/env.rb
|
272
273
|
- spec/lib/foreplay/deploy_spec.rb
|
273
274
|
- spec/lib/foreplay/engine_spec.rb
|
275
|
+
- spec/lib/foreplay/secrets_spec.rb
|
274
276
|
- spec/lib/foreplay/setup_spec.rb
|
275
277
|
- spec/spec_helper.rb
|