k2hr3-api 1.0.24 → 1.0.26

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.
Files changed (42) hide show
  1. package/ChangeLog +12 -0
  2. package/app.js +63 -30
  3. package/bin/run.sh +14 -0
  4. package/config/default.json +3 -2
  5. package/lib/k2hr3config.js +12 -0
  6. package/lib/k2hr3dkc.js +903 -13
  7. package/lib/k2hr3keys.js +1 -0
  8. package/lib/k2hr3tokens.js +147 -60
  9. package/package.json +10 -5
  10. package/routes/tenant.js +1014 -0
  11. package/routes/userTokens.js +77 -126
  12. package/tests/auto_all_spec.js +4 -0
  13. package/tests/auto_tenant.js +989 -0
  14. package/tests/auto_tenant_spec.js +79 -0
  15. package/tests/auto_usertokens.js +6 -6
  16. package/tests/manual_acr_delete.js +1 -0
  17. package/tests/manual_acr_get.js +1 -0
  18. package/tests/manual_acr_postput.js +1 -0
  19. package/tests/manual_allusertenant_get.js +58 -3
  20. package/tests/manual_extdata_get.js +1 -0
  21. package/tests/manual_list_gethead.js +1 -0
  22. package/tests/manual_policy_delete.js +1 -0
  23. package/tests/manual_policy_gethead.js +3 -1
  24. package/tests/manual_policy_postput.js +1 -0
  25. package/tests/manual_resource_delete.js +1 -0
  26. package/tests/manual_resource_gethead.js +1 -0
  27. package/tests/manual_resource_postput.js +1 -0
  28. package/tests/manual_role_delete.js +2 -0
  29. package/tests/manual_role_gethead.js +4 -0
  30. package/tests/manual_role_postput.js +2 -0
  31. package/tests/manual_service_delete.js +1 -0
  32. package/tests/manual_service_gethead.js +1 -0
  33. package/tests/manual_service_postput.js +1 -0
  34. package/tests/manual_tenant_delete.js +152 -0
  35. package/tests/manual_tenant_gethead.js +268 -0
  36. package/tests/manual_tenant_postput.js +293 -0
  37. package/tests/manual_test.sh +21 -7
  38. package/tests/manual_userdata_get.js +1 -0
  39. package/tests/manual_usertoken_gethead.js +1 -0
  40. package/tests/manual_usertoken_postput.js +1 -0
  41. package/tests/manual_version_get.js +1 -0
  42. package/tests/test.sh +2 -0
@@ -0,0 +1,989 @@
1
+ /*
2
+ * K2HR3 REST API
3
+ *
4
+ * Copyright 2023 Yahoo Japan Corporation.
5
+ *
6
+ * K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
7
+ * common management information for the cloud.
8
+ * K2HR3 can dynamically manage information as "who", "what", "operate".
9
+ * These are stored as roles, resources, policies in K2hdkc, and the
10
+ * client system can dynamically read and modify these information.
11
+ *
12
+ * For the full copyright and license information, please view
13
+ * the license file that was distributed with this source code.
14
+ *
15
+ * AUTHOR: Takeshi Nakatani
16
+ * CREATE: Thu Jul 6 2023
17
+ * REVISION:
18
+ *
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ var common = require('./auto_common'); // Common objects for Chai
24
+ var chai = common.chai;
25
+ var chaiHttp = common.chaiHttp; // eslint-disable-line no-unused-vars
26
+ var app = common.app;
27
+ var assert = common.assert; // eslint-disable-line no-unused-vars
28
+ var expect = common.expect;
29
+ var tokenutil = require('./auto_token_util'); // Token utility
30
+
31
+ //--------------------------------------------------------------
32
+ // Main describe section
33
+ //--------------------------------------------------------------
34
+ describe('API : TENANT', function(){ // eslint-disable-line no-undef
35
+ //
36
+ // Common data
37
+ //
38
+ var alltokens = {};
39
+
40
+ var autotest_post_tenant_0_id = '';
41
+ var autotest_post_tenant_1_id = '';
42
+ var autotest_put_tenant_0_id = '';
43
+ var autotest_put_tenant_1_id = '';
44
+
45
+ //
46
+ // Before in describe section
47
+ //
48
+ before(function(done){ // eslint-disable-line no-undef
49
+ // Nothing to do
50
+ tokenutil.before(this, alltokens, done);
51
+ });
52
+
53
+ //
54
+ // After in describe section
55
+ //
56
+ after(function(){ // eslint-disable-line no-undef
57
+ // Nothing to do
58
+ });
59
+
60
+ //
61
+ // Run Test(POST - CREATE TENANT - SUCCESS/FAILURE)
62
+ //
63
+ it('POST /v1/tenant : create tenant(autotest_post_tenant_0) : success 201', function(done){ // eslint-disable-line no-undef
64
+ chai.request(app)
65
+ .post('/v1/tenant')
66
+ .set('content-type', 'application/json')
67
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
68
+ .send({
69
+ tenant: {
70
+ name: 'autotest_post_tenant_0'
71
+ }
72
+ })
73
+ .end(function(err, res){
74
+ expect(res).to.have.status(201);
75
+ expect(res).to.be.json;
76
+ expect(res.body).to.be.an('object');
77
+ expect(res.body.result).to.be.a('boolean').to.be.true;
78
+ expect(res.body.message).to.be.a('null');
79
+
80
+ //
81
+ // Check resource data(not expand) set by this case.
82
+ //
83
+ chai.request(app)
84
+ .get('/v1/tenant/autotest_post_tenant_0')
85
+ .set('content-type', 'application/json')
86
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
87
+ .end(function(err, res){
88
+ expect(res).to.have.status(200);
89
+ expect(res).to.be.json;
90
+ expect(res.body).to.be.an('object');
91
+ expect(res.body.result).to.be.a('boolean').to.be.true;
92
+ expect(res.body.message).to.be.a('null');
93
+ expect(res.body.tenant).to.be.an('object');
94
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_0');
95
+ expect(res.body.tenant.id).to.be.a('string');
96
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('K2HR3 Cluster Local tenant');
97
+ expect(res.body.tenant.display).to.be.a('string').to.equal('local@autotest_post_tenant_0');
98
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
99
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
100
+
101
+ // backup for "delete" test
102
+ autotest_post_tenant_0_id = res.body.tenant.id;
103
+
104
+ done();
105
+ });
106
+ });
107
+ });
108
+
109
+ it('POST /v1/tenant : create tenant(local@autotest_post_tenant_1) with all: success 201', function(done){ // eslint-disable-line no-undef
110
+ chai.request(app)
111
+ .post('/v1/tenant')
112
+ .set('content-type', 'application/json')
113
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
114
+ .send({
115
+ tenant: {
116
+ name: 'local@autotest_post_tenant_1',
117
+ desc: 'Description for local@autotest_post_tenant_1',
118
+ display: '[LOCAL] local@autotest_post_tenant_1',
119
+ users: ['dummyuser']
120
+ }
121
+ })
122
+ .end(function(err, res){
123
+ expect(res).to.have.status(201);
124
+ expect(res).to.be.json;
125
+ expect(res.body).to.be.an('object');
126
+ expect(res.body.result).to.be.a('boolean').to.be.true;
127
+ expect(res.body.message).to.be.a('null');
128
+
129
+ //
130
+ // Check resource data(not expand) set by this case.
131
+ //
132
+ chai.request(app)
133
+ .get('/v1/tenant/local@autotest_post_tenant_1')
134
+ .set('content-type', 'application/json')
135
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
136
+ .end(function(err, res){
137
+ expect(res).to.have.status(200);
138
+ expect(res).to.be.json;
139
+ expect(res.body).to.be.an('object');
140
+ expect(res.body.result).to.be.a('boolean').to.be.true;
141
+ expect(res.body.message).to.be.a('null');
142
+ expect(res.body.tenant).to.be.an('object');
143
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_1');
144
+ expect(res.body.tenant.id).to.be.a('string');
145
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('Description for local@autotest_post_tenant_1');
146
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[LOCAL] local@autotest_post_tenant_1');
147
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
148
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
149
+
150
+ // backup for "delete" test
151
+ autotest_post_tenant_1_id = res.body.tenant.id;
152
+
153
+ done();
154
+ });
155
+ });
156
+ });
157
+
158
+ it('POST /v1/tenant : create tenant(autotest_post_tenant_0) : failure(exist tenant) 400', function(done){ // eslint-disable-line no-undef
159
+ chai.request(app)
160
+ .post('/v1/tenant')
161
+ .set('content-type', 'application/json')
162
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
163
+ .send({
164
+ tenant: {
165
+ name: 'autotest_post_tenant_0'
166
+ }
167
+ })
168
+ .end(function(err, res){
169
+ expect(res).to.have.status(400);
170
+ expect(res).to.be.json;
171
+ expect(res.body).to.be.an('object');
172
+ expect(res.body.result).to.be.a('boolean').to.be.false;
173
+ expect(res.body.message).to.be.a('string').to.equal('POST request failed to update tenant by failed to create tenant by already tenant(local@autotest_post_tenant_0) existed');
174
+
175
+ done();
176
+ });
177
+ });
178
+
179
+ it('POST /v1/tenant : create tenant(autotest_post_tenant_2) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
180
+ chai.request(app)
181
+ .post('/v1/tenant')
182
+ .set('content-type', 'application/json')
183
+ .send({
184
+ tenant: {
185
+ name: 'autotest_post_tenant_2',
186
+ desc: 'Description for autotest_post_tenant_2',
187
+ display: '[LOCAL] autotest_post_tenant_2',
188
+ users: ['dummyuser']
189
+ }
190
+ })
191
+ .end(function(err, res){
192
+ expect(res).to.have.status(400);
193
+ expect(res).to.be.json;
194
+ expect(res.body).to.be.an('object');
195
+ expect(res.body.result).to.be.a('boolean').to.be.false;
196
+ expect(res.body.message).to.be.a('string').to.equal('POST request tenant must specify <User Token>');
197
+
198
+ done();
199
+ });
200
+ });
201
+
202
+ //
203
+ // Run Test(PUT - CREATE TENANT - SUCCESS/FAILURE)
204
+ //
205
+ it('PUT /v1/tenant : create tenant(autotest_put_tenant_0) : success 201', function(done){ // eslint-disable-line no-undef
206
+ var uri = '/v1/tenant';
207
+ uri += '?name=autotest_put_tenant_0'; // name: autotest_put_tenant_0
208
+
209
+ chai.request(app)
210
+ .put(uri)
211
+ .set('content-type', 'application/json')
212
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
213
+ .end(function(err, res){
214
+ expect(res).to.have.status(201);
215
+ expect(res).to.be.json;
216
+ expect(res.body).to.be.an('object');
217
+ expect(res.body.result).to.be.a('boolean').to.be.true;
218
+ expect(res.body.message).to.be.a('null');
219
+
220
+ //
221
+ // Check resource data(not expand) set by this case.
222
+ //
223
+ chai.request(app)
224
+ .get('/v1/tenant/autotest_put_tenant_0')
225
+ .set('content-type', 'application/json')
226
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
227
+ .end(function(err, res){
228
+ expect(res).to.have.status(200);
229
+ expect(res).to.be.json;
230
+ expect(res.body).to.be.an('object');
231
+ expect(res.body.result).to.be.a('boolean').to.be.true;
232
+ expect(res.body.message).to.be.a('null');
233
+ expect(res.body.tenant).to.be.an('object');
234
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_put_tenant_0');
235
+ expect(res.body.tenant.id).to.be.a('string');
236
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('K2HR3 Cluster Local tenant');
237
+ expect(res.body.tenant.display).to.be.a('string').to.equal('local@autotest_put_tenant_0');
238
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
239
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
240
+
241
+ // backup for "delete" test
242
+ autotest_put_tenant_0_id = res.body.tenant.id;
243
+
244
+ done();
245
+ });
246
+ });
247
+ });
248
+
249
+ it('PUT /v1/tenant : create tenant(local@autotest_put_tenant_1) with all: success 201', function(done){ // eslint-disable-line no-undef
250
+ var uri = '/v1/tenant';
251
+ uri += '?name=local@autotest_put_tenant_1'; // name: local@autotest_put_tenant_1
252
+ uri += '&desc=Description_for_local@autotest_put_tenant_1'; // desc: string
253
+ uri += '&display=[LOCAL]local@autotest_put_tenant_1'; // display: string
254
+ uri += '&users=' + JSON.stringify(['dummyuser']); // users: [dummyuser]
255
+
256
+ chai.request(app)
257
+ .put(uri)
258
+ .set('content-type', 'application/json')
259
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
260
+ .end(function(err, res){
261
+ expect(res).to.have.status(201);
262
+ expect(res).to.be.json;
263
+ expect(res.body).to.be.an('object');
264
+ expect(res.body.result).to.be.a('boolean').to.be.true;
265
+ expect(res.body.message).to.be.a('null');
266
+
267
+ //
268
+ // Check resource data(not expand) set by this case.
269
+ //
270
+ chai.request(app)
271
+ .get('/v1/tenant/local@autotest_put_tenant_1')
272
+ .set('content-type', 'application/json')
273
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
274
+ .end(function(err, res){
275
+ expect(res).to.have.status(200);
276
+ expect(res).to.be.json;
277
+ expect(res.body).to.be.an('object');
278
+ expect(res.body.result).to.be.a('boolean').to.be.true;
279
+ expect(res.body.message).to.be.a('null');
280
+ expect(res.body.tenant).to.be.an('object');
281
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_put_tenant_1');
282
+ expect(res.body.tenant.id).to.be.a('string');
283
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('Description_for_local@autotest_put_tenant_1');
284
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[LOCAL]local@autotest_put_tenant_1');
285
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
286
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
287
+
288
+ // backup for "delete" test
289
+ autotest_put_tenant_1_id = res.body.tenant.id;
290
+
291
+ done();
292
+ });
293
+ });
294
+ });
295
+
296
+ it('PUT /v1/tenant : create tenant(autotest_put_tenant_0) : failure(exist tenant) 400', function(done){ // eslint-disable-line no-undef
297
+ var uri = '/v1/tenant';
298
+ uri += '?name=autotest_put_tenant_0'; // name: autotest_put_tenant_0
299
+
300
+ chai.request(app)
301
+ .put(uri)
302
+ .set('content-type', 'application/json')
303
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
304
+ .end(function(err, res){
305
+ expect(res).to.have.status(400);
306
+ expect(res).to.be.json;
307
+ expect(res.body).to.be.an('object');
308
+ expect(res.body.result).to.be.a('boolean').to.be.false;
309
+ expect(res.body.message).to.be.a('string').to.equal('PUT request failed to update tenant by failed to create tenant by already tenant(local@autotest_put_tenant_0) existed');
310
+
311
+ done();
312
+ });
313
+ });
314
+
315
+ it('PUT /v1/tenant : create tenant(autotest_put_tenant_2) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
316
+ var uri = '/v1/tenant';
317
+ uri += '?name=autotest_put_tenant_2'; // name: autotest_put_tenant_2
318
+ uri += '&desc=Description_for_autotest_put_tenant_2'; // desc: string
319
+ uri += '&display=[LOCAL]autotest_put_tenant_2'; // display: string
320
+ uri += '&users=' + JSON.stringify(['dummyuser']); // users: [dummyuser]
321
+
322
+ chai.request(app)
323
+ .put(uri)
324
+ .set('content-type', 'application/json')
325
+ .end(function(err, res){
326
+ expect(res).to.have.status(400);
327
+ expect(res).to.be.json;
328
+ expect(res.body).to.be.an('object');
329
+ expect(res.body.result).to.be.a('boolean').to.be.false;
330
+ expect(res.body.message).to.be.a('string').to.equal('PUT request tenant must specify <User Token>');
331
+
332
+ done();
333
+ });
334
+ });
335
+
336
+ //
337
+ // Run Test(POST - UPDATE TENANT - SUCCESS/FAILURE)
338
+ //
339
+ it('POST /v1/tenant/<tenant> : update tenant(autotest_post_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
340
+ chai.request(app)
341
+ .post('/v1/tenant/autotest_post_tenant_0')
342
+ .set('content-type', 'application/json')
343
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
344
+ .send({
345
+ tenant: {
346
+ id: autotest_post_tenant_0_id, // correct id
347
+ desc: 'K2HR3 Cluster Local tenant(updated)', // changed
348
+ display: '[UPDATED] autotest_post_tenant_0', // changed
349
+ users: ['dummyuser'] // not changed(because there is one user in test data)
350
+ }
351
+ })
352
+ .end(function(err, res){
353
+ expect(res).to.have.status(200);
354
+ expect(res).to.be.json;
355
+ expect(res.body).to.be.an('object');
356
+ expect(res.body.result).to.be.a('boolean').to.be.true;
357
+ expect(res.body.message).to.be.a('null');
358
+
359
+ //
360
+ // Check resource data(not expand) set by this case.
361
+ //
362
+ chai.request(app)
363
+ .get('/v1/tenant/autotest_post_tenant_0')
364
+ .set('content-type', 'application/json')
365
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
366
+ .end(function(err, res){
367
+ expect(res).to.have.status(200);
368
+ expect(res).to.be.json;
369
+ expect(res.body).to.be.an('object');
370
+ expect(res.body.result).to.be.a('boolean').to.be.true;
371
+ expect(res.body.message).to.be.a('null');
372
+ expect(res.body.tenant).to.be.an('object');
373
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_0');
374
+ expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_post_tenant_0_id);
375
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('K2HR3 Cluster Local tenant(updated)');
376
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED] autotest_post_tenant_0');
377
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
378
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
379
+
380
+ done();
381
+ });
382
+ });
383
+ });
384
+
385
+ it('POST /v1/tenant/<tenant> : update tenant(local@autotest_post_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
386
+ chai.request(app)
387
+ .post('/v1/tenant/local@autotest_post_tenant_1')
388
+ .set('content-type', 'application/json')
389
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
390
+ .send({
391
+ tenant: {
392
+ id: autotest_post_tenant_1_id, // correct id
393
+ desc: 'Updated local@autotest_post_tenant_1', // changed
394
+ display: '[UPDATED] local@autotest_post_tenant_1', // changed
395
+ users: ['dummyuser'] // not changed(because there is one user in test data)
396
+ }
397
+ })
398
+ .end(function(err, res){
399
+ expect(res).to.have.status(200);
400
+ expect(res).to.be.json;
401
+ expect(res.body).to.be.an('object');
402
+ expect(res.body.result).to.be.a('boolean').to.be.true;
403
+ expect(res.body.message).to.be.a('null');
404
+
405
+ //
406
+ // Check resource data(not expand) set by this case.
407
+ //
408
+ chai.request(app)
409
+ .get('/v1/tenant/local@autotest_post_tenant_1')
410
+ .set('content-type', 'application/json')
411
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
412
+ .end(function(err, res){
413
+ expect(res).to.have.status(200);
414
+ expect(res).to.be.json;
415
+ expect(res.body).to.be.an('object');
416
+ expect(res.body.result).to.be.a('boolean').to.be.true;
417
+ expect(res.body.message).to.be.a('null');
418
+ expect(res.body.tenant).to.be.an('object');
419
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_1');
420
+ expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_post_tenant_1_id);
421
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('Updated local@autotest_post_tenant_1');
422
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED] local@autotest_post_tenant_1');
423
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
424
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
425
+
426
+ done();
427
+ });
428
+ });
429
+ });
430
+
431
+ it('POST /v1/tenant/<tenant> : update tenant(autotest_post_tenant_3) : failure(not exist tenant) 400', function(done){ // eslint-disable-line no-undef
432
+ chai.request(app)
433
+ .post('/v1/tenant/autotest_post_tenant_3')
434
+ .set('content-type', 'application/json')
435
+ .send({
436
+ tenant: {
437
+ id: 'autotest_post_tenant_0_id', // wrong id
438
+ desc: 'K2HR3 Cluster Local tenant(updated)', // changed
439
+ display: '[UPDATED] autotest_post_tenant_3', // changed
440
+ users: ['dummyuser'] // not changed(because there is one user in test data)
441
+ }
442
+ })
443
+ .end(function(err, res){
444
+ expect(res).to.have.status(400);
445
+ expect(res).to.be.json;
446
+ expect(res.body).to.be.an('object');
447
+ expect(res.body.result).to.be.a('boolean').to.be.false;
448
+ expect(res.body.message).to.be.a('string').to.equal('POST request tenant must specify <User Token>');
449
+
450
+ done();
451
+ });
452
+ });
453
+
454
+ it('POST /v1/tenant/<tenant> : update tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
455
+ chai.request(app)
456
+ .post('/v1/tenant/autotest_post_tenant_0')
457
+ .set('content-type', 'application/json')
458
+ .send({
459
+ tenant: {
460
+ id: autotest_post_tenant_0_id, // correct id
461
+ desc: 'K2HR3 Cluster Local tenant(updated2)', // changed
462
+ display: '[UPDATED2] autotest_post_tenant_0', // changed
463
+ users: ['dummyuser'] // not changed(because there is one user in test data)
464
+ }
465
+ })
466
+ .end(function(err, res){
467
+ expect(res).to.have.status(400);
468
+ expect(res).to.be.json;
469
+ expect(res.body).to.be.an('object');
470
+ expect(res.body.result).to.be.a('boolean').to.be.false;
471
+ expect(res.body.message).to.be.a('string').to.equal('POST request tenant must specify <User Token>');
472
+
473
+ done();
474
+ });
475
+ });
476
+
477
+ it('POST /v1/tenant/<tenant> : update tenant(autotest_post_tenant_0) : failure(no id) 400', function(done){ // eslint-disable-line no-undef
478
+ chai.request(app)
479
+ .post('/v1/tenant/autotest_post_tenant_0')
480
+ .set('content-type', 'application/json')
481
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
482
+ .send({
483
+ tenant: {
484
+ desc: 'K2HR3 Cluster Local tenant(updated3)', // changed
485
+ display: '[UPDATED3] autotest_post_tenant_0', // changed
486
+ users: ['dummyuser'] // not changed(because there is one user in test data)
487
+ }
488
+ })
489
+ .end(function(err, res){
490
+ expect(res).to.have.status(400);
491
+ expect(res).to.be.json;
492
+ expect(res.body).to.be.an('object');
493
+ expect(res.body.result).to.be.a('boolean').to.be.false;
494
+ expect(res.body.message).to.be.a('string').to.equal('POST request tenant(local@autotest_post_tenant_0) body does not have tenant.id string object.');
495
+
496
+ done();
497
+ });
498
+ });
499
+
500
+ //
501
+ // Run Test(PUT - UPDATE TENANT - SUCCESS/FAILURE)
502
+ //
503
+ it('PUT /v1/tenant/<tenant> : update tenant(autotest_put_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
504
+ var uri = '/v1/tenant/autotest_put_tenant_0';
505
+ uri += '?id=' + autotest_put_tenant_0_id; // correct id
506
+ uri += '&desc=Updated_autotest_put_tenant_0'; // changed
507
+ uri += '&display=[UPDATED]autotest_put_tenant_0'; // chnaged
508
+ uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
509
+
510
+ chai.request(app)
511
+ .put(uri)
512
+ .set('content-type', 'application/json')
513
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
514
+ .end(function(err, res){
515
+ expect(res).to.have.status(200);
516
+ expect(res).to.be.json;
517
+ expect(res.body).to.be.an('object');
518
+ expect(res.body.result).to.be.a('boolean').to.be.true;
519
+ expect(res.body.message).to.be.a('null');
520
+
521
+ //
522
+ // Check resource data(not expand) set by this case.
523
+ //
524
+ chai.request(app)
525
+ .get('/v1/tenant/autotest_put_tenant_0')
526
+ .set('content-type', 'application/json')
527
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
528
+ .end(function(err, res){
529
+ expect(res).to.have.status(200);
530
+ expect(res).to.be.json;
531
+ expect(res.body).to.be.an('object');
532
+ expect(res.body.result).to.be.a('boolean').to.be.true;
533
+ expect(res.body.message).to.be.a('null');
534
+ expect(res.body.tenant).to.be.an('object');
535
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_put_tenant_0');
536
+ expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_put_tenant_0_id);
537
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('Updated_autotest_put_tenant_0');
538
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED]autotest_put_tenant_0');
539
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
540
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
541
+
542
+ done();
543
+ });
544
+ });
545
+ });
546
+
547
+ it('PUT /v1/tenant/<tenant> : update tenant(local@autotest_put_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
548
+ var uri = '/v1/tenant/local@autotest_put_tenant_1';
549
+ uri += '?id=' + autotest_put_tenant_1_id; // correct id
550
+ uri += '&desc=Updated_local@autotest_put_tenant_1'; // changed
551
+ uri += '&display=[UPDATED]local@autotest_put_tenant_1'; // chnaged
552
+ uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
553
+
554
+ chai.request(app)
555
+ .put(uri)
556
+ .set('content-type', 'application/json')
557
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
558
+ .end(function(err, res){
559
+ expect(res).to.have.status(200);
560
+ expect(res).to.be.json;
561
+ expect(res.body).to.be.an('object');
562
+ expect(res.body.result).to.be.a('boolean').to.be.true;
563
+ expect(res.body.message).to.be.a('null');
564
+
565
+ //
566
+ // Check resource data(not expand) set by this case.
567
+ //
568
+ chai.request(app)
569
+ .get('/v1/tenant/local@autotest_put_tenant_1')
570
+ .set('content-type', 'application/json')
571
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
572
+ .end(function(err, res){
573
+ expect(res).to.have.status(200);
574
+ expect(res).to.be.json;
575
+ expect(res.body).to.be.an('object');
576
+ expect(res.body.result).to.be.a('boolean').to.be.true;
577
+ expect(res.body.message).to.be.a('null');
578
+ expect(res.body.tenant).to.be.an('object');
579
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_put_tenant_1');
580
+ expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_put_tenant_1_id);
581
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('Updated_local@autotest_put_tenant_1');
582
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED]local@autotest_put_tenant_1');
583
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
584
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
585
+
586
+ done();
587
+ });
588
+ });
589
+ });
590
+
591
+ it('PUT /v1/tenant/<tenant> : update tenant(autotest_put_tenant_3) : failure(not exist tenant) 400', function(done){ // eslint-disable-line no-undef
592
+ var uri = '/v1/tenant/autotest_put_tenant_3';
593
+ uri += '?id=' + autotest_put_tenant_0_id; // wrong id
594
+ uri += '&desc=Updated_autotest_put_tenant_3'; // changed
595
+ uri += '&display=[UPDATED]autotest_put_tenant_3'; // chnaged
596
+ uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
597
+
598
+ chai.request(app)
599
+ .put(uri)
600
+ .set('content-type', 'application/json')
601
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
602
+ .end(function(err, res){
603
+ expect(res).to.have.status(400);
604
+ expect(res).to.be.json;
605
+ expect(res.body).to.be.an('object');
606
+ expect(res.body.result).to.be.a('boolean').to.be.false;
607
+ expect(res.body.message).to.be.a('string').to.have.string('PUT request failed to update tenant by failed to update tenant by could not find tenant(local@autotest_put_tenant_3) with user="dummyuser" and id=');
608
+
609
+ done();
610
+ });
611
+ });
612
+
613
+ it('PUT /v1/tenant/<tenant> : update tenant(autotest_put_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
614
+ var uri = '/v1/tenant/autotest_put_tenant_0';
615
+ uri += '?id=' + autotest_put_tenant_0_id; // correct id
616
+ uri += '&desc=Updated2_autotest_put_tenant_0'; // changed
617
+ uri += '&display=[UPDATED2]autotest_put_tenant_0'; // chnaged
618
+ uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
619
+
620
+ chai.request(app)
621
+ .put(uri)
622
+ .set('content-type', 'application/json')
623
+ .end(function(err, res){
624
+ expect(res).to.have.status(400);
625
+ expect(res).to.be.json;
626
+ expect(res.body).to.be.an('object');
627
+ expect(res.body.result).to.be.a('boolean').to.be.false;
628
+ expect(res.body.message).to.be.a('string').to.equal('PUT request tenant must specify <User Token>');
629
+
630
+ done();
631
+ });
632
+ });
633
+
634
+ it('PUT /v1/tenant/<tenant> : update tenant(autotest_put_tenant_0) : failure(no id) 400', function(done){ // eslint-disable-line no-undef
635
+ var uri = '/v1/tenant/autotest_put_tenant_0';
636
+ uri += '?desc=Updated_autotest_put_tenant_0'; // changed
637
+ uri += '&display=[UPDATED]autotest_put_tenant_0'; // chnaged
638
+ uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
639
+
640
+ chai.request(app)
641
+ .put(uri)
642
+ .set('content-type', 'application/json')
643
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
644
+ .end(function(err, res){
645
+ expect(res).to.have.status(400);
646
+ expect(res).to.be.json;
647
+ expect(res.body).to.be.an('object');
648
+ expect(res.body.result).to.be.a('boolean').to.be.false;
649
+ expect(res.body.message).to.be.a('string').to.equal('PUT request tenant(local@autotest_put_tenant_0) body does not have tenant.id string object.');
650
+
651
+ done();
652
+ });
653
+ });
654
+
655
+ //
656
+ // Run Test(GET - TENANT LIST - SUCCESS/FAILURE)
657
+ //
658
+ it('GET /v1/tenant : get tenant list and expanding : success 200', function(done){ // eslint-disable-line no-undef
659
+ chai.request(app)
660
+ .get('/v1/tenant?expand=true') // expand: true
661
+ .set('content-type', 'application/json')
662
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
663
+ .end(function(err, res){
664
+ expect(res).to.have.status(200);
665
+ expect(res).to.be.json;
666
+ expect(res.body).to.be.an('object');
667
+ expect(res.body.result).to.be.a('boolean').to.be.true;
668
+ expect(res.body.message).to.be.a('null');
669
+ expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(4);
670
+ expect(res.body.tenants[0]).to.be.an('object');
671
+ expect(res.body.tenants[0].name).to.be.a('string'); // not check string
672
+ expect(res.body.tenants[0].id).to.be.a('string'); // not check string
673
+ expect(res.body.tenants[0].desc).to.be.a('string'); // not check string
674
+ expect(res.body.tenants[0].display).to.be.a('string'); // not check string
675
+ expect(res.body.tenants[0].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
676
+ expect(res.body.tenants[1]).to.be.an('object');
677
+ expect(res.body.tenants[1].name).to.be.a('string'); // not check string
678
+ expect(res.body.tenants[1].id).to.be.a('string'); // not check string
679
+ expect(res.body.tenants[1].desc).to.be.a('string'); // not check string
680
+ expect(res.body.tenants[1].display).to.be.a('string'); // not check string
681
+ expect(res.body.tenants[1].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
682
+ expect(res.body.tenants[2]).to.be.an('object');
683
+ expect(res.body.tenants[2].name).to.be.a('string'); // not check string
684
+ expect(res.body.tenants[2].id).to.be.a('string'); // not check string
685
+ expect(res.body.tenants[2].desc).to.be.a('string'); // not check string
686
+ expect(res.body.tenants[2].display).to.be.a('string'); // not check string
687
+ expect(res.body.tenants[2].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
688
+ expect(res.body.tenants[3]).to.be.an('object');
689
+ expect(res.body.tenants[3].name).to.be.a('string'); // not check string
690
+ expect(res.body.tenants[3].id).to.be.a('string'); // not check string
691
+ expect(res.body.tenants[3].desc).to.be.a('string'); // not check string
692
+ expect(res.body.tenants[3].display).to.be.a('string'); // not check string
693
+ expect(res.body.tenants[3].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
694
+
695
+ done();
696
+ });
697
+ });
698
+
699
+ it('GET /v1/tenant : get tenant list and no expanding: success 200', function(done){ // eslint-disable-line no-undef
700
+ chai.request(app)
701
+ .get('/v1/tenant?expand=false') // expand: false
702
+ .set('content-type', 'application/json')
703
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
704
+ .end(function(err, res){
705
+ expect(res).to.have.status(200);
706
+ expect(res).to.be.json;
707
+ expect(res.body).to.be.an('object');
708
+ expect(res.body.result).to.be.a('boolean').to.be.true;
709
+ expect(res.body.message).to.be.a('null');
710
+ expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(4);
711
+ expect(res.body.tenants[0]).to.be.a('string'); // not check string
712
+ expect(res.body.tenants[1]).to.be.a('string'); // not check string
713
+ expect(res.body.tenants[2]).to.be.a('string'); // not check string
714
+ expect(res.body.tenants[3]).to.be.a('string'); // not check string
715
+
716
+ done();
717
+ });
718
+ });
719
+
720
+ it('GET /v1/tenant : get tenant list and expanding : failure(no token) 400', function(done){ // eslint-disable-line no-undef
721
+ chai.request(app)
722
+ .get('/v1/tenant?expand=true') // expand: true
723
+ .set('content-type', 'application/json')
724
+ .end(function(err, res){
725
+ expect(res).to.have.status(400);
726
+ expect(res).to.be.json;
727
+ expect(res.body).to.be.an('object');
728
+ expect(res.body.result).to.be.a('boolean').to.be.false;
729
+ expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
730
+
731
+ done();
732
+ });
733
+ });
734
+
735
+ it('GET /v1/tenant : get tenant list and no expanding: failure(no token) 400', function(done){ // eslint-disable-line no-undef
736
+ chai.request(app)
737
+ .get('/v1/tenant?expand=false') // expand: false
738
+ .set('content-type', 'application/json')
739
+ .end(function(err, res){
740
+ expect(res).to.have.status(400);
741
+ expect(res).to.be.json;
742
+ expect(res.body).to.be.an('object');
743
+ expect(res.body.result).to.be.a('boolean').to.be.false;
744
+ expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
745
+
746
+ done();
747
+ });
748
+ });
749
+
750
+ //
751
+ // Run Test(GET - TENANT INFORMATION - SUCCESS/FAILURE)
752
+ //
753
+ it('GET /v1/tenant/<tenant> : get tenant(autotest_post_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
754
+ chai.request(app)
755
+ .get('/v1/tenant/autotest_post_tenant_0') // specify tenant name
756
+ .set('content-type', 'application/json')
757
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
758
+ .end(function(err, res){
759
+ expect(res).to.have.status(200);
760
+ expect(res).to.be.json;
761
+ expect(res.body).to.be.an('object');
762
+ expect(res.body.result).to.be.a('boolean').to.be.true;
763
+ expect(res.body.message).to.be.a('null');
764
+ expect(res.body.tenant).to.be.an('object');
765
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_0');
766
+ expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_post_tenant_0_id);
767
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('K2HR3 Cluster Local tenant(updated)');
768
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED] autotest_post_tenant_0');
769
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
770
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
771
+
772
+ done();
773
+ });
774
+ });
775
+
776
+ it('GET /v1/tenant/<tenant> : get tenant(local@autotest_post_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
777
+ chai.request(app)
778
+ .get('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name with prefix
779
+ .set('content-type', 'application/json')
780
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
781
+ .end(function(err, res){
782
+ expect(res).to.have.status(200);
783
+ expect(res).to.be.json;
784
+ expect(res.body).to.be.an('object');
785
+ expect(res.body.result).to.be.a('boolean').to.be.true;
786
+ expect(res.body.message).to.be.a('null');
787
+ expect(res.body.tenant).to.be.an('object');
788
+ expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_1');
789
+ expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_post_tenant_1_id);
790
+ expect(res.body.tenant.desc).to.be.a('string').to.equal('Updated local@autotest_post_tenant_1');
791
+ expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED] local@autotest_post_tenant_1');
792
+ expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
793
+ expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
794
+
795
+ done();
796
+ });
797
+ });
798
+
799
+ it('GET /v1/tenant/<tenant> : get tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
800
+ chai.request(app)
801
+ .get('/v1/tenant/autotest_post_tenant_0') // specify tenant name
802
+ .set('content-type', 'application/json')
803
+ .end(function(err, res){
804
+ expect(res).to.have.status(400);
805
+ expect(res).to.be.json;
806
+ expect(res.body).to.be.an('object');
807
+ expect(res.body.result).to.be.a('boolean').to.be.false;
808
+ expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
809
+
810
+ done();
811
+ });
812
+ });
813
+
814
+ it('GET /v1/tenant/<tenant> : get tenant(local@autotest_post_tenant_1) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
815
+ chai.request(app)
816
+ .get('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name
817
+ .set('content-type', 'application/json')
818
+ .end(function(err, res){
819
+ expect(res).to.have.status(400);
820
+ expect(res).to.be.json;
821
+ expect(res.body).to.be.an('object');
822
+ expect(res.body.result).to.be.a('boolean').to.be.false;
823
+ expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
824
+
825
+ done();
826
+ });
827
+ });
828
+
829
+ it('GET /v1/tenant/<tenant> : get tenant(autotest_post_tenant_X) : failure(no tenant) 400', function(done){ // eslint-disable-line no-undef
830
+ chai.request(app)
831
+ .get('/v1/tenant/autotest_post_tenant_X') // specify tenant name
832
+ .set('content-type', 'application/json')
833
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
834
+ .end(function(err, res){
835
+ expect(res).to.have.status(400);
836
+ expect(res).to.be.json;
837
+ expect(res.body).to.be.an('object');
838
+ expect(res.body.result).to.be.a('boolean').to.be.false;
839
+ expect(res.body.message).to.be.a('string').to.equal('GET request failed to update tenant by could not find tenant(local@autotest_post_tenant_x) with user=undefined and id=undefined');
840
+
841
+ done();
842
+ });
843
+ });
844
+
845
+ //
846
+ // Run Test(HEAD - TENANT - SUCCESS/FAILURE)
847
+ //
848
+ it('HEAD /v1/tenant/<tenant> : head tenant(autotest_post_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
849
+ chai.request(app)
850
+ .head('/v1/tenant/autotest_post_tenant_0') // specify tenant name
851
+ .set('content-type', 'application/json')
852
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
853
+ .end(function(err, res){
854
+ expect(res).to.have.status(204);
855
+
856
+ done();
857
+ });
858
+ });
859
+
860
+ it('HEAD /v1/tenant/<tenant> : head tenant(local@autotest_post_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
861
+ chai.request(app)
862
+ .head('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name with prefix
863
+ .set('content-type', 'application/json')
864
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
865
+ .end(function(err, res){
866
+ expect(res).to.have.status(204);
867
+
868
+ done();
869
+ });
870
+ });
871
+
872
+ it('HEAD /v1/tenant/<tenant> : head tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
873
+ chai.request(app)
874
+ .head('/v1/tenant/autotest_post_tenant_0') // specify tenant name
875
+ .set('content-type', 'application/json')
876
+ .end(function(err, res){
877
+ expect(res).to.have.status(400);
878
+
879
+ done();
880
+ });
881
+ });
882
+
883
+ it('HEAD /v1/tenant/<tenant> : head tenant(local@autotest_post_tenant_1) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
884
+ chai.request(app)
885
+ .head('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name
886
+ .set('content-type', 'application/json')
887
+ .end(function(err, res){
888
+ expect(res).to.have.status(400);
889
+
890
+ done();
891
+ });
892
+ });
893
+
894
+ it('HEAD /v1/tenant/<tenant> : head tenant(autotest_post_tenant_X) : failure(no tenant) 400', function(done){ // eslint-disable-line no-undef
895
+ chai.request(app)
896
+ .head('/v1/tenant/autotest_post_tenant_X') // specify tenant name
897
+ .set('content-type', 'application/json')
898
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
899
+ .end(function(err, res){
900
+ expect(res).to.have.status(400);
901
+
902
+ done();
903
+ });
904
+ });
905
+
906
+ //
907
+ // Run Test(DELETE - TENANT - SUCCESS/FAILURE)
908
+ //
909
+ it('DELETE /v1/tenant/<tenant> : delete tenant(autotest_put_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
910
+ var uri = '/v1/tenant/autotest_put_tenant_0'; // tenant name
911
+ uri += '?id=' + autotest_put_tenant_0_id; // correct id
912
+
913
+ chai.request(app)
914
+ .delete(uri)
915
+ .set('content-type', 'application/json')
916
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
917
+ .end(function(err, res){
918
+ expect(res).to.have.status(204);
919
+
920
+ done();
921
+ });
922
+ });
923
+
924
+ it('DELETE /v1/tenant/<tenant> : delete tenant(local@autotest_put_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
925
+ var uri = '/v1/tenant/local@autotest_put_tenant_1'; // tenant name
926
+ uri += '?id=' + autotest_put_tenant_1_id; // correct id
927
+
928
+ chai.request(app)
929
+ .delete(uri)
930
+ .set('content-type', 'application/json')
931
+ .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
932
+ .end(function(err, res){
933
+ expect(res).to.have.status(204);
934
+
935
+ done();
936
+ });
937
+ });
938
+
939
+ it('DELETE /v1/tenant/<tenant> : delete tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
940
+ var uri = '/v1/tenant/autotest_post_tenant_0'; // tenant name
941
+ uri += '?id=' + autotest_post_tenant_0_id; // correct id
942
+
943
+ chai.request(app)
944
+ .delete(uri)
945
+ .set('content-type', 'application/json')
946
+ .end(function(err, res){
947
+ expect(res).to.have.status(400);
948
+
949
+ done();
950
+ });
951
+ });
952
+
953
+ it('DELETE /v1/tenant/<tenant> : delete tenant(local@autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
954
+ var uri = '/v1/tenant/local@autotest_post_tenant_0'; // tenant name
955
+ uri += '?id=' + autotest_post_tenant_0_id; // correct id
956
+
957
+ chai.request(app)
958
+ .delete(uri)
959
+ .set('content-type', 'application/json')
960
+ .end(function(err, res){
961
+ expect(res).to.have.status(400);
962
+
963
+ done();
964
+ });
965
+ });
966
+
967
+ it('DELETE /v1/tenant/<tenant> : delete tenant(autotest_post_tenant_X) : failure(no exist tenant) 400', function(done){ // eslint-disable-line no-undef
968
+ var uri = '/v1/tenant/autotest_post_tenant_X'; // not exist tenant name
969
+ uri += '?id=' + autotest_post_tenant_0_id; // wrong id
970
+
971
+ chai.request(app)
972
+ .delete(uri)
973
+ .set('content-type', 'application/json')
974
+ .end(function(err, res){
975
+ expect(res).to.have.status(400);
976
+
977
+ done();
978
+ });
979
+ });
980
+ });
981
+
982
+ /*
983
+ * Local variables:
984
+ * tab-width: 4
985
+ * c-basic-offset: 4
986
+ * End:
987
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
988
+ * vim<600: noexpandtab sw=4 ts=4
989
+ */