MuranoCLI 3.0.2 → 3.0.4
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 +30 -59
- data/Gemfile +9 -3
- data/MuranoCLI.gemspec +11 -4
- data/bin/murano +2 -90
- data/lib/MrMurano.rb +5 -1
- data/lib/MrMurano/{spec_commander.rb → Commander-Entry.rb} +1 -2
- data/lib/MrMurano/Solution.rb +12 -15
- data/lib/MrMurano/SolutionId.rb +1 -5
- data/lib/MrMurano/SyncAllowed.rb +2 -2
- data/lib/MrMurano/SyncUpDown.rb +6 -3
- data/lib/MrMurano/progress.rb +11 -2
- data/lib/MrMurano/verbosing.rb +3 -2
- data/lib/MrMurano/version.rb +2 -2
- data/spec/Account-Passwords_spec.rb +34 -48
- data/spec/Account_spec.rb +58 -63
- data/spec/Business_spec.rb +151 -139
- data/spec/ConfigFile_spec.rb +15 -11
- data/spec/ConfigMigrate_spec.rb +23 -12
- data/spec/Config_spec.rb +57 -54
- data/spec/Content_spec.rb +233 -201
- data/spec/GatewayBase_spec.rb +35 -27
- data/spec/GatewayDevice_spec.rb +149 -149
- data/spec/GatewayResource_spec.rb +115 -102
- data/spec/GatewaySettings_spec.rb +69 -62
- data/spec/Http_spec.rb +66 -56
- data/spec/MakePretties_spec.rb +82 -73
- data/spec/Mock_spec.rb +38 -29
- data/spec/ProjectFile_spec.rb +118 -106
- data/spec/Setting_spec.rb +24 -15
- data/spec/Solution-ServiceConfig_spec.rb +168 -140
- data/spec/Solution-ServiceEventHandler_spec.rb +186 -188
- data/spec/Solution-ServiceModules_spec.rb +314 -232
- data/spec/Solution-UsersRoles_spec.rb +136 -86
- data/spec/Solution_spec.rb +78 -50
- data/spec/SyncRoot_spec.rb +26 -24
- data/spec/SyncUpDown_spec.rb +268 -249
- data/spec/Verbosing_spec.rb +95 -93
- data/spec/Webservice-Cors_spec.rb +141 -95
- data/spec/Webservice-Endpoint_spec.rb +382 -346
- data/spec/Webservice-File_spec.rb +148 -109
- data/spec/Webservice-Setting_spec.rb +47 -41
- data/spec/cmd_business_spec.rb +17 -17
- data/spec/cmd_common.rb +27 -7
- data/spec/cmd_config_spec.rb +31 -20
- data/spec/cmd_content_spec.rb +80 -68
- data/spec/cmd_cors_spec.rb +11 -5
- data/spec/cmd_device_spec.rb +16 -14
- data/spec/cmd_domain_spec.rb +10 -8
- data/spec/cmd_exchange_spec.rb +3 -3
- data/spec/cmd_init_spec.rb +100 -101
- data/spec/cmd_keystore_spec.rb +17 -12
- data/spec/cmd_link_spec.rb +22 -37
- data/spec/cmd_password_spec.rb +11 -7
- data/spec/cmd_setting_application_spec.rb +47 -33
- data/spec/cmd_setting_product_spec.rb +32 -27
- data/spec/cmd_status_spec.rb +125 -114
- data/spec/cmd_syncdown_spec.rb +70 -65
- data/spec/cmd_syncup_spec.rb +19 -15
- data/spec/cmd_usage_spec.rb +14 -10
- metadata +29 -15
data/spec/Verbosing_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Last Modified: 2017.07.03 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
# frozen_string_literal: probably not yet
|
3
5
|
|
4
6
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -19,7 +21,7 @@ class VTst
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
RSpec.describe MrMurano::Verbose do
|
22
|
-
include_context
|
24
|
+
include_context 'WORKSPACE'
|
23
25
|
|
24
26
|
before(:example) do
|
25
27
|
$cfg = MrMurano::Config.new
|
@@ -27,53 +29,53 @@ RSpec.describe MrMurano::Verbose do
|
|
27
29
|
@tst = VTst.new
|
28
30
|
end
|
29
31
|
|
30
|
-
it
|
32
|
+
it 'verboses' do
|
31
33
|
$cfg['tool.verbose'] = true
|
32
34
|
expect($terminal).to receive(:say).with('hello').once
|
33
|
-
@tst.verbose
|
35
|
+
@tst.verbose 'hello'
|
34
36
|
end
|
35
37
|
|
36
|
-
it
|
38
|
+
it 'is quiet' do
|
37
39
|
expect($terminal).to_not receive(:say)
|
38
|
-
@tst.verbose
|
40
|
+
@tst.verbose 'hello'
|
39
41
|
end
|
40
42
|
|
41
|
-
it
|
43
|
+
it 'debugs' do
|
42
44
|
$cfg['tool.debug'] = true
|
43
45
|
expect($terminal).to receive(:say).with('hello').once
|
44
|
-
@tst.debug
|
46
|
+
@tst.debug 'hello'
|
45
47
|
end
|
46
48
|
|
47
|
-
it
|
49
|
+
it 'warns' do
|
48
50
|
expect($stderr).to receive(:puts).with("\e[33mhello\e[0m").once
|
49
|
-
@tst.warning
|
51
|
+
@tst.warning 'hello'
|
50
52
|
end
|
51
53
|
|
52
|
-
it
|
54
|
+
it 'errors' do
|
53
55
|
expect($stderr).to receive(:puts).with("\e[31mhello\e[0m").once
|
54
|
-
@tst.error
|
56
|
+
@tst.error 'hello'
|
55
57
|
end
|
56
58
|
|
57
|
-
context
|
58
|
-
context
|
59
|
+
context 'tabularize' do
|
60
|
+
context 'generating CSV' do
|
59
61
|
before(:example) do
|
60
62
|
$cfg['tool.outformat'] = 'csv'
|
61
63
|
end
|
62
64
|
|
63
|
-
it
|
65
|
+
it 'takes Array' do
|
64
66
|
$stdout = StringIO.new
|
65
67
|
|
66
|
-
@tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
|
68
|
+
@tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]])
|
67
69
|
|
68
70
|
expect($stdout.string).to eq("1,2,3,4,5,6,7\n10,20,30,40,50,60,70\n")
|
69
71
|
end
|
70
72
|
|
71
|
-
it
|
73
|
+
it 'ducks to_a' do
|
72
74
|
$stdout = StringIO.new
|
73
75
|
|
74
76
|
class DuckToATest
|
75
77
|
def to_a
|
76
|
-
[[12],[13]]
|
78
|
+
[[12], [13]]
|
77
79
|
end
|
78
80
|
end
|
79
81
|
@tst.tabularize(DuckToATest.new)
|
@@ -81,11 +83,11 @@ RSpec.describe MrMurano::Verbose do
|
|
81
83
|
expect($stdout.string).to eq("12\n13\n")
|
82
84
|
end
|
83
85
|
|
84
|
-
it
|
86
|
+
it 'ducks each' do
|
85
87
|
$stdout = StringIO.new
|
86
88
|
|
87
89
|
class DuckEachTest
|
88
|
-
def each
|
90
|
+
def each
|
89
91
|
yield [22]
|
90
92
|
yield [44]
|
91
93
|
end
|
@@ -95,38 +97,38 @@ RSpec.describe MrMurano::Verbose do
|
|
95
97
|
expect($stdout.string).to eq("22\n44\n")
|
96
98
|
end
|
97
99
|
|
98
|
-
context
|
100
|
+
context 'takes Hash' do
|
99
101
|
before(:example) do
|
100
102
|
@hsh = {
|
101
|
-
:
|
102
|
-
:
|
103
|
-
:
|
103
|
+
headers: %i[one two three],
|
104
|
+
title: 'Test output',
|
105
|
+
rows: [[1, 2, 3], [10, 20, 30]],
|
104
106
|
}
|
105
107
|
$stdout = StringIO.new
|
106
108
|
end
|
107
|
-
it
|
109
|
+
it 'has all' do
|
108
110
|
@tst.tabularize(@hsh)
|
109
111
|
expect($stdout.string).to eq("one,two,three\n1,2,3\n10,20,30\n")
|
110
112
|
end
|
111
113
|
|
112
|
-
it
|
114
|
+
it 'is empty' do
|
113
115
|
@tst.tabularize({})
|
114
116
|
expect($stdout.string).to eq("\n")
|
115
117
|
end
|
116
118
|
|
117
|
-
it
|
119
|
+
it 'no headers' do
|
118
120
|
@hsh.delete :headers
|
119
121
|
@tst.tabularize(@hsh)
|
120
122
|
expect($stdout.string).to eq("1,2,3\n10,20,30\n")
|
121
123
|
end
|
122
124
|
|
123
|
-
it
|
125
|
+
it 'no title' do
|
124
126
|
@hsh.delete :title
|
125
127
|
@tst.tabularize(@hsh)
|
126
128
|
expect($stdout.string).to eq("one,two,three\n1,2,3\n10,20,30\n")
|
127
129
|
end
|
128
130
|
|
129
|
-
it
|
131
|
+
it 'no rows' do
|
130
132
|
@hsh.delete :rows
|
131
133
|
@tst.tabularize(@hsh)
|
132
134
|
expect($stdout.string).to eq("one,two,three\n\n")
|
@@ -141,144 +143,144 @@ RSpec.describe MrMurano::Verbose do
|
|
141
143
|
@tst.tabularize(12)
|
142
144
|
end
|
143
145
|
|
144
|
-
it
|
146
|
+
it 'takes Array, to custom stream' do
|
145
147
|
$stdout = StringIO.new
|
146
148
|
outer = StringIO.new
|
147
149
|
|
148
|
-
@tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]], outer)
|
150
|
+
@tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]], outer)
|
149
151
|
|
150
152
|
expect(outer.string).to eq("1,2,3,4,5,6,7\n10,20,30,40,50,60,70\n")
|
151
153
|
expect($stdout.string).to eq('')
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
155
|
-
context
|
156
|
-
it
|
157
|
+
context 'generating a table' do
|
158
|
+
it 'takes Array' do
|
157
159
|
$stdout = StringIO.new
|
158
|
-
@tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
|
160
|
+
@tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]])
|
159
161
|
expect($stdout.string).to eq(
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
%(+----+----+----+----+----+----+----+
|
163
|
+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|
164
|
+
| 10 | 20 | 30 | 40 | 50 | 60 | 70 |
|
165
|
+
+----+----+----+----+----+----+----+
|
166
|
+
).gsub(/^\s+/, '')
|
165
167
|
)
|
166
168
|
end
|
167
169
|
|
168
|
-
context
|
170
|
+
context 'takes Hash' do
|
169
171
|
before(:example) do
|
170
172
|
@hsh = {
|
171
|
-
:
|
172
|
-
:
|
173
|
-
:
|
173
|
+
headers: %i[one two three],
|
174
|
+
title: 'Test output',
|
175
|
+
rows: [[1, 2, 3], [10, 20, 30]],
|
174
176
|
}
|
175
177
|
$stdout = StringIO.new
|
176
178
|
end
|
177
|
-
it
|
179
|
+
it 'has all' do
|
178
180
|
@tst.tabularize(@hsh)
|
179
181
|
expect($stdout.string).to eq(
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
182
|
+
%(+-----+-----+-------+
|
183
|
+
| Test output |
|
184
|
+
+-----+-----+-------+
|
185
|
+
| one | two | three |
|
186
|
+
+-----+-----+-------+
|
187
|
+
| 1 | 2 | 3 |
|
188
|
+
| 10 | 20 | 30 |
|
189
|
+
+-----+-----+-------+
|
190
|
+
).gsub(/^\s+/, '')
|
191
|
+
)
|
190
192
|
end
|
191
193
|
|
192
|
-
it
|
194
|
+
it 'is empty' do
|
193
195
|
@tst.tabularize({})
|
194
196
|
expect($stdout.string).to eq("++\n++\n")
|
195
197
|
end
|
196
198
|
|
197
|
-
it
|
199
|
+
it 'no headers' do
|
198
200
|
@hsh.delete :headers
|
199
201
|
@tst.tabularize(@hsh)
|
200
202
|
expect($stdout.string).to eq(
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
203
|
+
%(+----+----+----+
|
204
|
+
| Test output |
|
205
|
+
+----+----+----+
|
206
|
+
| 1 | 2 | 3 |
|
207
|
+
| 10 | 20 | 30 |
|
208
|
+
+----+----+----+
|
209
|
+
).gsub(/^\s+/, '')
|
210
|
+
)
|
209
211
|
end
|
210
212
|
|
211
|
-
it
|
213
|
+
it 'no title' do
|
212
214
|
@hsh.delete :title
|
213
215
|
@tst.tabularize(@hsh)
|
214
216
|
expect($stdout.string).to eq(
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
217
|
+
%(+-----+-----+-------+
|
218
|
+
| one | two | three |
|
219
|
+
+-----+-----+-------+
|
220
|
+
| 1 | 2 | 3 |
|
221
|
+
| 10 | 20 | 30 |
|
222
|
+
+-----+-----+-------+
|
223
|
+
).gsub(/^\s+/, '')
|
224
|
+
)
|
223
225
|
end
|
224
226
|
|
225
|
-
it
|
227
|
+
it 'no rows' do
|
226
228
|
@hsh.delete :rows
|
227
229
|
@tst.tabularize(@hsh)
|
228
230
|
expect($stdout.string).to eq(
|
229
|
-
%
|
230
|
-
| Test output |
|
231
|
-
+-----+-----+-------+
|
232
|
-
| one | two | three |
|
233
|
-
+-----+-----+-------+
|
234
|
-
+-----+-----+-------+
|
235
|
-
|
236
|
-
|
231
|
+
%(+-----+-----+-------+
|
232
|
+
| Test output |
|
233
|
+
+-----+-----+-------+
|
234
|
+
| one | two | three |
|
235
|
+
+-----+-----+-------+
|
236
|
+
+-----+-----+-------+
|
237
|
+
).gsub(/^\s+/, '')
|
238
|
+
)
|
237
239
|
end
|
238
240
|
end
|
239
241
|
end
|
240
242
|
end
|
241
243
|
|
242
|
-
context
|
244
|
+
context 'outf' do
|
243
245
|
before(:example) do
|
244
246
|
@data = {
|
245
|
-
:
|
246
|
-
:
|
247
|
+
one: 'three',
|
248
|
+
two: [{ one: 3 }, { one: 4 }],
|
247
249
|
}
|
248
250
|
$stdout = StringIO.new
|
249
251
|
end
|
250
252
|
|
251
|
-
it
|
253
|
+
it 'outputs yaml' do
|
252
254
|
$cfg['tool.outformat'] = 'yaml'
|
253
255
|
@tst.outf(@data)
|
254
256
|
expect($stdout.string).to eq("---\none: three\ntwo:\n- one: 3\n- one: 4\n")
|
255
257
|
end
|
256
258
|
|
257
|
-
it
|
259
|
+
it 'outputs json' do
|
258
260
|
$cfg['tool.outformat'] = 'json'
|
259
261
|
@tst.outf(@data)
|
260
262
|
expect($stdout.string).to eq("{\"one\":\"three\",\"two\":[{\"one\":3},{\"one\":4}]}\n")
|
261
263
|
end
|
262
264
|
|
263
|
-
it
|
265
|
+
it 'outputs ruby' do
|
264
266
|
$cfg['tool.outformat'] = 'pp'
|
265
267
|
@tst.outf(@data)
|
266
268
|
expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
|
267
269
|
end
|
268
270
|
|
269
|
-
it
|
271
|
+
it 'outputs as String' do
|
270
272
|
@tst.outf(@data)
|
271
273
|
expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
|
272
274
|
end
|
273
275
|
|
274
|
-
it
|
275
|
-
@tst.outf([1,2,3,4,5])
|
276
|
+
it 'outputs as Array' do
|
277
|
+
@tst.outf([1, 2, 3, 4, 5])
|
276
278
|
expect($stdout.string).to eq("1\n2\n3\n4\n5\n")
|
277
279
|
end
|
278
280
|
|
279
|
-
it
|
280
|
-
@tst.outf(@data) do |
|
281
|
-
ios.puts
|
281
|
+
it 'returns to block' do
|
282
|
+
@tst.outf(@data) do |_dd, ios|
|
283
|
+
ios.puts 'pop'
|
282
284
|
end
|
283
285
|
expect($stdout.string).to eq("pop\n")
|
284
286
|
end
|
@@ -1,3 +1,10 @@
|
|
1
|
+
# Last Modified: 2017.09.12 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
7
|
+
|
1
8
|
require 'tempfile'
|
2
9
|
require 'yaml'
|
3
10
|
require 'MrMurano/version'
|
@@ -7,7 +14,7 @@ require 'MrMurano/Webservice-Cors'
|
|
7
14
|
require '_workspace'
|
8
15
|
|
9
16
|
RSpec.describe MrMurano::Webservice::Cors do
|
10
|
-
include_context
|
17
|
+
include_context 'WORKSPACE'
|
11
18
|
before(:example) do
|
12
19
|
MrMurano::SyncRoot.instance.reset
|
13
20
|
$cfg = MrMurano::Config.new
|
@@ -16,48 +23,60 @@ RSpec.describe MrMurano::Webservice::Cors do
|
|
16
23
|
$cfg['application.id'] = 'XYZ'
|
17
24
|
|
18
25
|
@srv = MrMurano::Webservice::Cors.new
|
19
|
-
allow(@srv).to receive(:token).and_return(
|
26
|
+
allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
|
20
27
|
|
21
|
-
@
|
28
|
+
@base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors'
|
22
29
|
end
|
23
30
|
|
24
|
-
it
|
31
|
+
it 'initializes' do
|
25
32
|
uri = @srv.endpoint('/')
|
26
|
-
expect(uri.to_s).to eq("#{@
|
33
|
+
expect(uri.to_s).to eq("#{@base_uri}/")
|
27
34
|
end
|
28
35
|
|
29
|
-
context
|
30
|
-
context
|
31
|
-
it
|
32
|
-
cors = {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
context 'when server gives string' do
|
37
|
+
context 'fetches' do
|
38
|
+
it 'as a hash' do
|
39
|
+
cors = {
|
40
|
+
origin: true,
|
41
|
+
methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
|
42
|
+
headers: ['Content-Type', 'Cookie', 'Authorization'],
|
43
|
+
credentials: true,
|
44
|
+
}
|
45
|
+
body = { cors: cors.to_json }
|
46
|
+
stub_request(
|
47
|
+
:get, @base_uri.to_s
|
48
|
+
).with(
|
49
|
+
headers: {
|
50
|
+
'Authorization' => 'token TTTTTTTTTT',
|
51
|
+
'Content-Type' => 'application/json',
|
52
|
+
}
|
53
|
+
).to_return(body: body.to_json)
|
54
|
+
|
55
|
+
ret = @srv.fetch
|
43
56
|
expect(ret).to eq(cors)
|
44
57
|
end
|
45
|
-
it
|
46
|
-
cors = {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
it 'as a block' do
|
59
|
+
cors = {
|
60
|
+
origin: true,
|
61
|
+
methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
|
62
|
+
headers: ['Content-Type', 'Cookie', 'Authorization'],
|
63
|
+
credentials: true,
|
64
|
+
}
|
65
|
+
body = { cors: cors.to_json }
|
66
|
+
stub_request(
|
67
|
+
:get, @base_uri.to_s
|
68
|
+
).with(
|
69
|
+
headers: {
|
70
|
+
'Authorization' => 'token TTTTTTTTTT',
|
71
|
+
'Content-Type' => 'application/json',
|
72
|
+
}
|
73
|
+
).to_return(body: body.to_json)
|
55
74
|
|
56
75
|
ret = ''
|
57
76
|
loops = 0
|
58
|
-
@srv.fetch
|
77
|
+
@srv.fetch do |chunk|
|
59
78
|
loops += 1
|
60
|
-
ret
|
79
|
+
ret += chunk
|
61
80
|
expect(loops).to be <= 1
|
62
81
|
end
|
63
82
|
expect(ret).to eq(Hash.transform_keys_to_strings(cors).to_yaml)
|
@@ -65,38 +84,50 @@ RSpec.describe MrMurano::Webservice::Cors do
|
|
65
84
|
end
|
66
85
|
end
|
67
86
|
|
68
|
-
context
|
69
|
-
context
|
70
|
-
it
|
71
|
-
cors = {
|
72
|
-
|
73
|
-
|
74
|
-
|
87
|
+
context 'when server gives object' do
|
88
|
+
context 'fetches' do
|
89
|
+
it 'as a hash' do
|
90
|
+
cors = {
|
91
|
+
origin: true,
|
92
|
+
methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
|
93
|
+
headers: ['Content-Type', 'Cookie', 'Authorization'],
|
94
|
+
credentials: true,
|
95
|
+
}
|
75
96
|
body = cors
|
76
|
-
stub_request(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
97
|
+
stub_request(
|
98
|
+
:get, @base_uri.to_s
|
99
|
+
).with(
|
100
|
+
headers: {
|
101
|
+
'Authorization' => 'token TTTTTTTTTT',
|
102
|
+
'Content-Type' => 'application/json',
|
103
|
+
}
|
104
|
+
).to_return(body: body.to_json)
|
105
|
+
|
106
|
+
ret = @srv.fetch
|
82
107
|
expect(ret).to eq(cors)
|
83
108
|
end
|
84
|
-
it
|
85
|
-
cors = {
|
86
|
-
|
87
|
-
|
88
|
-
|
109
|
+
it 'as a block' do
|
110
|
+
cors = {
|
111
|
+
origin: true,
|
112
|
+
methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
|
113
|
+
headers: ['Content-Type', 'Cookie', 'Authorization'],
|
114
|
+
credentials: true,
|
115
|
+
}
|
89
116
|
body = cors
|
90
|
-
stub_request(
|
91
|
-
|
92
|
-
|
93
|
-
|
117
|
+
stub_request(
|
118
|
+
:get, @base_uri.to_s
|
119
|
+
).with(
|
120
|
+
headers: {
|
121
|
+
'Authorization' => 'token TTTTTTTTTT',
|
122
|
+
'Content-Type' => 'application/json',
|
123
|
+
}
|
124
|
+
).to_return(body: body.to_json)
|
94
125
|
|
95
126
|
ret = ''
|
96
127
|
loops = 0
|
97
|
-
@srv.fetch
|
128
|
+
@srv.fetch do |chunk|
|
98
129
|
loops += 1
|
99
|
-
ret
|
130
|
+
ret += chunk
|
100
131
|
expect(loops).to be <= 1
|
101
132
|
end
|
102
133
|
expect(ret).to eq(Hash.transform_keys_to_strings(cors).to_yaml)
|
@@ -104,64 +135,79 @@ RSpec.describe MrMurano::Webservice::Cors do
|
|
104
135
|
end
|
105
136
|
end
|
106
137
|
|
107
|
-
context
|
138
|
+
context 'uploads' do
|
108
139
|
before(:example) do
|
109
140
|
$project = MrMurano::ProjectFile.new
|
110
141
|
$project.load
|
111
|
-
@cors = {
|
112
|
-
|
113
|
-
|
114
|
-
|
142
|
+
@cors = {
|
143
|
+
origin: true,
|
144
|
+
methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
|
145
|
+
headers: ['Content-Type', 'Cookie', 'Authorization'],
|
146
|
+
credentials: true,
|
147
|
+
}
|
115
148
|
end
|
116
|
-
it
|
117
|
-
File.open(File.join(@project_dir, 'bob.yaml'), 'w'){|io| io << @cors.to_yaml}
|
118
|
-
stub_request(
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
149
|
+
it 'specified file' do
|
150
|
+
File.open(File.join(@project_dir, 'bob.yaml'), 'w') { |io| io << @cors.to_yaml }
|
151
|
+
stub_request(
|
152
|
+
:put, @base_uri.to_s
|
153
|
+
).with(
|
154
|
+
body: @cors.to_json,
|
155
|
+
headers: {
|
156
|
+
'Authorization' => 'token TTTTTTTTTT',
|
157
|
+
'Content-Type' => 'application/json',
|
158
|
+
}
|
159
|
+
).to_return(body: '')
|
123
160
|
|
124
161
|
ret = @srv.upload('bob.yaml')
|
125
162
|
expect(ret).to eq({})
|
126
163
|
end
|
127
164
|
|
128
|
-
it
|
129
|
-
File.open(File.join(@project_dir, 'bob.yaml'), 'w'){|io| io << @cors.to_yaml}
|
165
|
+
it 'file in $project' do
|
166
|
+
File.open(File.join(@project_dir, 'bob.yaml'), 'w') { |io| io << @cors.to_yaml }
|
130
167
|
$project['routes.cors'] = 'bob.yaml'
|
131
|
-
stub_request(
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
168
|
+
stub_request(
|
169
|
+
:put, @base_uri.to_s
|
170
|
+
).with(body: @cors.to_json,
|
171
|
+
headers: {
|
172
|
+
'Authorization' => 'token TTTTTTTTTT',
|
173
|
+
'Content-Type' => 'application/json',
|
174
|
+
}).to_return(body: '')
|
175
|
+
|
176
|
+
ret = @srv.upload
|
138
177
|
expect(ret).to eq({})
|
139
178
|
end
|
140
179
|
|
141
|
-
it
|
142
|
-
File.open(File.join(@project_dir, 'cors.yaml'), 'w'){|io| io << @cors.to_yaml}
|
143
|
-
stub_request(
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
180
|
+
it 'file defaults thru $project' do
|
181
|
+
File.open(File.join(@project_dir, 'cors.yaml'), 'w') { |io| io << @cors.to_yaml }
|
182
|
+
stub_request(
|
183
|
+
:put, @base_uri.to_s
|
184
|
+
).with(
|
185
|
+
body: @cors.to_json,
|
186
|
+
headers: {
|
187
|
+
'Authorization' => 'token TTTTTTTTTT',
|
188
|
+
'Content-Type' => 'application/json',
|
189
|
+
}
|
190
|
+
).to_return(body: '')
|
191
|
+
|
192
|
+
ret = @srv.upload
|
150
193
|
expect(ret).to eq({})
|
151
194
|
end
|
152
195
|
|
153
|
-
it
|
196
|
+
it 'cors in $project' do
|
154
197
|
$project['routes.cors'] = @cors
|
155
|
-
stub_request(
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
198
|
+
stub_request(
|
199
|
+
:put, @base_uri.to_s
|
200
|
+
).with(
|
201
|
+
body: @cors.to_json,
|
202
|
+
headers: {
|
203
|
+
'Authorization' => 'token TTTTTTTTTT',
|
204
|
+
'Content-Type' => 'application/json',
|
205
|
+
}
|
206
|
+
).to_return(body: '')
|
207
|
+
|
208
|
+
ret = @srv.upload
|
162
209
|
expect(ret).to eq({})
|
163
210
|
end
|
164
211
|
end
|
165
|
-
|
166
212
|
end
|
167
|
-
|
213
|
+
|