MuranoCLI 2.2.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +3 -0
- data/.gitignore +18 -1
- data/.rubocop.yml +222 -0
- data/.trustme.sh +185 -0
- data/.trustme.vim +24 -0
- data/Gemfile +23 -4
- data/LICENSE.txt +1 -1
- data/MuranoCLI.gemspec +43 -8
- data/README.markdown +9 -11
- data/Rakefile +187 -143
- data/TODO.taskpaper +2 -2
- data/bin/murano +51 -52
- data/docs/basic_example.rst +436 -0
- data/docs/completions/murano_completion-bash +3484 -0
- data/docs/demo.md +32 -32
- data/docs/develop.rst +391 -0
- data/lib/MrMurano.rb +21 -7
- data/lib/MrMurano/Account.rb +159 -174
- data/lib/MrMurano/Business.rb +381 -0
- data/lib/MrMurano/Config-Migrate.rb +32 -26
- data/lib/MrMurano/Config.rb +407 -128
- data/lib/MrMurano/Content.rb +191 -0
- data/lib/MrMurano/Gateway.rb +489 -0
- data/lib/MrMurano/Keystore.rb +48 -0
- data/lib/MrMurano/Passwords.rb +103 -0
- data/lib/MrMurano/ProjectFile.rb +121 -79
- data/lib/MrMurano/ReCommander.rb +114 -10
- data/lib/MrMurano/Setting.rb +90 -0
- data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
- data/lib/MrMurano/Solution-Services.rb +461 -166
- data/lib/MrMurano/Solution-Users.rb +70 -31
- data/lib/MrMurano/Solution.rb +372 -13
- data/lib/MrMurano/SolutionId.rb +73 -0
- data/lib/MrMurano/SyncRoot.rb +137 -0
- data/lib/MrMurano/SyncUpDown.rb +594 -284
- data/lib/MrMurano/Webservice-Cors.rb +71 -0
- data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
- data/lib/MrMurano/Webservice-File.rb +193 -0
- data/lib/MrMurano/Webservice.rb +51 -0
- data/lib/MrMurano/commands.rb +18 -15
- data/lib/MrMurano/commands/business.rb +300 -6
- data/lib/MrMurano/commands/completion-bash.erb +166 -0
- data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
- data/lib/MrMurano/commands/completion.rb +76 -39
- data/lib/MrMurano/commands/config.rb +108 -44
- data/lib/MrMurano/commands/content.rb +115 -72
- data/lib/MrMurano/commands/cors.rb +29 -14
- data/lib/MrMurano/commands/devices.rb +286 -0
- data/lib/MrMurano/commands/domain.rb +52 -12
- data/lib/MrMurano/commands/gb.rb +24 -9
- data/lib/MrMurano/commands/globals.rb +64 -0
- data/lib/MrMurano/commands/init.rb +377 -155
- data/lib/MrMurano/commands/keystore.rb +92 -82
- data/lib/MrMurano/commands/link.rb +300 -0
- data/lib/MrMurano/commands/login.rb +74 -11
- data/lib/MrMurano/commands/logs.rb +63 -32
- data/lib/MrMurano/commands/mock.rb +57 -29
- data/lib/MrMurano/commands/password.rb +57 -39
- data/lib/MrMurano/commands/postgresql.rb +127 -94
- data/lib/MrMurano/commands/settings.rb +203 -0
- data/lib/MrMurano/commands/show.rb +79 -38
- data/lib/MrMurano/commands/solution.rb +423 -5
- data/lib/MrMurano/commands/solution_picker.rb +547 -0
- data/lib/MrMurano/commands/status.rb +195 -61
- data/lib/MrMurano/commands/sync.rb +78 -39
- data/lib/MrMurano/commands/timeseries.rb +71 -55
- data/lib/MrMurano/commands/tsdb.rb +113 -87
- data/lib/MrMurano/commands/usage.rb +57 -15
- data/lib/MrMurano/hash.rb +100 -10
- data/lib/MrMurano/http.rb +187 -43
- data/lib/MrMurano/makePretty.rb +16 -14
- data/lib/MrMurano/optparse.rb +2178 -0
- data/lib/MrMurano/progress.rb +138 -0
- data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
- data/lib/MrMurano/template/projectFile.murano.erb +16 -13
- data/lib/MrMurano/verbosing.rb +166 -29
- data/lib/MrMurano/version.rb +30 -1
- data/spec/Account-Passwords_spec.rb +21 -4
- data/spec/Account_spec.rb +69 -146
- data/spec/Business_spec.rb +290 -0
- data/spec/ConfigFile_spec.rb +1 -0
- data/spec/ConfigMigrate_spec.rb +12 -8
- data/spec/Config_spec.rb +40 -34
- data/spec/Content_spec.rb +363 -0
- data/spec/GatewayBase_spec.rb +54 -0
- data/spec/GatewayDevice_spec.rb +321 -0
- data/spec/GatewayResource_spec.rb +266 -0
- data/spec/GatewaySettings_spec.rb +120 -0
- data/spec/Http_spec.rb +18 -8
- data/spec/Mock_spec.rb +2 -2
- data/spec/ProjectFile_spec.rb +25 -14
- data/spec/Setting_spec.rb +110 -0
- data/spec/Solution-ServiceConfig_spec.rb +44 -5
- data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
- data/spec/Solution-ServiceModules_spec.rb +47 -37
- data/spec/Solution-UsersRoles_spec.rb +10 -8
- data/spec/Solution_spec.rb +17 -8
- data/spec/SyncRoot_spec.rb +46 -20
- data/spec/SyncUpDown_spec.rb +437 -201
- data/spec/Verbosing_spec.rb +12 -4
- data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
- data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
- data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
- data/spec/Webservice-Setting_spec.rb +89 -0
- data/spec/_workspace.rb +4 -4
- data/spec/cmd_business_spec.rb +9 -4
- data/spec/cmd_common.rb +44 -1
- data/spec/cmd_content_spec.rb +43 -17
- data/spec/cmd_cors_spec.rb +4 -4
- data/spec/cmd_device_spec.rb +61 -16
- data/spec/cmd_domain_spec.rb +29 -6
- data/spec/cmd_init_spec.rb +281 -126
- data/spec/cmd_keystore_spec.rb +3 -3
- data/spec/cmd_link_spec.rb +98 -0
- data/spec/cmd_password_spec.rb +1 -1
- data/spec/cmd_setting_application_spec.rb +260 -0
- data/spec/cmd_setting_product_spec.rb +220 -0
- data/spec/cmd_status_spec.rb +223 -114
- data/spec/cmd_syncdown_spec.rb +115 -35
- data/spec/cmd_syncup_spec.rb +68 -15
- data/spec/cmd_usage_spec.rb +35 -8
- data/spec/fixtures/dumped_config +6 -4
- data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
- data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
- data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
- data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
- data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
- data/spec/spec_helper.rb +5 -0
- metadata +262 -171
- data/bin/mr +0 -8
- data/lib/MrMurano/Product-1P-Device.rb +0 -145
- data/lib/MrMurano/Product-Resources.rb +0 -205
- data/lib/MrMurano/Product.rb +0 -358
- data/lib/MrMurano/Solution-Cors.rb +0 -47
- data/lib/MrMurano/Solution-Endpoint.rb +0 -191
- data/lib/MrMurano/Solution-File.rb +0 -166
- data/lib/MrMurano/commands/assign.rb +0 -57
- data/lib/MrMurano/commands/businessList.rb +0 -45
- data/lib/MrMurano/commands/product.rb +0 -14
- data/lib/MrMurano/commands/productCreate.rb +0 -39
- data/lib/MrMurano/commands/productDelete.rb +0 -33
- data/lib/MrMurano/commands/productDevice.rb +0 -87
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
- data/lib/MrMurano/commands/productList.rb +0 -45
- data/lib/MrMurano/commands/productWrite.rb +0 -27
- data/lib/MrMurano/commands/solutionCreate.rb +0 -41
- data/lib/MrMurano/commands/solutionDelete.rb +0 -34
- data/lib/MrMurano/commands/solutionList.rb +0 -45
- data/spec/ProductBase_spec.rb +0 -113
- data/spec/ProductContent_spec.rb +0 -162
- data/spec/ProductResources_spec.rb +0 -329
- data/spec/Product_1P_Device_spec.rb +0 -202
- data/spec/Product_1P_RPC_spec.rb +0 -175
- data/spec/Product_spec.rb +0 -153
- data/spec/Solution-ServiceDevice_spec.rb +0 -176
- data/spec/cmd_assign_spec.rb +0 -51
data/spec/ConfigFile_spec.rb
CHANGED
data/spec/ConfigMigrate_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
#require 'erb'
|
2
|
+
require 'highline/import'
|
3
|
+
#require 'tempfile'
|
1
4
|
require 'MrMurano/version'
|
2
5
|
require 'MrMurano/Config-Migrate'
|
3
|
-
require '
|
6
|
+
require 'MrMurano/ProjectFile'
|
4
7
|
require '_workspace'
|
5
|
-
#require 'tempfile'
|
6
|
-
#require 'erb'
|
7
8
|
|
8
9
|
RSpec.describe MrMurano::ConfigMigrate do
|
9
10
|
include_context "WORKSPACE"
|
@@ -17,7 +18,10 @@ RSpec.describe MrMurano::ConfigMigrate do
|
|
17
18
|
$cfg.load
|
18
19
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
19
20
|
|
20
|
-
|
21
|
+
$project = MrMurano::ProjectFile.new
|
22
|
+
$project.load
|
23
|
+
|
24
|
+
@lry = Pathname.new(@project_dir) + '.Solutionfile.secret'
|
21
25
|
FileUtils.copy(File.join(@testdir, 'spec/fixtures/SolutionFiles/secret.json'), @lry.to_path)
|
22
26
|
|
23
27
|
@mrt = MrMurano::ConfigMigrate.new
|
@@ -35,7 +39,7 @@ RSpec.describe MrMurano::ConfigMigrate do
|
|
35
39
|
it "imports all" do
|
36
40
|
@mrt.import_secret
|
37
41
|
|
38
|
-
expect($cfg['
|
42
|
+
expect($cfg['application.id']).to eq('ABCDEFG')
|
39
43
|
expect($cfg['product.id']).to eq('HIJKLMNOP')
|
40
44
|
expect($cfg['user.name']).to eq('test@user.account')
|
41
45
|
pff = $cfg.file_at('passwords', :user)
|
@@ -47,7 +51,7 @@ RSpec.describe MrMurano::ConfigMigrate do
|
|
47
51
|
end
|
48
52
|
|
49
53
|
it "imports over" do
|
50
|
-
$cfg['
|
54
|
+
$cfg['application.id'] = '12'
|
51
55
|
$cfg['product.id'] = 'awdfvs'
|
52
56
|
$cfg['user.name'] = '3qrarvsa'
|
53
57
|
$cfg = MrMurano::Config.new
|
@@ -56,7 +60,7 @@ RSpec.describe MrMurano::ConfigMigrate do
|
|
56
60
|
|
57
61
|
@mrt.import_secret
|
58
62
|
|
59
|
-
expect($cfg['
|
63
|
+
expect($cfg['application.id']).to eq('ABCDEFG')
|
60
64
|
expect($cfg['product.id']).to eq('HIJKLMNOP')
|
61
65
|
expect($cfg['user.name']).to eq('test@user.account')
|
62
66
|
pff = $cfg.file_at('passwords', :user)
|
@@ -77,7 +81,7 @@ RSpec.describe MrMurano::ConfigMigrate do
|
|
77
81
|
|
78
82
|
@mrt.import_secret
|
79
83
|
|
80
|
-
expect($cfg['
|
84
|
+
expect($cfg['application.id']).to eq('ABCDEFG')
|
81
85
|
expect($cfg['product.id']).to eq('HIJKLMNOP')
|
82
86
|
expect($cfg['user.name']).to eq('test@user.account')
|
83
87
|
pff = $cfg.file_at('passwords', :user)
|
data/spec/Config_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'tempfile'
|
1
3
|
require 'MrMurano/version'
|
2
4
|
require 'MrMurano/Config'
|
3
5
|
require '_workspace'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'erb'
|
6
6
|
|
7
7
|
RSpec.describe MrMurano::Config do
|
8
8
|
|
@@ -47,7 +47,7 @@ RSpec.describe MrMurano::Config do
|
|
47
47
|
expect(cfg['bob.test']).to eq('twelve')
|
48
48
|
expect(cfg.get('bob.test', :project)).to eq('twelve')
|
49
49
|
|
50
|
-
expect(FileTest.exist?(@
|
50
|
+
expect(FileTest.exist?(@project_dir + '.murano/config'))
|
51
51
|
|
52
52
|
#reload
|
53
53
|
cfg = MrMurano::Config.new
|
@@ -73,7 +73,7 @@ RSpec.describe MrMurano::Config do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "loads from a specific file" do
|
76
|
-
File.open(@
|
76
|
+
File.open(@project_dir + '/foo.cfg', 'w') do |io|
|
77
77
|
io << %{[test]
|
78
78
|
bob = test
|
79
79
|
}.gsub(/^\s\+/,'')
|
@@ -81,7 +81,7 @@ RSpec.describe MrMurano::Config do
|
|
81
81
|
|
82
82
|
cfg = MrMurano::Config.new
|
83
83
|
cfg.load
|
84
|
-
cfg.load_specific(@
|
84
|
+
cfg.load_specific(@project_dir + '/foo.cfg')
|
85
85
|
|
86
86
|
expect(cfg['test.bob']).to eq('test')
|
87
87
|
end
|
@@ -91,7 +91,7 @@ RSpec.describe MrMurano::Config do
|
|
91
91
|
cfg = MrMurano::Config.new
|
92
92
|
cfg.load
|
93
93
|
path = cfg.file_at('testfile').realdirpath
|
94
|
-
want = Pathname.new(@
|
94
|
+
want = Pathname.new(@project_dir + '/.murano/testfile').realdirpath
|
95
95
|
|
96
96
|
expect(path).to eq(want)
|
97
97
|
end
|
@@ -177,8 +177,12 @@ RSpec.describe MrMurano::Config do
|
|
177
177
|
it "errors if both are defined" do
|
178
178
|
ENV['MURANO_CONFIGFILE'] = @tmpdir + '/home/testcreate.config'
|
179
179
|
ENV['MR_CONFIGFILE'] = @tmpdir + '/home/testcreate.config'
|
180
|
-
|
181
|
-
|
180
|
+
# 2 warnings:
|
181
|
+
# ENV "MR_CONFIGFILE" is no longer supported. Rename it to "MURANO_CONFIGFILE"
|
182
|
+
# Both "MURANO_CONFIGFILE" and "MR_CONFIGFILE" defined,
|
183
|
+
# please remove "MR_CONFIGFILE".
|
184
|
+
expect_any_instance_of(MrMurano::Config).to receive(:warning).twice
|
185
|
+
#expect_any_instance_of(MrMurano::Config).to receive(:error).once
|
182
186
|
MrMurano::Config.new
|
183
187
|
end
|
184
188
|
end
|
@@ -191,7 +195,7 @@ RSpec.describe MrMurano::Config do
|
|
191
195
|
cfg['sync.bydefault'] = 'files'
|
192
196
|
ret = cfg.dump
|
193
197
|
|
194
|
-
rawwant = IO.read(File.join(@testdir.to_path, 'spec','fixtures','dumped_config'))
|
198
|
+
rawwant = IO.read(File.join(@testdir.to_path, 'spec', 'fixtures', 'dumped_config'))
|
195
199
|
template = ERB.new(rawwant)
|
196
200
|
want = template.result(binding)
|
197
201
|
|
@@ -203,7 +207,7 @@ RSpec.describe MrMurano::Config do
|
|
203
207
|
it "fixes a directory" do
|
204
208
|
Dir.mkdir('test')
|
205
209
|
cfg = MrMurano::Config.new
|
206
|
-
cfg.
|
210
|
+
cfg.fix_modes(Pathname.new('test'))
|
207
211
|
if Gem.win_platform? then
|
208
212
|
expect(FileTest.world_readable? 'test').to eq(493)
|
209
213
|
expect(FileTest.world_writable? 'test').to be_nil
|
@@ -216,7 +220,7 @@ RSpec.describe MrMurano::Config do
|
|
216
220
|
it "fixes a file" do
|
217
221
|
FileUtils.touch('test')
|
218
222
|
cfg = MrMurano::Config.new
|
219
|
-
cfg.
|
223
|
+
cfg.fix_modes(Pathname.new('test'))
|
220
224
|
if Gem.win_platform? then
|
221
225
|
expect(FileTest.world_readable? 'test').to eq(420)
|
222
226
|
expect(FileTest.world_writable? 'test').to be_nil
|
@@ -232,10 +236,10 @@ RSpec.describe MrMurano::Config do
|
|
232
236
|
before(:example) do
|
233
237
|
@tmpdir = Dir.tmpdir
|
234
238
|
path = '/home/work/project/some/where'
|
235
|
-
@
|
239
|
+
@project_dir = @tmpdir + '/home/work/project'
|
236
240
|
FileUtils.mkpath(@tmpdir + path)
|
237
|
-
FileUtils.mkpath(@
|
238
|
-
FileUtils.touch(@
|
241
|
+
FileUtils.mkpath(@project_dir + '/.murano')
|
242
|
+
FileUtils.touch(@project_dir + '/.murano/config')
|
239
243
|
|
240
244
|
# Set ENV to override output of Dir.home
|
241
245
|
ENV['HOME'] = @tmpdir + '/home'
|
@@ -246,36 +250,36 @@ RSpec.describe MrMurano::Config do
|
|
246
250
|
end
|
247
251
|
|
248
252
|
it "when in project directory" do
|
249
|
-
Dir.chdir(@
|
253
|
+
Dir.chdir(@project_dir) do
|
250
254
|
cfg = MrMurano::Config.new
|
251
255
|
cfg.load
|
252
256
|
# Follow symlinks to get the paths comparable.
|
253
257
|
locbase = cfg.get('location.base', :defaults).realdirpath
|
254
|
-
wkd = Pathname.new(@
|
258
|
+
wkd = Pathname.new(@project_dir).realdirpath
|
255
259
|
expect(locbase).to eq(wkd)
|
256
260
|
end
|
257
261
|
end
|
258
262
|
|
259
263
|
it "when in sub directory" do
|
260
|
-
Dir.chdir(@
|
264
|
+
Dir.chdir(@project_dir + '/some/where') do
|
261
265
|
cfg = MrMurano::Config.new
|
262
266
|
cfg.load
|
263
267
|
# Follow symlinks to get the paths comparable.
|
264
268
|
locbase = cfg.get('location.base', :defaults).realdirpath
|
265
|
-
wkd = Pathname.new(@
|
269
|
+
wkd = Pathname.new(@project_dir).realdirpath
|
266
270
|
expect(locbase).to eq(wkd)
|
267
271
|
end
|
268
272
|
end
|
269
273
|
|
270
274
|
it "when .murano is in both PWD and parent dir" do
|
271
|
-
Dir.chdir(@
|
275
|
+
Dir.chdir(@project_dir + '/some') do
|
272
276
|
FileUtils.mkpath('.murano')
|
273
277
|
FileUtils.touch('.murano/config')
|
274
278
|
cfg = MrMurano::Config.new
|
275
279
|
cfg.load
|
276
280
|
# Follow symlinks to get the paths comparable.
|
277
281
|
locbase = cfg.get('location.base', :defaults).realdirpath
|
278
|
-
wkd = (Pathname.new(@
|
282
|
+
wkd = (Pathname.new(@project_dir) + 'some').realdirpath
|
279
283
|
expect(locbase).to eq(wkd)
|
280
284
|
end
|
281
285
|
end
|
@@ -285,9 +289,9 @@ RSpec.describe MrMurano::Config do
|
|
285
289
|
before(:example) do
|
286
290
|
@tmpdir = Dir.tmpdir
|
287
291
|
path = '/home/work/project/some/where'
|
288
|
-
@
|
292
|
+
@project_dir = @tmpdir + '/home/work/project'
|
289
293
|
FileUtils.mkpath(@tmpdir + path)
|
290
|
-
FileUtils.mkpath(@
|
294
|
+
FileUtils.mkpath(@project_dir + '/.murano')
|
291
295
|
|
292
296
|
# Set ENV to override output of Dir.home
|
293
297
|
ENV['HOME'] = @tmpdir + '/home'
|
@@ -298,35 +302,35 @@ RSpec.describe MrMurano::Config do
|
|
298
302
|
end
|
299
303
|
|
300
304
|
it "when in project directory" do
|
301
|
-
Dir.chdir(@
|
305
|
+
Dir.chdir(@project_dir) do
|
302
306
|
cfg = MrMurano::Config.new
|
303
307
|
cfg.load
|
304
308
|
# Follow symlinks to get the paths comparable.
|
305
309
|
locbase = cfg.get('location.base', :defaults).realdirpath
|
306
|
-
wkd = Pathname.new(@
|
310
|
+
wkd = Pathname.new(@project_dir).realdirpath
|
307
311
|
expect(locbase).to eq(wkd)
|
308
312
|
end
|
309
313
|
end
|
310
314
|
|
311
315
|
it "when in sub directory" do
|
312
|
-
Dir.chdir(@
|
316
|
+
Dir.chdir(@project_dir + '/some/where') do
|
313
317
|
cfg = MrMurano::Config.new
|
314
318
|
cfg.load
|
315
319
|
# Follow symlinks to get the paths comparable.
|
316
320
|
locbase = cfg.get('location.base', :defaults).realdirpath
|
317
|
-
wkd = Pathname.new(@
|
321
|
+
wkd = Pathname.new(@project_dir).realdirpath
|
318
322
|
expect(locbase).to eq(wkd)
|
319
323
|
end
|
320
324
|
end
|
321
325
|
|
322
326
|
it "when .murano is in both PWD and parent dir" do
|
323
|
-
Dir.chdir(@
|
327
|
+
Dir.chdir(@project_dir + '/some') do
|
324
328
|
FileUtils.mkpath('.murano')
|
325
329
|
cfg = MrMurano::Config.new
|
326
330
|
cfg.load
|
327
331
|
# Follow symlinks to get the paths comparable.
|
328
332
|
locbase = cfg.get('location.base', :defaults).realdirpath
|
329
|
-
wkd = (Pathname.new(@
|
333
|
+
wkd = (Pathname.new(@project_dir) + 'some').realdirpath
|
330
334
|
expect(locbase).to eq(wkd)
|
331
335
|
end
|
332
336
|
end
|
@@ -335,8 +339,8 @@ RSpec.describe MrMurano::Config do
|
|
335
339
|
context "When pwd is $HOME:" do
|
336
340
|
before(:example) do
|
337
341
|
@tmpdir = Dir.tmpdir
|
338
|
-
@
|
339
|
-
FileUtils.mkpath(@
|
342
|
+
@project_dir = @tmpdir + '/home/work/project'
|
343
|
+
FileUtils.mkpath(@project_dir)
|
340
344
|
# Set ENV to override output of Dir.home
|
341
345
|
ENV['HOME'] = @tmpdir + '/home'
|
342
346
|
end
|
@@ -408,15 +412,17 @@ RSpec.describe MrMurano::Config do
|
|
408
412
|
include_context "WORKSPACE"
|
409
413
|
|
410
414
|
it "config file name" do
|
411
|
-
FileUtils.touch(@
|
415
|
+
FileUtils.touch(@project_dir + '/.mrmuranorc')
|
412
416
|
expect_any_instance_of(MrMurano::Config).to receive(:warning).once
|
413
|
-
MrMurano::Config.new
|
417
|
+
cfg = MrMurano::Config.new
|
418
|
+
cfg.validate_cmd
|
414
419
|
end
|
415
420
|
|
416
421
|
it "config directory name" do
|
417
|
-
FileUtils.mkpath(@
|
422
|
+
FileUtils.mkpath(@project_dir + '/.mrmurano')
|
418
423
|
expect_any_instance_of(MrMurano::Config).to receive(:warning).once
|
419
|
-
MrMurano::Config.new
|
424
|
+
cfg = MrMurano::Config.new
|
425
|
+
cfg.validate_cmd
|
420
426
|
end
|
421
427
|
end
|
422
428
|
end
|
@@ -0,0 +1,363 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'MrMurano/version'
|
3
|
+
require 'MrMurano/Content'
|
4
|
+
require 'MrMurano/SyncRoot'
|
5
|
+
require '_workspace'
|
6
|
+
|
7
|
+
RSpec.describe MrMurano::Content::Base do
|
8
|
+
include_context "WORKSPACE"
|
9
|
+
before(:example) do
|
10
|
+
MrMurano::SyncRoot.instance.reset
|
11
|
+
$cfg = MrMurano::Config.new
|
12
|
+
$cfg.load
|
13
|
+
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
14
|
+
$cfg['product.id'] = 'XYZ'
|
15
|
+
|
16
|
+
@ct = MrMurano::Content::Base.new
|
17
|
+
allow(@ct).to receive(:token).and_return("TTTTTTTTTT")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "initializes" do
|
21
|
+
uri = @ct.endpoint('/')
|
22
|
+
expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "lists" do
|
26
|
+
body = [{
|
27
|
+
:type=> "binary/octet-stream",
|
28
|
+
:length=> 5622,
|
29
|
+
:last_modified=> "2017-02-10T17:43:45.000Z",
|
30
|
+
:id=> "TODO.taskpaper"
|
31
|
+
}]
|
32
|
+
|
33
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item?full=true").
|
34
|
+
to_return(:body => body.to_json)
|
35
|
+
|
36
|
+
ret = @ct.list
|
37
|
+
expect(ret).to eq(body)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "clears all" do
|
41
|
+
stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item")
|
42
|
+
ret = @ct.clear_all
|
43
|
+
expect(ret).to eq({})
|
44
|
+
end
|
45
|
+
|
46
|
+
it "fetches info for one" do
|
47
|
+
body = {
|
48
|
+
:type=> "binary/octet-stream",
|
49
|
+
:length=> 5622,
|
50
|
+
:last_modified=> "2017-02-10T17:43:45.000Z",
|
51
|
+
:id=> "TODO.taskpaper"
|
52
|
+
}
|
53
|
+
|
54
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/TODO.taskpaper").
|
55
|
+
to_return(:body => body.to_json)
|
56
|
+
|
57
|
+
ret = @ct.fetch('TODO.taskpaper')
|
58
|
+
expect(ret).to eq(body)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "removes one" do
|
62
|
+
stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/TODO.taskpaper")
|
63
|
+
|
64
|
+
ret = @ct.remove('TODO.taskpaper')
|
65
|
+
expect(ret).to eq({})
|
66
|
+
end
|
67
|
+
|
68
|
+
context "uploads" do
|
69
|
+
before(:example) do
|
70
|
+
@tup = Pathname.new(@project_dir) + 'Solutionfile.json'
|
71
|
+
FileUtils.copy(File.join(@testdir, 'spec/fixtures/SolutionFiles/basic.json'), @tup.to_path)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "uploads file" do
|
75
|
+
body = {
|
76
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging",
|
77
|
+
:method=>"POST",
|
78
|
+
:inputs=>{
|
79
|
+
:"x-amz-meta-name"=>"Solutionfile.json",
|
80
|
+
:"x-amz-signature"=>"Bunch of Hex",
|
81
|
+
:"x-amz-date"=>"20170214T200752Z",
|
82
|
+
:"x-amz-credential"=>"AAA/BBB/us-west-1/s3/aws4_request",
|
83
|
+
:"x-amz-algorithm"=>"AWS4-HMAC-SHA256",
|
84
|
+
:policy=>"something base64 encoded.",
|
85
|
+
:key=>"XXX/ZZZ",
|
86
|
+
:acl=>"authenticated-read"
|
87
|
+
},
|
88
|
+
:id=>"more Hex",
|
89
|
+
:field=>"file",
|
90
|
+
:enctype=>"multipart/form-data"
|
91
|
+
}
|
92
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/Solutionfile.json/upload").
|
93
|
+
with(:query=>{
|
94
|
+
:expires_in=>30,
|
95
|
+
:sha256=>'018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136',
|
96
|
+
:type=>'application/json'}).
|
97
|
+
to_return(:body => body.to_json)
|
98
|
+
|
99
|
+
stub_request(:post, "https://s3-us-west-1.amazonaws.com/murano-content-service-staging").
|
100
|
+
with(:headers=>{"Content-Type"=>%r|\Amultipart/form-data|}) do |request|
|
101
|
+
request.body =~ /something base64 encoded/
|
102
|
+
end.
|
103
|
+
to_return(:status=>200)
|
104
|
+
|
105
|
+
@ct.upload('Solutionfile.json', @tup.to_path)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "uploads with tags" do
|
109
|
+
body = {
|
110
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging",
|
111
|
+
:method=>"POST",
|
112
|
+
:inputs=>{
|
113
|
+
:"x-amz-meta-name"=>"Solutionfile.json",
|
114
|
+
:"x-amz-signature"=>"Bunch of Hex",
|
115
|
+
:"x-amz-date"=>"20170214T200752Z",
|
116
|
+
:"x-amz-credential"=>"AAA/BBB/us-west-1/s3/aws4_request",
|
117
|
+
:"x-amz-algorithm"=>"AWS4-HMAC-SHA256",
|
118
|
+
:policy=>"something base64 encoded.",
|
119
|
+
:key=>"XXX/ZZZ",
|
120
|
+
:acl=>"authenticated-read"
|
121
|
+
},
|
122
|
+
:id=>"more Hex",
|
123
|
+
:field=>"file",
|
124
|
+
:enctype=>"multipart/form-data"
|
125
|
+
}
|
126
|
+
tags = {:one=>12, :four=>'bob'}
|
127
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/Solutionfile.json/upload").
|
128
|
+
with(:query=>{
|
129
|
+
:expires_in=>30,
|
130
|
+
:sha256=>'018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136',
|
131
|
+
:type=>'application/json',
|
132
|
+
:tags => tags.to_json}).
|
133
|
+
to_return(:body => body.to_json)
|
134
|
+
|
135
|
+
stub_request(:post, "https://s3-us-west-1.amazonaws.com/murano-content-service-staging").
|
136
|
+
with(:headers=>{"Content-Type"=>%r|\Amultipart/form-data|}) do |request|
|
137
|
+
request.body =~ /something base64 encoded/
|
138
|
+
end.
|
139
|
+
to_return(:status=>200)
|
140
|
+
|
141
|
+
@ct.upload('Solutionfile.json', @tup.to_path, tags)
|
142
|
+
end
|
143
|
+
|
144
|
+
it "uploads fail at S3" do
|
145
|
+
body = {
|
146
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging",
|
147
|
+
:method=>"POST",
|
148
|
+
:inputs=>{
|
149
|
+
:"x-amz-meta-name"=>"Solutionfile.json",
|
150
|
+
:"x-amz-signature"=>"Bunch of Hex",
|
151
|
+
:"x-amz-date"=>"20170214T200752Z",
|
152
|
+
:"x-amz-credential"=>"AAA/BBB/us-west-1/s3/aws4_request",
|
153
|
+
:"x-amz-algorithm"=>"AWS4-HMAC-SHA256",
|
154
|
+
:policy=>"something base64 encoded.",
|
155
|
+
:key=>"XXX/ZZZ",
|
156
|
+
:acl=>"authenticated-read"
|
157
|
+
},
|
158
|
+
:id=>"more Hex",
|
159
|
+
:field=>"file",
|
160
|
+
:enctype=>"multipart/form-data"
|
161
|
+
}
|
162
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/Solutionfile.json/upload").
|
163
|
+
with(:query=>{
|
164
|
+
:expires_in=>30,
|
165
|
+
:sha256=>'018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136',
|
166
|
+
:type=>'application/json'}).
|
167
|
+
to_return(:body => body.to_json)
|
168
|
+
|
169
|
+
stub_request(:post, "https://s3-us-west-1.amazonaws.com/murano-content-service-staging").
|
170
|
+
with(:headers=>{"Content-Type"=>%r|\Amultipart/form-data|}) do |request|
|
171
|
+
request.body =~ /something base64 encoded/
|
172
|
+
end.
|
173
|
+
to_return(:status=>500)
|
174
|
+
|
175
|
+
saved = $stderr
|
176
|
+
$stderr = StringIO.new
|
177
|
+
|
178
|
+
@ct.upload('Solutionfile.json', @tup.to_path)
|
179
|
+
expect($stderr.string).to eq("\e[31mRequest Failed: 500: nil\e[0m\n")
|
180
|
+
$stderr = saved
|
181
|
+
end
|
182
|
+
|
183
|
+
it "uploads with --dry" do
|
184
|
+
body = {
|
185
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging",
|
186
|
+
:method=>"POST",
|
187
|
+
:inputs=>{
|
188
|
+
:"x-amz-meta-name"=>"resources.yaml",
|
189
|
+
:"x-amz-signature"=>"Bunch of Hex",
|
190
|
+
:"x-amz-date"=>"20170214T200752Z",
|
191
|
+
:"x-amz-credential"=>"AAA/BBB/us-west-1/s3/aws4_request",
|
192
|
+
:"x-amz-algorithm"=>"AWS4-HMAC-SHA256",
|
193
|
+
:policy=>"something base64 encoded.",
|
194
|
+
:key=>"XXX/ZZZ",
|
195
|
+
:acl=>"authenticated-read"
|
196
|
+
},
|
197
|
+
:id=>"more Hex",
|
198
|
+
:field=>"file",
|
199
|
+
:enctype=>"multipart/form-data"
|
200
|
+
}
|
201
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/Solutionfile.json/upload").
|
202
|
+
with(:query=>{
|
203
|
+
:expires_in=>30,
|
204
|
+
:sha256=>'018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136',
|
205
|
+
:type=>'application/json'}).
|
206
|
+
to_return(:body => body.to_json)
|
207
|
+
|
208
|
+
$cfg['tool.dry'] = true
|
209
|
+
@ct.upload('Solutionfile.json', @tup.to_path)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "uploads with --curl" do
|
213
|
+
body = {
|
214
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging",
|
215
|
+
:method=>"POST",
|
216
|
+
:inputs=>{
|
217
|
+
:"x-amz-meta-name"=>"Solutionfile.json",
|
218
|
+
:"x-amz-signature"=>"Bunch of Hex",
|
219
|
+
:"x-amz-date"=>"20170214T200752Z",
|
220
|
+
:"x-amz-credential"=>"AAA/BBB/us-west-1/s3/aws4_request",
|
221
|
+
:"x-amz-algorithm"=>"AWS4-HMAC-SHA256",
|
222
|
+
:policy=>"something base64 encoded.",
|
223
|
+
:key=>"XXX/ZZZ",
|
224
|
+
:acl=>"authenticated-read"
|
225
|
+
},
|
226
|
+
:id=>"more Hex",
|
227
|
+
:field=>"file",
|
228
|
+
:enctype=>"multipart/form-data"
|
229
|
+
}
|
230
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/Solutionfile.json/upload").
|
231
|
+
with(:query=>{
|
232
|
+
:expires_in=>30,
|
233
|
+
:sha256=>'018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136',
|
234
|
+
:type=>'application/json'}).
|
235
|
+
to_return(:body => body.to_json)
|
236
|
+
|
237
|
+
stub_request(:post, "https://s3-us-west-1.amazonaws.com/murano-content-service-staging").
|
238
|
+
with(:headers=>{"Content-Type"=>%r|\Amultipart/form-data|}) do |request|
|
239
|
+
request.body =~ /something base64 encoded/
|
240
|
+
end.
|
241
|
+
to_return(:status=>200)
|
242
|
+
|
243
|
+
saved = $stdout
|
244
|
+
$stdout = StringIO.new
|
245
|
+
|
246
|
+
$cfg['tool.curldebug'] = true
|
247
|
+
$cfg.curlfile_f = nil
|
248
|
+
@ct.upload('Solutionfile.json', @tup.to_path)
|
249
|
+
expect($stdout.string).to match(%r{curl -s -H 'Authorization: token TTTTTTTTTT' -H 'User-Agent: MrMurano/[^']+' -H 'Content-Type: application/json' -X GET 'https://bizapi\.hosted\.exosite\.io/api:1/service/XYZ/content/item/Solutionfile\.json/upload\?sha256=018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136&expires_in=30&type=application%2Fjson'\ncurl -s -H 'User-Agent: MrMurano/[^']+' -X POST 'https://s3-us-west-1\.amazonaws\.com/murano-content-service-staging' -F 'x-amz-meta-name=Solutionfile\.json' -F 'x-amz-signature=Bunch of Hex' -F 'x-amz-date=20170214T200752Z' -F 'x-amz-credential=AAA/BBB/us-west-1/s3/aws4_request' -F 'x-amz-algorithm=AWS4-HMAC-SHA256' -F 'policy=something base64 encoded\.' -F 'key=XXX/ZZZ' -F 'acl=authenticated-read' -F file=@.*/home/work/project/Solutionfile\.json\n})
|
250
|
+
$stdout = saved
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context "downloads" do
|
255
|
+
it "something to stdout" do
|
256
|
+
body = {
|
257
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ",
|
258
|
+
:method=>"GET",
|
259
|
+
:id=>"8076e5d091844814d7f5cd97a1a730aa"
|
260
|
+
}
|
261
|
+
|
262
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/TODO.taskpaper/download").
|
263
|
+
to_return(:body => body.to_json)
|
264
|
+
|
265
|
+
stub_request(:get , "https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ").
|
266
|
+
to_return(:body => "FOOOOOOOOOOOO")
|
267
|
+
|
268
|
+
# This test does not work with curldebug enabled.
|
269
|
+
$cfg['tool.curldebug'] = false
|
270
|
+
$cfg.curlfile_f = nil
|
271
|
+
|
272
|
+
saved = $stdout
|
273
|
+
$stdout = StringIO.new
|
274
|
+
|
275
|
+
@ct.download('TODO.taskpaper')
|
276
|
+
expect($stdout.string).to eq("FOOOOOOOOOOOO")
|
277
|
+
$stdout = saved
|
278
|
+
end
|
279
|
+
|
280
|
+
it "something to block" do
|
281
|
+
body = {
|
282
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ",
|
283
|
+
:method=>"GET",
|
284
|
+
:id=>"8076e5d091844814d7f5cd97a1a730aa"
|
285
|
+
}
|
286
|
+
|
287
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/TODO.taskpaper/download").
|
288
|
+
to_return(:body => body.to_json)
|
289
|
+
|
290
|
+
stub_request(:get , "https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ").
|
291
|
+
to_return(:body => "FOOOOOOOOOOOO")
|
292
|
+
|
293
|
+
expect{|b| @ct.download('TODO.taskpaper', &b) }.to yield_with_args("FOOOOOOOOOOOO")
|
294
|
+
end
|
295
|
+
|
296
|
+
it "something that isn't there" do
|
297
|
+
# bizapi/content/download always returns GET instructions? yes.
|
298
|
+
body = {
|
299
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ",
|
300
|
+
:method=>"GET",
|
301
|
+
:id=>"8076e5d091844814d7f5cd97a1a730aa"
|
302
|
+
}
|
303
|
+
|
304
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/Notthere/download").
|
305
|
+
to_return(:body => body.to_json)
|
306
|
+
|
307
|
+
resp = %{
|
308
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
309
|
+
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>XXX/ZZZ</Key><RequestId>12</RequestId><HostId>=</HostId></Error>
|
310
|
+
}
|
311
|
+
stub_request(:get , "https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ").
|
312
|
+
to_return(:status=>404, :body => resp)
|
313
|
+
|
314
|
+
saved = $stderr
|
315
|
+
$stderr = StringIO.new
|
316
|
+
|
317
|
+
ret = @ct.download('Notthere')
|
318
|
+
expect(ret).to match(Net::HTTPNotFound)
|
319
|
+
expect($stderr.string).to eq("\e[31mRequest Failed: 404: " + resp + "\e[0m\n")
|
320
|
+
$stderr = saved
|
321
|
+
end
|
322
|
+
|
323
|
+
it "something to block with --curl" do
|
324
|
+
body = {
|
325
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ",
|
326
|
+
:method=>"GET",
|
327
|
+
:id=>"8076e5d091844814d7f5cd97a1a730aa"
|
328
|
+
}
|
329
|
+
|
330
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/TODO.taskpaper/download").
|
331
|
+
to_return(:body => body.to_json)
|
332
|
+
|
333
|
+
stub_request(:get , "https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ").
|
334
|
+
to_return(:body => "FOOOOOOOOOOOO")
|
335
|
+
|
336
|
+
saved = $stdout
|
337
|
+
$stdout = StringIO.new
|
338
|
+
|
339
|
+
$cfg['tool.curldebug'] = true
|
340
|
+
$cfg.curlfile_f = nil
|
341
|
+
@ct.download('TODO.taskpaper')
|
342
|
+
expect($stdout.string).to match(%r{curl -s -H 'Authorization: token TTTTTTTTTT' -H 'User-Agent: MrMurano/[^']+' -H 'Content-Type: application/json' -X GET 'https://bizapi\.hosted\.exosite\.io/api:1/service/XYZ/content/item/TODO\.taskpaper/download'\ncurl -s -H 'User-Agent: MrMurano/[^']+' -X GET 'https://s3-us-west-1\.amazonaws\.com/murano-content-service-staging/XXX/ZZZ'\nFOOOOOOOOOOOO})
|
343
|
+
$stdout = saved
|
344
|
+
end
|
345
|
+
|
346
|
+
it "something to block with --dry" do
|
347
|
+
body = {
|
348
|
+
:url=>"https://s3-us-west-1.amazonaws.com/murano-content-service-staging/XXX/ZZZ",
|
349
|
+
:method=>"GET",
|
350
|
+
:id=>"8076e5d091844814d7f5cd97a1a730aa"
|
351
|
+
}
|
352
|
+
|
353
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/content/item/TODO.taskpaper/download").
|
354
|
+
to_return(:body => body.to_json)
|
355
|
+
|
356
|
+
$cfg['tool.dry'] = true
|
357
|
+
@ct.download('TODO.taskpaper')
|
358
|
+
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
end
|
363
|
+
# vim: set ai et sw=2 ts=2 :
|