1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class SecuritySchemeTest extends SwaggerGen_TestCase |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
|
6
|
|
|
protected $parent; |
7
|
|
|
|
8
|
|
|
protected function setUp() |
9
|
|
|
{ |
10
|
|
|
$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
protected function assertPreConditions() |
14
|
|
|
{ |
15
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
20
|
|
|
*/ |
21
|
|
|
public function testConstructor_UnknownType() |
22
|
|
|
{ |
23
|
|
|
$this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'"); |
24
|
|
|
|
25
|
|
|
new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
30
|
|
|
*/ |
31
|
|
|
public function testConstructor_Basic() |
32
|
|
|
{ |
33
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
34
|
|
|
|
35
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
36
|
|
|
|
37
|
|
|
$this->assertSame(array( |
38
|
|
|
'type' => 'basic', |
39
|
|
|
), $object->toArray()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
44
|
|
|
*/ |
45
|
|
|
public function testConstructor_BasicDescription() |
46
|
|
|
{ |
47
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text'); |
48
|
|
|
|
49
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
50
|
|
|
|
51
|
|
|
$this->assertSame(array( |
52
|
|
|
'type' => 'basic', |
53
|
|
|
'description' => 'Some text', |
54
|
|
|
), $object->toArray()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
59
|
|
|
*/ |
60
|
|
|
public function testConstructor_ApiKeyNoName() |
61
|
|
|
{ |
62
|
|
|
$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''" |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey'); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
70
|
|
|
*/ |
71
|
|
|
public function testConstructor_ApiKeyNoIn() |
72
|
|
|
{ |
73
|
|
|
$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"); |
74
|
|
|
|
75
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name'); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
80
|
|
|
*/ |
81
|
|
|
public function testConstructor_ApiKeyWrongIn() |
82
|
|
|
{ |
83
|
|
|
$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'"); |
84
|
|
|
|
85
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad'); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
90
|
|
|
*/ |
91
|
|
|
public function testConstructor_ApiKey() |
92
|
|
|
{ |
93
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query'); |
94
|
|
|
|
95
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
96
|
|
|
|
97
|
|
|
$this->assertSame(array( |
98
|
|
|
'type' => 'apiKey', |
99
|
|
|
'name' => 'Name', |
100
|
|
|
'in' => 'query', |
101
|
|
|
), $object->toArray()); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
106
|
|
|
*/ |
107
|
|
|
public function testConstructor_ApiKeyDescription() |
108
|
|
|
{ |
109
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words'); |
110
|
|
|
|
111
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
112
|
|
|
|
113
|
|
|
$this->assertSame(array( |
114
|
|
|
'type' => 'apiKey', |
115
|
|
|
'description' => 'Some words', |
116
|
|
|
'name' => 'Name', |
117
|
|
|
'in' => 'query', |
118
|
|
|
), $object->toArray()); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
123
|
|
|
*/ |
124
|
|
|
public function testConstructor_Oauth2NoFlow() |
125
|
|
|
{ |
126
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''"); |
127
|
|
|
|
128
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2'); |
|
|
|
|
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
133
|
|
|
*/ |
134
|
|
|
public function testConstructor_Oauth2WrongFlow() |
135
|
|
|
{ |
136
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'"); |
137
|
|
|
|
138
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow'); |
|
|
|
|
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
143
|
|
|
*/ |
144
|
|
|
public function testConstructor_Oauth2ImplicitNoUrl() |
145
|
|
|
{ |
146
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
147
|
|
|
|
148
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit'); |
|
|
|
|
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
153
|
|
|
*/ |
154
|
|
|
public function testConstructor_Oauth2ImplicitBadUrl() |
155
|
|
|
{ |
156
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
157
|
|
|
|
158
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad'); |
|
|
|
|
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
163
|
|
|
*/ |
164
|
|
|
public function testConstructor_Oauth2ImplicitUrl() |
165
|
|
|
{ |
166
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test'); |
167
|
|
|
|
168
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
169
|
|
|
|
170
|
|
|
$this->assertSame(array( |
171
|
|
|
'type' => 'oauth2', |
172
|
|
|
'flow' => 'implicit', |
173
|
|
|
'authorizationUrl' => 'http://www.test', |
174
|
|
|
), $object->toArray()); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
179
|
|
|
*/ |
180
|
|
|
public function testConstructor_Oauth2ImplicitUrlDescription() |
181
|
|
|
{ |
182
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words'); |
183
|
|
|
|
184
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
185
|
|
|
|
186
|
|
|
$this->assertSame(array( |
187
|
|
|
'type' => 'oauth2', |
188
|
|
|
'description' => 'Some words', |
189
|
|
|
'flow' => 'implicit', |
190
|
|
|
'authorizationUrl' => 'http://www.test', |
191
|
|
|
), $object->toArray()); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
196
|
|
|
*/ |
197
|
|
|
public function testConstructor_Oauth2PasswordNoUrl() |
198
|
|
|
{ |
199
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
200
|
|
|
|
201
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password'); |
|
|
|
|
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
206
|
|
|
*/ |
207
|
|
|
public function testConstructor_Oauth2PasswordBadUrl() |
208
|
|
|
{ |
209
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
210
|
|
|
|
211
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad'); |
|
|
|
|
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
216
|
|
|
*/ |
217
|
|
|
public function testConstructor_Oauth2Password() |
218
|
|
|
{ |
219
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test'); |
220
|
|
|
|
221
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
222
|
|
|
|
223
|
|
|
$this->assertSame(array( |
224
|
|
|
'type' => 'oauth2', |
225
|
|
|
'flow' => 'password', |
226
|
|
|
'tokenUrl' => 'http://token.test', |
227
|
|
|
), $object->toArray()); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
232
|
|
|
*/ |
233
|
|
|
public function testConstructor_Oauth2PasswordDescription() |
234
|
|
|
{ |
235
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words'); |
236
|
|
|
|
237
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
238
|
|
|
|
239
|
|
|
$this->assertSame(array( |
240
|
|
|
'type' => 'oauth2', |
241
|
|
|
'description' => 'Some words', |
242
|
|
|
'flow' => 'password', |
243
|
|
|
'tokenUrl' => 'http://token.test', |
244
|
|
|
), $object->toArray()); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
249
|
|
|
*/ |
250
|
|
|
public function testConstructor_Oauth2ApplicationNoUrl() |
251
|
|
|
{ |
252
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
253
|
|
|
|
254
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application'); |
|
|
|
|
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
259
|
|
|
*/ |
260
|
|
|
public function testConstructor_Oauth2ApplicationBadUrl() |
261
|
|
|
{ |
262
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
263
|
|
|
|
264
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad'); |
|
|
|
|
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
269
|
|
|
*/ |
270
|
|
|
public function testConstructor_Oauth2Application() |
271
|
|
|
{ |
272
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test'); |
273
|
|
|
|
274
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
275
|
|
|
|
276
|
|
|
$this->assertSame(array( |
277
|
|
|
'type' => 'oauth2', |
278
|
|
|
'flow' => 'application', |
279
|
|
|
'tokenUrl' => 'http://token.test', |
280
|
|
|
), $object->toArray()); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
285
|
|
|
*/ |
286
|
|
|
public function testConstructor_Oauth2ApplicationDescription() |
287
|
|
|
{ |
288
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words'); |
289
|
|
|
|
290
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
291
|
|
|
|
292
|
|
|
$this->assertSame(array( |
293
|
|
|
'type' => 'oauth2', |
294
|
|
|
'description' => 'Some words', |
295
|
|
|
'flow' => 'application', |
296
|
|
|
'tokenUrl' => 'http://token.test', |
297
|
|
|
), $object->toArray()); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
303
|
|
|
*/ |
304
|
|
|
public function testConstructor_Oauth2AccesscodeNoUrl1() |
305
|
|
|
{ |
306
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
307
|
|
|
|
308
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode'); |
|
|
|
|
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
313
|
|
|
*/ |
314
|
|
|
public function testConstructor_Oauth2AccesscodeBadUrl1() |
315
|
|
|
{ |
316
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
317
|
|
|
|
318
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad'); |
|
|
|
|
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
323
|
|
|
*/ |
324
|
|
|
public function testConstructor_Oauth2AccesscodeNoUrl2() |
325
|
|
|
{ |
326
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
327
|
|
|
|
328
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test'); |
|
|
|
|
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
333
|
|
|
*/ |
334
|
|
|
public function testConstructor_Oauth2AccesscodeBadUrl2() |
335
|
|
|
{ |
336
|
|
|
$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
337
|
|
|
|
338
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad'); |
|
|
|
|
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
343
|
|
|
*/ |
344
|
|
|
public function testConstructor_Oauth2Accesscode() |
345
|
|
|
{ |
346
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
347
|
|
|
|
348
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
349
|
|
|
|
350
|
|
|
$this->assertSame(array( |
351
|
|
|
'type' => 'oauth2', |
352
|
|
|
'flow' => 'accessCode', |
353
|
|
|
'authorizationUrl' => 'http://auth.test', |
354
|
|
|
'tokenUrl' => 'http://token.test', |
355
|
|
|
), $object->toArray()); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
360
|
|
|
*/ |
361
|
|
|
public function testConstructor_Oauth2AccesscodeDescription() |
362
|
|
|
{ |
363
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
364
|
|
|
|
365
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
366
|
|
|
|
367
|
|
|
$this->assertSame(array( |
368
|
|
|
'type' => 'oauth2', |
369
|
|
|
'description' => 'Some words', |
370
|
|
|
'flow' => 'accessCode', |
371
|
|
|
'authorizationUrl' => 'http://auth.test', |
372
|
|
|
'tokenUrl' => 'http://token.test', |
373
|
|
|
), $object->toArray()); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
378
|
|
|
*/ |
379
|
|
|
public function testCommandDescription() |
380
|
|
|
{ |
381
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
382
|
|
|
|
383
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
384
|
|
|
|
385
|
|
|
$object->handleCommand('description', 'Some words'); |
386
|
|
|
|
387
|
|
|
$this->assertSame(array( |
388
|
|
|
'type' => 'oauth2', |
389
|
|
|
'description' => 'Some words', |
390
|
|
|
'flow' => 'accessCode', |
391
|
|
|
'authorizationUrl' => 'http://auth.test', |
392
|
|
|
'tokenUrl' => 'http://token.test', |
393
|
|
|
), $object->toArray()); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
398
|
|
|
*/ |
399
|
|
|
public function testCommandDescriptionEmpty() |
400
|
|
|
{ |
401
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
402
|
|
|
|
403
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
404
|
|
|
|
405
|
|
|
$object->handleCommand('description', ''); |
406
|
|
|
|
407
|
|
|
$this->assertSame(array( |
408
|
|
|
'type' => 'oauth2', |
409
|
|
|
'flow' => 'accessCode', |
410
|
|
|
'authorizationUrl' => 'http://auth.test', |
411
|
|
|
'tokenUrl' => 'http://token.test', |
412
|
|
|
), $object->toArray()); |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
417
|
|
|
*/ |
418
|
|
|
public function testCommandScopeNotOauth() |
419
|
|
|
{ |
420
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
421
|
|
|
|
422
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
423
|
|
|
|
424
|
|
|
$this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'"); |
425
|
|
|
|
426
|
|
|
$object->handleCommand('scope', 'scope1'); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
431
|
|
|
*/ |
432
|
|
|
public function testCommandScope() |
433
|
|
|
{ |
434
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
435
|
|
|
|
436
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
437
|
|
|
|
438
|
|
|
$object->handleCommand('scope', 'scope1'); |
439
|
|
|
|
440
|
|
|
$this->assertSame(array( |
441
|
|
|
'type' => 'oauth2', |
442
|
|
|
'flow' => 'accessCode', |
443
|
|
|
'authorizationUrl' => 'http://auth.test', |
444
|
|
|
'tokenUrl' => 'http://token.test', |
445
|
|
|
'scopes' => array( |
446
|
|
|
'scope1' => '', |
447
|
|
|
) |
448
|
|
|
), $object->toArray()); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
453
|
|
|
*/ |
454
|
|
|
public function testCommandScopeDescription() |
455
|
|
|
{ |
456
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
457
|
|
|
|
458
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
459
|
|
|
|
460
|
|
|
$object->handleCommand('scope', 'scope1 Some text'); |
461
|
|
|
|
462
|
|
|
$this->assertSame(array( |
463
|
|
|
'type' => 'oauth2', |
464
|
|
|
'flow' => 'accessCode', |
465
|
|
|
'authorizationUrl' => 'http://auth.test', |
466
|
|
|
'tokenUrl' => 'http://token.test', |
467
|
|
|
'scopes' => array( |
468
|
|
|
'scope1' => 'Some text', |
469
|
|
|
) |
470
|
|
|
), $object->toArray()); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
475
|
|
|
*/ |
476
|
|
|
public function testCommandScopes() |
477
|
|
|
{ |
478
|
|
|
$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
479
|
|
|
|
480
|
|
|
$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
481
|
|
|
|
482
|
|
|
$object->handleCommand('scope', 'scope2 Some text'); |
483
|
|
|
$object->handleCommand('scope', 'scope1 Some text'); |
484
|
|
|
|
485
|
|
|
$this->assertSame(array( |
486
|
|
|
'type' => 'oauth2', |
487
|
|
|
'flow' => 'accessCode', |
488
|
|
|
'authorizationUrl' => 'http://auth.test', |
489
|
|
|
'tokenUrl' => 'http://token.test', |
490
|
|
|
'scopes' => array( |
491
|
|
|
'scope2' => 'Some text', |
492
|
|
|
'scope1' => 'Some text', |
493
|
|
|
) |
494
|
|
|
), $object->toArray()); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
} |
498
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.