chamber 2.10.1 → 2.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/chamber/encryption_methods/none.rb +2 -0
  5. data/lib/chamber/version.rb +1 -1
  6. metadata +22 -99
  7. metadata.gz.sig +0 -0
  8. data/spec/fixtures/settings.yml +0 -28
  9. data/spec/lib/chamber/commands/files_spec.rb +0 -24
  10. data/spec/lib/chamber/commands/heroku/clear_spec.rb +0 -12
  11. data/spec/lib/chamber/commands/heroku/compare_spec.rb +0 -12
  12. data/spec/lib/chamber/commands/heroku/pull_spec.rb +0 -12
  13. data/spec/lib/chamber/commands/heroku/push_spec.rb +0 -12
  14. data/spec/lib/chamber/commands/secure_spec.rb +0 -42
  15. data/spec/lib/chamber/commands/show_spec.rb +0 -59
  16. data/spec/lib/chamber/context_resolver_spec.rb +0 -164
  17. data/spec/lib/chamber/file_set_spec.rb +0 -250
  18. data/spec/lib/chamber/file_spec.rb +0 -241
  19. data/spec/lib/chamber/filters/boolean_conversion_filter_spec.rb +0 -57
  20. data/spec/lib/chamber/filters/decryption_filter_spec.rb +0 -252
  21. data/spec/lib/chamber/filters/encryption_filter_spec.rb +0 -195
  22. data/spec/lib/chamber/filters/environment_filter_spec.rb +0 -48
  23. data/spec/lib/chamber/filters/failed_decryption_filter_spec.rb +0 -54
  24. data/spec/lib/chamber/filters/insecure_filter_spec.rb +0 -82
  25. data/spec/lib/chamber/filters/namespace_filter_spec.rb +0 -92
  26. data/spec/lib/chamber/filters/secure_filter_spec.rb +0 -41
  27. data/spec/lib/chamber/filters/translate_secure_keys_filter_spec.rb +0 -39
  28. data/spec/lib/chamber/namespace_set_spec.rb +0 -129
  29. data/spec/lib/chamber/settings_spec.rb +0 -390
  30. data/spec/lib/chamber/types/secured_spec.rb +0 -70
  31. data/spec/lib/chamber_spec.rb +0 -314
  32. data/spec/rails-2-test/config.ru +0 -0
  33. data/spec/rails-2-test/config/application.rb +0 -6
  34. data/spec/rails-2-test/script/console +0 -0
  35. data/spec/rails-3-test/config.ru +0 -0
  36. data/spec/rails-3-test/config/application.rb +0 -6
  37. data/spec/rails-3-test/script/rails +0 -0
  38. data/spec/rails-4-test/bin/rails +0 -0
  39. data/spec/rails-4-test/config.ru +0 -0
  40. data/spec/rails-4-test/config/application.rb +0 -6
  41. data/spec/rails-engine-test/spec/dummy/config.ru +0 -0
  42. data/spec/rails-engine-test/spec/dummy/config/application.rb +0 -5
  43. data/spec/rails-engine-test/spec/dummy/script/rails +0 -0
  44. data/spec/spec_key +0 -27
  45. data/spec/spec_key.pub +0 -9
@@ -1,314 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber'
4
- require 'fileutils'
5
-
6
- FileUtils.mkdir_p '/tmp/chamber/settings' unless File.exist? '/tmp/chamber/settings'
7
-
8
- File.open('/tmp/chamber/settings.yml', 'w+') do |file|
9
- file.puts <<-HEREDOC
10
- test:
11
- my_setting: my_value
12
- my_boolean: "false"
13
- my_dynamic_setting: <%= 1 + 1 %>
14
- my_ftp_url: ftp://username:password@127.0.0.1
15
- another_level:
16
- setting_one: 1
17
- setting_two: 2
18
- level_three:
19
- an_array:
20
- - item 1
21
- - item 2
22
- - item 3
23
- a_scalar: 'hello'
24
- HEREDOC
25
- end
26
-
27
- File.open('/tmp/chamber/secure.yml', 'w+') do |file|
28
- file.puts <<-HEREDOC
29
- test:
30
- _secure_my_encrpyted_setting: cJbFe0NI5wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4mpsspg/ZTBtmjx7kMwcF6cjXFLDVw3FxptTHwzJUd4akun6EZ57m+QzCMJYnfY95gB2/emEAQLSz4/YwsE4LDGydkEjY1ZprfXznf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZDwS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNXWS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1kKTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==
31
- HEREDOC
32
- end
33
-
34
- File.open('/tmp/chamber/settings-blue.yml', 'w+') do |file|
35
- file.puts <<-HEREDOC
36
- test:
37
- my_other_setting: my_other_value
38
- another_level:
39
- setting_one: 3
40
- other:
41
- everything: works
42
- HEREDOC
43
- end
44
-
45
- File.open('/tmp/chamber/settings/some_settings_file.yml', 'w+') do |file|
46
- file.puts <<-HEREDOC
47
- blue:
48
- my_settings_for_inline_namespace: my_value_for_inline_namespace
49
- my_non_inline_namespaced_setting: my_value_for_non_inline_namespace
50
- HEREDOC
51
- end
52
-
53
- File.open('/tmp/chamber/settings/sub_settings.yml', 'w+') do |file|
54
- file.puts <<-HEREDOC
55
- sub_settings:
56
- my_sub_setting: my_sub_setting_value
57
- HEREDOC
58
- end
59
-
60
- File.open('/tmp/chamber/settings/sub_settings-blue.yml', 'w+') do |file|
61
- file.puts <<-HEREDOC
62
- sub_settings:
63
- my_namespaced_sub_setting: my_namespaced_sub_setting_value
64
- HEREDOC
65
- end
66
-
67
- File.open('/tmp/chamber/settings/only_namespaced_settings-blue.yml', 'w+') do |file|
68
- file.puts <<-HEREDOC
69
- only_namespaced_sub_settings:
70
- another_sub_setting: namespaced
71
- HEREDOC
72
- end
73
-
74
- describe 'Chamber' do
75
- before(:each) { Chamber.load(basepath: '/tmp/chamber') }
76
-
77
- it 'knows how to load itself with a path string' do
78
- Chamber.load(basepath: '/tmp/chamber')
79
-
80
- expect(Chamber.configuration.basepath.to_s).to eql '/tmp/chamber'
81
- end
82
-
83
- it 'knows how to load itself with a path object' do
84
- Chamber.load(basepath: Pathname.new('/tmp/chamber'))
85
-
86
- expect(Chamber.configuration.basepath.to_s).to eql '/tmp/chamber'
87
- end
88
-
89
- it 'processes settings files through ERB before YAML' do
90
- expect(Chamber[:test][:my_dynamic_setting]).to eql 2
91
- end
92
-
93
- it 'can access settings through a hash-like syntax' do
94
- expect(Chamber[:test][:my_setting]).to eql 'my_value'
95
- end
96
-
97
- it 'can access the settings through method-based access' do
98
- expect(Chamber.test.my_setting).to eql 'my_value'
99
- end
100
-
101
- it 'can access the settings via "env"' do
102
- expect(Chamber.env.test.my_setting).to eql 'my_value'
103
- end
104
-
105
- it 'prefers values stored in environment variables over those in the YAML files' do
106
- ENV['TEST_MY_SETTING'] = 'some_other_value'
107
- ENV['TEST_ANOTHER_LEVEL_LEVEL_THREE_AN_ARRAY'] = 'something'
108
-
109
- Chamber.load(basepath: '/tmp/chamber')
110
- expect(Chamber.test.my_setting).to eql 'some_other_value'
111
- expect(Chamber.test.another_level.level_three.an_array).to eql 'something'
112
- expect(Chamber.test.my_dynamic_setting).to eql 2
113
-
114
- ENV.delete 'TEST_MY_SETTING'
115
- ENV.delete 'TEST_ANOTHER_LEVEL_LEVEL_THREE_AN_ARRAY'
116
- end
117
-
118
- it 'can load files based on the namespace passed in' do
119
- Chamber.load(basepath: '/tmp/chamber',
120
- namespaces: {
121
- my_namespace: -> { 'blue' },
122
- })
123
-
124
- expect(Chamber.other.everything).to eql 'works'
125
- expect(Chamber.test.my_dynamic_setting).to eql 2
126
- end
127
-
128
- it 'loads multiple namespaces if it is called twice' do
129
- Chamber.load(basepath: '/tmp/chamber',
130
- namespaces: {
131
- first_namespace_call: -> { :first },
132
- second_namespace_call: -> { :second },
133
- })
134
-
135
- expect(Chamber.namespaces.to_a).to eql %w{first second}
136
- end
137
-
138
- # rubocop:disable Lint/DuplicatedKey
139
- it 'does not load the same namespace twice' do
140
- Chamber.load(basepath: '/tmp/chamber',
141
- namespaces: {
142
- first_namespace_call: -> { :first },
143
- first_namespace_call: -> { :first },
144
- })
145
-
146
- expect(Chamber.namespaces.to_a).to eql ['first']
147
- end
148
- # rubocop:enable Lint/DuplicatedKey
149
-
150
- it 'will load settings files which are only namespaced' do
151
- Chamber.load(basepath: '/tmp/chamber',
152
- namespaces: {
153
- my_namespace: -> { 'blue' },
154
- })
155
-
156
- expect(Chamber[:only_namespaced_sub_settings][:another_sub_setting]).to eql 'namespaced'
157
- end
158
-
159
- it 'clears all settings each time the settings are loaded' do
160
- Chamber.load(basepath: '/tmp/chamber',
161
- namespaces: {
162
- my_namespace: -> { 'blue' },
163
- })
164
-
165
- expect(Chamber[:only_namespaced_sub_settings][:another_sub_setting]).to eql 'namespaced'
166
-
167
- Chamber.load(basepath: '/tmp/chamber')
168
-
169
- expect(Chamber[:only_namespaced_sub_settings]).to be_nil
170
- end
171
-
172
- it 'still raises an error if you try to send a message which the settings hash ' \
173
- 'does not understand' do
174
-
175
- expect { Chamber.env.i_do_not_know }.to raise_error NoMethodError
176
- end
177
-
178
- it 'does not raise an exception if a namespaced file does not exist' do
179
- Chamber.load(basepath: '/tmp/chamber',
180
- namespaces: {
181
- non_existant_namespace: -> { false },
182
- })
183
-
184
- expect { Chamber.load(basepath: '/tmp/chamber') }.not_to raise_error
185
- end
186
-
187
- it 'merges (not overrides) subsequent settings' do
188
- Chamber.load(basepath: '/tmp/chamber',
189
- namespaces: {
190
- my_namespace: -> { 'blue' },
191
- })
192
-
193
- expect(Chamber.test.my_setting).to eql 'my_value'
194
- expect(Chamber.test.my_other_setting).to eql 'my_other_value'
195
- expect(Chamber.test.another_level.setting_one).to eql 3
196
- end
197
-
198
- it 'loads YAML files from the "settings" directory under the base directory if ' \
199
- 'any exist' do
200
-
201
- expect(Chamber.sub_settings.my_sub_setting).to eql 'my_sub_setting_value'
202
- end
203
-
204
- it 'does not load YAML files from the "settings" directory if it is namespaced' do
205
- expect(Chamber['sub_settings-namespaced']).to be_nil
206
- end
207
-
208
- it 'loads namespaced YAML files in the "settings" directory if they correspond to ' \
209
- 'a value namespace' do
210
-
211
- Chamber.load(basepath: '/tmp/chamber',
212
- namespaces: {
213
- my_namespace: -> { 'blue' },
214
- })
215
-
216
- expect(Chamber['sub_settings']['my_namespaced_sub_setting']).to eql 'my_namespaced_sub_setting_value'
217
- end
218
-
219
- it 'loads namespaced settings if they are inline in a non-namespaced filename' do
220
- Chamber.load(basepath: '/tmp/chamber',
221
- namespaces: {
222
- my_namespace: -> { 'blue' },
223
- })
224
-
225
- expect(Chamber['my_settings_for_inline_namespace']).to eql 'my_value_for_inline_namespace'
226
- end
227
-
228
- it 'does not load non-namespaced data from a file if inline namespaces are found' do
229
- Chamber.load(basepath: '/tmp/chamber',
230
- namespaces: {
231
- my_namespace: -> { 'blue' },
232
- })
233
-
234
- expect(Chamber['my_non_inline_namespaced_setting']).not_to eql 'my_value_for_non_inline_namespace'
235
- end
236
-
237
- it 'loads the entire inline namespaced file if no namespaces are passed in since ' \
238
- 'it does not know they are namespaced' do
239
-
240
- Chamber.load(basepath: '/tmp/chamber')
241
-
242
- expect(Chamber['blue']['my_settings_for_inline_namespace']).to eql 'my_value_for_inline_namespace'
243
- expect(Chamber['my_non_inline_namespaced_setting']).to eql 'my_value_for_non_inline_namespace'
244
- end
245
-
246
- # rubocop:disable Lint/DuplicatedKey
247
- it 'can convert the settings to their environment variable versions' do
248
- Chamber.load(basepath: '/tmp/chamber')
249
-
250
- expect(Chamber.to_environment).to eql(
251
- 'SUB_SETTINGS_MY_SUB_SETTING' => 'my_sub_setting_value',
252
- 'TEST_ANOTHER_LEVEL_LEVEL_THREE_AN_ARRAY' => '["item 1", "item 2", "item 3"]',
253
- 'TEST_ANOTHER_LEVEL_LEVEL_THREE_A_SCALAR' => 'hello',
254
- 'TEST_ANOTHER_LEVEL_SETTING_ONE' => '1',
255
- 'TEST_ANOTHER_LEVEL_SETTING_TWO' => '2',
256
- 'TEST_MY_DYNAMIC_SETTING' => '2',
257
- 'TEST_MY_SETTING' => 'my_value',
258
- 'TEST_MY_FTP_URL' => 'ftp://username:password@127.0.0.1',
259
- 'TEST_MY_SETTING' => 'my_value',
260
- 'TEST_MY_BOOLEAN' => 'false',
261
- 'BLUE_MY_SETTINGS_FOR_INLINE_NAMESPACE' => 'my_value_for_inline_namespace',
262
- 'MY_NON_INLINE_NAMESPACED_SETTING' => 'my_value_for_non_inline_namespace',
263
- )
264
- end
265
- # rubocop:enable Lint/DuplicatedKey
266
-
267
- it 'can convert boolean-like strings to actual booleans' do
268
- expect(Chamber[:test][:my_boolean]).to be_a FalseClass
269
- end
270
-
271
- it 'can notify properly whether it responds to messages if the underlying ' \
272
- 'settings does' do
273
-
274
- expect(Chamber.respond_to?(:sub_settings)).to be_a TrueClass
275
- end
276
-
277
- it 'can explicitly specify files without specifying a basepath' do
278
- Chamber.load files: ['/tmp/chamber/settings.yml']
279
-
280
- expect(Chamber.filenames).to eql ['/tmp/chamber/settings.yml']
281
- expect(Chamber.to_hash).to include(
282
- 'test' => include(
283
- 'my_setting' => 'my_value',
284
- 'my_ftp_url' => 'ftp://username:password@127.0.0.1',
285
- ),
286
- )
287
- end
288
-
289
- it 'ignores the basepath if file patterns are explicitly passed in' do
290
- Chamber.load basepath: '/tmp/chamber',
291
- files: 'settings.yml'
292
-
293
- expect(Chamber.filenames).to be_empty
294
- end
295
-
296
- it 'can render itself as a string even if it has not been loaded' do
297
- Chamber.load basepath: '/'
298
-
299
- expect(Chamber.to_s).to eql ''
300
- end
301
-
302
- it 'can determine settings even if it has not been loaded' do
303
- Chamber.load basepath: '/'
304
-
305
- expect(Chamber.to_hash).to eql({})
306
- end
307
-
308
- it 'can unencrpyt an already encrpyted value if it has access to the private key' do
309
- Chamber.load(files: '/tmp/chamber/secure.yml',
310
- decryption_key: './spec/spec_key')
311
-
312
- expect(Chamber.test.my_encrpyted_setting).to eql 'hello'
313
- end
314
- end
File without changes
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- class Rails
3
- def self.env
4
- 'development'
5
- end
6
- end
File without changes
File without changes
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- class Rails
3
- def self.env
4
- 'development'
5
- end
6
- end
File without changes
File without changes
File without changes
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- class Rails
3
- def self.env
4
- 'development'
5
- end
6
- end
File without changes
@@ -1,5 +0,0 @@
1
- class Rails
2
- def self.env
3
- 'development'
4
- end
5
- end
File without changes
data/spec/spec_key DELETED
@@ -1,27 +0,0 @@
1
- -----BEGIN RSA PRIVATE KEY-----
2
- MIIEowIBAAKCAQEAvYcqkBjBLhSaTKOCMoq+ZxcuxTaA5UQpf/vDXbOiI871+6x7
3
- yKbTr+Xr9oFDvFldyvUFiK6LX0rj/jgLnaTBsLyXjH46dOmiPUO3k/QvDmRKN8zv
4
- l4x9T7YZKuoEkxZwE3T3MxKPmBorKGv/22VbKocqkGGgx9gKIvSfxVXfTMfcvTDr
5
- Fllm1bCaXEVGcRAknJg94ul2yMgqmYA2KJcPy2naped90yzv0A7c/UI5zjBcJPgk
6
- um79aDTSv095yl+Pk+5JM2jD85x3ph3ij++LdAXJ1fBJrV1H39UJ4A6yOupEG3+Q
7
- sZTPDXkBBnX8+mWXYCClI/GF6iA/G3njeMqUfQIDAQABAoIBAQCNfvwn2FNhM8B+
8
- txPc5/h+vrAMTESu5dSV2EBjFFlYoorC+mLvyp0AFYe04YzQcWe0vnkDMkybOC4+
9
- /ViuuPJiIGqEWTkLT+HwGz5TF1qKRBWk0zuMyTZE7I6dm1kO9xF1dT2Yw6Kwy9is
10
- tPSvt1v4xDDi2gBPMttefYNKsHGlv8dYWwwTUd1JA4Cx4QOTimH1OK0OJJZMa2Fo
11
- wW/fcHHQd1IkwkHo4gHLs5vIQLjQIyFazIwSmaCeiyXZm0gTEP1Zc5+NQUuascnD
12
- k6CIOM51hmK8x+8DNU0edOs9tm8kIkqxwapjpfzJZtJy19yNam7psX+d8T4YY/Vq
13
- uuv2XyOBAoGBAOrmlJ9ES7Nb+ssQ0stPqsz9pWp3HVfxkR9jWoye793EDvPx+/7u
14
- ggiKt/vMsNQSrO7LiKXrTETjLeprHDun4ekIF6QoyiA8A0El2SHVyFDUVrQ70MWo
15
- 5G+t/HvMcbfuwHEmHKZxx/G+5d571v5TnVr/SO+X/aUsCpnvI+n3unGDAoGB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TDrFllm1bCaXEVGcRAknJg94ul2yMgqmYA2KJcP
6
- y2naped90yzv0A7c/UI5zjBcJPgkum79aDTSv095yl+Pk+5JM2jD85x3ph3ij++L
7
- dAXJ1fBJrV1H39UJ4A6yOupEG3+QsZTPDXkBBnX8+mWXYCClI/GF6iA/G3njeMqU
8
- fQIDAQAB
9
- -----END PUBLIC KEY-----