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/cmd_keystore_spec.rb
CHANGED
@@ -8,8 +8,8 @@ RSpec.describe 'murano keystore', :cmd, :needs_password do
|
|
8
8
|
include_context "CI_CMD"
|
9
9
|
|
10
10
|
before(:example) do
|
11
|
-
@
|
12
|
-
out, err, status = Open3.capture3(capcmd('murano', '
|
11
|
+
@product_name = rname('keystoreTest')
|
12
|
+
out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @product_name, '--save'))
|
13
13
|
expect(err).to eq('')
|
14
14
|
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
15
15
|
expect(status.exitstatus).to eq(0)
|
@@ -20,7 +20,7 @@ RSpec.describe 'murano keystore', :cmd, :needs_password do
|
|
20
20
|
expect(status.exitstatus).to eq(0)
|
21
21
|
end
|
22
22
|
after(:example) do
|
23
|
-
out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @
|
23
|
+
out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
|
24
24
|
expect(out).to eq('')
|
25
25
|
expect(err).to eq('')
|
26
26
|
expect(status.exitstatus).to eq(0)
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# Last Modified: 2017.08.16 /coding: utf-8
|
2
|
+
# frozen_string_literal: probably not yet
|
3
|
+
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
require 'open3'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cmd_common'
|
12
|
+
|
13
|
+
RSpec.describe 'murano link', :cmd, :needs_password do
|
14
|
+
include_context "CI_CMD"
|
15
|
+
|
16
|
+
before(:example) do
|
17
|
+
@solz_name = rname('linktest')
|
18
|
+
out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @solz_name, '--save'))
|
19
|
+
expect(err).to eq('')
|
20
|
+
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
21
|
+
expect(status.exitstatus).to eq(0)
|
22
|
+
|
23
|
+
out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @solz_name, '--save'))
|
24
|
+
expect(err).to eq('')
|
25
|
+
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
26
|
+
expect(status.exitstatus).to eq(0)
|
27
|
+
end
|
28
|
+
after(:example) do
|
29
|
+
out, err, status = Open3.capture3(capcmd('murano', 'application', 'delete', @solz_name, '-y'))
|
30
|
+
expect(out).to eq('')
|
31
|
+
expect(err).to eq('')
|
32
|
+
expect(status.exitstatus).to eq(0)
|
33
|
+
|
34
|
+
out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @solz_name, '-y'))
|
35
|
+
expect(out).to eq('')
|
36
|
+
expect(err).to eq('')
|
37
|
+
expect(status.exitstatus).to eq(0)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "links and lists" do
|
41
|
+
out, err, status = Open3.capture3(capcmd('murano', 'assign', 'set'))
|
42
|
+
#expect(out).to a_string_starting_with("Linked product #{@solz_name}")
|
43
|
+
olines = out.lines
|
44
|
+
|
45
|
+
# Windows has a complaint about the fancy quotes if you don't encode!, which is
|
46
|
+
#
|
47
|
+
# expected: "Linked \u2018syncdowntestprd1e8b4034\u2019
|
48
|
+
# to \u2018syncdowntestapp23d5135b\u2019\n"
|
49
|
+
# got: "Linked \xE2\x80\x98syncdowntestprd1e8b4034\xE2\x80\x99
|
50
|
+
# to \xE2\x80\x98syncdowntestapp23d5135b\xE2\x80\x99\n"
|
51
|
+
#
|
52
|
+
# or, to put it another way,
|
53
|
+
#
|
54
|
+
# -Linked ?syncdowntestprd1e8b4034? to ?syncdowntestapp23d5135b?
|
55
|
+
# +Linked ΓÇÿsyncdowntestprd1e8b4034ΓÇÖ to ΓÇÿsyncdowntestapp23d5135bΓÇÖ
|
56
|
+
#
|
57
|
+
# which we can solve with an encode call. (Or but using norm quotes.)
|
58
|
+
#
|
59
|
+
#expect(olines[0]).to eq("Linked ‘#{@solz_name}’ to ‘#{@solz_name}’\n")
|
60
|
+
expect(olines[0].encode!('UTF-8', 'UTF-8')).to eq("Linked ‘#{@solz_name}’ to ‘#{@solz_name}’\n")
|
61
|
+
|
62
|
+
expect(olines[1]).to eq("Created default event handler\n")
|
63
|
+
expect(err).to eq('')
|
64
|
+
expect(status.exitstatus).to eq(0)
|
65
|
+
|
66
|
+
out, err, status = Open3.capture3(capcmd('murano', 'assign', 'list'))
|
67
|
+
expect(err).to eq('')
|
68
|
+
olines = out.lines
|
69
|
+
expect(olines[0]).to match(/^(\+-+){3}\+$/)
|
70
|
+
expect(olines[1]).to match(/^\| name\s+\| script_key\s+\| service\s+\|$/)
|
71
|
+
expect(olines[2]).to match(/^(\+-+){3}\+$/)
|
72
|
+
expect(olines[-1]).to match(/^(\+-+){3}\+$/)
|
73
|
+
expect(status.exitstatus).to eq(0)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "unlinks" do
|
77
|
+
out, err, status = Open3.capture3(capcmd('murano', 'assign', 'set'))
|
78
|
+
#expect(out).to a_string_starting_with("Linked product #{@solz_name}")
|
79
|
+
olines = out.lines
|
80
|
+
expect(olines[0].encode!('UTF-8', 'UTF-8')).to eq("Linked ‘#{@solz_name}’ to ‘#{@solz_name}’\n")
|
81
|
+
expect(olines[1]).to eq("Created default event handler\n")
|
82
|
+
expect(err).to eq('')
|
83
|
+
expect(status.exitstatus).to eq(0)
|
84
|
+
|
85
|
+
out, err, status = Open3.capture3(capcmd('murano', 'link', 'unset'))
|
86
|
+
#expect(out).to a_string_starting_with("Unlinked #{@solz_name}")
|
87
|
+
# E.g.,
|
88
|
+
# Unlinked ‘linktest3e7def1b86a1d680’ from ‘linktest3e7def1b86a1d680’\n
|
89
|
+
# Removed ‘h2thqll2z9sqoooc0_w4w3vxla11ngg4cok_event’ from ‘linktest3e7def1b86a1d680\n
|
90
|
+
olines = out.lines
|
91
|
+
expect(olines[0].encode!('UTF-8', 'UTF-8')).to eq("Unlinked ‘#{@solz_name}’ from ‘#{@solz_name}’\n")
|
92
|
+
expect(olines[1].encode!('UTF-8', 'UTF-8')).to a_string_starting_with("Removed ‘")
|
93
|
+
expect(olines[1].encode!('UTF-8', 'UTF-8')).to match(/^Removed ‘[_a-z0-9]*’ from ‘#{@solz_name}’\n$/)
|
94
|
+
expect(err).to eq('')
|
95
|
+
expect(status.exitstatus).to eq(0)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
data/spec/cmd_password_spec.rb
CHANGED
@@ -40,7 +40,7 @@ RSpec.describe 'murano password', :cmd do
|
|
40
40
|
io << " bob@bob.bob: badpassword\n"
|
41
41
|
io << " rich@er.u: notbetter\n"
|
42
42
|
end
|
43
|
-
out, err, status = Open3.capture3(capcmd('murano', 'password', 'delete', 'rich@er.u', 'an.API.host.i'))
|
43
|
+
out, err, status = Open3.capture3(capcmd('murano', 'password', 'delete', 'rich@er.u', 'an.API.host.i', '-y'))
|
44
44
|
expect(err).to eq('')
|
45
45
|
expect(out).to eq('')
|
46
46
|
expect(status.exitstatus).to eq(0)
|
@@ -0,0 +1,260 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
require 'pathname'
|
4
|
+
require 'json'
|
5
|
+
require 'vine'
|
6
|
+
require 'cmd_common'
|
7
|
+
|
8
|
+
RSpec.describe 'murano setting', :cmd, :needs_password do
|
9
|
+
include_context "CI_CMD"
|
10
|
+
|
11
|
+
before(:example) do
|
12
|
+
@product_name = rname('settingtest')
|
13
|
+
out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @product_name, '--save'))
|
14
|
+
expect(err).to eq('')
|
15
|
+
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
16
|
+
expect(status.exitstatus).to eq(0)
|
17
|
+
end
|
18
|
+
after(:example) do
|
19
|
+
out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
|
20
|
+
expect(out).to eq('')
|
21
|
+
expect(err).to eq('')
|
22
|
+
expect(status.exitstatus).to eq(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "reads Webservice.cors" do
|
26
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
27
|
+
expect { JSON.parse(out) }.to_not raise_error
|
28
|
+
expect(err).to eq('')
|
29
|
+
expect(status.exitstatus).to eq(0)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "reads Webservice.cors to a file" do
|
33
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-o', 'testout', '-c', 'outformat=json'))
|
34
|
+
expect(err).to eq('')
|
35
|
+
expect(out).to eq('')
|
36
|
+
expect(status.exitstatus).to eq(0)
|
37
|
+
expect(File.exist?('testout')).to be true
|
38
|
+
end
|
39
|
+
|
40
|
+
context "Writes (using Webservice.cors)" do
|
41
|
+
before(:example) do
|
42
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
43
|
+
expect { @json_before = JSON.parse(out) }.to_not raise_error
|
44
|
+
expect(err).to eq('')
|
45
|
+
expect(status.exitstatus).to eq(0)
|
46
|
+
end
|
47
|
+
# {"origin"=>true,
|
48
|
+
# "methods"=>["HEAD", "GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
49
|
+
# "headers"=>["Content-Type", "Cookie", "Authorization"],
|
50
|
+
# "credentials"=>true}
|
51
|
+
|
52
|
+
context "a bool value" do
|
53
|
+
it "Yes" do
|
54
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'Yes'))
|
55
|
+
expect(err).to eq('')
|
56
|
+
expect(out).to eq('')
|
57
|
+
expect(status.exitstatus).to eq(0)
|
58
|
+
|
59
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
60
|
+
json_after = nil
|
61
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
62
|
+
expect(err).to eq('')
|
63
|
+
expect(status.exitstatus).to eq(0)
|
64
|
+
@json_before['origin'] = true
|
65
|
+
expect(json_after).to match(@json_before)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "true" do
|
69
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'true'))
|
70
|
+
expect(err).to eq('')
|
71
|
+
expect(out).to eq('')
|
72
|
+
expect(status.exitstatus).to eq(0)
|
73
|
+
|
74
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
75
|
+
json_after = nil
|
76
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
77
|
+
expect(err).to eq('')
|
78
|
+
expect(status.exitstatus).to eq(0)
|
79
|
+
@json_before['origin'] = true
|
80
|
+
expect(json_after).to match(@json_before)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "on" do
|
84
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'on'))
|
85
|
+
expect(err).to eq('')
|
86
|
+
expect(out).to eq('')
|
87
|
+
expect(status.exitstatus).to eq(0)
|
88
|
+
|
89
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
90
|
+
json_after = nil
|
91
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
92
|
+
expect(err).to eq('')
|
93
|
+
expect(status.exitstatus).to eq(0)
|
94
|
+
@json_before['origin'] = true
|
95
|
+
expect(json_after).to match(@json_before)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "1" do
|
99
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', '1'))
|
100
|
+
expect(err).to eq('')
|
101
|
+
expect(out).to eq('')
|
102
|
+
expect(status.exitstatus).to eq(0)
|
103
|
+
|
104
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
105
|
+
json_after = nil
|
106
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
107
|
+
expect(err).to eq('')
|
108
|
+
expect(status.exitstatus).to eq(0)
|
109
|
+
@json_before['origin'] = true
|
110
|
+
expect(json_after).to match(@json_before)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "bob" do
|
114
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'bob'))
|
115
|
+
expect(err).to eq("\e[31mValue \"bob\" is not a bool type!\e[0m\n")
|
116
|
+
expect(out).to eq('')
|
117
|
+
expect(status.exitstatus).to eq(2)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "No" do
|
121
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'No'))
|
122
|
+
expect(err).to eq('')
|
123
|
+
expect(out).to eq('')
|
124
|
+
expect(status.exitstatus).to eq(0)
|
125
|
+
|
126
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
127
|
+
json_after = nil
|
128
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
129
|
+
expect(err).to eq('')
|
130
|
+
expect(status.exitstatus).to eq(0)
|
131
|
+
@json_before['origin'] = false
|
132
|
+
expect(json_after).to match(@json_before)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "false" do
|
136
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'false'))
|
137
|
+
expect(err).to eq('')
|
138
|
+
expect(out).to eq('')
|
139
|
+
expect(status.exitstatus).to eq(0)
|
140
|
+
|
141
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
142
|
+
json_after = nil
|
143
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
144
|
+
expect(err).to eq('')
|
145
|
+
expect(status.exitstatus).to eq(0)
|
146
|
+
@json_before['origin'] = false
|
147
|
+
expect(json_after).to match(@json_before)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "off" do
|
151
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', 'Off'))
|
152
|
+
expect(err).to eq('')
|
153
|
+
expect(out).to eq('')
|
154
|
+
expect(status.exitstatus).to eq(0)
|
155
|
+
|
156
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
157
|
+
json_after = nil
|
158
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
159
|
+
expect(err).to eq('')
|
160
|
+
expect(status.exitstatus).to eq(0)
|
161
|
+
@json_before['origin'] = false
|
162
|
+
expect(json_after).to match(@json_before)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "0" do
|
166
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool', '0'))
|
167
|
+
expect(err).to eq('')
|
168
|
+
expect(out).to eq('')
|
169
|
+
expect(status.exitstatus).to eq(0)
|
170
|
+
|
171
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
172
|
+
json_after = nil
|
173
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
174
|
+
expect(err).to eq('')
|
175
|
+
expect(status.exitstatus).to eq(0)
|
176
|
+
@json_before['origin'] = false
|
177
|
+
expect(json_after).to match(@json_before)
|
178
|
+
end
|
179
|
+
|
180
|
+
it "on STDIN" do
|
181
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool'), :stdin_data=>'true')
|
182
|
+
expect(err).to eq('')
|
183
|
+
expect(out).to eq('')
|
184
|
+
expect(status.exitstatus).to eq(0)
|
185
|
+
|
186
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
187
|
+
json_after = nil
|
188
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
189
|
+
expect(err).to eq('')
|
190
|
+
expect(status.exitstatus).to eq(0)
|
191
|
+
@json_before['origin'] = true
|
192
|
+
expect(json_after).to match(@json_before)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
it "a json array blob" do
|
197
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'headers', '--json', '["fidget", "forgotten", "tokens"]'))
|
198
|
+
expect(err).to eq('')
|
199
|
+
expect(out).to eq('')
|
200
|
+
expect(status.exitstatus).to eq(0)
|
201
|
+
|
202
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
203
|
+
json_after = nil
|
204
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
205
|
+
expect(err).to eq('')
|
206
|
+
expect(status.exitstatus).to eq(0)
|
207
|
+
@json_before['headers'] = ['fidget', 'forgotten', 'tokens']
|
208
|
+
expect(json_after).to match(@json_before)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "a json array blob with STDIN" do
|
212
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'headers', '--json'), :stdin_data=>'["fidget", "forgotten", "tokens"]')
|
213
|
+
expect(err).to eq('')
|
214
|
+
expect(out).to eq('')
|
215
|
+
expect(status.exitstatus).to eq(0)
|
216
|
+
|
217
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
218
|
+
json_after = nil
|
219
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
220
|
+
expect(err).to eq('')
|
221
|
+
expect(status.exitstatus).to eq(0)
|
222
|
+
@json_before['headers'] = ['fidget', 'forgotten', 'tokens']
|
223
|
+
expect(json_after).to match(@json_before)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "an array" do
|
227
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'headers', '--array', 'fidget', 'forgotten', 'tokens'))
|
228
|
+
expect(err).to eq('')
|
229
|
+
expect(out).to eq('')
|
230
|
+
expect(status.exitstatus).to eq(0)
|
231
|
+
|
232
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
233
|
+
json_after = nil
|
234
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
235
|
+
expect(err).to eq('')
|
236
|
+
expect(status.exitstatus).to eq(0)
|
237
|
+
@json_before['headers'] = ['fidget', 'forgotten', 'tokens']
|
238
|
+
expect(json_after).to match(@json_before)
|
239
|
+
end
|
240
|
+
|
241
|
+
it "appends an array" do
|
242
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Webservice.cors', 'headers', '--array', '--append', 'fidget', 'forgotten', 'tokens'))
|
243
|
+
expect(err).to eq('')
|
244
|
+
expect(out).to eq('')
|
245
|
+
expect(status.exitstatus).to eq(0)
|
246
|
+
|
247
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
248
|
+
json_after = nil
|
249
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
250
|
+
expect(err).to eq('')
|
251
|
+
expect(status.exitstatus).to eq(0)
|
252
|
+
@json_before['headers'] = @json_before['headers'] + ['fidget', 'forgotten', 'tokens']
|
253
|
+
expect(json_after).to match(@json_before)
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|
259
|
+
|
260
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -0,0 +1,220 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
require 'pathname'
|
4
|
+
require 'json'
|
5
|
+
require 'vine'
|
6
|
+
require 'cmd_common'
|
7
|
+
|
8
|
+
RSpec.describe 'murano setting', :cmd, :needs_password do
|
9
|
+
include_context "CI_CMD"
|
10
|
+
|
11
|
+
before(:example) do
|
12
|
+
@product_name = rname('settingtest')
|
13
|
+
out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @product_name, '--save'))
|
14
|
+
expect(err).to eq('')
|
15
|
+
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
16
|
+
expect(status.exitstatus).to eq(0)
|
17
|
+
end
|
18
|
+
after(:example) do
|
19
|
+
out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
|
20
|
+
expect(out).to eq('')
|
21
|
+
expect(err).to eq('')
|
22
|
+
expect(status.exitstatus).to eq(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "Writes (using Device2.identity_format)" do
|
26
|
+
before(:example) do
|
27
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
28
|
+
expect { @json_before = JSON.parse(out) }.to_not raise_error
|
29
|
+
expect(err).to eq('')
|
30
|
+
expect(status.exitstatus).to eq(0)
|
31
|
+
end
|
32
|
+
# {"prefix"=>"", "type"=>"opaque", "options"=>{"casing"=>"mixed", "length"=>0}}
|
33
|
+
|
34
|
+
it "a string value" do
|
35
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'prefix', 'fidget'))
|
36
|
+
expect(err).to eq('')
|
37
|
+
expect(out).to eq('')
|
38
|
+
expect(status.exitstatus).to eq(0)
|
39
|
+
|
40
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
41
|
+
json_after = nil
|
42
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
43
|
+
expect(err).to eq('')
|
44
|
+
expect(status.exitstatus).to eq(0)
|
45
|
+
@json_before['prefix'] = 'fidget'
|
46
|
+
expect(json_after).to match(@json_before)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "a forced string value" do
|
50
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'prefix', '--string', 'fidget'))
|
51
|
+
expect(err).to eq('')
|
52
|
+
expect(out).to eq('')
|
53
|
+
expect(status.exitstatus).to eq(0)
|
54
|
+
|
55
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
56
|
+
json_after = nil
|
57
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
58
|
+
expect(err).to eq('')
|
59
|
+
expect(status.exitstatus).to eq(0)
|
60
|
+
@json_before['prefix'] = 'fidget'
|
61
|
+
expect(json_after).to match(@json_before)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "a forced string value on STDIN" do
|
65
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'prefix', '--string'), :stdin_data=>'fidget')
|
66
|
+
expect(err).to eq('')
|
67
|
+
expect(out).to eq('')
|
68
|
+
expect(status.exitstatus).to eq(0)
|
69
|
+
|
70
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
71
|
+
json_after = nil
|
72
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
73
|
+
expect(err).to eq('')
|
74
|
+
expect(status.exitstatus).to eq(0)
|
75
|
+
@json_before['prefix'] = 'fidget'
|
76
|
+
expect(json_after).to match(@json_before)
|
77
|
+
end
|
78
|
+
|
79
|
+
# This may not be testable in integration. (since it does things that get filtered out)
|
80
|
+
it "all intermediate keys" #do
|
81
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'one.two.three', 'fidget'))
|
82
|
+
# expect(err).to eq('')
|
83
|
+
# expect(out).to eq('')
|
84
|
+
# expect(status.exitstatus).to eq(0)
|
85
|
+
#
|
86
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
87
|
+
# json_after = nil
|
88
|
+
# expect { json_after = JSON.parse(out) }.to_not raise_error
|
89
|
+
# expect(err).to eq('')
|
90
|
+
# expect(status.exitstatus).to eq(0)
|
91
|
+
# @json_before.set('one.two.three', 'figdet')
|
92
|
+
# expect(json_after).to match(@json_before)
|
93
|
+
# end
|
94
|
+
|
95
|
+
context "a number value" do
|
96
|
+
it "integer 12" do
|
97
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'options.length', '--num', '12'))
|
98
|
+
expect(err).to eq('')
|
99
|
+
expect(out).to eq('')
|
100
|
+
expect(status.exitstatus).to eq(0)
|
101
|
+
|
102
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
103
|
+
json_after = nil
|
104
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
105
|
+
expect(err).to eq('')
|
106
|
+
expect(status.exitstatus).to eq(0)
|
107
|
+
@json_before.set('options.length', 12)
|
108
|
+
expect(json_after).to match(@json_before)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "float 12.67" do
|
112
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'options.length', '--num', '12.67'))
|
113
|
+
expect(err).to eq('')
|
114
|
+
expect(out).to eq('')
|
115
|
+
expect(status.exitstatus).to eq(0)
|
116
|
+
|
117
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
118
|
+
json_after = nil
|
119
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
120
|
+
expect(err).to eq('')
|
121
|
+
expect(status.exitstatus).to eq(0)
|
122
|
+
@json_before.set('options.length', 12.67)
|
123
|
+
expect(json_after).to match(@json_before)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "fiftyHalf" do
|
127
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'options.length', '--num', 'fiftyHalf'))
|
128
|
+
expect(err).to eq("\e[31mValue \"fiftyHalf\" is not a number\e[0m\n")
|
129
|
+
expect(out).to eq('')
|
130
|
+
expect(status.exitstatus).to eq(2)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "on STDIN" do
|
134
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'options.length', '--num'), :stdin_data=>'12')
|
135
|
+
expect(err).to eq('')
|
136
|
+
expect(out).to eq('')
|
137
|
+
expect(status.exitstatus).to eq(0)
|
138
|
+
|
139
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
140
|
+
json_after = nil
|
141
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
142
|
+
expect(err).to eq('')
|
143
|
+
expect(status.exitstatus).to eq(0)
|
144
|
+
@json_before.set('options.length', 12)
|
145
|
+
expect(json_after).to match(@json_before)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it "a json object blob" #do
|
150
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'type', 'base16'))
|
151
|
+
# expect(err).to eq('')
|
152
|
+
# expect(out).to eq('')
|
153
|
+
# expect(status.exitstatus).to eq(0)
|
154
|
+
#
|
155
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'options', '--json', '{"casing": "lower", "length": 0}'))
|
156
|
+
# expect(err).to eq('')
|
157
|
+
# expect(out).to eq('')
|
158
|
+
# expect(status.exitstatus).to eq(0)
|
159
|
+
#
|
160
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
161
|
+
# json_after = nil
|
162
|
+
# expect { json_after = JSON.parse(out) }.to_not raise_error
|
163
|
+
# expect(err).to eq('')
|
164
|
+
# expect(status.exitstatus).to eq(0)
|
165
|
+
# @json_before['type'] = 'base16'
|
166
|
+
# @json_before['options'] = {'casing'=>'lower', 'length'=>0}
|
167
|
+
# expect(json_after).to match(@json_before)
|
168
|
+
# end
|
169
|
+
|
170
|
+
it "a json object blob with stdin"
|
171
|
+
|
172
|
+
# This may not be testable in integration.
|
173
|
+
it "a dictionary" #do
|
174
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', 'options', '--dict', 'casing', 'lower'))
|
175
|
+
# expect(err).to eq('')
|
176
|
+
# expect(out).to eq('')
|
177
|
+
# expect(status.exitstatus).to eq(0)
|
178
|
+
#
|
179
|
+
# out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
180
|
+
# json_after = nil
|
181
|
+
# expect { json_after = JSON.parse(out) }.to_not raise_error
|
182
|
+
# expect(err).to eq('')
|
183
|
+
# expect(status.exitstatus).to eq(0)
|
184
|
+
# @json_before['options'] = {'casing'=>'lower', 'length'=>0}
|
185
|
+
# expect(json_after).to match(@json_before)
|
186
|
+
# end
|
187
|
+
|
188
|
+
it "merges into a dictionary" do
|
189
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'write', 'Device2.identity_format', '.', '--dict', '--merge', 'prefix', 'tix', 'type', 'base10'))
|
190
|
+
expect(err).to eq('')
|
191
|
+
expect(out).to eq('')
|
192
|
+
expect(status.exitstatus).to eq(0)
|
193
|
+
|
194
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Device2.identity_format', '-c', 'outformat=json'))
|
195
|
+
json_after = nil
|
196
|
+
expect { json_after = JSON.parse(out) }.to_not raise_error
|
197
|
+
expect(err).to eq('')
|
198
|
+
expect(status.exitstatus).to eq(0)
|
199
|
+
@json_before['prefix'] = 'tix'
|
200
|
+
@json_before['type'] = 'base10'
|
201
|
+
expect(json_after).to match(@json_before)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context "Writes (using Webservice.cors)" do
|
206
|
+
before(:example) do
|
207
|
+
out, err, status = Open3.capture3(capcmd('murano', 'setting', 'read', 'Webservice.cors', '-c', 'outformat=json'))
|
208
|
+
expect { @json_before = JSON.parse(out) }.to_not raise_error
|
209
|
+
expect(err).to eq('')
|
210
|
+
expect(status.exitstatus).to eq(0)
|
211
|
+
end
|
212
|
+
# {"origin"=>true,
|
213
|
+
# "methods"=>["HEAD", "GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
214
|
+
# "headers"=>["Content-Type", "Cookie", "Authorization"],
|
215
|
+
# "credentials"=>true}
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
# vim: set ai et sw=2 ts=2 :
|