MuranoCLI 3.2.0.beta.1 → 3.2.0.beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/.trustme.plugin +137 -0
- data/.trustme.sh +217 -117
- data/.trustme.vim +9 -3
- data/Gemfile +9 -3
- data/MuranoCLI.gemspec +8 -5
- data/Rakefile +1 -0
- data/dockers/Dockerfile.2.2.9 +6 -3
- data/dockers/Dockerfile.2.3.6 +6 -3
- data/dockers/Dockerfile.2.4.3 +6 -3
- data/dockers/Dockerfile.2.5.0 +6 -3
- data/dockers/Dockerfile.GemRelease +10 -8
- data/dockers/Dockerfile.m4 +23 -5
- data/dockers/docker-test.sh +65 -28
- data/docs/completions/murano_completion-bash +751 -57
- data/docs/develop.rst +10 -9
- data/lib/MrMurano/AccountBase.rb +95 -6
- data/lib/MrMurano/Commander-Entry.rb +9 -4
- data/lib/MrMurano/Config-Migrate.rb +2 -0
- data/lib/MrMurano/Config.rb +94 -26
- data/lib/MrMurano/Content.rb +1 -1
- data/lib/MrMurano/Exchange.rb +77 -42
- data/lib/MrMurano/Gateway.rb +1 -1
- data/lib/MrMurano/HttpAuthed.rb +20 -7
- data/lib/MrMurano/Logs.rb +10 -1
- data/lib/MrMurano/ProjectFile.rb +1 -1
- data/lib/MrMurano/ReCommander.rb +129 -73
- data/lib/MrMurano/Solution-ServiceConfig.rb +18 -11
- data/lib/MrMurano/Solution-Services.rb +78 -50
- data/lib/MrMurano/Solution-Users.rb +1 -1
- data/lib/MrMurano/Solution.rb +13 -63
- data/lib/MrMurano/SyncUpDown-Core.rb +185 -77
- data/lib/MrMurano/SyncUpDown-Item.rb +29 -4
- data/lib/MrMurano/SyncUpDown.rb +11 -11
- data/lib/MrMurano/Webservice-Cors.rb +1 -1
- data/lib/MrMurano/Webservice-Endpoint.rb +28 -17
- data/lib/MrMurano/Webservice-File.rb +103 -43
- data/lib/MrMurano/commands/domain.rb +1 -0
- data/lib/MrMurano/commands/element.rb +585 -0
- data/lib/MrMurano/commands/exchange.rb +211 -204
- data/lib/MrMurano/commands/gb.rb +1 -0
- data/lib/MrMurano/commands/globals.rb +17 -7
- data/lib/MrMurano/commands/init.rb +115 -101
- data/lib/MrMurano/commands/keystore.rb +1 -1
- data/lib/MrMurano/commands/logs.rb +2 -1
- data/lib/MrMurano/commands/postgresql.rb +17 -7
- data/lib/MrMurano/commands/service.rb +572 -0
- data/lib/MrMurano/commands/show.rb +7 -3
- data/lib/MrMurano/commands/solution.rb +2 -1
- data/lib/MrMurano/commands/solution_picker.rb +31 -15
- data/lib/MrMurano/commands/status.rb +205 -169
- data/lib/MrMurano/commands/sync.rb +70 -38
- data/lib/MrMurano/commands/token.rb +59 -14
- data/lib/MrMurano/commands/usage.rb +1 -0
- data/lib/MrMurano/commands.rb +2 -0
- data/lib/MrMurano/hash.rb +91 -0
- data/lib/MrMurano/http.rb +55 -6
- data/lib/MrMurano/makePretty.rb +47 -0
- data/lib/MrMurano/optparse.rb +60 -45
- data/lib/MrMurano/variegated/TruthyFalsey.rb +48 -0
- data/lib/MrMurano/variegated/ruby_dig.rb +64 -0
- data/lib/MrMurano/verbosing.rb +113 -3
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Account_spec.rb +34 -20
- data/spec/Business_spec.rb +12 -9
- data/spec/Config_spec.rb +7 -1
- data/spec/Content_spec.rb +17 -1
- data/spec/GatewayBase_spec.rb +5 -2
- data/spec/GatewayDevice_spec.rb +4 -2
- data/spec/GatewayResource_spec.rb +4 -1
- data/spec/GatewaySettings_spec.rb +4 -1
- data/spec/HttpAuthed_spec.rb +73 -0
- data/spec/Http_spec.rb +32 -35
- data/spec/ProjectFile_spec.rb +1 -1
- data/spec/Solution-ServiceConfig_spec.rb +4 -1
- data/spec/Solution-ServiceEventHandler_spec.rb +6 -3
- data/spec/Solution-ServiceModules_spec.rb +4 -1
- data/spec/Solution-UsersRoles_spec.rb +4 -1
- data/spec/Solution_spec.rb +4 -1
- data/spec/SyncUpDown_spec.rb +1 -1
- data/spec/Webservice-Cors_spec.rb +4 -1
- data/spec/Webservice-Endpoint_spec.rb +9 -6
- data/spec/Webservice-File_spec.rb +17 -4
- data/spec/Webservice-Setting_spec.rb +6 -2
- data/spec/_workspace.rb +2 -0
- data/spec/cmd_common.rb +42 -13
- data/spec/cmd_content_spec.rb +17 -7
- data/spec/cmd_device_spec.rb +1 -1
- data/spec/cmd_domain_spec.rb +2 -2
- data/spec/cmd_element_spec.rb +400 -0
- data/spec/cmd_exchange_spec.rb +2 -2
- data/spec/cmd_init_spec.rb +59 -25
- data/spec/cmd_keystore_spec.rb +6 -3
- data/spec/cmd_link_spec.rb +10 -5
- data/spec/cmd_logs_spec.rb +1 -1
- data/spec/cmd_setting_application_spec.rb +18 -15
- data/spec/cmd_setting_product_spec.rb +7 -7
- data/spec/cmd_status_spec.rb +27 -17
- data/spec/cmd_syncdown_application_spec.rb +30 -3
- data/spec/cmd_syncdown_both_spec.rb +72 -18
- data/spec/cmd_syncup_spec.rb +71 -5
- data/spec/cmd_token_spec.rb +2 -2
- data/spec/cmd_usage_spec.rb +2 -2
- data/spec/dry_run_formatter.rb +27 -0
- data/spec/fixtures/dumped_config +8 -0
- data/spec/fixtures/exchange_element/element-show.json +1 -0
- data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +282 -0
- data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +588 -0
- data/spec/variegated_TruthyFalsey_spec.rb +29 -0
- metadata +51 -25
data/lib/MrMurano/verbosing.rb
CHANGED
|
@@ -89,7 +89,12 @@ module MrMurano
|
|
|
89
89
|
if fmt =~ /csv/i
|
|
90
90
|
cols = [] if cols.nil?
|
|
91
91
|
rows = [[]] if rows.nil?
|
|
92
|
-
CSV(
|
|
92
|
+
CSV(
|
|
93
|
+
ios,
|
|
94
|
+
headers: cols,
|
|
95
|
+
write_headers: !cols.empty?,
|
|
96
|
+
force_quotes: true
|
|
97
|
+
) do |csv|
|
|
93
98
|
# MAYBE/2017-07-02: Does shover operator work on frozen string literals?
|
|
94
99
|
rows.each { |v| csv << v }
|
|
95
100
|
end
|
|
@@ -103,9 +108,15 @@ module MrMurano
|
|
|
103
108
|
end
|
|
104
109
|
end
|
|
105
110
|
|
|
111
|
+
def prepare_hash_csv(elem)
|
|
112
|
+
headers = elem.keys
|
|
113
|
+
row_lkup = [elem.values]
|
|
114
|
+
[headers, row_lkup]
|
|
115
|
+
end
|
|
116
|
+
|
|
106
117
|
## Format and print the object
|
|
107
118
|
# Handles many of the raw 'unpolished' formats.
|
|
108
|
-
def outf(obj, ios=nil)
|
|
119
|
+
def outf(obj, ios=nil, pretty: false)
|
|
109
120
|
fmt = $cfg['tool.outformat']
|
|
110
121
|
ios = $stdout if ios.nil?
|
|
111
122
|
case fmt
|
|
@@ -114,7 +125,11 @@ module MrMurano
|
|
|
114
125
|
when /pp/
|
|
115
126
|
pp obj
|
|
116
127
|
when /json/i
|
|
117
|
-
|
|
128
|
+
if pretty
|
|
129
|
+
ios.puts JSON.pretty_generate(obj)
|
|
130
|
+
else
|
|
131
|
+
ios.puts obj.to_json
|
|
132
|
+
end
|
|
118
133
|
else # aka best.
|
|
119
134
|
# sometime ‘best’ is only know by the caller, so block.
|
|
120
135
|
if block_given?
|
|
@@ -127,6 +142,101 @@ module MrMurano
|
|
|
127
142
|
end
|
|
128
143
|
end
|
|
129
144
|
|
|
145
|
+
def read_hashf!(path, fmt=nil)
|
|
146
|
+
fmt = outformat_engine(path.extname.downcase) if fmt.nil?
|
|
147
|
+
load_input_file(path, fmt)
|
|
148
|
+
rescue StandardError => err
|
|
149
|
+
type = fancy_ticks(fmt)
|
|
150
|
+
warning %(Could not load input file of type #{type} at: #{path})
|
|
151
|
+
error err.message
|
|
152
|
+
exit 2
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def outformat_engine(fext)
|
|
156
|
+
case fext
|
|
157
|
+
when /\.?csv$/i
|
|
158
|
+
:csv
|
|
159
|
+
when /\.?json$/i
|
|
160
|
+
:json
|
|
161
|
+
when /\.?ya?ml$/i
|
|
162
|
+
:yaml
|
|
163
|
+
when /\.?te?xt$/i
|
|
164
|
+
:plain
|
|
165
|
+
else
|
|
166
|
+
:json
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def load_input_file(inpf, fmt)
|
|
171
|
+
case fmt
|
|
172
|
+
when :json
|
|
173
|
+
load_file_json(inpf)
|
|
174
|
+
when :yaml
|
|
175
|
+
load_file_yaml(inpf)
|
|
176
|
+
when :plain
|
|
177
|
+
load_file_plain(inpf)
|
|
178
|
+
else
|
|
179
|
+
error_file_format!(fmt)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def load_file_json(inpf)
|
|
184
|
+
# (lb) Why doesn't rubocop like JSON.load(inpf)? Whatever.
|
|
185
|
+
# NOPE: JSON.load(inpf)
|
|
186
|
+
JSON.parse(inpf.read)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def load_file_yaml(inpf)
|
|
190
|
+
begin
|
|
191
|
+
path = inpf.path
|
|
192
|
+
rescue NoMethodError
|
|
193
|
+
path = inpf.to_s
|
|
194
|
+
end
|
|
195
|
+
# The @data is false if the file exists but is empty.
|
|
196
|
+
YAML.load_file(path) || {}
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def load_file_plain(inpf)
|
|
200
|
+
inpf.read
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def dump_output_file(obj, outf, fmt, **opts)
|
|
204
|
+
case fmt
|
|
205
|
+
when :json
|
|
206
|
+
dump_file_json(obj, outf, **opts)
|
|
207
|
+
when :yaml
|
|
208
|
+
dump_file_yaml(obj, outf)
|
|
209
|
+
when :plain
|
|
210
|
+
dump_file_plain(obj, outf)
|
|
211
|
+
else
|
|
212
|
+
error_file_format!(fmt)
|
|
213
|
+
end
|
|
214
|
+
outf.flush
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def dump_file_json(obj, outf, pretty: false)
|
|
218
|
+
if pretty
|
|
219
|
+
outf.write(JSON.pretty_generate(obj))
|
|
220
|
+
else
|
|
221
|
+
JSON.dump(obj, outf)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def dump_file_yaml(obj, outf)
|
|
226
|
+
YAML.dump(obj, outf)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def dump_file_plain(obj, outf)
|
|
230
|
+
outf.write(obj)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def error_file_format!(fmt)
|
|
234
|
+
pfmt = fancy_ticks(fmt)
|
|
235
|
+
error %(Specified format is not a valid format: #{pfmt})
|
|
236
|
+
error %(Try one of: --json, or --yaml)
|
|
237
|
+
exit 2
|
|
238
|
+
end
|
|
239
|
+
|
|
130
240
|
def self.ask_yes_no(question, default)
|
|
131
241
|
answer = default
|
|
132
242
|
whirly_interject do
|
data/lib/MrMurano/version.rb
CHANGED
|
@@ -26,7 +26,7 @@ module MrMurano
|
|
|
26
26
|
# '3.0.0-beta.2' is changed to '3.0.0.pre.beta.2'
|
|
27
27
|
# which breaks our build (which expects the version to match herein).
|
|
28
28
|
# So stick to using the '.pre.X' syntax, which ruby/gems knows.
|
|
29
|
-
VERSION = '3.2.0.beta.
|
|
29
|
+
VERSION = '3.2.0.beta.5'
|
|
30
30
|
EXE_NAME = File.basename($PROGRAM_NAME)
|
|
31
31
|
SIGN_UP_URL = 'https://exosite.com/signup/'
|
|
32
32
|
end
|
data/spec/Account_spec.rb
CHANGED
|
@@ -9,19 +9,30 @@ require 'highline/import'
|
|
|
9
9
|
require 'MrMurano/version'
|
|
10
10
|
require 'MrMurano/Account'
|
|
11
11
|
require 'MrMurano/Config'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require 'MrMurano/ProjectFile'
|
|
13
14
|
require '_workspace'
|
|
15
|
+
require 'HttpAuthed_spec'
|
|
14
16
|
|
|
15
17
|
RSpec.describe MrMurano::Account, 'token' do
|
|
16
18
|
include_context 'WORKSPACE'
|
|
17
19
|
before(:example) do
|
|
18
|
-
@saved_cfg = ENV['MURANO_CONFIGFILE']
|
|
19
|
-
ENV['MURANO_CONFIGFILE'] = nil
|
|
20
20
|
$cfg = MrMurano::Config.new
|
|
21
21
|
$cfg.load
|
|
22
22
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
23
|
$cfg['business.id'] = 'XYZxyz'
|
|
24
24
|
$cfg['product.id'] = 'XYZ'
|
|
25
|
+
$cfg['user.name'] = 'BoB@place.net'
|
|
26
|
+
|
|
27
|
+
# Trickery: Copy tool.curl* settings from :env into :user.
|
|
28
|
+
$cfg['tool.curldebug'] = $cfg['tool.curldebug']
|
|
29
|
+
$cfg['tool.curlfile'] = $cfg['tool.curlfile']
|
|
30
|
+
# Unload the MURANO_CONFIGFILE :env scoped config, so
|
|
31
|
+
# its keys do not mess with our tests, e.g., to avoid
|
|
32
|
+
# using user.name from test runner's ~/.murano/config.
|
|
33
|
+
$cfg.unload(:env)
|
|
34
|
+
|
|
35
|
+
stub_request_email_password
|
|
25
36
|
|
|
26
37
|
$project = MrMurano::ProjectFile.new
|
|
27
38
|
$project.load
|
|
@@ -31,7 +42,6 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
|
31
42
|
|
|
32
43
|
after(:example) do
|
|
33
44
|
@acc.token_reset
|
|
34
|
-
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
|
35
45
|
end
|
|
36
46
|
|
|
37
47
|
context 'Get login info' do
|
|
@@ -43,33 +53,34 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
|
43
53
|
end
|
|
44
54
|
|
|
45
55
|
it 'Asks for nothing' do
|
|
56
|
+
@acc.credentials_reset
|
|
46
57
|
$cfg['user.name'] = 'bob'
|
|
47
58
|
expect(@pswd).to receive(:get).once.and_return('built')
|
|
48
|
-
expect(@pswd).to receive(:lookup).once.and_return(nil)
|
|
49
59
|
|
|
50
60
|
ret = @acc.login_info
|
|
51
61
|
expect(ret).to eq(email: 'bob', password: 'built')
|
|
52
62
|
end
|
|
53
63
|
|
|
54
64
|
it 'Asks for user name' do
|
|
65
|
+
@acc.credentials_reset
|
|
55
66
|
$cfg['user.name'] = nil
|
|
56
67
|
expect($terminal).to receive(:ask).once.and_return('bob')
|
|
57
68
|
expect(@acc).to receive(:error).once
|
|
58
69
|
expect($cfg).to receive(:set).with('user.name', 'bob', :user).once.and_call_original
|
|
59
70
|
expect(@pswd).to receive(:get).once.and_return('built')
|
|
60
|
-
expect(@pswd).to receive(:lookup).once.and_return(nil)
|
|
61
71
|
|
|
62
72
|
ret = @acc.login_info
|
|
63
73
|
expect(ret).to eq(email: 'bob', password: 'built')
|
|
64
74
|
end
|
|
65
75
|
|
|
66
76
|
it 'Asks for password' do
|
|
77
|
+
@acc.credentials_reset
|
|
67
78
|
$cfg['user.name'] = 'bob'
|
|
68
79
|
expect(@pswd).to receive(:get).with('bizapi.hosted.exosite.io', 'bob').once.and_return(nil)
|
|
69
80
|
expect(@acc).to receive(:error).once
|
|
70
81
|
expect($terminal).to receive(:ask).once.and_return('dog')
|
|
82
|
+
$cfg['auth.persist-basic'] = true
|
|
71
83
|
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob', 'dog')
|
|
72
|
-
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob/token', nil)
|
|
73
84
|
# 2017-07-31: login_info may exit unless the command okays prompting for the password.
|
|
74
85
|
# (If we don't set this, login_info exits, which we'd want to
|
|
75
86
|
# catch with
|
|
@@ -83,7 +94,10 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
|
83
94
|
|
|
84
95
|
context 'token' do
|
|
85
96
|
before(:example) do
|
|
97
|
+
@acc.credentials_reset
|
|
86
98
|
allow(@acc).to receive(:login_info).and_return(email: 'bob', password: 'v')
|
|
99
|
+
http_authed = MrMurano::HttpAuthed.instance
|
|
100
|
+
http_authed.instance_variable_set(:@login_info, email: 'bob', password: 'v')
|
|
87
101
|
end
|
|
88
102
|
|
|
89
103
|
it 'gets a token' do
|
|
@@ -100,28 +114,24 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
|
100
114
|
.with(body: { email: 'bob', password: 'v' }.to_json)
|
|
101
115
|
.to_return(status: 401, body: {}.to_json)
|
|
102
116
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
# running without a valid token and then fail unexpectedly later.)
|
|
109
|
-
#expect {
|
|
110
|
-
# @acc.token
|
|
111
|
-
#}.to raise_error(SystemExit).and output("\e[31mNot logged in!\e[0m\n").to_stderr
|
|
117
|
+
# Note that we stub out error and warning so nothing gets output.
|
|
118
|
+
expect(MrMurano::HttpAuthed.instance).to receive(:error).exactly(3).times.and_return(nil)
|
|
119
|
+
# The warning is about ENV['MURANO_PASSWORD'] specifying the password.
|
|
120
|
+
expect(MrMurano::HttpAuthed.instance).to receive(:warning).once.and_return(nil)
|
|
121
|
+
expect { @acc.token }.to raise_error(SystemExit).and output(//).to_stderr
|
|
112
122
|
end
|
|
113
123
|
|
|
114
124
|
it 'uses existing token' do
|
|
115
|
-
@acc.token_reset
|
|
125
|
+
@acc.token_reset('XXX')
|
|
116
126
|
ret = @acc.token
|
|
117
|
-
expect(ret).to eq('')
|
|
127
|
+
expect(ret).to eq('XXX')
|
|
118
128
|
end
|
|
119
129
|
|
|
120
130
|
it 'uses existing token, even with new instance' do
|
|
121
|
-
@acc.token_reset
|
|
131
|
+
@acc.token_reset('XXX')
|
|
122
132
|
acc = MrMurano::Account.new
|
|
123
133
|
ret = acc.token
|
|
124
|
-
expect(ret).to eq('')
|
|
134
|
+
expect(ret).to eq('XXX')
|
|
125
135
|
end
|
|
126
136
|
end
|
|
127
137
|
end
|
|
@@ -136,9 +146,11 @@ RSpec.describe MrMurano::Account do
|
|
|
136
146
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
137
147
|
$cfg['business.id'] = 'XYZxyz'
|
|
138
148
|
$cfg['product.id'] = 'XYZ'
|
|
149
|
+
$cfg['user.name'] = 'BoB@place.net'
|
|
150
|
+
stub_request_email_password
|
|
139
151
|
|
|
140
152
|
@acc = MrMurano::Account.new
|
|
141
|
-
|
|
153
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
142
154
|
end
|
|
143
155
|
after(:example) do
|
|
144
156
|
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
|
@@ -168,6 +180,7 @@ RSpec.describe MrMurano::Account do
|
|
|
168
180
|
buslist << MrMurano::Business.new(bizlist[1])
|
|
169
181
|
|
|
170
182
|
$cfg['user.name'] = 'BoB@place.net'
|
|
183
|
+
stub_request_email_password
|
|
171
184
|
ret = @acc.businesses
|
|
172
185
|
expect(ret).to eq(buslist)
|
|
173
186
|
end
|
|
@@ -192,6 +205,7 @@ RSpec.describe MrMurano::Account do
|
|
|
192
205
|
expect(@acc).to receive(:login_info) do |_arg|
|
|
193
206
|
$cfg['user.name'] = 'BoB@place.net'
|
|
194
207
|
end
|
|
208
|
+
stub_request_email_password
|
|
195
209
|
|
|
196
210
|
ret = @acc.businesses
|
|
197
211
|
expect(ret).to eq(buslist)
|
data/spec/Business_spec.rb
CHANGED
|
@@ -7,28 +7,28 @@
|
|
|
7
7
|
|
|
8
8
|
require 'highline/import'
|
|
9
9
|
require 'MrMurano/version'
|
|
10
|
-
require 'MrMurano/Config'
|
|
11
10
|
require 'MrMurano/Account'
|
|
11
|
+
require 'MrMurano/Config'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require '_workspace'
|
|
14
|
+
require 'HttpAuthed_spec'
|
|
13
15
|
|
|
14
16
|
MISSING_BIZ_ID_MSG = MrMurano::Business.missing_business_id_msg
|
|
15
17
|
|
|
16
18
|
RSpec.describe MrMurano::Business do
|
|
17
19
|
include_context 'WORKSPACE'
|
|
18
20
|
before(:example) do
|
|
19
|
-
@saved_cfg = ENV['MURANO_CONFIGFILE']
|
|
20
|
-
ENV['MURANO_CONFIGFILE'] = nil
|
|
21
21
|
$cfg = MrMurano::Config.new
|
|
22
22
|
$cfg.load
|
|
23
23
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
24
24
|
$cfg['business.id'] = 'XYZxyz'
|
|
25
25
|
$cfg['product.id'] = 'XYZ'
|
|
26
|
+
$cfg['user.name'] = 'BoB@place.net'
|
|
27
|
+
stub_request_email_password
|
|
26
28
|
|
|
27
29
|
@biz = MrMurano::Business.new
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
after(:example) do
|
|
31
|
-
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
|
30
|
+
|
|
31
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it 'lists products' do
|
|
@@ -223,8 +223,11 @@ RSpec.describe MrMurano::Business do
|
|
|
223
223
|
it 'creates solution' do
|
|
224
224
|
stub_request(
|
|
225
225
|
:post, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
|
|
226
|
-
).with(
|
|
227
|
-
|
|
226
|
+
).with(
|
|
227
|
+
body: { label: 'one', type: 'product' }
|
|
228
|
+
).to_return(
|
|
229
|
+
body: '{"id": "abc123def456ghi78", "name": "one"}'
|
|
230
|
+
)
|
|
228
231
|
|
|
229
232
|
sol = @biz.new_solution!('one', :product)
|
|
230
233
|
expect(sol.valid?).to be true
|
data/spec/Config_spec.rb
CHANGED
|
@@ -13,7 +13,7 @@ require 'MrMurano/Config'
|
|
|
13
13
|
require '_workspace'
|
|
14
14
|
|
|
15
15
|
RSpec.describe MrMurano::Config do
|
|
16
|
-
context 'Basics
|
|
16
|
+
context 'Basics' do
|
|
17
17
|
include_context 'WORKSPACE'
|
|
18
18
|
it 'Sets defaults' do
|
|
19
19
|
cfg = MrMurano::Config.new
|
|
@@ -247,11 +247,13 @@ RSpec.describe MrMurano::Config do
|
|
|
247
247
|
FileUtils.touch(@project_dir + '/.murano/config')
|
|
248
248
|
|
|
249
249
|
# Set ENV to override output of Dir.home
|
|
250
|
+
@saved_home = Dir.home
|
|
250
251
|
ENV['HOME'] = @tmpdir + '/home'
|
|
251
252
|
end
|
|
252
253
|
|
|
253
254
|
after(:example) do
|
|
254
255
|
FileUtils.remove_dir(@tmpdir + '/home', true) if FileTest.exist? @tmpdir
|
|
256
|
+
ENV['HOME'] = @saved_home
|
|
255
257
|
end
|
|
256
258
|
|
|
257
259
|
it 'when in project directory' do
|
|
@@ -299,11 +301,13 @@ RSpec.describe MrMurano::Config do
|
|
|
299
301
|
FileUtils.mkpath(@project_dir + '/.murano')
|
|
300
302
|
|
|
301
303
|
# Set ENV to override output of Dir.home
|
|
304
|
+
@saved_home = Dir.home
|
|
302
305
|
ENV['HOME'] = @tmpdir + '/home'
|
|
303
306
|
end
|
|
304
307
|
|
|
305
308
|
after(:example) do
|
|
306
309
|
FileUtils.remove_dir(@tmpdir + '/home', true) if FileTest.exist? @tmpdir
|
|
310
|
+
ENV['HOME'] = @saved_home
|
|
307
311
|
end
|
|
308
312
|
|
|
309
313
|
it 'when in project directory' do
|
|
@@ -347,11 +351,13 @@ RSpec.describe MrMurano::Config do
|
|
|
347
351
|
@project_dir = @tmpdir + '/home/work/project'
|
|
348
352
|
FileUtils.mkpath(@project_dir)
|
|
349
353
|
# Set ENV to override output of Dir.home
|
|
354
|
+
@saved_home = Dir.home
|
|
350
355
|
ENV['HOME'] = @tmpdir + '/home'
|
|
351
356
|
end
|
|
352
357
|
|
|
353
358
|
after(:example) do
|
|
354
359
|
FileUtils.remove_dir(@tmpdir + '/home', true) if FileTest.exist? @tmpdir
|
|
360
|
+
ENV['HOME'] = @saved_home
|
|
355
361
|
end
|
|
356
362
|
|
|
357
363
|
it 'Sets a user value' do
|
data/spec/Content_spec.rb
CHANGED
|
@@ -9,8 +9,10 @@ require 'fileutils'
|
|
|
9
9
|
require 'pathname'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
11
|
require 'MrMurano/Content'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require 'MrMurano/SyncRoot'
|
|
13
14
|
require '_workspace'
|
|
15
|
+
require 'HttpAuthed_spec'
|
|
14
16
|
|
|
15
17
|
# rubocop:disable Style/HashSyntax
|
|
16
18
|
# - 'Use the new Ruby 1.9 hash syntax.'
|
|
@@ -28,9 +30,11 @@ RSpec.describe MrMurano::Content::Base do
|
|
|
28
30
|
$cfg.load
|
|
29
31
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
30
32
|
$cfg['product.id'] = 'XYZ'
|
|
33
|
+
$cfg['tool.no-progress'] = true
|
|
34
|
+
stub_request_email_password
|
|
31
35
|
|
|
32
36
|
@ct = MrMurano::Content::Base.new
|
|
33
|
-
|
|
37
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
it 'initializes' do
|
|
@@ -237,7 +241,15 @@ RSpec.describe MrMurano::Content::Base do
|
|
|
237
241
|
).to_return(body: body.to_json)
|
|
238
242
|
|
|
239
243
|
$cfg['tool.dry'] = true
|
|
244
|
+
saved = $stdout
|
|
245
|
+
$stdout = StringIO.new
|
|
240
246
|
@ct.upload('Solutionfile.json', @tup.to_path)
|
|
247
|
+
expect($stdout.string.lines).to match_array(
|
|
248
|
+
[
|
|
249
|
+
"--dry: Not uploading item: ‘Solutionfile.json’\n",
|
|
250
|
+
]
|
|
251
|
+
)
|
|
252
|
+
$stdout = saved
|
|
241
253
|
end
|
|
242
254
|
|
|
243
255
|
it 'uploads with --curl' do
|
|
@@ -263,6 +275,7 @@ RSpec.describe MrMurano::Content::Base do
|
|
|
263
275
|
).with(
|
|
264
276
|
query: {
|
|
265
277
|
expires_in: 30,
|
|
278
|
+
# FIXME/2018-04-17: (lb): Still sha256? Or md5 now?
|
|
266
279
|
sha256: '018d1e072e1e9734cbc804c27121d00a2912fe14bcc11244e3fc20c5b72ab136',
|
|
267
280
|
type: 'application/json',
|
|
268
281
|
}
|
|
@@ -278,6 +291,7 @@ RSpec.describe MrMurano::Content::Base do
|
|
|
278
291
|
$stdout = StringIO.new
|
|
279
292
|
|
|
280
293
|
$cfg['tool.curldebug'] = true
|
|
294
|
+
$cfg['tool.curlfancy'] = false
|
|
281
295
|
$cfg.curlfile_f = nil
|
|
282
296
|
@ct.upload('Solutionfile.json', @tup.to_path)
|
|
283
297
|
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})
|
|
@@ -303,6 +317,7 @@ RSpec.describe MrMurano::Content::Base do
|
|
|
303
317
|
|
|
304
318
|
# This test does not work with curldebug enabled.
|
|
305
319
|
$cfg['tool.curldebug'] = false
|
|
320
|
+
$cfg['tool.curlfancy'] = false
|
|
306
321
|
$cfg.curlfile_f = nil
|
|
307
322
|
|
|
308
323
|
saved = $stdout
|
|
@@ -379,6 +394,7 @@ RSpec.describe MrMurano::Content::Base do
|
|
|
379
394
|
$stdout = StringIO.new
|
|
380
395
|
|
|
381
396
|
$cfg['tool.curldebug'] = true
|
|
397
|
+
$cfg['tool.curlfancy'] = false
|
|
382
398
|
$cfg.curlfile_f = nil
|
|
383
399
|
@ct.download('TODO.taskpaper')
|
|
384
400
|
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})
|
data/spec/GatewayBase_spec.rb
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
require 'fileutils'
|
|
9
9
|
require 'MrMurano/version'
|
|
10
|
-
require 'MrMurano/
|
|
10
|
+
require 'MrMurano/HttpAuthed'
|
|
11
11
|
require 'MrMurano/Gateway'
|
|
12
|
+
require 'MrMurano/SyncRoot'
|
|
12
13
|
require '_workspace'
|
|
14
|
+
require 'HttpAuthed_spec'
|
|
13
15
|
|
|
14
16
|
RSpec.describe MrMurano::Gateway::GweBase do
|
|
15
17
|
include_context 'WORKSPACE'
|
|
@@ -19,9 +21,10 @@ RSpec.describe MrMurano::Gateway::GweBase do
|
|
|
19
21
|
$cfg.load
|
|
20
22
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
21
23
|
$cfg['product.id'] = 'XYZ'
|
|
24
|
+
stub_request_email_password
|
|
22
25
|
|
|
23
26
|
@gw = MrMurano::Gateway::GweBase.new
|
|
24
|
-
|
|
27
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
it 'initializes' do
|
data/spec/GatewayDevice_spec.rb
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
require 'fileutils'
|
|
9
9
|
require 'MrMurano/version'
|
|
10
|
+
require 'MrMurano/HttpAuthed'
|
|
10
11
|
require 'MrMurano/Gateway'
|
|
11
12
|
require 'MrMurano/SyncRoot'
|
|
12
13
|
require '_workspace'
|
|
14
|
+
require 'HttpAuthed_spec'
|
|
13
15
|
|
|
14
16
|
RSpec.describe MrMurano::Gateway::Device do
|
|
15
17
|
include_context 'WORKSPACE'
|
|
@@ -19,6 +21,7 @@ RSpec.describe MrMurano::Gateway::Device do
|
|
|
19
21
|
$cfg.load
|
|
20
22
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
21
23
|
$cfg['product.id'] = 'XYZ'
|
|
24
|
+
stub_request_email_password
|
|
22
25
|
|
|
23
26
|
@gw = MrMurano::Gateway::Device.new
|
|
24
27
|
allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
|
|
@@ -225,10 +228,9 @@ RSpec.describe MrMurano::Gateway::Device do
|
|
|
225
228
|
|
|
226
229
|
context 'activates' do
|
|
227
230
|
before(:example) do
|
|
231
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
228
232
|
@bgw = MrMurano::Gateway::GweBase.new
|
|
229
|
-
allow(@bgw).to receive(:token).and_return('TTTTTTTTTT')
|
|
230
233
|
expect(MrMurano::Gateway::GweBase).to receive(:new).and_return(@bgw)
|
|
231
|
-
allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
|
|
232
234
|
stub_request(
|
|
233
235
|
:get,
|
|
234
236
|
'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2'
|
|
@@ -9,9 +9,11 @@ require 'fileutils'
|
|
|
9
9
|
require 'pathname'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
11
|
require 'MrMurano/Gateway'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require 'MrMurano/ProjectFile'
|
|
13
14
|
require 'MrMurano/SyncRoot'
|
|
14
15
|
require '_workspace'
|
|
16
|
+
require 'HttpAuthed_spec'
|
|
15
17
|
|
|
16
18
|
RSpec.describe MrMurano::Gateway::Resources do
|
|
17
19
|
include_context 'WORKSPACE'
|
|
@@ -23,9 +25,10 @@ RSpec.describe MrMurano::Gateway::Resources do
|
|
|
23
25
|
$cfg['product.id'] = 'XYZ'
|
|
24
26
|
$project = MrMurano::ProjectFile.new
|
|
25
27
|
$project.load
|
|
28
|
+
stub_request_email_password
|
|
26
29
|
|
|
27
30
|
@gw = MrMurano::Gateway::Resources.new
|
|
28
|
-
|
|
31
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
it 'initializes' do
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
require 'fileutils'
|
|
9
9
|
require 'MrMurano/version'
|
|
10
|
+
require 'MrMurano/HttpAuthed'
|
|
10
11
|
require 'MrMurano/Gateway'
|
|
11
12
|
require 'MrMurano/SyncRoot'
|
|
12
13
|
require '_workspace'
|
|
14
|
+
require 'HttpAuthed_spec'
|
|
13
15
|
|
|
14
16
|
RSpec.describe MrMurano::Gateway::Settings do
|
|
15
17
|
include_context 'WORKSPACE'
|
|
@@ -19,9 +21,10 @@ RSpec.describe MrMurano::Gateway::Settings do
|
|
|
19
21
|
$cfg.load
|
|
20
22
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
21
23
|
$cfg['product.id'] = 'XYZ'
|
|
24
|
+
stub_request_email_password
|
|
22
25
|
|
|
23
26
|
@gw = MrMurano::Gateway::Settings.new
|
|
24
|
-
|
|
27
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
25
28
|
|
|
26
29
|
@infoblob = {
|
|
27
30
|
name: 'XXXXXXXX',
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Copyright © 2016-2017 Exosite LLC. All Rights Reserved
|
|
2
|
+
# License: PROPRIETARY. See LICENSE.txt.
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
|
|
5
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
|
6
|
+
# Unauthorized copying of this file is strictly prohibited.
|
|
7
|
+
|
|
8
|
+
require 'MrMurano/HttpAuthed'
|
|
9
|
+
|
|
10
|
+
# (lb): Not sure why, but getting "method redefined" errors, so need
|
|
11
|
+
# defined? guard clauses around method definitions. Otherwise, e.g.,:
|
|
12
|
+
# MuranoCLI/spec/HttpAuthed_spec.rb:10: warning: method redefined;
|
|
13
|
+
# discarding old stub_request_email_password_from_cfg
|
|
14
|
+
# MuranoCLI/spec/HttpAuthed_spec.rb:10: warning: previous definition of
|
|
15
|
+
# stub_request_email_password_from_cfg was here
|
|
16
|
+
|
|
17
|
+
unless defined? stub_request_email_password_from_cfg
|
|
18
|
+
def stub_request_email_password_from_cfg
|
|
19
|
+
stub_request(
|
|
20
|
+
:post,
|
|
21
|
+
"#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/token/"
|
|
22
|
+
).with(
|
|
23
|
+
body: {
|
|
24
|
+
email: $cfg['user.name'],
|
|
25
|
+
password: MrMurano::HttpAuthed.instance.password,
|
|
26
|
+
}.to_json
|
|
27
|
+
).to_return(
|
|
28
|
+
status: 200,
|
|
29
|
+
body: { token: 'TTTTTTTTTT' }.to_json,
|
|
30
|
+
headers: {}
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
unless defined? stub_request_email_password_from_bob
|
|
36
|
+
def stub_request_email_password_from_bob
|
|
37
|
+
stub_request(
|
|
38
|
+
:post,
|
|
39
|
+
"#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/token/"
|
|
40
|
+
).with(
|
|
41
|
+
body: {
|
|
42
|
+
email: 'bob',
|
|
43
|
+
password: 'v',
|
|
44
|
+
}.to_json
|
|
45
|
+
).to_return(
|
|
46
|
+
status: 200,
|
|
47
|
+
body: { token: 'TTTTTTTTTT' }.to_json,
|
|
48
|
+
headers: {}
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
unless defined? stub_request_token_verification
|
|
54
|
+
def stub_request_token_verification
|
|
55
|
+
stub_request(
|
|
56
|
+
:get,
|
|
57
|
+
"#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/token/TTTTTTTTTT"
|
|
58
|
+
).to_return(
|
|
59
|
+
status: 200,
|
|
60
|
+
body: {}.to_json,
|
|
61
|
+
headers: {}
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
unless defined? stub_request_email_password
|
|
67
|
+
def stub_request_email_password
|
|
68
|
+
stub_request_email_password_from_cfg
|
|
69
|
+
stub_request_email_password_from_bob
|
|
70
|
+
stub_request_token_verification
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|