k2hr3-api 1.0.42 → 2.0.1

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 +4 -4
  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,565 +0,0 @@
1
- /*
2
- * K2HR3 REST API
3
- *
4
- * Copyright 2017 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: Mon Dec 25 2017
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
-
30
- //--------------------------------------------------------------
31
- // Main describe section
32
- //--------------------------------------------------------------
33
- describe('API : USER TOKEN', function(){ // eslint-disable-line no-undef
34
- //
35
- // Common data
36
- //
37
- let unscopedToken = '';
38
- let scopedToken = '';
39
-
40
- //
41
- // Before in describe section
42
- //
43
- before(function(){ // eslint-disable-line no-undef
44
- // Nothing to do
45
- });
46
-
47
- //
48
- // After in describe section
49
- //
50
- after(function(){ // eslint-disable-line no-undef
51
- // Nothing to do
52
- });
53
-
54
- //
55
- // Run Test(POST - SUCCESS)
56
- //
57
- it('POST /v1/user/tokens : unscoped token by user credential(no tenant) with status 201', function(done){ // eslint-disable-line no-undef
58
- chai.request(app)
59
- .post('/v1/user/tokens')
60
- .set('content-type', 'application/json')
61
- .send({
62
- auth: {
63
- tenantName: null,
64
- passwordCredentials: {
65
- username: 'dummyuser',
66
- password: null
67
- }
68
- }
69
- })
70
- .end(function(err, res){
71
- expect(res).to.have.status(201);
72
- expect(res).to.be.json;
73
- expect(res.body).to.be.an('object');
74
- expect(res.body.result).to.be.a('boolean').to.be.true;
75
- expect(res.body.message).to.be.a('string').to.equal('succeed');
76
- expect(res.body.scoped).to.be.a('boolean').to.be.false;
77
- expect(res.body.token).to.be.a('string').is.not.empty;
78
-
79
- unscopedToken = 'U=' + res.body.token;
80
- done();
81
- });
82
- });
83
-
84
- it('POST /v1/user/tokens : scoped token by user credential(and tenant) with status 201', function(done){ // eslint-disable-line no-undef
85
- chai.request(app)
86
- .post('/v1/user/tokens')
87
- .set('content-type', 'application/json')
88
- .send({
89
- auth: {
90
- tenantName: 'tenant0',
91
- passwordCredentials: {
92
- username: 'dummyuser',
93
- password: null
94
- }
95
- }
96
- })
97
- .end(function(err, res){
98
- expect(res).to.have.status(201);
99
- expect(res).to.be.json;
100
- expect(res.body).to.be.an('object');
101
- expect(res.body.result).to.be.a('boolean').to.be.true;
102
- expect(res.body.message).to.be.a('string').to.equal('succeed');
103
- expect(res.body.scoped).to.be.a('boolean').to.be.true;
104
- expect(res.body.token).to.be.a('string').is.not.empty;
105
-
106
- scopedToken = 'U=' + res.body.token;
107
- done();
108
- });
109
- });
110
-
111
- it('POST /v1/user/tokens : scoped token by unscoped token with status 201', function(done){ // eslint-disable-line no-undef
112
- chai.request(app)
113
- .post('/v1/user/tokens')
114
- .set('content-type', 'application/json')
115
- .set('x-auth-token', unscopedToken)
116
- .send({
117
- auth: {
118
- tenantName: 'tenant0'
119
- }
120
- })
121
- .end(function(err, res){
122
- expect(res).to.have.status(201);
123
- expect(res).to.be.json;
124
- expect(res.body).to.be.an('object');
125
- expect(res.body.result).to.be.a('boolean').to.be.true;
126
- expect(res.body.message).to.be.a('string').to.equal('succeed');
127
- expect(res.body.scoped).to.be.a('boolean').to.be.true;
128
- expect(res.body.token).to.be.a('string').is.not.empty;
129
-
130
- scopedToken = 'U=' + res.body.token;
131
- done();
132
- });
133
- });
134
-
135
-
136
- //
137
- // Run Test(POST - FAILURE)
138
- //
139
- it('POST /v1/user/tokens : failure unscoped token by invalid user credential(no tenant) with status 400', function(done){ // eslint-disable-line no-undef
140
- chai.request(app)
141
- .post('/v1/user/tokens')
142
- .set('content-type', 'application/json')
143
- .send({
144
- auth: {
145
- tenantName: null,
146
- passwordCredentials: {
147
- username: null, // any string for user name is allowed, then set null.
148
- password: null
149
- }
150
- }
151
- })
152
- .end(function(err, res){
153
- expect(res).to.have.status(400);
154
- expect(res).to.be.json;
155
- expect(res.body).to.be.an('object');
156
- expect(res.body.result).to.be.a('boolean').to.be.false;
157
- expect(res.body.message).to.be.a('string').to.equal('Some parameter(user name or unscoped token) is wrong.');
158
-
159
- done();
160
- });
161
- });
162
-
163
- it('POST /v1/user/tokens : failure scoped token by invalid user credential(and tenant) with status 400', function(done){ // eslint-disable-line no-undef
164
- chai.request(app)
165
- .post('/v1/user/tokens')
166
- .set('content-type', 'application/json')
167
- .send({
168
- auth: {
169
- tenantName: 'tenant0',
170
- passwordCredentials: {
171
- username: null, // any string for user name is allowed, then set null.
172
- password: null
173
- }
174
- }
175
- })
176
- .end(function(err, res){
177
- expect(res).to.have.status(400);
178
- expect(res).to.be.json;
179
- expect(res.body).to.be.an('object');
180
- expect(res.body.result).to.be.a('boolean').to.be.false;
181
- expect(res.body.message).to.be.a('string').to.equal('Some parameter(user name or unscoped token) is wrong.');
182
-
183
- done();
184
- });
185
- });
186
-
187
- it('POST /v1/user/tokens : failure scoped token by user credential(and invalid tenant) with status 404', function(done){ // eslint-disable-line no-undef
188
- chai.request(app)
189
- .post('/v1/user/tokens')
190
- .set('content-type', 'application/json')
191
- .send({
192
- auth: {
193
- tenantName: 'tenantERROR',
194
- passwordCredentials: {
195
- username: 'dummyuser',
196
- password: null
197
- }
198
- }
199
- })
200
- .end(function(err, res){
201
- expect(res).to.have.status(404);
202
- expect(res).to.be.json;
203
- expect(res.body).to.be.an('object');
204
- expect(res.body.result).to.be.a('boolean').to.be.false;
205
- expect(res.body.message).to.be.a('string').to.have.string('could not get scoped user token for user=dummyuser, tenant=tenantERROR by could not get scoped user token for user dummyuser by some parameters are wrong : token=');
206
-
207
- done();
208
- });
209
- });
210
-
211
- it('POST /v1/user/tokens : failure scoped token by invalid unscoped token with status 404', function(done){ // eslint-disable-line no-undef
212
- chai.request(app)
213
- .post('/v1/user/tokens')
214
- .set('content-type', 'application/json')
215
- .set('x-auth-token', 'error_dummy_token')
216
- .send({
217
- auth: {
218
- tenantName: 'tenant0'
219
- }
220
- })
221
- .end(function(err, res){
222
- expect(res).to.have.status(404);
223
- expect(res).to.be.json;
224
- expect(res.body).to.be.an('object');
225
- expect(res.body.result).to.be.a('boolean').to.be.false;
226
- expect(res.body.message).to.be.a('string').to.equal('could not get scoped user token for other token, tenant=tenant0 by could not get user access token by could not get user access token by getUserUnscopedTokenByToken is not implemented');
227
-
228
- done();
229
- });
230
- });
231
-
232
- it('POST /v1/user/tokens : failure scoped token by invalid tenant name and unscoped token with status 404', function(done){ // eslint-disable-line no-undef
233
- chai.request(app)
234
- .post('/v1/user/tokens')
235
- .set('content-type', 'application/json')
236
- .set('x-auth-token', unscopedToken)
237
- .send({
238
- auth: {
239
- tenantName: 'tenantERROR'
240
- }
241
- })
242
- .end(function(err, res){
243
- expect(res).to.have.status(404);
244
- expect(res).to.be.json;
245
- expect(res.body).to.be.an('object');
246
- expect(res.body.result).to.be.a('boolean').to.be.false;
247
- expect(res.body.message).to.be.a('string').to.have.string('could not get scoped user token for user=dummyuser, tenant=tenantERROR by could not get scoped user token for user dummyuser by some parameters are wrong : token=');
248
-
249
- done();
250
- });
251
- });
252
-
253
- //
254
- // Run Test(PUT - SUCCESS)
255
- //
256
- it('PUT /v1/user/tokens : unscoped token by user credential(no tenant) with status 201', function(done){ // eslint-disable-line no-undef
257
- let url = '/v1/user/tokens';
258
- url += '?tenantname=';
259
- url += '&username=dummyuser';
260
- url += '&password=';
261
- chai.request(app)
262
- .put(url)
263
- .set('content-type', 'application/json')
264
- .end(function(err, res){
265
- expect(res).to.have.status(201);
266
- expect(res).to.be.json;
267
- expect(res.body).to.be.an('object');
268
- expect(res.body.result).to.be.a('boolean').to.be.true;
269
- expect(res.body.message).to.be.a('string').to.equal('succeed');
270
- expect(res.body.scoped).to.be.a('boolean').to.be.false;
271
- expect(res.body.token).to.be.a('string').is.not.empty;
272
-
273
- unscopedToken = 'U=' + res.body.token;
274
- done();
275
- });
276
- });
277
-
278
- it('PUT /v1/user/tokens : scoped token by user credential(and tenant) with status 201', function(done){ // eslint-disable-line no-undef
279
- let url = '/v1/user/tokens';
280
- url += '?tenantname=tenant0';
281
- url += '&username=dummyuser';
282
- url += '&password=';
283
- chai.request(app)
284
- .put(url)
285
- .set('content-type', 'application/json')
286
- .end(function(err, res){
287
- expect(res).to.have.status(201);
288
- expect(res).to.be.json;
289
- expect(res.body).to.be.an('object');
290
- expect(res.body.result).to.be.a('boolean').to.be.true;
291
- expect(res.body.message).to.be.a('string').to.equal('succeed');
292
- expect(res.body.scoped).to.be.a('boolean').to.be.true;
293
- expect(res.body.token).to.be.a('string').is.not.empty;
294
-
295
- scopedToken = 'U=' + res.body.token;
296
- done();
297
- });
298
- });
299
-
300
- it('PUT /v1/user/tokens : scoped token by unscoped token with status 201', function(done){ // eslint-disable-line no-undef
301
- let url = '/v1/user/tokens';
302
- url += '?tenantname=tenant0';
303
- chai.request(app)
304
- .put(url)
305
- .set('content-type', 'application/json')
306
- .set('x-auth-token', unscopedToken)
307
- .end(function(err, res){
308
- expect(res).to.have.status(201);
309
- expect(res).to.be.json;
310
- expect(res.body).to.be.an('object');
311
- expect(res.body.result).to.be.a('boolean').to.be.true;
312
- expect(res.body.message).to.be.a('string').to.equal('succeed');
313
- expect(res.body.scoped).to.be.a('boolean').to.be.true;
314
- expect(res.body.token).to.be.a('string').is.not.empty;
315
-
316
- scopedToken = 'U=' + res.body.token;
317
- done();
318
- });
319
- });
320
-
321
- //
322
- // Run Test(PUT - FAILURE)
323
- //
324
- it('PUT /v1/user/tokens : failure unscoped token by invalid user credential(no tenant) with status 400', function(done){ // eslint-disable-line no-undef
325
- let url = '/v1/user/tokens';
326
- url += '?tenantname=';
327
- url += '&username='; // any string for user name is allowed, then set null.
328
- url += '&password=';
329
- chai.request(app)
330
- .put(url)
331
- .set('content-type', 'application/json')
332
- .end(function(err, res){
333
- expect(res).to.have.status(400);
334
- expect(res).to.be.json;
335
- expect(res.body).to.be.an('object');
336
- expect(res.body.result).to.be.a('boolean').to.be.false;
337
- expect(res.body.message).to.be.a('string').to.equal('There is no x-auth-token header');
338
-
339
- done();
340
- });
341
- });
342
-
343
- it('PUT /v1/user/tokens : failure scoped token by invalid user credential(and tenant) with status 400', function(done){ // eslint-disable-line no-undef
344
- let url = '/v1/user/tokens';
345
- url += '?tenantname=tenant0';
346
- url += '&username='; // any string for user name is allowed, then set null.
347
- url += '&password=';
348
- chai.request(app)
349
- .put(url)
350
- .set('content-type', 'application/json')
351
- .end(function(err, res){
352
- expect(res).to.have.status(400);
353
- expect(res).to.be.json;
354
- expect(res.body).to.be.an('object');
355
- expect(res.body.result).to.be.a('boolean').to.be.false;
356
- expect(res.body.message).to.be.a('string').to.equal('There is no x-auth-token header');
357
-
358
- done();
359
- });
360
- });
361
-
362
- it('PUT /v1/user/tokens : failure scoped token by user credential(and invalid tenant) with status 404', function(done){ // eslint-disable-line no-undef
363
- let url = '/v1/user/tokens';
364
- url += '?tenantname=tenantERROR';
365
- url += '&username=dummyuser';
366
- url += '&password=';
367
- chai.request(app)
368
- .put(url)
369
- .set('content-type', 'application/json')
370
- .end(function(err, res){
371
- expect(res).to.have.status(404);
372
- expect(res).to.be.json;
373
- expect(res.body).to.be.an('object');
374
- expect(res.body.result).to.be.a('boolean').to.be.false;
375
- expect(res.body.message).to.be.a('string').to.have.string('could not get scoped user token for user=dummyuser, tenant=tenantERROR by could not get scoped user token for user dummyuser by some parameters are wrong : token=');
376
-
377
- done();
378
- });
379
- });
380
-
381
- it('PUT /v1/user/tokens : failure scoped token by invalid unscoped token with status 404', function(done){ // eslint-disable-line no-undef
382
- let url = '/v1/user/tokens';
383
- url += '?tenantname=tenant0';
384
- chai.request(app)
385
- .put(url)
386
- .set('content-type', 'application/json')
387
- .set('x-auth-token', 'error_dummy_token')
388
- .end(function(err, res){
389
- expect(res).to.have.status(404);
390
- expect(res).to.be.json;
391
- expect(res.body).to.be.an('object');
392
- expect(res.body.result).to.be.a('boolean').to.be.false;
393
- expect(res.body.message).to.be.a('string').to.equal('could not get scoped user token for other token, tenant=tenant0 by could not get user access token by could not get user access token by getUserUnscopedTokenByToken is not implemented');
394
-
395
- done();
396
- });
397
- });
398
-
399
- it('PUT /v1/user/tokens : failure scoped token by invalid tenant name and unscoped token with status 404', function(done){ // eslint-disable-line no-undef
400
- let url = '/v1/user/tokens';
401
- url += '?tenantname=tenantERROR';
402
- chai.request(app)
403
- .put(url)
404
- .set('content-type', 'application/json')
405
- .set('x-auth-token', unscopedToken)
406
- .end(function(err, res){
407
- expect(res).to.have.status(404);
408
- expect(res).to.be.json;
409
- expect(res.body).to.be.an('object');
410
- expect(res.body.result).to.be.a('boolean').to.be.false;
411
- expect(res.body.message).to.be.a('string').to.have.string('could not get scoped user token for user=dummyuser, tenant=tenantERROR by could not get scoped user token for user dummyuser by some parameters are wrong : token=');
412
-
413
- done();
414
- });
415
- });
416
-
417
- //
418
- // Run Test(GET - SUCCESS)
419
- //
420
- it('GET /v1/user/tokens : tenant list by unscoped token with status 200', function(done){ // eslint-disable-line no-undef
421
- chai.request(app)
422
- .get('/v1/user/tokens')
423
- .set('content-type', 'application/json')
424
- .set('x-auth-token', unscopedToken)
425
- .end(function(err, res){
426
- expect(res).to.have.status(200);
427
- expect(res).to.be.json;
428
- expect(res.body).to.be.an('object');
429
- expect(res.body.result).to.be.a('boolean').to.be.true;
430
- expect(res.body.message).to.be.a('string').to.equal('succeed');
431
- expect(res.body.scoped).to.be.a('boolean').to.be.false;
432
- expect(res.body.user).to.be.a('string').to.equal('dummyuser');
433
- expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(5);
434
- expect(res.body.tenants[0]).to.deep.equal({name: 'tenant0', id: '1000', description: 'dummy tenant no.0', display: 'dummy_tenant_0'});
435
- expect(res.body.tenants[1]).to.deep.equal({name: 'tenant1', id: '1001', description: 'dummy tenant no.1', display: 'dummy_tenant_1'});
436
- expect(res.body.tenants[2]).to.deep.equal({name: 'tenant2', id: '1002', description: 'dummy tenant no.2', display: 'dummy_tenant_2'});
437
- expect(res.body.tenants[3]).to.deep.equal({name: 'tenant3', id: '1003', description: 'dummy tenant no.3', display: 'dummy_tenant_3'});
438
- expect(res.body.tenants[4]).to.deep.equal({name: 'tenant4', id: '1004', description: 'dummy tenant no.4', display: 'dummy_tenant_4'});
439
-
440
- done();
441
- });
442
- });
443
-
444
- it('GET /v1/user/tokens : tenant list by scoped token with status 200', function(done){ // eslint-disable-line no-undef
445
- chai.request(app)
446
- .get('/v1/user/tokens')
447
- .set('content-type', 'application/json')
448
- .set('x-auth-token', scopedToken)
449
- .end(function(err, res){
450
- expect(res).to.have.status(200);
451
- expect(res).to.be.json;
452
- expect(res.body).to.be.an('object');
453
- expect(res.body.result).to.be.a('boolean').to.be.true;
454
- expect(res.body.message).to.be.a('string').to.equal('succeed');
455
- expect(res.body.scoped).to.be.a('boolean').to.be.true;
456
- expect(res.body.user).to.be.a('string').to.equal('dummyuser');
457
- expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(1);
458
- expect(res.body.tenants[0]).to.deep.equal({name: 'tenant0', id: '1000', description: 'dummy tenant no.0', display: 'dummy_tenant_0'});
459
-
460
- done();
461
- });
462
- });
463
-
464
- //
465
- // Run Test(GET - FAILURE)
466
- //
467
- it('GET /v1/user/tokens : failure tenant list by invalid unscoped token with status 401', function(done){ // eslint-disable-line no-undef
468
- chai.request(app)
469
- .get('/v1/user/tokens')
470
- .set('content-type', 'application/json')
471
- .set('x-auth-token', 'error_dummy_token')
472
- .end(function(err, res){
473
- expect(res).to.have.status(401);
474
- expect(res).to.be.json;
475
- expect(res.body).to.be.an('object');
476
- expect(res.body.result).to.be.a('boolean').to.be.false;
477
- expect(res.body.message).to.be.a('string').to.equal('token(error_dummy_token) is not existed, because it is expired or not set yet.');
478
-
479
- done();
480
- });
481
- });
482
-
483
- it('GET /v1/user/tokens : failure tenant list by invalid scoped token with status 401', function(done){ // eslint-disable-line no-undef
484
- chai.request(app)
485
- .get('/v1/user/tokens')
486
- .set('content-type', 'application/json')
487
- .set('x-auth-token', 'error_dummy_token')
488
- .end(function(err, res){
489
- expect(res).to.have.status(401);
490
- expect(res).to.be.json;
491
- expect(res.body).to.be.an('object');
492
- expect(res.body.result).to.be.a('boolean').to.be.false;
493
- expect(res.body.message).to.be.a('string').to.equal('token(error_dummy_token) is not existed, because it is expired or not set yet.');
494
-
495
- done();
496
- });
497
- });
498
-
499
- //
500
- // Run Test(HEAD - SUCCESS)
501
- //
502
- it('HEAD /v1/user/tokens : tenant list by unscoped token with status 204', function(done){ // eslint-disable-line no-undef
503
- chai.request(app)
504
- .head('/v1/user/tokens')
505
- .set('content-type', 'application/json')
506
- .set('x-auth-token', unscopedToken)
507
- .end(function(err, res){
508
- expect(res).to.have.status(204);
509
- expect(res.body).to.be.empty;
510
-
511
- done();
512
- });
513
- });
514
-
515
- it('HEAD /v1/user/tokens : tenant list by scoped token with status 204', function(done){ // eslint-disable-line no-undef
516
- chai.request(app)
517
- .head('/v1/user/tokens')
518
- .set('content-type', 'application/json')
519
- .set('x-auth-token', scopedToken)
520
- .end(function(err, res){
521
- expect(res).to.have.status(204);
522
- expect(res.body).to.be.empty;
523
-
524
- done();
525
- });
526
- });
527
-
528
- //
529
- // Run Test(HEAD - FAILURE)
530
- //
531
- it('HEAD /v1/user/tokens : failure tenant list by invalid unscoped token with status 401', function(done){ // eslint-disable-line no-undef
532
- chai.request(app)
533
- .head('/v1/user/tokens')
534
- .set('content-type', 'application/json')
535
- .set('x-auth-token', 'error_dummy_token')
536
- .end(function(err, res){
537
- expect(res).to.have.status(401);
538
- expect(res.body).to.be.empty;
539
-
540
- done();
541
- });
542
- });
543
-
544
- it('HEAD /v1/user/tokens : failure tenant list by invalid scoped token with status 401', function(done){ // eslint-disable-line no-undef
545
- chai.request(app)
546
- .head('/v1/user/tokens')
547
- .set('content-type', 'application/json')
548
- .set('x-auth-token', 'error_dummy_token')
549
- .end(function(err, res){
550
- expect(res).to.have.status(401);
551
- expect(res.body).to.be.empty;
552
-
553
- done();
554
- });
555
- });
556
- });
557
-
558
- /*
559
- * Local variables:
560
- * tab-width: 4
561
- * c-basic-offset: 4
562
- * End:
563
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
564
- * vim<600: noexpandtab sw=4 ts=4
565
- */
@@ -1,79 +0,0 @@
1
- /*
2
- * K2HR3 REST API
3
- *
4
- * Copyright 2017 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: Mon Dec 25 2017
17
- * REVISION:
18
- *
19
- */
20
-
21
- 'use strict';
22
-
23
- var common = require('./auto_common'); // Common objects for Chai
24
- var chai = common.chai; // eslint-disable-line no-unused-vars
25
- var chaiHttp = common.chaiHttp; // eslint-disable-line no-unused-vars
26
- var app = common.app; // eslint-disable-line no-unused-vars
27
- var assert = common.assert; // eslint-disable-line no-unused-vars
28
- var expect = common.expect; // eslint-disable-line no-unused-vars
29
- var subproc = require('./auto_subprocesses');
30
-
31
- //--------------------------------------------------------------
32
- // Before in global section
33
- //--------------------------------------------------------------
34
- before(function(){ // eslint-disable-line no-undef
35
- //
36
- // Start all sub processes
37
- //
38
- subproc.start(this);
39
- });
40
-
41
- //--------------------------------------------------------------
42
- // After in global section
43
- //--------------------------------------------------------------
44
- after(function(){ // eslint-disable-line no-undef
45
- //
46
- // Stop all sub processes
47
- //
48
- subproc.stop(this);
49
- });
50
-
51
- //--------------------------------------------------------------
52
- // BeforeEach in global section
53
- //--------------------------------------------------------------
54
- beforeEach(function(){ // eslint-disable-line no-undef
55
- // Nothing to do
56
- });
57
-
58
- //--------------------------------------------------------------
59
- // AfterEach in global section
60
- //--------------------------------------------------------------
61
- afterEach(function(){ // eslint-disable-line no-undef
62
- // Nothing to do
63
- });
64
-
65
- //--------------------------------------------------------------
66
- // Sub describe section
67
- //--------------------------------------------------------------
68
- describe('SUB API TEST: USER TOKEN', function(){ // eslint-disable-line no-undef
69
- require('./auto_usertokens');
70
- });
71
-
72
- /*
73
- * Local variables:
74
- * tab-width: 4
75
- * c-basic-offset: 4
76
- * End:
77
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
78
- * vim<600: noexpandtab sw=4 ts=4
79
- */