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
@@ -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 '_workspace'
|
3
10
|
require 'MrMurano/version'
|
@@ -5,7 +12,7 @@ require 'MrMurano/ProjectFile'
|
|
5
12
|
require 'MrMurano/Webservice-Endpoint'
|
6
13
|
|
7
14
|
RSpec.describe MrMurano::Webservice::Endpoint do
|
8
|
-
include_context
|
15
|
+
include_context 'WORKSPACE'
|
9
16
|
before(:example) do
|
10
17
|
$cfg = MrMurano::Config.new
|
11
18
|
$cfg.load
|
@@ -15,180 +22,192 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
15
22
|
$cfg['application.id'] = 'XYZ'
|
16
23
|
|
17
24
|
@srv = MrMurano::Webservice::Endpoint.new
|
18
|
-
allow(@srv).to receive(:token).and_return(
|
25
|
+
allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
|
19
26
|
|
20
|
-
@
|
27
|
+
@base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/endpoint'
|
21
28
|
end
|
22
29
|
|
23
|
-
it
|
30
|
+
it 'initializes' do
|
24
31
|
uri = @srv.endpoint('/')
|
25
|
-
expect(uri.to_s).to eq("#{@
|
32
|
+
expect(uri.to_s).to eq("#{@base_uri}/")
|
26
33
|
end
|
27
34
|
|
28
|
-
context
|
29
|
-
it
|
30
|
-
body = [
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
context 'lists' do
|
36
|
+
it 'same content_type' do
|
37
|
+
body = [
|
38
|
+
{
|
39
|
+
id: '9K0',
|
40
|
+
method: 'websocket',
|
41
|
+
path: '/api/v1/bar',
|
42
|
+
content_type: 'application/json',
|
43
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
|
44
|
+
},
|
45
|
+
{ id: 'B76',
|
46
|
+
method: 'websocket',
|
47
|
+
path: '/api/v1/foo/{id}',
|
48
|
+
content_type: 'application/json',
|
49
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
|
50
|
+
]
|
51
|
+
stub_request(:get, @base_uri)
|
52
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
53
|
+
'Content-Type' => 'application/json', })
|
54
|
+
.to_return(body: body.to_json)
|
46
55
|
|
47
56
|
ret = @srv.list
|
48
57
|
expect(ret).to eq(body)
|
49
58
|
end
|
50
59
|
|
51
|
-
it
|
52
|
-
body = [
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
it 'missing headers' do
|
61
|
+
body = [
|
62
|
+
{
|
63
|
+
id: '9K0',
|
64
|
+
method: 'websocket',
|
65
|
+
path: '/api/v1/bar',
|
66
|
+
content_type: 'application/json',
|
67
|
+
script: "response.message = \"HI\"\n\n",
|
68
|
+
},
|
69
|
+
{ id: 'B76',
|
70
|
+
method: 'websocket',
|
71
|
+
path: '/api/v1/foo/{id}',
|
72
|
+
content_type: 'application/json',
|
73
|
+
script: "response.message = \"HI\"\n\n-- BOB WAS HERE\n", },
|
74
|
+
]
|
75
|
+
stub_request(:get, @base_uri)
|
76
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
77
|
+
'Content-Type' => 'application/json', })
|
78
|
+
.to_return(body: body.to_json)
|
68
79
|
|
69
80
|
ret = @srv.list
|
70
81
|
expect(ret).to eq(body)
|
71
82
|
end
|
72
83
|
|
73
|
-
it
|
74
|
-
body = [
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
it 'not default content_type' do
|
85
|
+
body = [
|
86
|
+
{
|
87
|
+
id: '9K0',
|
88
|
+
method: 'websocket',
|
89
|
+
path: '/api/v1/bar',
|
90
|
+
content_type: 'text/csv',
|
91
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n\n",
|
92
|
+
},
|
93
|
+
{ id: 'B76',
|
94
|
+
method: 'websocket',
|
95
|
+
path: '/api/v1/foo/{id}',
|
96
|
+
content_type: 'image/png',
|
97
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id} image/png\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
|
98
|
+
]
|
99
|
+
stub_request(:get, @base_uri)
|
100
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
101
|
+
'Content-Type' => 'application/json', })
|
102
|
+
.to_return(body: body.to_json)
|
90
103
|
|
91
104
|
ret = @srv.list
|
92
105
|
expect(ret).to eq(body)
|
93
106
|
end
|
94
107
|
|
95
|
-
it
|
96
|
-
body = [
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
it 'mismatched content_type header' do
|
109
|
+
body = [
|
110
|
+
{
|
111
|
+
id: '9K0',
|
112
|
+
method: 'websocket',
|
113
|
+
path: '/api/v1/bar',
|
114
|
+
content_type: 'text/csv',
|
115
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
|
116
|
+
},
|
117
|
+
{ id: 'B76',
|
118
|
+
method: 'websocket',
|
119
|
+
path: '/api/v1/foo/{id}',
|
120
|
+
content_type: 'image/png',
|
121
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
|
122
|
+
]
|
123
|
+
stub_request(:get, @base_uri)
|
124
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
125
|
+
'Content-Type' => 'application/json', })
|
126
|
+
.to_return(body: body.to_json)
|
112
127
|
|
113
128
|
ret = @srv.list
|
114
129
|
expect(ret).to eq(body)
|
115
130
|
end
|
116
131
|
|
117
|
-
it
|
118
|
-
body = [
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
132
|
+
it 'returns empty content type' do
|
133
|
+
body = [
|
134
|
+
{
|
135
|
+
id: '9K0',
|
136
|
+
method: 'websocket',
|
137
|
+
path: '/api/v1/bar',
|
138
|
+
content_type: '',
|
139
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
|
140
|
+
},
|
141
|
+
{ id: 'B76',
|
142
|
+
method: 'websocket',
|
143
|
+
path: '/api/v1/foo/{id}',
|
144
|
+
content_type: 'image/png',
|
145
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
|
146
|
+
]
|
147
|
+
stub_request(:get, @base_uri)
|
148
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
149
|
+
'Content-Type' => 'application/json', })
|
150
|
+
.to_return(body: body.to_json)
|
134
151
|
ret = @srv.list
|
135
|
-
body.first
|
152
|
+
body.first[:content_type] = 'application/json'
|
136
153
|
expect(ret).to eq(body)
|
137
154
|
end
|
138
155
|
|
139
|
-
it
|
140
|
-
body = [
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
156
|
+
it 'returns missing content type' do
|
157
|
+
body = [
|
158
|
+
{
|
159
|
+
id: '9K0',
|
160
|
+
method: 'websocket',
|
161
|
+
path: '/api/v1/bar',
|
162
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
|
163
|
+
},
|
164
|
+
{ id: 'B76',
|
165
|
+
method: 'websocket',
|
166
|
+
path: '/api/v1/foo/{id}',
|
167
|
+
content_type: 'image/png',
|
168
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
|
169
|
+
]
|
170
|
+
stub_request(:get, @base_uri)
|
171
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
172
|
+
'Content-Type' => 'application/json', })
|
173
|
+
.to_return(body: body.to_json)
|
155
174
|
|
156
175
|
ret = @srv.list
|
157
|
-
body.first
|
176
|
+
body.first[:content_type] = 'application/json'
|
158
177
|
expect(ret).to eq(body)
|
159
178
|
end
|
160
|
-
|
161
179
|
end
|
162
180
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
181
|
+
context 'fetches' do
|
182
|
+
it 'fetches' do
|
183
|
+
body = {
|
184
|
+
id: '9K0',
|
185
|
+
method: 'websocket',
|
186
|
+
path: '/api/v1/bar',
|
187
|
+
content_type: 'application/json',
|
188
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
|
171
189
|
}
|
172
|
-
stub_request(:get, "#{@
|
173
|
-
with(:
|
174
|
-
|
175
|
-
|
190
|
+
stub_request(:get, "#{@base_uri}/9K0")
|
191
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
192
|
+
'Content-Type' => 'application/json', })
|
193
|
+
.to_return(body: body.to_json)
|
176
194
|
|
177
195
|
ret = @srv.fetch('9K0')
|
178
196
|
expect(ret).to eq(body[:script])
|
179
197
|
end
|
180
198
|
|
181
|
-
it
|
182
|
-
body = {
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
199
|
+
it 'yields' do
|
200
|
+
body = {
|
201
|
+
id: '9K0',
|
202
|
+
method: 'websocket',
|
203
|
+
path: '/api/v1/bar',
|
204
|
+
content_type: 'application/json',
|
205
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
|
187
206
|
}
|
188
|
-
stub_request(:get, "#{@
|
189
|
-
with(:
|
190
|
-
|
191
|
-
|
207
|
+
stub_request(:get, "#{@base_uri}/9K0")
|
208
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
209
|
+
'Content-Type' => 'application/json', })
|
210
|
+
.to_return(body: body.to_json)
|
192
211
|
|
193
212
|
ret = nil
|
194
213
|
@srv.fetch('9K0') do |sc|
|
@@ -197,82 +216,88 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
197
216
|
expect(ret).to eq(body[:script])
|
198
217
|
end
|
199
218
|
|
200
|
-
it
|
201
|
-
body = {
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
219
|
+
it 'missing headers' do
|
220
|
+
body = {
|
221
|
+
id: '9K0',
|
222
|
+
method: 'websocket',
|
223
|
+
path: '/api/v1/bar',
|
224
|
+
content_type: 'application/json',
|
225
|
+
script: "response.message = \"HI\"\n",
|
206
226
|
}
|
207
|
-
stub_request(:get, "#{@
|
208
|
-
with(:
|
209
|
-
|
210
|
-
|
227
|
+
stub_request(:get, "#{@base_uri}/9K0")
|
228
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
229
|
+
'Content-Type' => 'application/json', })
|
230
|
+
.to_return(body: body.to_json)
|
211
231
|
|
212
232
|
ret = @srv.fetch('9K0')
|
213
233
|
expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n")
|
214
234
|
end
|
215
235
|
|
216
|
-
it
|
217
|
-
body = {
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
236
|
+
it 'not default content_type' do
|
237
|
+
body = {
|
238
|
+
id: '9K0',
|
239
|
+
method: 'websocket',
|
240
|
+
path: '/api/v1/bar',
|
241
|
+
content_type: 'text/csv',
|
242
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n",
|
222
243
|
}
|
223
|
-
stub_request(:get, "#{@
|
224
|
-
with(:
|
225
|
-
|
226
|
-
|
244
|
+
stub_request(:get, "#{@base_uri}/9K0")
|
245
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
246
|
+
'Content-Type' => 'application/json', })
|
247
|
+
.to_return(body: body.to_json)
|
227
248
|
|
228
249
|
ret = @srv.fetch('9K0')
|
229
250
|
expect(ret).to eq(body[:script])
|
230
251
|
end
|
231
252
|
|
232
|
-
it
|
233
|
-
body = {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
253
|
+
it 'missing content_type header' do
|
254
|
+
body = {
|
255
|
+
id: '9K0',
|
256
|
+
method: 'websocket',
|
257
|
+
path: '/api/v1/bar',
|
258
|
+
content_type: 'text/csv',
|
259
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
|
238
260
|
}
|
239
|
-
stub_request(:get, "#{@
|
240
|
-
with(:
|
241
|
-
|
242
|
-
|
261
|
+
stub_request(:get, "#{@base_uri}/9K0")
|
262
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
263
|
+
'Content-Type' => 'application/json', })
|
264
|
+
.to_return(body: body.to_json)
|
243
265
|
|
244
266
|
ret = @srv.fetch('9K0')
|
245
267
|
expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n")
|
246
268
|
end
|
247
269
|
|
248
|
-
it
|
249
|
-
body = {
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
270
|
+
it 'mismatched content_type header' do
|
271
|
+
body = {
|
272
|
+
id: '9K0',
|
273
|
+
method: 'websocket',
|
274
|
+
path: '/api/v1/bar',
|
275
|
+
content_type: 'text/csv',
|
276
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar image/png\nresponse.message = \"HI\"\n",
|
254
277
|
}
|
255
|
-
stub_request(:get, "#{@
|
256
|
-
with(:
|
257
|
-
|
258
|
-
|
278
|
+
stub_request(:get, "#{@base_uri}/9K0")
|
279
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
280
|
+
'Content-Type' => 'application/json', })
|
281
|
+
.to_return(body: body.to_json)
|
259
282
|
|
260
283
|
ret = @srv.fetch('9K0')
|
261
|
-
expect(ret).to eq(
|
284
|
+
expect(ret).to eq(
|
285
|
+
"--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n"
|
286
|
+
)
|
262
287
|
end
|
263
288
|
end
|
264
289
|
|
265
|
-
it
|
266
|
-
stub_request(:delete, "#{@
|
267
|
-
with(:
|
268
|
-
|
269
|
-
to_return(body:
|
290
|
+
it 'removes' do
|
291
|
+
stub_request(:delete, "#{@base_uri}/9K0")
|
292
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
293
|
+
'Content-Type' => 'application/json', })
|
294
|
+
.to_return(body: '')
|
270
295
|
|
271
296
|
ret = @srv.remove('9K0')
|
272
297
|
expect(ret).to eq({})
|
273
298
|
end
|
274
299
|
|
275
|
-
context
|
300
|
+
context 'uploads' do
|
276
301
|
around(:example) do |ex|
|
277
302
|
Tempfile.open('foo') do |tio|
|
278
303
|
tio << %{-- lua code is here
|
@@ -286,228 +311,239 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
286
311
|
end
|
287
312
|
end
|
288
313
|
|
289
|
-
it
|
290
|
-
stub_request(:put, "#{@
|
291
|
-
with(:
|
292
|
-
|
293
|
-
|
314
|
+
it 'over old version' do
|
315
|
+
stub_request(:put, "#{@base_uri}/9K0")
|
316
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
317
|
+
'Content-Type' => 'application/json', })
|
318
|
+
.to_return(body: '')
|
294
319
|
|
295
320
|
ret = @srv.upload(@tio_.path,
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
321
|
+
MrMurano::Webservice::Endpoint::RouteItem.new(
|
322
|
+
id: '9K0',
|
323
|
+
method: 'websocket',
|
324
|
+
path: '/api/v1/bar',
|
325
|
+
content_type: 'application/json',
|
326
|
+
), true)
|
302
327
|
expect(ret)
|
303
328
|
end
|
304
329
|
|
305
|
-
it
|
306
|
-
stub_request(:put, "#{@
|
307
|
-
with(:
|
308
|
-
|
309
|
-
|
310
|
-
stub_request(:post, "#{@
|
311
|
-
with(:
|
312
|
-
|
313
|
-
|
330
|
+
it 'when nothing is there' do
|
331
|
+
stub_request(:put, "#{@base_uri}/9K0")
|
332
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
333
|
+
'Content-Type' => 'application/json', })
|
334
|
+
.to_return(status: 404)
|
335
|
+
stub_request(:post, "#{@base_uri}/")
|
336
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
337
|
+
'Content-Type' => 'application/json', })
|
338
|
+
.to_return(body: '')
|
314
339
|
|
315
|
-
ret = @srv.upload(
|
340
|
+
ret = @srv.upload(
|
341
|
+
@tio_.path,
|
316
342
|
MrMurano::Webservice::Endpoint::RouteItem.new(
|
317
|
-
:
|
318
|
-
:
|
319
|
-
:
|
320
|
-
:
|
321
|
-
|
343
|
+
id: '9K0',
|
344
|
+
method: 'websocket',
|
345
|
+
path: '/api/v1/bar',
|
346
|
+
content_type: 'application/json',
|
347
|
+
), false
|
348
|
+
)
|
322
349
|
expect(ret)
|
323
350
|
end
|
324
351
|
|
325
|
-
it
|
326
|
-
stub_request(:post, @
|
327
|
-
with(:
|
328
|
-
|
329
|
-
|
352
|
+
it 'without an itemkey' do
|
353
|
+
stub_request(:post, @base_uri)
|
354
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
355
|
+
'Content-Type' => 'application/json', })
|
356
|
+
.to_return(body: '')
|
330
357
|
|
331
|
-
ret = @srv.upload(
|
358
|
+
ret = @srv.upload(
|
359
|
+
@tio_.path,
|
332
360
|
MrMurano::Webservice::Endpoint::RouteItem.new(
|
333
|
-
:
|
334
|
-
:
|
335
|
-
:
|
336
|
-
|
361
|
+
method: 'websocket',
|
362
|
+
path: '/api/v1/bar',
|
363
|
+
content_type: 'application/json',
|
364
|
+
), false
|
365
|
+
)
|
337
366
|
expect(ret)
|
338
367
|
end
|
339
368
|
|
340
|
-
it
|
341
|
-
stub_request(:put, "#{@
|
342
|
-
with(:
|
343
|
-
|
344
|
-
|
369
|
+
it 'Handles others errors' do
|
370
|
+
stub_request(:put, "#{@base_uri}/9K0")
|
371
|
+
.with(headers: { 'Authorization' => 'token TTTTTTTTTT',
|
372
|
+
'Content-Type' => 'application/json', })
|
373
|
+
.to_return(status: 502, body: '{}')
|
345
374
|
|
346
375
|
expect(@srv).to receive(:error).and_return(nil)
|
347
|
-
ret = @srv.upload(
|
376
|
+
ret = @srv.upload(
|
377
|
+
@tio_.path,
|
348
378
|
MrMurano::Webservice::Endpoint::RouteItem.new(
|
349
|
-
:
|
350
|
-
:
|
351
|
-
:
|
352
|
-
:
|
353
|
-
|
379
|
+
id: '9K0',
|
380
|
+
method: 'websocket',
|
381
|
+
path: '/api/v1/bar',
|
382
|
+
content_type: 'application/json',
|
383
|
+
), true
|
384
|
+
)
|
354
385
|
expect(ret)
|
355
386
|
end
|
356
387
|
end
|
357
388
|
|
358
|
-
context
|
389
|
+
context 'compares' do
|
359
390
|
before(:example) do
|
360
|
-
@
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
391
|
+
@i_a = {
|
392
|
+
id: '9K0',
|
393
|
+
method: 'websocket',
|
394
|
+
path: '/api/v1/bar',
|
395
|
+
content_type: 'application/json',
|
396
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
|
397
|
+
}
|
398
|
+
@i_b = {
|
399
|
+
id: '9K0',
|
400
|
+
method: 'websocket',
|
401
|
+
path: '/api/v1/bar',
|
402
|
+
content_type: 'application/json',
|
403
|
+
script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
|
404
|
+
}
|
405
|
+
end
|
406
|
+
it 'both have script' do
|
407
|
+
ret = @srv.docmp(@i_a, @i_b)
|
375
408
|
expect(ret).to eq(false)
|
376
409
|
end
|
377
410
|
|
378
|
-
it
|
411
|
+
it 'i_a is a local file' do
|
379
412
|
Tempfile.open('foo') do |tio|
|
380
|
-
tio << @
|
413
|
+
tio << @i_a[:script]
|
381
414
|
tio.close
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
ret = @srv.docmp(
|
415
|
+
i_a = @i_a.reject do |k, _v|
|
416
|
+
k == :script
|
417
|
+
end.merge(local_path: Pathname.new(tio.path))
|
418
|
+
ret = @srv.docmp(i_a, @i_b)
|
386
419
|
expect(ret).to eq(false)
|
387
420
|
|
388
|
-
|
389
|
-
|
390
|
-
ret = @srv.docmp(
|
421
|
+
i_b = @i_b.dup
|
422
|
+
i_b[:script] = 'BOB'
|
423
|
+
ret = @srv.docmp(i_a, i_b)
|
391
424
|
expect(ret).to eq(true)
|
392
425
|
end
|
393
426
|
end
|
394
427
|
|
395
|
-
it
|
428
|
+
it 'i_b is a local file' do
|
396
429
|
Tempfile.open('foo') do |tio|
|
397
|
-
tio << @
|
430
|
+
tio << @i_b[:script]
|
398
431
|
tio.close
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
ret = @srv.docmp(@
|
432
|
+
i_b = @i_b.reject do |k, _v|
|
433
|
+
k == :script
|
434
|
+
end.merge(local_path: Pathname.new(tio.path))
|
435
|
+
ret = @srv.docmp(@i_a, i_b)
|
403
436
|
expect(ret).to eq(false)
|
404
437
|
|
405
|
-
|
406
|
-
|
407
|
-
ret = @srv.docmp(
|
438
|
+
i_a = @i_b.dup
|
439
|
+
i_a[:script] = 'BOB'
|
440
|
+
ret = @srv.docmp(i_a, i_b)
|
408
441
|
expect(ret).to eq(true)
|
409
442
|
end
|
410
443
|
end
|
411
444
|
end
|
412
445
|
|
413
|
-
context
|
414
|
-
it
|
415
|
-
ret = @srv.tolocalname({ :
|
446
|
+
context 'Lookup functions' do
|
447
|
+
it 'gets local name' do
|
448
|
+
ret = @srv.tolocalname({ method: 'get', path: 'one/two/three' }, nil)
|
416
449
|
expect(ret).to eq('one-two-three.get.lua')
|
417
450
|
end
|
418
451
|
|
419
|
-
it
|
420
|
-
ret = @srv.synckey(
|
421
|
-
expect(ret).to eq(
|
452
|
+
it 'gets synckey' do
|
453
|
+
ret = @srv.synckey(method: 'get', path: 'one/two/three')
|
454
|
+
expect(ret).to eq('GET_one/two/three')
|
422
455
|
end
|
423
456
|
|
424
|
-
it
|
425
|
-
$cfg['endpoints.searchFor'] = %
|
457
|
+
it 'gets searchfor' do
|
458
|
+
$cfg['endpoints.searchFor'] = %(a b c/**/d/*.bob)
|
426
459
|
ret = @srv.searchFor
|
427
|
-
expect(ret).to eq([
|
460
|
+
expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
|
428
461
|
end
|
429
462
|
|
430
|
-
it
|
431
|
-
$cfg['endpoints.ignoring'] = %
|
463
|
+
it 'gets ignoring' do
|
464
|
+
$cfg['endpoints.ignoring'] = %(a b c/**/d/*.bob)
|
432
465
|
ret = @srv.ignoring
|
433
|
-
expect(ret).to eq([
|
466
|
+
expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
|
434
467
|
end
|
435
468
|
end
|
436
469
|
|
437
|
-
context
|
438
|
-
it
|
439
|
-
Tempfile.open(
|
440
|
-
tio << %
|
470
|
+
context 'to_remote_item' do
|
471
|
+
it 'reads one' do
|
472
|
+
Tempfile.open('foo') do |tio|
|
473
|
+
tio << %(--#ENDPOINT GET /one/two
|
441
474
|
return request
|
442
475
|
|
443
|
-
|
476
|
+
).gsub(/^\s+/, '')
|
444
477
|
tio.close
|
445
478
|
|
446
479
|
ret = @srv.to_remote_item(nil, tio.path)
|
447
|
-
e = {
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
480
|
+
e = {
|
481
|
+
method: 'GET',
|
482
|
+
path: '/one/two',
|
483
|
+
content_type: 'application/json',
|
484
|
+
local_path: Pathname.new(tio.path),
|
485
|
+
line: 0,
|
486
|
+
script: "--#ENDPOINT GET /one/two\nreturn request\n",
|
487
|
+
line_end: 2,
|
454
488
|
}
|
455
489
|
expect(ret).to eq([e])
|
456
490
|
end
|
457
491
|
end
|
458
492
|
|
459
|
-
it
|
460
|
-
Tempfile.open(
|
461
|
-
tio << %
|
493
|
+
it 'reads many' do
|
494
|
+
Tempfile.open('foo') do |tio|
|
495
|
+
tio << %(--#ENDPOINT GET /one/two
|
462
496
|
return request
|
463
497
|
--#ENDPOINT PUT /one/two
|
464
498
|
return request
|
465
499
|
|
466
500
|
--#ENDPOINT DELETE /three/two
|
467
501
|
return request
|
468
|
-
|
502
|
+
).gsub(/^\s+/, '')
|
469
503
|
tio.close
|
470
504
|
|
471
505
|
ret = @srv.to_remote_item(nil, tio.path)
|
472
506
|
|
473
|
-
expect(ret).to eq(
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
507
|
+
expect(ret).to eq(
|
508
|
+
[
|
509
|
+
{
|
510
|
+
method: 'GET',
|
511
|
+
path: '/one/two',
|
512
|
+
content_type: 'application/json',
|
513
|
+
local_path: Pathname.new(tio.path),
|
514
|
+
line: 0,
|
515
|
+
script: "--#ENDPOINT GET /one/two\nreturn request\n",
|
516
|
+
line_end: 2,
|
517
|
+
},
|
518
|
+
{
|
519
|
+
method: 'PUT',
|
520
|
+
path: '/one/two',
|
521
|
+
content_type: 'application/json',
|
522
|
+
local_path: Pathname.new(tio.path),
|
523
|
+
line: 2,
|
524
|
+
script: "--#ENDPOINT PUT /one/two\nreturn request\n",
|
525
|
+
line_end: 4,
|
526
|
+
},
|
527
|
+
{
|
528
|
+
method: 'DELETE',
|
529
|
+
path: '/three/two',
|
530
|
+
content_type: 'application/json',
|
531
|
+
local_path: Pathname.new(tio.path),
|
532
|
+
line: 4,
|
533
|
+
script: "--#ENDPOINT DELETE /three/two\nreturn request\n",
|
534
|
+
line_end: 6,
|
535
|
+
},
|
536
|
+
]
|
537
|
+
)
|
502
538
|
end
|
503
539
|
end
|
504
540
|
|
505
|
-
it
|
506
|
-
Tempfile.open(
|
507
|
-
tio << %
|
541
|
+
it 'skips all when no header found' do
|
542
|
+
Tempfile.open('foo') do |tio|
|
543
|
+
tio << %(
|
508
544
|
return request
|
509
545
|
|
510
|
-
|
546
|
+
).gsub(/^\s+/, '')
|
511
547
|
tio.close
|
512
548
|
|
513
549
|
ret = @srv.to_remote_item(nil, tio.path)
|
@@ -515,70 +551,71 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
515
551
|
end
|
516
552
|
end
|
517
553
|
|
518
|
-
it
|
519
|
-
Tempfile.open(
|
520
|
-
tio << %
|
554
|
+
it 'skips junk at begining' do
|
555
|
+
Tempfile.open('foo') do |tio|
|
556
|
+
tio << %(
|
521
557
|
return flex
|
522
558
|
--#ENDPOINT GET /one/two
|
523
559
|
return request
|
524
560
|
|
525
|
-
|
561
|
+
).gsub(/^\s+/, '')
|
526
562
|
tio.close
|
527
563
|
|
528
564
|
ret = @srv.to_remote_item(nil, tio.path)
|
529
|
-
e = {
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
565
|
+
e = {
|
566
|
+
method: 'GET',
|
567
|
+
path: '/one/two',
|
568
|
+
content_type: 'application/json',
|
569
|
+
local_path: Pathname.new(tio.path),
|
570
|
+
line: 1,
|
571
|
+
script: "--#ENDPOINT GET /one/two\nreturn request\n",
|
572
|
+
line_end: 3,
|
536
573
|
}
|
537
574
|
expect(ret).to eq([e])
|
538
575
|
end
|
539
576
|
end
|
540
577
|
end
|
541
578
|
|
542
|
-
context
|
579
|
+
context 'Matching' do
|
543
580
|
before(:example) do
|
544
581
|
@an_item = {
|
545
|
-
:
|
546
|
-
:
|
547
|
-
:
|
582
|
+
method: 'get',
|
583
|
+
path: '/api/read/stuff',
|
584
|
+
local_path: Pathname.new('a/relative/path.lua'),
|
548
585
|
}
|
549
586
|
end
|
550
|
-
context
|
551
|
-
it
|
587
|
+
context 'method' do
|
588
|
+
it 'any path' do
|
552
589
|
ret = @srv.match(@an_item, '#get#')
|
553
590
|
expect(ret).to be true
|
554
591
|
ret = @srv.match(@an_item, '#post#')
|
555
592
|
expect(ret).to be false
|
556
593
|
end
|
557
|
-
it
|
594
|
+
it 'exact path' do
|
558
595
|
ret = @srv.match(@an_item, '#get#/api/read/stuff')
|
559
596
|
expect(ret).to be true
|
560
597
|
ret = @srv.match(@an_item, '#post#/api/read/stuff')
|
561
598
|
expect(ret).to be false
|
562
599
|
end
|
563
|
-
it
|
600
|
+
it 'path glob' do
|
564
601
|
ret = @srv.match(@an_item, '#get#/api/*/stuff')
|
565
602
|
expect(ret).to be true
|
566
603
|
ret = @srv.match(@an_item, '#get#/**/stuff')
|
567
604
|
expect(ret).to be true
|
568
605
|
end
|
569
606
|
end
|
570
|
-
context
|
571
|
-
it
|
607
|
+
context 'any method' do
|
608
|
+
it 'any path' do
|
572
609
|
ret = @srv.match(@an_item, '##')
|
573
610
|
expect(ret).to be true
|
574
611
|
end
|
575
|
-
it
|
612
|
+
it 'exact path' do
|
576
613
|
ret = @srv.match(@an_item, '##/api/read/stuff')
|
577
614
|
expect(ret).to be true
|
578
615
|
ret = @srv.match(@an_item, '##/api/do/stuff')
|
579
616
|
expect(ret).to be false
|
580
617
|
end
|
581
|
-
it
|
618
|
+
it 'path glob' do
|
582
619
|
ret = @srv.match(@an_item, '##/api/*/stuff')
|
583
620
|
expect(ret).to be true
|
584
621
|
ret = @srv.match(@an_item, '##/**/stuff')
|
@@ -586,6 +623,5 @@ RSpec.describe MrMurano::Webservice::Endpoint do
|
|
586
623
|
end
|
587
624
|
end
|
588
625
|
end
|
589
|
-
|
590
626
|
end
|
591
|
-
|
627
|
+
|