k2hr3-api 1.0.42 → 2.0.0

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 (149) hide show
  1. package/config/k2hr3-init.sh.templ +2 -2
  2. package/dist/.gitkeep +0 -0
  3. package/dist/src/app.js +262 -0
  4. package/{bin → dist/src/bin}/run.sh +1 -1
  5. package/dist/src/bin/watcher.js +113 -0
  6. package/dist/src/bin/www.js +217 -0
  7. package/dist/src/lib/basicipcheck.js +392 -0
  8. package/dist/src/lib/cacerts.js +106 -0
  9. package/dist/src/lib/dbglogging.js +190 -0
  10. package/dist/src/lib/dummyuserapi.js +719 -0
  11. package/dist/src/lib/ipwatch.js +354 -0
  12. package/dist/src/lib/k2hr3acrutil.js +532 -0
  13. package/dist/src/lib/k2hr3apiutil.js +1444 -0
  14. package/dist/src/lib/k2hr3cliutil.js +183 -0
  15. package/dist/src/lib/k2hr3config.js +832 -0
  16. package/dist/src/lib/k2hr3cryptutil.js +258 -0
  17. package/dist/src/lib/k2hr3dkc.js +12121 -0
  18. package/dist/src/lib/k2hr3extdata.js +198 -0
  19. package/dist/src/lib/k2hr3keys.js +207 -0
  20. package/dist/src/lib/k2hr3resutil.js +111 -0
  21. package/dist/src/lib/k2hr3template.js +6546 -0
  22. package/dist/src/lib/k2hr3tokens.js +2643 -0
  23. package/dist/src/lib/k2hr3userdata.js +296 -0
  24. package/dist/src/lib/k8soidc.js +1000 -0
  25. package/dist/src/lib/openstackapiv2.js +695 -0
  26. package/dist/src/lib/openstackapiv3.js +932 -0
  27. package/dist/src/lib/openstackep.js +667 -0
  28. package/{tests/auto_common.js → dist/src/lib/types.js} +4 -38
  29. package/dist/src/routes/acr.js +704 -0
  30. package/dist/src/routes/debugVerify.js +294 -0
  31. package/dist/src/routes/extdata.js +219 -0
  32. package/dist/src/routes/list.js +264 -0
  33. package/dist/src/routes/policy.js +840 -0
  34. package/dist/src/routes/resource.js +1489 -0
  35. package/dist/src/routes/role.js +2627 -0
  36. package/dist/src/routes/service.js +908 -0
  37. package/dist/src/routes/tenant.js +1141 -0
  38. package/dist/src/routes/userTokens.js +482 -0
  39. package/dist/src/routes/userdata.js +212 -0
  40. package/dist/src/routes/version.js +103 -0
  41. package/package.json +152 -121
  42. package/ChangeLog +0 -378
  43. package/app.js +0 -292
  44. package/bin/watcher +0 -122
  45. package/bin/www +0 -180
  46. package/eslint.config.mjs +0 -68
  47. package/lib/basicipcheck.js +0 -376
  48. package/lib/cacerts.js +0 -71
  49. package/lib/dbglogging.js +0 -151
  50. package/lib/dummyuserapi.js +0 -766
  51. package/lib/ipwatch.js +0 -379
  52. package/lib/k2hr3acrutil.js +0 -516
  53. package/lib/k2hr3apiutil.js +0 -1494
  54. package/lib/k2hr3cliutil.js +0 -191
  55. package/lib/k2hr3config.js +0 -826
  56. package/lib/k2hr3cryptutil.js +0 -254
  57. package/lib/k2hr3dkc.js +0 -12632
  58. package/lib/k2hr3extdata.js +0 -198
  59. package/lib/k2hr3keys.js +0 -234
  60. package/lib/k2hr3resutil.js +0 -100
  61. package/lib/k2hr3template.js +0 -6925
  62. package/lib/k2hr3tokens.js +0 -2799
  63. package/lib/k2hr3userdata.js +0 -312
  64. package/lib/k8soidc.js +0 -1012
  65. package/lib/openstackapiv2.js +0 -764
  66. package/lib/openstackapiv3.js +0 -1032
  67. package/lib/openstackep.js +0 -553
  68. package/routes/acr.js +0 -738
  69. package/routes/debugVerify.js +0 -263
  70. package/routes/extdata.js +0 -232
  71. package/routes/list.js +0 -270
  72. package/routes/policy.js +0 -869
  73. package/routes/resource.js +0 -1441
  74. package/routes/role.js +0 -2664
  75. package/routes/service.js +0 -894
  76. package/routes/tenant.js +0 -1095
  77. package/routes/userTokens.js +0 -511
  78. package/routes/userdata.js +0 -218
  79. package/routes/version.js +0 -108
  80. package/templ/Dockerfile.templ +0 -71
  81. package/tests/auto_acr.js +0 -1101
  82. package/tests/auto_acr_spec.js +0 -79
  83. package/tests/auto_all_spec.js +0 -142
  84. package/tests/auto_control_subprocess.sh +0 -243
  85. package/tests/auto_extdata.js +0 -220
  86. package/tests/auto_extdata_spec.js +0 -79
  87. package/tests/auto_init_config_json.sh +0 -275
  88. package/tests/auto_k2hdkc_server.ini +0 -109
  89. package/tests/auto_k2hdkc_slave.ini +0 -83
  90. package/tests/auto_list.js +0 -439
  91. package/tests/auto_list_spec.js +0 -79
  92. package/tests/auto_policy.js +0 -1579
  93. package/tests/auto_policy_spec.js +0 -79
  94. package/tests/auto_resource.js +0 -10956
  95. package/tests/auto_resource_spec.js +0 -79
  96. package/tests/auto_role.js +0 -6150
  97. package/tests/auto_role_spec.js +0 -79
  98. package/tests/auto_service.js +0 -770
  99. package/tests/auto_service_spec.js +0 -79
  100. package/tests/auto_subprocesses.js +0 -114
  101. package/tests/auto_template.sh +0 -126
  102. package/tests/auto_tenant.js +0 -1100
  103. package/tests/auto_tenant_spec.js +0 -79
  104. package/tests/auto_token_util.js +0 -219
  105. package/tests/auto_userdata.js +0 -292
  106. package/tests/auto_userdata_spec.js +0 -79
  107. package/tests/auto_usertokens.js +0 -565
  108. package/tests/auto_usertokens_spec.js +0 -79
  109. package/tests/auto_version.js +0 -127
  110. package/tests/auto_version_spec.js +0 -79
  111. package/tests/auto_watcher.js +0 -157
  112. package/tests/auto_watcher_spec.js +0 -79
  113. package/tests/k2hdkc_test.data +0 -986
  114. package/tests/k2hdkc_test_load.sh +0 -255
  115. package/tests/k2hr3template_test.js +0 -187
  116. package/tests/k2hr3template_test.sh +0 -339
  117. package/tests/k2hr3template_test_async.js +0 -216
  118. package/tests/k2hr3template_test_template.result +0 -7117
  119. package/tests/k2hr3template_test_template.txt +0 -3608
  120. package/tests/k2hr3template_test_vars.js +0 -194
  121. package/tests/manual_acr_delete.js +0 -143
  122. package/tests/manual_acr_get.js +0 -297
  123. package/tests/manual_acr_postput.js +0 -215
  124. package/tests/manual_allusertenant_get.js +0 -113
  125. package/tests/manual_extdata_get.js +0 -191
  126. package/tests/manual_k2hr3keys_get.js +0 -84
  127. package/tests/manual_list_gethead.js +0 -230
  128. package/tests/manual_policy_delete.js +0 -132
  129. package/tests/manual_policy_gethead.js +0 -275
  130. package/tests/manual_policy_postput.js +0 -297
  131. package/tests/manual_resource_delete.js +0 -433
  132. package/tests/manual_resource_gethead.js +0 -423
  133. package/tests/manual_resource_postput.js +0 -487
  134. package/tests/manual_role_delete.js +0 -404
  135. package/tests/manual_role_gethead.js +0 -547
  136. package/tests/manual_role_postput.js +0 -544
  137. package/tests/manual_service_delete.js +0 -153
  138. package/tests/manual_service_gethead.js +0 -178
  139. package/tests/manual_service_postput.js +0 -348
  140. package/tests/manual_tenant_delete.js +0 -186
  141. package/tests/manual_tenant_gethead.js +0 -268
  142. package/tests/manual_tenant_postput.js +0 -293
  143. package/tests/manual_test.sh +0 -352
  144. package/tests/manual_userdata_get.js +0 -173
  145. package/tests/manual_usertoken_gethead.js +0 -136
  146. package/tests/manual_usertoken_postput.js +0 -310
  147. package/tests/manual_version_get.js +0 -127
  148. package/tests/run_local_test_k2hdkc.sh +0 -174
  149. package/tests/test.sh +0 -333
@@ -1,1100 +0,0 @@
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 tenant(local@autotest_put_tenant_3) does not allow user(dummyuser).');
608
- done();
609
- });
610
- });
611
-
612
- it('PUT /v1/tenant/<tenant> : update tenant(autotest_put_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
613
- var uri = '/v1/tenant/autotest_put_tenant_0';
614
- uri += '?id=' + autotest_put_tenant_0_id; // correct id
615
- uri += '&desc=Updated2_autotest_put_tenant_0'; // changed
616
- uri += '&display=[UPDATED2]autotest_put_tenant_0'; // chnaged
617
- uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
618
-
619
- chai.request(app)
620
- .put(uri)
621
- .set('content-type', 'application/json')
622
- .end(function(err, res){
623
- expect(res).to.have.status(400);
624
- expect(res).to.be.json;
625
- expect(res.body).to.be.an('object');
626
- expect(res.body.result).to.be.a('boolean').to.be.false;
627
- expect(res.body.message).to.be.a('string').to.equal('PUT request tenant must specify <User Token>');
628
-
629
- done();
630
- });
631
- });
632
-
633
- it('PUT /v1/tenant/<tenant> : update tenant(autotest_put_tenant_0) : failure(no id) 400', function(done){ // eslint-disable-line no-undef
634
- var uri = '/v1/tenant/autotest_put_tenant_0';
635
- uri += '?desc=Updated_autotest_put_tenant_0'; // changed
636
- uri += '&display=[UPDATED]autotest_put_tenant_0'; // chnaged
637
- uri += '&users=' + JSON.stringify(['dummyuser']); // not changed(because there is one user in test data)
638
-
639
- chai.request(app)
640
- .put(uri)
641
- .set('content-type', 'application/json')
642
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
643
- .end(function(err, res){
644
- expect(res).to.have.status(400);
645
- expect(res).to.be.json;
646
- expect(res.body).to.be.an('object');
647
- expect(res.body.result).to.be.a('boolean').to.be.false;
648
- 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.');
649
-
650
- done();
651
- });
652
- });
653
-
654
- //
655
- // Run Test(GET - TENANT LIST - SUCCESS/FAILURE)
656
- //
657
- it('GET /v1/tenant : get tenant list and expanding : success 200', function(done){ // eslint-disable-line no-undef
658
- chai.request(app)
659
- .get('/v1/tenant?expand=true') // expand: true
660
- .set('content-type', 'application/json')
661
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
662
- .end(function(err, res){
663
- expect(res).to.have.status(200);
664
- expect(res).to.be.json;
665
- expect(res.body).to.be.an('object');
666
- expect(res.body.result).to.be.a('boolean').to.be.true;
667
- expect(res.body.message).to.be.a('null');
668
- expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(4);
669
- expect(res.body.tenants[0]).to.be.an('object');
670
- expect(res.body.tenants[0].name).to.be.a('string'); // not check string
671
- expect(res.body.tenants[0].id).to.be.a('string'); // not check string
672
- expect(res.body.tenants[0].desc).to.be.a('string'); // not check string
673
- expect(res.body.tenants[0].display).to.be.a('string'); // not check string
674
- expect(res.body.tenants[0].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
675
- expect(res.body.tenants[1]).to.be.an('object');
676
- expect(res.body.tenants[1].name).to.be.a('string'); // not check string
677
- expect(res.body.tenants[1].id).to.be.a('string'); // not check string
678
- expect(res.body.tenants[1].desc).to.be.a('string'); // not check string
679
- expect(res.body.tenants[1].display).to.be.a('string'); // not check string
680
- expect(res.body.tenants[1].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
681
- expect(res.body.tenants[2]).to.be.an('object');
682
- expect(res.body.tenants[2].name).to.be.a('string'); // not check string
683
- expect(res.body.tenants[2].id).to.be.a('string'); // not check string
684
- expect(res.body.tenants[2].desc).to.be.a('string'); // not check string
685
- expect(res.body.tenants[2].display).to.be.a('string'); // not check string
686
- expect(res.body.tenants[2].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
687
- expect(res.body.tenants[3]).to.be.an('object');
688
- expect(res.body.tenants[3].name).to.be.a('string'); // not check string
689
- expect(res.body.tenants[3].id).to.be.a('string'); // not check string
690
- expect(res.body.tenants[3].desc).to.be.a('string'); // not check string
691
- expect(res.body.tenants[3].display).to.be.a('string'); // not check string
692
- expect(res.body.tenants[3].users).to.be.an.instanceof(Array).to.have.lengthOf(1); // not check array contents
693
-
694
- done();
695
- });
696
- });
697
-
698
- it('GET /v1/tenant : get tenant list and no expanding: success 200', function(done){ // eslint-disable-line no-undef
699
- chai.request(app)
700
- .get('/v1/tenant?expand=false') // expand: false
701
- .set('content-type', 'application/json')
702
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
703
- .end(function(err, res){
704
- expect(res).to.have.status(200);
705
- expect(res).to.be.json;
706
- expect(res.body).to.be.an('object');
707
- expect(res.body.result).to.be.a('boolean').to.be.true;
708
- expect(res.body.message).to.be.a('null');
709
- expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(4);
710
- expect(res.body.tenants[0]).to.be.a('string'); // not check string
711
- expect(res.body.tenants[1]).to.be.a('string'); // not check string
712
- expect(res.body.tenants[2]).to.be.a('string'); // not check string
713
- expect(res.body.tenants[3]).to.be.a('string'); // not check string
714
-
715
- done();
716
- });
717
- });
718
-
719
- it('GET /v1/tenant : get tenant list and expanding : failure(no token) 400', function(done){ // eslint-disable-line no-undef
720
- chai.request(app)
721
- .get('/v1/tenant?expand=true') // expand: true
722
- .set('content-type', 'application/json')
723
- .end(function(err, res){
724
- expect(res).to.have.status(400);
725
- expect(res).to.be.json;
726
- expect(res.body).to.be.an('object');
727
- expect(res.body.result).to.be.a('boolean').to.be.false;
728
- expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
729
-
730
- done();
731
- });
732
- });
733
-
734
- it('GET /v1/tenant : get tenant list and no expanding: failure(no token) 400', function(done){ // eslint-disable-line no-undef
735
- chai.request(app)
736
- .get('/v1/tenant?expand=false') // expand: false
737
- .set('content-type', 'application/json')
738
- .end(function(err, res){
739
- expect(res).to.have.status(400);
740
- expect(res).to.be.json;
741
- expect(res.body).to.be.an('object');
742
- expect(res.body.result).to.be.a('boolean').to.be.false;
743
- expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
744
-
745
- done();
746
- });
747
- });
748
-
749
- //
750
- // Run Test(GET - TENANT INFORMATION - SUCCESS/FAILURE)
751
- //
752
- it('GET /v1/tenant/<tenant> : get tenant(autotest_post_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
753
- chai.request(app)
754
- .get('/v1/tenant/autotest_post_tenant_0') // specify tenant name
755
- .set('content-type', 'application/json')
756
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
757
- .end(function(err, res){
758
- expect(res).to.have.status(200);
759
- expect(res).to.be.json;
760
- expect(res.body).to.be.an('object');
761
- expect(res.body.result).to.be.a('boolean').to.be.true;
762
- expect(res.body.message).to.be.a('null');
763
- expect(res.body.tenant).to.be.an('object');
764
- expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_0');
765
- expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_post_tenant_0_id);
766
- expect(res.body.tenant.desc).to.be.a('string').to.equal('K2HR3 Cluster Local tenant(updated)');
767
- expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED] autotest_post_tenant_0');
768
- expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
769
- expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
770
-
771
- done();
772
- });
773
- });
774
-
775
- it('GET /v1/tenant/<tenant> : get tenant(local@autotest_post_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
776
- chai.request(app)
777
- .get('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name with prefix
778
- .set('content-type', 'application/json')
779
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
780
- .end(function(err, res){
781
- expect(res).to.have.status(200);
782
- expect(res).to.be.json;
783
- expect(res.body).to.be.an('object');
784
- expect(res.body.result).to.be.a('boolean').to.be.true;
785
- expect(res.body.message).to.be.a('null');
786
- expect(res.body.tenant).to.be.an('object');
787
- expect(res.body.tenant.name).to.be.a('string').to.equal('local@autotest_post_tenant_1');
788
- expect(res.body.tenant.id).to.be.a('string').to.equal(autotest_post_tenant_1_id);
789
- expect(res.body.tenant.desc).to.be.a('string').to.equal('Updated local@autotest_post_tenant_1');
790
- expect(res.body.tenant.display).to.be.a('string').to.equal('[UPDATED] local@autotest_post_tenant_1');
791
- expect(res.body.tenant.users).to.be.an.instanceof(Array).to.have.lengthOf(1);
792
- expect(res.body.tenant.users[0]).to.be.a('string').to.equal('dummyuser');
793
-
794
- done();
795
- });
796
- });
797
-
798
- it('GET /v1/tenant/<tenant> : get tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
799
- chai.request(app)
800
- .get('/v1/tenant/autotest_post_tenant_0') // specify tenant name
801
- .set('content-type', 'application/json')
802
- .end(function(err, res){
803
- expect(res).to.have.status(400);
804
- expect(res).to.be.json;
805
- expect(res.body).to.be.an('object');
806
- expect(res.body.result).to.be.a('boolean').to.be.false;
807
- expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
808
-
809
- done();
810
- });
811
- });
812
-
813
- it('GET /v1/tenant/<tenant> : get tenant(local@autotest_post_tenant_1) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
814
- chai.request(app)
815
- .get('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name
816
- .set('content-type', 'application/json')
817
- .end(function(err, res){
818
- expect(res).to.have.status(400);
819
- expect(res).to.be.json;
820
- expect(res.body).to.be.an('object');
821
- expect(res.body.result).to.be.a('boolean').to.be.false;
822
- expect(res.body.message).to.be.a('string').to.equal('GET request tenant must specify <User Token>');
823
-
824
- done();
825
- });
826
- });
827
-
828
- it('GET /v1/tenant/<tenant> : get tenant(autotest_post_tenant_X) : failure(no tenant) 400', function(done){ // eslint-disable-line no-undef
829
- chai.request(app)
830
- .get('/v1/tenant/autotest_post_tenant_X') // specify tenant name
831
- .set('content-type', 'application/json')
832
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
833
- .end(function(err, res){
834
- expect(res).to.have.status(400);
835
- expect(res).to.be.json;
836
- expect(res.body).to.be.an('object');
837
- expect(res.body.result).to.be.a('boolean').to.be.false;
838
- 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');
839
-
840
- done();
841
- });
842
- });
843
-
844
- //
845
- // Run Test(HEAD - TENANT - SUCCESS/FAILURE)
846
- //
847
- it('HEAD /v1/tenant/<tenant> : head tenant(autotest_post_tenant_0) : success 200', function(done){ // eslint-disable-line no-undef
848
- chai.request(app)
849
- .head('/v1/tenant/autotest_post_tenant_0') // specify tenant name
850
- .set('content-type', 'application/json')
851
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
852
- .end(function(err, res){
853
- expect(res).to.have.status(204);
854
-
855
- done();
856
- });
857
- });
858
-
859
- it('HEAD /v1/tenant/<tenant> : head tenant(local@autotest_post_tenant_1) : success 200', function(done){ // eslint-disable-line no-undef
860
- chai.request(app)
861
- .head('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name with prefix
862
- .set('content-type', 'application/json')
863
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
864
- .end(function(err, res){
865
- expect(res).to.have.status(204);
866
-
867
- done();
868
- });
869
- });
870
-
871
- it('HEAD /v1/tenant/<tenant> : head tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
872
- chai.request(app)
873
- .head('/v1/tenant/autotest_post_tenant_0') // specify tenant name
874
- .set('content-type', 'application/json')
875
- .end(function(err, res){
876
- expect(res).to.have.status(400);
877
-
878
- done();
879
- });
880
- });
881
-
882
- it('HEAD /v1/tenant/<tenant> : head tenant(local@autotest_post_tenant_1) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
883
- chai.request(app)
884
- .head('/v1/tenant/local@autotest_post_tenant_1') // specify tenant name
885
- .set('content-type', 'application/json')
886
- .end(function(err, res){
887
- expect(res).to.have.status(400);
888
-
889
- done();
890
- });
891
- });
892
-
893
- it('HEAD /v1/tenant/<tenant> : head tenant(autotest_post_tenant_X) : failure(no tenant) 400', function(done){ // eslint-disable-line no-undef
894
- chai.request(app)
895
- .head('/v1/tenant/autotest_post_tenant_X') // specify tenant name
896
- .set('content-type', 'application/json')
897
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
898
- .end(function(err, res){
899
- expect(res).to.have.status(400);
900
-
901
- done();
902
- });
903
- });
904
-
905
- //
906
- // Run Test(DELETE - TENANT USER - SUCCESS/FAILURE)
907
- //
908
- it('DELETE /v1/tenant/<tenant> : delete tenant user(autotest_put_tenant_0) : success 204', function(done){ // eslint-disable-line no-undef
909
- var uri = '/v1/tenant/autotest_put_tenant_0'; // tenant name
910
- uri += '?id=' + autotest_put_tenant_0_id; // correct id
911
-
912
- chai.request(app)
913
- .delete(uri)
914
- .set('content-type', 'application/json')
915
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
916
- .end(function(err, res){
917
- expect(res).to.have.status(204);
918
-
919
- done();
920
- });
921
- });
922
-
923
- it('DELETE /v1/tenant/<tenant> : delete tenant user(local@autotest_put_tenant_1) : success 204', function(done){ // eslint-disable-line no-undef
924
- var uri = '/v1/tenant/local@autotest_put_tenant_1'; // tenant name
925
- uri += '?id=' + autotest_put_tenant_1_id; // correct id
926
-
927
- chai.request(app)
928
- .delete(uri)
929
- .set('content-type', 'application/json')
930
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
931
- .end(function(err, res){
932
- expect(res).to.have.status(204);
933
-
934
- done();
935
- });
936
- });
937
-
938
- it('DELETE /v1/tenant/<tenant> : delete tenant user(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
939
- var uri = '/v1/tenant/autotest_post_tenant_0'; // tenant name
940
- uri += '?id=' + autotest_post_tenant_0_id; // correct id
941
-
942
- chai.request(app)
943
- .delete(uri)
944
- .set('content-type', 'application/json')
945
- .end(function(err, res){
946
- expect(res).to.have.status(400);
947
-
948
- done();
949
- });
950
- });
951
-
952
- it('DELETE /v1/tenant/<tenant> : delete tenant user(local@autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
953
- var uri = '/v1/tenant/local@autotest_post_tenant_0'; // tenant name
954
- uri += '?id=' + autotest_post_tenant_0_id; // correct id
955
-
956
- chai.request(app)
957
- .delete(uri)
958
- .set('content-type', 'application/json')
959
- .end(function(err, res){
960
- expect(res).to.have.status(400);
961
-
962
- done();
963
- });
964
- });
965
-
966
- it('DELETE /v1/tenant/<tenant> : delete tenant user(autotest_post_tenant_X) : failure(no exist tenant) 400', function(done){ // eslint-disable-line no-undef
967
- var uri = '/v1/tenant/autotest_post_tenant_X'; // not exist tenant name
968
- uri += '?id=' + autotest_post_tenant_0_id; // wrong id
969
-
970
- chai.request(app)
971
- .delete(uri)
972
- .set('content-type', 'application/json')
973
- .end(function(err, res){
974
- expect(res).to.have.status(400);
975
-
976
- done();
977
- });
978
- });
979
-
980
- //
981
- // Run Test(DELETE - TENANT - SUCCESS/FAILURE)
982
- //
983
- it('DELETE /v1/tenant : delete tenant(autotest_post_tenant_0) : failure(no token) 400', function(done){ // eslint-disable-line no-undef
984
- var uri = '/v1/tenant';
985
- uri += '?tenant=autotest_post_tenant_0'; // tenant name
986
- uri += '&id=' + autotest_post_tenant_0_id; // correct id
987
-
988
- chai.request(app)
989
- .delete(uri)
990
- .set('content-type', 'application/json')
991
- .end(function(err, res){
992
- expect(res).to.have.status(400);
993
-
994
- done();
995
- });
996
- });
997
-
998
- it('DELETE /v1/tenant : delete tenant(local@autotest_post_tenant_0) : failure(no tenant) 400', function(done){ // eslint-disable-line no-undef
999
- var uri = '/v1/tenant';
1000
- uri += '?id=' + autotest_post_tenant_0_id; // correct id
1001
-
1002
- chai.request(app)
1003
- .delete(uri)
1004
- .set('content-type', 'application/json')
1005
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
1006
- .end(function(err, res){
1007
- expect(res).to.have.status(400);
1008
-
1009
- done();
1010
- });
1011
- });
1012
-
1013
- it('DELETE /v1/tenant : delete tenant(local@autotest_post_tenant_0) : failure(no id) 400', function(done){ // eslint-disable-line no-undef
1014
- var uri = '/v1/tenant';
1015
- uri += '?tenant=autotest_post_tenant_0'; // tenant name
1016
-
1017
- chai.request(app)
1018
- .delete(uri)
1019
- .set('content-type', 'application/json')
1020
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
1021
- .end(function(err, res){
1022
- expect(res).to.have.status(400);
1023
-
1024
- done();
1025
- });
1026
- });
1027
-
1028
- it('DELETE /v1/tenant : delete tenant(autotest_post_tenant_X) : failure(no exist tenant) 400', function(done){ // eslint-disable-line no-undef
1029
- var uri = '/v1/tenant';
1030
- uri += '?tenant=autotest_post_tenant_X'; // not exist tenant name
1031
- uri += '&id=' + autotest_post_tenant_0_id; // id
1032
-
1033
- chai.request(app)
1034
- .delete(uri)
1035
- .set('content-type', 'application/json')
1036
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
1037
- .end(function(err, res){
1038
- expect(res).to.have.status(400);
1039
-
1040
- done();
1041
- });
1042
- });
1043
-
1044
- it('DELETE /v1/tenant : delete tenant(autotest_post_tenant_X) : failure(wrong id) 400', function(done){ // eslint-disable-line no-undef
1045
- var uri = '/v1/tenant';
1046
- uri += '?tenant=autotest_post_tenant_0'; // tenant name
1047
- uri += '&id=' + autotest_post_tenant_1_id; // wrong id
1048
-
1049
- chai.request(app)
1050
- .delete(uri)
1051
- .set('content-type', 'application/json')
1052
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
1053
- .end(function(err, res){
1054
- expect(res).to.have.status(400);
1055
-
1056
- done();
1057
- });
1058
- });
1059
-
1060
- it('DELETE /v1/tenant : delete tenant(autotest_post_tenant_0) : failure(not local@) 400', function(done){ // eslint-disable-line no-undef
1061
- var uri = '/v1/tenant';
1062
- uri += '?tenant=autotest_post_tenant_0'; // tenant name
1063
- uri += '&id=' + autotest_post_tenant_0_id; // correct id
1064
-
1065
- chai.request(app)
1066
- .delete(uri)
1067
- .set('content-type', 'application/json')
1068
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
1069
- .end(function(err, res){
1070
- expect(res).to.have.status(400);
1071
-
1072
- done();
1073
- });
1074
- });
1075
-
1076
- it('DELETE /v1/tenant/<tenant> : delete tenant(local@autotest_post_tenant_1) : success 204', function(done){ // eslint-disable-line no-undef
1077
- var uri = '/v1/tenant';
1078
- uri += '?tenant=local@autotest_post_tenant_1'; // tenant name
1079
- uri += '&id=' + autotest_post_tenant_1_id; // correct id
1080
-
1081
- chai.request(app)
1082
- .delete(uri)
1083
- .set('content-type', 'application/json')
1084
- .set('x-auth-token', alltokens.unscopedtoken) // unscoped token
1085
- .end(function(err, res){
1086
- expect(res).to.have.status(204);
1087
-
1088
- done();
1089
- });
1090
- });
1091
- });
1092
-
1093
- /*
1094
- * Local variables:
1095
- * tab-width: 4
1096
- * c-basic-offset: 4
1097
- * End:
1098
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
1099
- * vim<600: noexpandtab sw=4 ts=4
1100
- */