bosh-core 1.5.0.pre.1226 → 1.5.0.pre.1244
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bosh/core/version.rb +1 -1
- metadata +3 -16
- data/.gitignore +0 -17
- data/.rspec +0 -2
- data/bosh-core.gemspec +0 -27
- data/spec/bosh/core/shell_spec.rb +0 -66
- data/spec/bosh/core/version_spec.rb +0 -12
- data/spec/bosh/core_spec.rb +0 -6
- data/spec/bosh/encryption_handler_spec.rb +0 -135
- data/spec/spec_helper.rb +0 -5
data/lib/bosh/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.pre.
|
4
|
+
version: 1.5.0.pre.1244
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gibberish
|
@@ -97,18 +97,10 @@ executables: []
|
|
97
97
|
extensions: []
|
98
98
|
extra_rdoc_files: []
|
99
99
|
files:
|
100
|
-
- .gitignore
|
101
|
-
- .rspec
|
102
|
-
- bosh-core.gemspec
|
103
100
|
- lib/bosh/core.rb
|
104
101
|
- lib/bosh/core/encryption_handler.rb
|
105
102
|
- lib/bosh/core/shell.rb
|
106
103
|
- lib/bosh/core/version.rb
|
107
|
-
- spec/bosh/core/shell_spec.rb
|
108
|
-
- spec/bosh/core/version_spec.rb
|
109
|
-
- spec/bosh/core_spec.rb
|
110
|
-
- spec/bosh/encryption_handler_spec.rb
|
111
|
-
- spec/spec_helper.rb
|
112
104
|
homepage: https://github.com/cloudfoundry/bosh
|
113
105
|
licenses:
|
114
106
|
- Apache 2.0
|
@@ -134,9 +126,4 @@ rubygems_version: 1.8.23
|
|
134
126
|
signing_key:
|
135
127
|
specification_version: 3
|
136
128
|
summary: Bosh::Core provides things BOSH needs to exist
|
137
|
-
test_files:
|
138
|
-
- spec/bosh/core/shell_spec.rb
|
139
|
-
- spec/bosh/core/version_spec.rb
|
140
|
-
- spec/bosh/core_spec.rb
|
141
|
-
- spec/bosh/encryption_handler_spec.rb
|
142
|
-
- spec/spec_helper.rb
|
129
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/bosh-core.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
version = File.read(File.expand_path('../../BOSH_VERSION', __FILE__)).strip
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = 'bosh-core'
|
6
|
-
spec.version = version
|
7
|
-
spec.authors = 'Pivotal'
|
8
|
-
spec.email = 'support@cloudfoundry.com'
|
9
|
-
spec.description = 'Bosh::Core provides things BOSH needs to exist'
|
10
|
-
spec.summary = 'Bosh::Core provides things BOSH needs to exist'
|
11
|
-
spec.homepage = 'https://github.com/cloudfoundry/bosh'
|
12
|
-
spec.license = 'Apache 2.0'
|
13
|
-
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 1.9.3')
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = %w[lib]
|
20
|
-
|
21
|
-
spec.add_dependency 'gibberish', '~>1.2.0'
|
22
|
-
spec.add_dependency 'yajl-ruby', '~>1.1.0'
|
23
|
-
|
24
|
-
spec.add_development_dependency 'rake'
|
25
|
-
spec.add_development_dependency 'rspec'
|
26
|
-
spec.add_development_dependency 'rspec-fire'
|
27
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'bosh/core/shell'
|
3
|
-
|
4
|
-
module Bosh::Core
|
5
|
-
describe Shell do
|
6
|
-
let(:stdout) { StringIO.new }
|
7
|
-
|
8
|
-
subject do
|
9
|
-
Shell.new(stdout)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#run' do
|
13
|
-
it 'shells out, prints and returns the output of the command' do
|
14
|
-
expect(subject.run('echo hello; echo world')).to eq("hello\nworld")
|
15
|
-
expect(stdout.string).to eq("hello\nworld\n")
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when "output_command" is specified' do
|
19
|
-
it 'outputs the command' do
|
20
|
-
cmd = 'echo 1;echo 2;echo 3;echo 4;echo 5'
|
21
|
-
subject.run(cmd, output_command: true)
|
22
|
-
|
23
|
-
expect(stdout.string).to include('echo 1;echo 2;echo 3;echo 4;echo 5')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'when "last_number" is specified' do
|
28
|
-
it 'tails "last_number" lines of output' do
|
29
|
-
cmd = 'echo 1;echo 2;echo 3;echo 4;echo 5'
|
30
|
-
expect(subject.run(cmd, last_number: 3)).to eq("3\n4\n5")
|
31
|
-
expect(stdout.string).to eq("1\n2\n3\n4\n5\n")
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'outputs the entire output if more lines are requested than generated' do
|
35
|
-
cmd = 'echo 1;echo 2;echo 3;echo 4;echo 5'
|
36
|
-
expect(subject.run(cmd, last_number: 6)).to eq("1\n2\n3\n4\n5")
|
37
|
-
expect(stdout.string).to eq("1\n2\n3\n4\n5\n")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when the command fails' do
|
42
|
-
it 'raises an error' do
|
43
|
-
expect {
|
44
|
-
subject.run('false')
|
45
|
-
}.to raise_error /Failed: 'false' from /
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'because the working directory has gone missing' do
|
49
|
-
it 'fails gracefully with a slightly helpful error message' do
|
50
|
-
Dir.stub(:pwd).and_raise(Errno::ENOENT, 'No such file or directory - getcwd')
|
51
|
-
expect {
|
52
|
-
subject.run('false')
|
53
|
-
}.to raise_error /from a deleted directory/
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'and ignoring failures' do
|
58
|
-
it 'raises an error' do
|
59
|
-
subject.run('false', ignore_failures: true)
|
60
|
-
expect(stdout.string).to match(/continuing anyway/)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'bosh/core/version'
|
3
|
-
|
4
|
-
module Bosh::Core
|
5
|
-
describe VERSION do
|
6
|
-
let(:bosh_version_file) do
|
7
|
-
File.expand_path('../../../../BOSH_VERSION', File.dirname(__FILE__))
|
8
|
-
end
|
9
|
-
|
10
|
-
it { should eq(File.read(bosh_version_file).strip) }
|
11
|
-
end
|
12
|
-
end
|
data/spec/bosh/core_spec.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'bosh/core/encryption_handler'
|
3
|
-
|
4
|
-
module Bosh::Core
|
5
|
-
describe EncryptionHandler do
|
6
|
-
before(:each) do
|
7
|
-
@credentials = EncryptionHandler.generate_credentials
|
8
|
-
@cipher = Gibberish::AES.new(@credentials['crypt_key'])
|
9
|
-
@sign_key = @credentials['sign_key']
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should encrypt data' do
|
13
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
14
|
-
encrypted_data = handler.encrypt('hubba' => 'bubba')
|
15
|
-
|
16
|
-
# double decode is not an error - data need to be serialized before it is
|
17
|
-
# signed and then serialized again to be encrypted
|
18
|
-
decrypted_data = handler.decode(handler.decode(@cipher.decrypt(encrypted_data))['json_data'])
|
19
|
-
decrypted_data['hubba'].should eq 'bubba'
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should be signed' do
|
23
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
24
|
-
encrypted_data = handler.encrypt('hubba' => 'bubba')
|
25
|
-
|
26
|
-
decrypted_data = handler.decode(@cipher.decrypt(encrypted_data))
|
27
|
-
signature = decrypted_data['hmac']
|
28
|
-
json_data = decrypted_data['json_data']
|
29
|
-
|
30
|
-
signature.should eq Gibberish.HMAC(@sign_key, json_data, { digest: :sha256 })
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should decrypt' do
|
34
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
35
|
-
|
36
|
-
encrypted_data = handler.encrypt('hubba' => 'bubba')
|
37
|
-
handler.decrypt(encrypted_data)['hubba'].should eq 'bubba'
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should verify signature' do
|
41
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
42
|
-
|
43
|
-
encrypted_data = handler.encrypt('hubba' => 'bubba')
|
44
|
-
|
45
|
-
# build bad data
|
46
|
-
manipulated_data = handler.decode(@cipher.decrypt(encrypted_data))
|
47
|
-
manipulated_data['hmac'] = 'foo'
|
48
|
-
encrypted_manipulated_data = @cipher.encrypt(handler.encode(manipulated_data))
|
49
|
-
|
50
|
-
lambda {
|
51
|
-
handler.decrypt(encrypted_manipulated_data)
|
52
|
-
}.should raise_error(EncryptionHandler::SignatureError,
|
53
|
-
/Expected hmac \(foo\)/)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should verify session' do
|
57
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
58
|
-
|
59
|
-
encrypted_data = handler.encrypt('knife' => 'fork')
|
60
|
-
|
61
|
-
# build bad data
|
62
|
-
decrypted_data = handler.decode(@cipher.decrypt(encrypted_data))
|
63
|
-
|
64
|
-
bad_data = handler.decode(decrypted_data['json_data'])
|
65
|
-
bad_data['session_id'] = 'bad_session_data'
|
66
|
-
|
67
|
-
bad_json_data = handler.encode(bad_data)
|
68
|
-
|
69
|
-
manipulated_data = {
|
70
|
-
'hmac' => handler.signature(bad_json_data),
|
71
|
-
'json_data' => bad_json_data
|
72
|
-
}
|
73
|
-
|
74
|
-
encrypted_manipulated_data = @cipher.encrypt(handler.encode(manipulated_data))
|
75
|
-
|
76
|
-
lambda {
|
77
|
-
handler.decrypt(encrypted_manipulated_data)
|
78
|
-
}.should raise_error(EncryptionHandler::SessionError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'should decrypt for multiple messages' do
|
82
|
-
h1 = EncryptionHandler.new('client_id', @credentials)
|
83
|
-
h2 = EncryptionHandler.new('client_id', @credentials)
|
84
|
-
encrypted_data1 = h1.encrypt('hubba' => 'bubba')
|
85
|
-
encrypted_data2 = h1.encrypt('bubba' => 'hubba')
|
86
|
-
|
87
|
-
h2.decrypt(encrypted_data1)['hubba'].should eq 'bubba'
|
88
|
-
h2.decrypt(encrypted_data2)['bubba'].should eq 'hubba'
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should exchange messages' do
|
92
|
-
h1 = EncryptionHandler.new('client_id', @credentials)
|
93
|
-
h2 = EncryptionHandler.new('client_id', @credentials)
|
94
|
-
|
95
|
-
encrypted_data1 = h1.encrypt('hubba' => 'bubba')
|
96
|
-
h2.decrypt(encrypted_data1)['hubba'].should eq 'bubba'
|
97
|
-
|
98
|
-
encrypted_data2 = h2.encrypt('kermit' => 'frog')
|
99
|
-
h1.decrypt(encrypted_data2)['kermit'].should eq 'frog'
|
100
|
-
|
101
|
-
encrypted_data3 = h1.encrypt('frank' => 'zappa')
|
102
|
-
h2.decrypt(encrypted_data3)['frank'].should eq 'zappa'
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should fail when sequence number is out of order' do
|
106
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
107
|
-
encrypted_data1 = handler.encrypt('foo' => 'bar')
|
108
|
-
encrypted_data2 = handler.encrypt('baz' => 'bus')
|
109
|
-
|
110
|
-
handler.decrypt(encrypted_data2)
|
111
|
-
|
112
|
-
lambda {
|
113
|
-
handler.decrypt(encrypted_data1)
|
114
|
-
}.should raise_error(EncryptionHandler::SequenceNumberError)
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'should handle garbage encrypt args' do
|
118
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
119
|
-
lambda {
|
120
|
-
handler.encrypt('bleh')
|
121
|
-
}.should raise_error(ArgumentError)
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'should handle garbage decrypt args' do
|
125
|
-
handler = EncryptionHandler.new('client_id', @credentials)
|
126
|
-
lambda {
|
127
|
-
handler.decrypt('f')
|
128
|
-
}.should raise_error(EncryptionHandler::DecryptionError, /TypeError/)
|
129
|
-
|
130
|
-
lambda {
|
131
|
-
handler.decrypt('fddddddddddddddddddddddddddddddddddddddddddddddddd')
|
132
|
-
}.should raise_error(EncryptionHandler::DecryptionError, /CipherError/)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|