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/spec/Http_spec.rb
CHANGED
|
@@ -9,53 +9,44 @@ require 'MrMurano/version'
|
|
|
9
9
|
require 'MrMurano/http'
|
|
10
10
|
require 'MrMurano/verbosing'
|
|
11
11
|
require 'MrMurano/Account'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require '_workspace'
|
|
13
14
|
|
|
14
|
-
class Tst
|
|
15
|
-
include MrMurano::Verbose
|
|
16
|
-
include MrMurano::Http
|
|
17
|
-
|
|
18
|
-
def initialize
|
|
19
|
-
@token = nil
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
15
|
RSpec.describe MrMurano::Http do
|
|
24
16
|
include_context 'WORKSPACE'
|
|
25
17
|
|
|
26
18
|
before(:example) do
|
|
27
19
|
$cfg = MrMurano::Config.new
|
|
28
20
|
$cfg.load
|
|
29
|
-
@
|
|
21
|
+
@hauth = MrMurano::HttpAuthed.instance
|
|
30
22
|
end
|
|
31
23
|
|
|
32
24
|
context 'gets a token' do
|
|
33
25
|
before(:example) do
|
|
34
26
|
@acc = instance_double('MrMurano::Account')
|
|
35
|
-
|
|
36
|
-
allow(MrMurano::Account).to receive(:instance).and_return(@acc)
|
|
27
|
+
allow(MrMurano::Account).to receive(:new).and_return(@acc)
|
|
37
28
|
end
|
|
38
29
|
|
|
39
30
|
it 'already has one' do
|
|
40
|
-
@
|
|
41
|
-
ret = @
|
|
31
|
+
@hauth.instance_variable_set(:@token_biz, 'ABCDEFG')
|
|
32
|
+
ret = @hauth.token
|
|
42
33
|
expect(ret).to eq('ABCDEFG')
|
|
43
34
|
end
|
|
44
35
|
|
|
45
36
|
it 'gets one' do
|
|
46
|
-
expect(@
|
|
47
|
-
ret = @
|
|
37
|
+
expect(@hauth).to receive(:token).and_return('ABCDEFG')
|
|
38
|
+
ret = @hauth.token
|
|
48
39
|
expect(ret).to eq('ABCDEFG')
|
|
49
40
|
end
|
|
50
41
|
|
|
51
42
|
it 'raises when not logged in' do
|
|
52
|
-
expect(@
|
|
43
|
+
expect(@hauth).to receive(:token).and_return(nil)
|
|
53
44
|
# 2017-07-13: The token command used to raise an error, but [lb]
|
|
54
45
|
# doesn't like seeing the "use --trace" message that Ruby spits
|
|
55
46
|
# out. So write to stderr and exit instead. Here, use check that
|
|
56
47
|
# the function exits by expecting it to raise SystemExit.
|
|
57
48
|
expect do
|
|
58
|
-
@
|
|
49
|
+
@hauth.ensure_token!
|
|
59
50
|
end.to raise_error(SystemExit).and output("\e[31mNot logged in!\e[0m\n").to_stderr
|
|
60
51
|
end
|
|
61
52
|
end
|
|
@@ -69,7 +60,7 @@ RSpec.describe MrMurano::Http do
|
|
|
69
60
|
it 'puts nothing' do
|
|
70
61
|
$cfg['tool.curldebug'] = false
|
|
71
62
|
$stdout = StringIO.new
|
|
72
|
-
@
|
|
63
|
+
@hauth.curldebug(@req)
|
|
73
64
|
expect($stdout.string).to eq('')
|
|
74
65
|
end
|
|
75
66
|
|
|
@@ -77,7 +68,7 @@ RSpec.describe MrMurano::Http do
|
|
|
77
68
|
$cfg['tool.curldebug'] = true
|
|
78
69
|
$cfg.curlfile_f = nil
|
|
79
70
|
$stdout = StringIO.new
|
|
80
|
-
@
|
|
71
|
+
@hauth.curldebug(@req)
|
|
81
72
|
expect($stdout.string).to eq(
|
|
82
73
|
%(curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n)
|
|
83
74
|
)
|
|
@@ -88,7 +79,7 @@ RSpec.describe MrMurano::Http do
|
|
|
88
79
|
$cfg.curlfile_f = nil
|
|
89
80
|
$stdout = StringIO.new
|
|
90
81
|
@req['Authorization'] = 'LetMeIn'
|
|
91
|
-
@
|
|
82
|
+
@hauth.curldebug(@req)
|
|
92
83
|
expect($stdout.string).to eq(
|
|
93
84
|
%(curl -s -H 'Authorization: LetMeIn' -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n)
|
|
94
85
|
)
|
|
@@ -99,7 +90,7 @@ RSpec.describe MrMurano::Http do
|
|
|
99
90
|
$cfg.curlfile_f = nil
|
|
100
91
|
$stdout = StringIO.new
|
|
101
92
|
@req.body = 'builder'
|
|
102
|
-
@
|
|
93
|
+
@hauth.curldebug(@req)
|
|
103
94
|
expect($stdout.string).to eq(
|
|
104
95
|
%(curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test' -d 'builder'\n)
|
|
105
96
|
)
|
|
@@ -108,13 +99,13 @@ RSpec.describe MrMurano::Http do
|
|
|
108
99
|
|
|
109
100
|
context 'checks if JSON' do
|
|
110
101
|
it 'is JSON' do
|
|
111
|
-
ok, data = @
|
|
102
|
+
ok, data = @hauth.isJSON(%({"one": "two", "three":[1,2,3,4,5,6]}))
|
|
112
103
|
expect(ok).to be true
|
|
113
104
|
expect(data).to eq(one: 'two',
|
|
114
105
|
three: [1, 2, 3, 4, 5, 6])
|
|
115
106
|
end
|
|
116
107
|
it 'is not JSON' do
|
|
117
|
-
ok, data = @
|
|
108
|
+
ok, data = @hauth.isJSON(%(woeiutepoxam))
|
|
118
109
|
expect(ok).to be false
|
|
119
110
|
expect(data).to eq('woeiutepoxam')
|
|
120
111
|
end
|
|
@@ -134,9 +125,9 @@ RSpec.describe MrMurano::Http do
|
|
|
134
125
|
$stderr = StringIO.new
|
|
135
126
|
|
|
136
127
|
allow(@rsp).to receive(:body).and_return('ok')
|
|
137
|
-
expect(@
|
|
128
|
+
expect(@hauth).to receive(:error).once.with('Request Failed: 410: ok')
|
|
138
129
|
|
|
139
|
-
@
|
|
130
|
+
@hauth.showHttpError(@req, @rsp)
|
|
140
131
|
expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
|
|
141
132
|
> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
142
133
|
> Accept: */*
|
|
@@ -155,9 +146,9 @@ RSpec.describe MrMurano::Http do
|
|
|
155
146
|
|
|
156
147
|
allow(@req).to receive(:body).and_return('this is my body')
|
|
157
148
|
allow(@rsp).to receive(:body).and_return('ok')
|
|
158
|
-
expect(@
|
|
149
|
+
expect(@hauth).to receive(:error).once.with('Request Failed: 410: ok')
|
|
159
150
|
|
|
160
|
-
@
|
|
151
|
+
@hauth.showHttpError(@req, @rsp)
|
|
161
152
|
expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
|
|
162
153
|
> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
163
154
|
> Accept: */*
|
|
@@ -176,9 +167,9 @@ RSpec.describe MrMurano::Http do
|
|
|
176
167
|
$stderr = StringIO.new
|
|
177
168
|
|
|
178
169
|
allow(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "ok"}))
|
|
179
|
-
expect(@
|
|
170
|
+
expect(@hauth).to receive(:error).once.with('Request Failed: 410: [123] ok')
|
|
180
171
|
|
|
181
|
-
@
|
|
172
|
+
@hauth.showHttpError(@req, @rsp)
|
|
182
173
|
expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
|
|
183
174
|
> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
184
175
|
> Accept: */*
|
|
@@ -196,11 +187,11 @@ RSpec.describe MrMurano::Http do
|
|
|
196
187
|
$stderr = StringIO.new
|
|
197
188
|
|
|
198
189
|
allow(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "ok"}))
|
|
199
|
-
expect(@
|
|
190
|
+
expect(@hauth).to receive(:error).once.with(
|
|
200
191
|
"Request Failed: 410: {\n \"statusCode\": 123,\n \"message\": \"ok\"\n}"
|
|
201
192
|
)
|
|
202
193
|
|
|
203
|
-
@
|
|
194
|
+
@hauth.showHttpError(@req, @rsp)
|
|
204
195
|
expect($stdout.string).to eq('')
|
|
205
196
|
expect($stderr.string).to eq('')
|
|
206
197
|
end
|
|
@@ -211,10 +202,16 @@ RSpec.describe MrMurano::Http do
|
|
|
211
202
|
|
|
212
203
|
idhttp = instance_double('Net::HTTP')
|
|
213
204
|
expect(idhttp).to receive(:request).once.and_return(@rsp)
|
|
214
|
-
expect(@
|
|
215
|
-
|
|
205
|
+
expect(@hauth).to receive(:http).once.and_return(idhttp)
|
|
206
|
+
|
|
207
|
+
# To test this:
|
|
208
|
+
# $cfg['tool.curldebug'] = false
|
|
209
|
+
times = $cfg['tool.curldebug'] && 2 || 1
|
|
210
|
+
expect(@rsp).to receive(:body).exactly(times).times.and_return(
|
|
211
|
+
(%({"statusCode": 123, "message": "gone"}))
|
|
212
|
+
)
|
|
216
213
|
|
|
217
|
-
@
|
|
214
|
+
@hauth.workit(@req)
|
|
218
215
|
expect($stdout.string).to eq('')
|
|
219
216
|
expect($stderr.string).to eq("\e[31mRequest Failed: 410: [123] gone\e[0m\n")
|
|
220
217
|
end
|
data/spec/ProjectFile_spec.rb
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
require 'tempfile'
|
|
9
9
|
require 'MrMurano/version'
|
|
10
|
+
require 'MrMurano/HttpAuthed'
|
|
10
11
|
require 'MrMurano/ProjectFile'
|
|
11
12
|
require 'MrMurano/Solution-ServiceConfig'
|
|
12
13
|
require 'MrMurano/SyncRoot'
|
|
13
14
|
require '_workspace'
|
|
15
|
+
require 'HttpAuthed_spec'
|
|
14
16
|
|
|
15
17
|
RSpec.describe MrMurano::ServiceConfig do
|
|
16
18
|
include_context 'WORKSPACE'
|
|
@@ -24,11 +26,12 @@ RSpec.describe MrMurano::ServiceConfig do
|
|
|
24
26
|
# serviceconfig works on all solution types.
|
|
25
27
|
$cfg['product.id'] = 'XYZ'
|
|
26
28
|
$cfg['application.id'] = 'XYZ'
|
|
29
|
+
stub_request_email_password
|
|
27
30
|
|
|
28
31
|
# ServiceConfig needs an api_id, else one could instantiate
|
|
29
32
|
# ServiceConfigApplication or ServiceConfigProduct.
|
|
30
33
|
@srv = MrMurano::ServiceConfig.new('XYZ')
|
|
31
|
-
|
|
34
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
it 'initializes' do
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
require 'pathname'
|
|
9
9
|
require 'tempfile'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
|
+
require 'MrMurano/HttpAuthed'
|
|
11
12
|
require 'MrMurano/ProjectFile'
|
|
12
13
|
require 'MrMurano/Solution-Services'
|
|
13
14
|
require '_workspace'
|
|
15
|
+
require 'HttpAuthed_spec'
|
|
14
16
|
|
|
15
17
|
RSpec.describe MrMurano::EventHandler do
|
|
16
18
|
include_context 'WORKSPACE'
|
|
@@ -21,6 +23,7 @@ RSpec.describe MrMurano::EventHandler do
|
|
|
21
23
|
$project.load
|
|
22
24
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
# 2017-06-23: EventHandler is an intermediate class now, and we
|
|
26
29
|
# cannot use it because its @project_section is not defined.
|
|
@@ -29,7 +32,7 @@ RSpec.describe MrMurano::EventHandler do
|
|
|
29
32
|
# the only different is if it uses application.id or product.id.
|
|
30
33
|
@srv = MrMurano::EventHandlerSolnApp.new
|
|
31
34
|
#@srv = MrMurano::EventHandlerSolnPrd.new
|
|
32
|
-
|
|
35
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
it 'initializes' do
|
|
@@ -346,7 +349,7 @@ end
|
|
|
346
349
|
event: 'datapoint',
|
|
347
350
|
svc_alias: nil,
|
|
348
351
|
type: nil,
|
|
349
|
-
|
|
352
|
+
line_beg: 0,
|
|
350
353
|
line_end: 3,
|
|
351
354
|
local_path: Pathname.new(tio.path),
|
|
352
355
|
script: %(--#EVENT device datapoint\n-- do something.\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n)
|
|
@@ -383,7 +386,7 @@ end
|
|
|
383
386
|
event: 'datapoint',
|
|
384
387
|
svc_alias: nil,
|
|
385
388
|
type: nil,
|
|
386
|
-
|
|
389
|
+
line_beg: 1,
|
|
387
390
|
line_end: 3,
|
|
388
391
|
local_path: Pathname.new(tio.path),
|
|
389
392
|
script: %(--#EVENT device datapoint\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n),
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
require 'pathname'
|
|
9
9
|
require 'tempfile'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
|
+
require 'MrMurano/HttpAuthed'
|
|
11
12
|
require 'MrMurano/ProjectFile'
|
|
12
13
|
require 'MrMurano/Solution-Services'
|
|
13
14
|
require '_workspace'
|
|
15
|
+
require 'HttpAuthed_spec'
|
|
14
16
|
|
|
15
17
|
RSpec.describe MrMurano::Module do
|
|
16
18
|
include_context 'WORKSPACE'
|
|
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Module do
|
|
|
21
23
|
$project.load
|
|
22
24
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
@srv = MrMurano::Module.new
|
|
26
|
-
|
|
29
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
it 'initializes' do
|
|
@@ -9,9 +9,11 @@ require 'pathname'
|
|
|
9
9
|
require 'tempfile'
|
|
10
10
|
require 'MrMurano/hash'
|
|
11
11
|
require 'MrMurano/version'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require 'MrMurano/Solution-Users'
|
|
13
14
|
require 'MrMurano/SyncRoot'
|
|
14
15
|
require '_workspace'
|
|
16
|
+
require 'HttpAuthed_spec'
|
|
15
17
|
|
|
16
18
|
RSpec.describe MrMurano::Role do
|
|
17
19
|
include_context 'WORKSPACE'
|
|
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Role do
|
|
|
21
23
|
$cfg.load
|
|
22
24
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
@srv = MrMurano::Role.new
|
|
26
|
-
|
|
29
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
it 'initializes' do
|
data/spec/Solution_spec.rb
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
require 'tempfile'
|
|
9
9
|
require 'yaml'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
|
+
require 'MrMurano/HttpAuthed'
|
|
11
12
|
require 'MrMurano/ProjectFile'
|
|
12
13
|
require 'MrMurano/Solution'
|
|
13
14
|
require 'MrMurano/SyncRoot'
|
|
14
15
|
require '_workspace'
|
|
16
|
+
require 'HttpAuthed_spec'
|
|
15
17
|
|
|
16
18
|
RSpec.describe MrMurano::Solution do
|
|
17
19
|
include_context 'WORKSPACE'
|
|
@@ -24,13 +26,14 @@ RSpec.describe MrMurano::Solution do
|
|
|
24
26
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
25
27
|
$cfg['product.id'] = 'XYZ'
|
|
26
28
|
$cfg['application.id'] = 'XYZ'
|
|
29
|
+
stub_request_email_password
|
|
27
30
|
|
|
28
31
|
# NOTE: This test works on either Product or Application.
|
|
29
32
|
# MAYBE: Add Application to this test.
|
|
30
33
|
@srv = MrMurano::Product.new
|
|
31
34
|
#@srv = MrMurano::Application.new
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
it 'initializes' do
|
data/spec/SyncUpDown_spec.rb
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
require 'tempfile'
|
|
9
9
|
require 'yaml'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
|
+
require 'MrMurano/HttpAuthed'
|
|
11
12
|
require 'MrMurano/ProjectFile'
|
|
12
13
|
require 'MrMurano/SyncRoot'
|
|
13
14
|
require 'MrMurano/Webservice-Cors'
|
|
14
15
|
require '_workspace'
|
|
16
|
+
require 'HttpAuthed_spec'
|
|
15
17
|
|
|
16
18
|
RSpec.describe MrMurano::Webservice::Cors do
|
|
17
19
|
include_context 'WORKSPACE'
|
|
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Webservice::Cors do
|
|
|
21
23
|
$cfg.load
|
|
22
24
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
@srv = MrMurano::Webservice::Cors.new
|
|
26
|
-
|
|
29
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
27
30
|
|
|
28
31
|
@base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors'
|
|
29
32
|
end
|
|
@@ -9,8 +9,10 @@ require 'pathname'
|
|
|
9
9
|
require 'tempfile'
|
|
10
10
|
require '_workspace'
|
|
11
11
|
require 'MrMurano/version'
|
|
12
|
+
require 'MrMurano/HttpAuthed'
|
|
12
13
|
require 'MrMurano/ProjectFile'
|
|
13
14
|
require 'MrMurano/Webservice-Endpoint'
|
|
15
|
+
require 'HttpAuthed_spec'
|
|
14
16
|
|
|
15
17
|
RSpec.describe MrMurano::Webservice::Endpoint do
|
|
16
18
|
include_context 'WORKSPACE'
|
|
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
|
21
23
|
$project.load
|
|
22
24
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
@srv = MrMurano::Webservice::Endpoint.new
|
|
26
|
-
|
|
29
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
27
30
|
|
|
28
31
|
@base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/endpoint'
|
|
29
32
|
end
|
|
@@ -483,7 +486,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
|
483
486
|
path: '/one/two',
|
|
484
487
|
content_type: 'application/json',
|
|
485
488
|
local_path: Pathname.new(tio.path),
|
|
486
|
-
|
|
489
|
+
line_beg: 0,
|
|
487
490
|
script: "--#ENDPOINT GET /one/two\nreturn request\n",
|
|
488
491
|
line_end: 2,
|
|
489
492
|
}
|
|
@@ -512,7 +515,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
|
512
515
|
path: '/one/two',
|
|
513
516
|
content_type: 'application/json',
|
|
514
517
|
local_path: Pathname.new(tio.path),
|
|
515
|
-
|
|
518
|
+
line_beg: 0,
|
|
516
519
|
script: "--#ENDPOINT GET /one/two\nreturn request\n",
|
|
517
520
|
line_end: 2,
|
|
518
521
|
},
|
|
@@ -521,7 +524,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
|
521
524
|
path: '/one/two',
|
|
522
525
|
content_type: 'application/json',
|
|
523
526
|
local_path: Pathname.new(tio.path),
|
|
524
|
-
|
|
527
|
+
line_beg: 2,
|
|
525
528
|
script: "--#ENDPOINT PUT /one/two\nreturn request\n",
|
|
526
529
|
line_end: 4,
|
|
527
530
|
},
|
|
@@ -530,7 +533,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
|
530
533
|
path: '/three/two',
|
|
531
534
|
content_type: 'application/json',
|
|
532
535
|
local_path: Pathname.new(tio.path),
|
|
533
|
-
|
|
536
|
+
line_beg: 4,
|
|
534
537
|
script: "--#ENDPOINT DELETE /three/two\nreturn request\n",
|
|
535
538
|
line_end: 6,
|
|
536
539
|
},
|
|
@@ -568,7 +571,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
|
568
571
|
path: '/one/two',
|
|
569
572
|
content_type: 'application/json',
|
|
570
573
|
local_path: Pathname.new(tio.path),
|
|
571
|
-
|
|
574
|
+
line_beg: 1,
|
|
572
575
|
script: "--#ENDPOINT GET /one/two\nreturn request\n",
|
|
573
576
|
line_end: 3,
|
|
574
577
|
}
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
require 'pathname'
|
|
9
9
|
require 'MrMurano/version'
|
|
10
|
+
require 'MrMurano/HttpAuthed'
|
|
10
11
|
require 'MrMurano/ProjectFile'
|
|
11
12
|
require 'MrMurano/Webservice-File'
|
|
12
13
|
require '_workspace'
|
|
14
|
+
require 'HttpAuthed_spec'
|
|
13
15
|
|
|
14
16
|
RSpec.describe MrMurano::Webservice::File do
|
|
15
17
|
include_context 'WORKSPACE'
|
|
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Webservice::File do
|
|
|
21
23
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
22
24
|
$cfg['product.id'] = 'XYZ'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
@srv = MrMurano::Webservice::File.new
|
|
26
|
-
|
|
29
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
27
30
|
|
|
28
31
|
@base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/file'
|
|
29
32
|
@fileupload_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/fileupload'
|
|
@@ -104,6 +107,8 @@ RSpec.describe MrMurano::Webservice::File do
|
|
|
104
107
|
}
|
|
105
108
|
)
|
|
106
109
|
.to_return(status: 200, body: 'nope')
|
|
110
|
+
# The progress bar clears itself, e.g., spaces to cover old message, than \r.
|
|
111
|
+
$cfg['tool.no-progress'] = true
|
|
107
112
|
saved = $stdout
|
|
108
113
|
$stdout = StringIO.new
|
|
109
114
|
ret = @srv.fetch('/bob')
|
|
@@ -172,13 +177,17 @@ RSpec.describe MrMurano::Webservice::File do
|
|
|
172
177
|
'Content-Type' => %r{multipart/form-data; boundary=.*},
|
|
173
178
|
},
|
|
174
179
|
)
|
|
180
|
+
$cfg['tool.no-progress'] = true
|
|
175
181
|
$cfg['tool.curldebug'] = true
|
|
182
|
+
$cfg['tool.curlfancy'] = false
|
|
176
183
|
$cfg.curlfile_f = nil
|
|
177
184
|
saved = $stdout
|
|
178
185
|
$stdout = StringIO.new
|
|
179
186
|
@srv.upload(@lp, { path: '/one.text' }, false)
|
|
180
|
-
expect($stdout.string).to
|
|
181
|
-
|
|
187
|
+
expect($stdout.string.lines).to match_array(
|
|
188
|
+
[
|
|
189
|
+
%r{^curl -s -H 'Authorization: token TTTTTTTTTT'.*-X PUT '#{@fileupload_uri}/one.text' -F file=@.*$},
|
|
190
|
+
]
|
|
182
191
|
)
|
|
183
192
|
$stdout = saved
|
|
184
193
|
end
|
|
@@ -255,7 +264,11 @@ RSpec.describe MrMurano::Webservice::File do
|
|
|
255
264
|
expect(ret).to eq(
|
|
256
265
|
path: '/files/one.text',
|
|
257
266
|
mime_type: 'text/plain',
|
|
258
|
-
|
|
267
|
+
# 2018-04-16: Did backend change from SHA1 to MD5 hash function?
|
|
268
|
+
# You can calculate this with `sha1sum one.text`
|
|
269
|
+
#checksum: 'd1af3dadf08479a1d43b282f95d61dda8efda5e7'
|
|
270
|
+
# You can calculate this with `md5sum one.text`
|
|
271
|
+
checksum: 'e9ea4a5be73a09f541ad0b611083f0df'
|
|
259
272
|
)
|
|
260
273
|
end
|
|
261
274
|
end
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
require 'tempfile'
|
|
9
9
|
require 'yaml'
|
|
10
10
|
require 'MrMurano/version'
|
|
11
|
+
require 'MrMurano/HttpAuthed'
|
|
11
12
|
require 'MrMurano/ProjectFile'
|
|
12
13
|
require 'MrMurano/SyncRoot'
|
|
13
14
|
require 'MrMurano/Webservice-Cors'
|
|
14
15
|
require '_workspace'
|
|
16
|
+
require 'HttpAuthed_spec'
|
|
15
17
|
|
|
16
18
|
RSpec.describe MrMurano::Webservice::Settings do
|
|
17
19
|
include_context 'WORKSPACE'
|
|
@@ -21,11 +23,13 @@ RSpec.describe MrMurano::Webservice::Settings do
|
|
|
21
23
|
$cfg.load
|
|
22
24
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
|
23
25
|
$cfg['application.id'] = 'XYZ'
|
|
26
|
+
stub_request_email_password
|
|
24
27
|
|
|
25
28
|
@srv = MrMurano::Webservice::Settings.new
|
|
26
|
-
allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
|
31
|
+
|
|
32
|
+
@base_uri = "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/XYZ/cors"
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
it 'initializes' do
|
data/spec/_workspace.rb
CHANGED
|
@@ -12,6 +12,7 @@ require 'tmpdir'
|
|
|
12
12
|
RSpec.shared_context 'WORKSPACE' do
|
|
13
13
|
around(:example) do |ex|
|
|
14
14
|
@testdir = Pathname.new(Dir.pwd).realpath
|
|
15
|
+
$exited_abnormally = true
|
|
15
16
|
Dir.mktmpdir do |hdir|
|
|
16
17
|
@tmpdir = hdir
|
|
17
18
|
saved_home = ENV['HOME']
|
|
@@ -27,6 +28,7 @@ RSpec.shared_context 'WORKSPACE' do
|
|
|
27
28
|
end
|
|
28
29
|
ENV['HOME'] = saved_home
|
|
29
30
|
end
|
|
31
|
+
$exited_abnormally = false
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|