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,770 +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: Tue Dec 19 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
- var tokenutil = require('./auto_token_util'); // Token utility
30
-
31
- //--------------------------------------------------------------
32
- // Main describe section
33
- //--------------------------------------------------------------
34
- describe('API : SERVICE', function(){ // eslint-disable-line no-undef
35
- var alltokens = {};
36
-
37
- //
38
- // Before in describe section
39
- //
40
- before(function(done){ // eslint-disable-line no-undef
41
- // Nothing to do
42
- tokenutil.before(this, alltokens, done);
43
- });
44
-
45
- //
46
- // After in describe section
47
- //
48
- after(function(){ // eslint-disable-line no-undef
49
- // Nothing to do
50
- });
51
-
52
- //
53
- // Run Test
54
- //
55
- // 1.1 add(or update if exists) a service.
56
- // 1.1.1 | name + verify(url(http))
57
- // 1.1.2 | name + verify(url(https))
58
- // 1.1.3 | name + verify(url(https+port))
59
- // 1.1.4 | name + verify(static_string)
60
- // 1.1.5 | name + verify(true)
61
- // 1.1.6 | name + verify(false)
62
- //
63
- // 1.1.1.1 POST /v1/service. short name + verify(url(http))
64
- it('POST /v1/service. service + verify(url(http))', function(done){ // eslint-disable-line no-undef
65
- chai.request(app)
66
- .post('/v1/service')
67
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
68
- .set('content-type', 'application/json')
69
- .send({
70
- name:'1.1.1.1',
71
- verify: 'http://localhost/service/verify'
72
- })
73
- .end(function(err, res){
74
- expect(res).to.have.status(201);
75
- expect(res).to.be.json;
76
- expect(res.body.result).to.be.a('boolean').to.be.true;
77
- expect(res.body.message).to.be.a('null');
78
- done();
79
- });
80
- });
81
- // 1.1.1.2 POST /v1/service. full name + verify(url(http))
82
- it('POST /v1/service. service + verify(url(http))', function(done){ // eslint-disable-line no-undef
83
- chai.request(app)
84
- .post('/v1/service')
85
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
86
- .set('content-type', 'application/json')
87
- .send({
88
- name:'yrn:yahoo::::service:1.1.1.2',
89
- verify: 'http://localhost/service/verify'
90
- })
91
- .end(function(err, res){
92
- expect(res).to.have.status(201);
93
- expect(res).to.be.json;
94
- expect(res.body.result).to.be.a('boolean').to.be.true;
95
- expect(res.body.message).to.be.a('null');
96
- done();
97
- });
98
- });
99
- // 1.1.2 POST /v1/service name + verify(url(https))
100
- it('POST /v1/service. name + verify(url(https))', function(done){ // eslint-disable-line no-undef
101
- chai.request(app)
102
- .post('/v1/service')
103
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
104
- .set('content-type', 'application/json')
105
- .send({
106
- name:'1.1.2',
107
- verify: 'https://localhost/service/verify'
108
- })
109
- .end(function(err, res){
110
- expect(res).to.have.status(201);
111
- expect(res).to.be.json;
112
- expect(res.body.result).to.be.a('boolean').to.be.true;
113
- expect(res.body.message).to.be.a('null');
114
- done();
115
- });
116
- });
117
- // 1.1.3 POST /v1/service. name + verify(url(https+port))
118
- it('POST /v1/service. name + verify(url(https+port)))', function(done){ // eslint-disable-line no-undef
119
- chai.request(app)
120
- .post('/v1/service')
121
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
122
- .set('content-type', 'application/json')
123
- .send({
124
- name:'1.1.3',
125
- verify: 'https://localhost:4443/service/verify'
126
- })
127
- .end(function(err, res){
128
- expect(res).to.have.status(201);
129
- expect(res).to.be.json;
130
- expect(res.body.result).to.be.a('boolean').to.be.true;
131
- expect(res.body.message).to.be.a('null');
132
- done();
133
- });
134
- });
135
- // 1.1.4 POST /v1/service. name + static_string
136
- it('POST /v1/service. name + static_string', function(done){ // eslint-disable-line no-undef
137
- chai.request(app)
138
- .post('/v1/service')
139
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
140
- .set('content-type', 'application/json')
141
- .send({
142
- name: '1.1.4',
143
- verify: 'static_string'
144
- })
145
- .end(function(err, res){
146
- expect(res).to.have.status(201);
147
- expect(res).to.be.json;
148
- expect(res.body.result).to.be.a('boolean').to.be.true;
149
- expect(res.body.message).to.be.a('null');
150
- done();
151
- });
152
- });
153
- // 1.1.5 POST /v1/service. name + verify(true)
154
- it('POST /v1/service. name + verify(true)', function(done){ // eslint-disable-line no-undef
155
- chai.request(app)
156
- .post('/v1/service')
157
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
158
- .set('content-type', 'application/json')
159
- .send({
160
- name: '1.1.5',
161
- verify: true
162
- })
163
- .end(function(err, res){
164
- expect(res).to.have.status(201);
165
- expect(res).to.be.json;
166
- expect(res.body.result).to.be.a('boolean').to.be.true;
167
- expect(res.body.message).to.be.a('null');
168
- done();
169
- });
170
- });
171
- // 1.1.6 POST /v1/service. name + verify(false)
172
- it('POST /v1/service. name + verify(false)', function(done){ // eslint-disable-line no-undef
173
- chai.request(app)
174
- .post('/v1/service')
175
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
176
- .set('content-type', 'application/json')
177
- .send({
178
- name: '1.1.6',
179
- verify: false
180
- })
181
- .end(function(err, res){
182
- expect(res).to.have.status(201);
183
- expect(res).to.be.json;
184
- expect(res.body.result).to.be.a('boolean').to.be.true;
185
- expect(res.body.message).to.be.a('null');
186
- done();
187
- });
188
- });
189
-
190
- // 1.2 update service membership.
191
- // 1.2.1 | a tenant + clear_tenant(true) + verify(url)
192
- // 1.2.2 | tenants + clear_tenant(true) + verify(url)
193
- // 1.2.3 | tenants + clear_tenant(false) + verify(url)
194
- // 1.2.4 | tenants + clear_tenant(false) + verify(url_http)
195
- // 1.2.5 | tenants + clear_tenant(false) + verify(url_http+port)
196
- // 1.2.6 | tenants + clear_tenant(false) + verify(static_string)
197
- // 1.2.7 | tenants + clear_tenant(false) + verify(false)
198
- //
199
- // 1.2.1 POST /v1/service/1.2.1 + a tenant + clear_tenant(true) + verify(url)
200
- // 1.2.1.1 POST /v1/service/1.2.1 + a tenant(short name) + clear_tenant(true) + verify(url)
201
- it('POST /v1/service/1.2.1.1 + tenant + clear_tenant(true) + verify(url)', function(done){ // eslint-disable-line no-undef
202
- chai.request(app)
203
- .post('/v1/service/1.2.1.1')
204
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
205
- .set('content-type', 'application/json')
206
- .send({
207
- tenant: 'tenant1',
208
- clear_tenant: true ,
209
- verify: 'https://localhost/1.2.1.1/verify'
210
- })
211
- .end(function(err, res){
212
- expect(res).to.have.status(201);
213
- expect(res).to.be.json;
214
- expect(res.body.result).to.be.a('boolean').to.be.true;
215
- expect(res.body.message).to.be.a('null');
216
- done();
217
- });
218
- });
219
- // 1.2.1.2. POST /v1/service/1.2.1.2 + a tenant(full name) + clear_tenant(true) + verify(url)
220
- it('POST /v1/service/1.2.1.2 + tenant + clear_tenant(true) + verify(url)', function(done){ // eslint-disable-line no-undef
221
- chai.request(app)
222
- .post('/v1/service/yrn:yahoo::::service:1.2.1.2')
223
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
224
- .set('content-type', 'application/json')
225
- .send({
226
- tenant: 'yrn:yahoo:::tenant1',
227
- clear_tenant: true ,
228
- verify: 'https://localhost/1.2.1.2/verify'
229
- })
230
- .end(function(err, res){
231
- expect(res).to.have.status(201);
232
- expect(res).to.be.json;
233
- expect(res.body.result).to.be.a('boolean').to.be.true;
234
- expect(res.body.message).to.be.a('null');
235
- done();
236
- });
237
- });
238
- // 1.2.2.1 POST /v1/service/1.2.2.1 + tenant(s)(short name) + clear_tenant(true) + verify(url)
239
- it('POST /v1/service/1.2.2.1 + tenant(s) + clear_tenant(true) + verify(url)', function(done){ // eslint-disable-line no-undef
240
- chai.request(app)
241
- .post('/v1/service/1.2.2.1')
242
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
243
- .set('content-type', 'application/json')
244
- .send({
245
- tenant: ['tenant0', 'tenant1'],
246
- clear_tenant: true ,
247
- verify: 'https://localhost/1.2.2.1/verify'
248
- })
249
- .end(function(err, res){
250
- expect(res).to.have.status(201);
251
- expect(res).to.be.json;
252
- expect(res.body.result).to.be.a('boolean').to.be.true;
253
- expect(res.body.message).to.be.a('null');
254
- done();
255
- });
256
- });
257
- // 1.2.2.2 POST /v1/service/1.2.2.2 + tenant(s)(full name) + clear_tenant(true) + verify(url)
258
- it('POST /v1/service/1.2.2.2 + tenant(s) + clear_tenant(true) + verify(url)', function(done){ // eslint-disable-line no-undef
259
- chai.request(app)
260
- .post('/v1/service/yrn:yahoo::::service:1.2.2.2')
261
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
262
- .set('content-type', 'application/json')
263
- .send({
264
- tenant: ['yrn:yahoo:testservice::tenant0', 'yrn:yahoo:testservice::tenant1'],
265
- clear_tenant: true ,
266
- verify: 'https://localhost/1.2.2.2/verify'
267
- })
268
- .end(function(err, res){
269
- expect(res).to.have.status(201);
270
- expect(res).to.be.json;
271
- expect(res.body.result).to.be.a('boolean').to.be.true;
272
- expect(res.body.message).to.be.a('null');
273
- done();
274
- });
275
- });
276
- // 1.2.3.1 POST /v1/service/1.2.3.1 + short tenant(s) + clear_tenant(false) + verify(url)
277
- it('POST /v1/service/1.2.3.1 + short tenant(s) + clear_tenant(false) + verify(url)', function(done){ // eslint-disable-line no-undef
278
- chai.request(app)
279
- .post('/v1/service/1.2.3.1')
280
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
281
- .set('content-type', 'application/json')
282
- .send({
283
- tenant: ['tenant0', 'tenant1'],
284
- clear_tenant: false,
285
- verify: 'https://localhost/1.2.3.1/verify'
286
- })
287
- .end(function(err, res){
288
- expect(res).to.have.status(201);
289
- expect(res).to.be.json;
290
- expect(res.body.result).to.be.a('boolean').to.be.true;
291
- expect(res.body.message).to.be.a('null');
292
- done();
293
- });
294
- });
295
- // 1.2.3.2 POST /v1/service/1.2.3.2 + full tenant(s) + clear_tenant(false) + verify(url)
296
- it('POST /v1/service/1.2.3.2 + full tenant(s) + clear_tenant(false) + verify(url)', function(done){ // eslint-disable-line no-undef
297
- chai.request(app)
298
- .post('/v1/service/yrn:yahoo::::service:1.2.3.2')
299
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
300
- .set('content-type', 'application/json')
301
- .send({
302
- tenant: ['yrn:yahoo:::tenant0', 'yrn:yahoo:::tenant1', 'yrn:yahoo:::tenant2'],
303
- clear_tenant: false,
304
- verify: 'https://localhost/1.2.3.2/verify'
305
- })
306
- .end(function(err, res){
307
- expect(res).to.have.status(201);
308
- expect(res).to.be.json;
309
- expect(res.body.result).to.be.a('boolean').to.be.true;
310
- expect(res.body.message).to.be.a('null');
311
- done();
312
- });
313
- });
314
- // 1.2.4 POST /v1/service/1.2.4 + tenant(s) + clear_tenant(false) + verify(url_http)
315
- it('POST /v1/service/1.2.4 + tenant(s) + clear_tenant(false) + verify(url_http)', function(done){ // eslint-disable-line no-undef
316
- chai.request(app)
317
- .post('/v1/service/1.2.4')
318
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
319
- .set('content-type', 'application/json')
320
- .send({
321
- tenant: ['tenant0', 'tenant1'],
322
- clear_tenant: false,
323
- verify: 'http://localhost/1.2.4/verify'
324
- })
325
- .end(function(err, res){
326
- expect(res).to.have.status(201);
327
- expect(res).to.be.json;
328
- expect(res.body.result).to.be.a('boolean').to.be.true;
329
- expect(res.body.message).to.be.a('null');
330
- done();
331
- });
332
- });
333
- // 1.2.5 POST /v1/service/1.2.5 + tenant(s) + clear_tenant(false) + verify(url_http+port)
334
- it('POST /v1/service/1.2.5 + tenant(s) + clear_tenant(false) + verify(url_http+port)', function(done){ // eslint-disable-line no-undef
335
- chai.request(app)
336
- .post('/v1/service/1.2.5')
337
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
338
- .set('content-type', 'application/json')
339
- .send({
340
- tenant: ['tenant0','tenant1'],
341
- clear_tenant: false,
342
- verify: 'https://localhost:3000/1.2.5/verify'
343
- })
344
- .end(function(err, res){
345
- expect(res).to.have.status(201);
346
- expect(res).to.be.json;
347
- expect(res.body.result).to.be.a('boolean').to.be.true;
348
- expect(res.body.message).to.be.a('null');
349
- done();
350
- });
351
- });
352
- // 1.2.6 POST /v1/service/1.2.6 + tenant(s) + clear_tenant(false) + verify(static_string)
353
- it('POST /v1/service/1.2.6 + tenant(s) + clear_tenant(false) + verify(static_string)', function(done){ // eslint-disable-line no-undef
354
- chai.request(app)
355
- .post('/v1/service/1.2.6')
356
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
357
- .set('content-type', 'application/json')
358
- .send({
359
- tenant: ['tenant0','tenant1'],
360
- clear_tenant: false,
361
- verify: 'testservice_verify_static_string'
362
- })
363
- .end(function(err, res){
364
- expect(res).to.have.status(201);
365
- expect(res).to.be.json;
366
- expect(res.body.result).to.be.a('boolean').to.be.true;
367
- expect(res.body.message).to.be.a('null');
368
- done();
369
- });
370
- });
371
- // 1.2.7 POST /v1/service/1.2.7 + no tenant + clear_tenant(false) + verify(false)
372
- it('POST /v1/service/1.2.7 + no tenant + clear_tenant(false) + verify(false)', function(done){ // eslint-disable-line no-undef
373
- chai.request(app)
374
- .post('/v1/service/1.2.7')
375
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
376
- .set('content-type', 'application/json')
377
- .send({
378
- clear_tenant: false,
379
- verify: false
380
- })
381
- .end(function(err, res){
382
- expect(res).to.have.status(201);
383
- expect(res).to.be.json;
384
- expect(res.body.result).to.be.a('boolean').to.be.true;
385
- expect(res.body.message).to.be.a('null');
386
- done();
387
- });
388
- });
389
-
390
- // PUT is idempotent whereas POST is not idempotent.
391
- //
392
- // 2.1 add(or overwrite if exists) a service.
393
- // 2.1.1 | name + verify(url(http))
394
- // 2.1.2 | name + verify(url(https))
395
- // 2.1.3 | name + verify(url(https+port))
396
- // 2.1.4 | name + verify(static_string)
397
- // 2.1.5 | name + verify(true)
398
- // 2.1.6 | name + verify(false)
399
- //
400
- // 2.1.1 PUT /v1/service name + verify(url(http))
401
- it('PUT /v1/service. service + verify(url(http))', function(done){ // eslint-disable-line no-undef
402
- var json = {
403
- name: '2.1.1',
404
- verify: 'http://localhost/service/verify'
405
- };
406
- var url = '/v1/service?' + common.json2url(json);
407
- chai.request(app)
408
- .put(url)
409
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
410
- .set('content-type', 'application/json')
411
- .end(function(err, res){
412
- expect(res).to.have.status(201);
413
- expect(res).to.be.json;
414
- expect(res.body.result).to.be.a('boolean').to.be.true;
415
- expect(res.body.message).to.be.a('null');
416
- done();
417
- });
418
- });
419
- // 2.1.2 PUT /v1/service name + verify(url(https))
420
- it('PUT /v1/service. name + verify(url(https))', function(done){ // eslint-disable-line no-undef
421
- var json = {
422
- name:'2.1.2',
423
- verify: 'https://localhost/service/verify'
424
- };
425
- var url = '/v1/service?' + common.json2url(json);
426
- chai.request(app)
427
- .put(url)
428
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
429
- .set('content-type', 'application/json')
430
- .end(function(err, res){
431
- expect(res).to.have.status(201);
432
- expect(res).to.be.json;
433
- expect(res.body.result).to.be.a('boolean').to.be.true;
434
- expect(res.body.message).to.be.a('null');
435
- done();
436
- });
437
- });
438
- // 2.1.3 PUT /v1/service. name + verify(url(https+port))
439
- it('PUT /v1/service. name + verify(url(https+port)))', function(done){ // eslint-disable-line no-undef
440
- var json = {
441
- name:'2.1.3',
442
- verify: 'https://localhost:4443/service/verify'
443
- };
444
- var url = '/v1/service?' + common.json2url(json);
445
- chai.request(app)
446
- .put(url)
447
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
448
- .set('content-type', 'application/json')
449
- .end(function(err, res){
450
- expect(res).to.have.status(201);
451
- expect(res).to.be.json;
452
- expect(res.body.result).to.be.a('boolean').to.be.true;
453
- expect(res.body.message).to.be.a('null');
454
- done();
455
- });
456
- });
457
- // 2.1.4 PUT /v1/service. name + static_string
458
- it('PUT /v1/service. name + static_string', function(done){ // eslint-disable-line no-undef
459
- var json = {
460
- name: '2.1.4',
461
- verify: 'static_string'
462
- };
463
- var url = '/v1/service?' + common.json2url(json);
464
- chai.request(app)
465
- .put(url)
466
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
467
- .set('content-type', 'application/json')
468
- .end(function(err, res){
469
- expect(res).to.have.status(201);
470
- expect(res).to.be.json;
471
- expect(res.body.result).to.be.a('boolean').to.be.true;
472
- expect(res.body.message).to.be.a('null');
473
- done();
474
- });
475
- });
476
- // 2.1.5 PUT /v1/service. name + verify(true)
477
- it('PUT /v1/service. name + verify(true)', function(done){ // eslint-disable-line no-undef
478
- var json = {
479
- name: '2.1.5',
480
- verify: true
481
- };
482
- var url = '/v1/service?' + common.json2url(json);
483
- chai.request(app)
484
- .put(url)
485
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
486
- .set('content-type', 'application/json')
487
- .end(function(err, res){
488
- expect(res).to.have.status(201);
489
- expect(res).to.be.json;
490
- expect(res.body.result).to.be.a('boolean').to.be.true;
491
- expect(res.body.message).to.be.a('null');
492
- done();
493
- });
494
- });
495
- // 2.1.6 PUT /v1/service. name + verify(false)
496
- it('PUT /v1/service. name + verify(false)', function(done){ // eslint-disable-line no-undef
497
- var json = {
498
- name: '2.1.6',
499
- verify: false
500
- };
501
- var url = '/v1/service?' + common.json2url(json);
502
- chai.request(app)
503
- .put(url)
504
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
505
- .set('content-type', 'application/json')
506
- .end(function(err, res){
507
- expect(res).to.have.status(201);
508
- expect(res).to.be.json;
509
- expect(res.body.result).to.be.a('boolean').to.be.true;
510
- expect(res.body.message).to.be.a('null');
511
- done();
512
- });
513
- });
514
-
515
- // 2.2 add(or overwrite if exists) a service.
516
- // 2.2.1 | a tenant + clear_tenant(true) + verify(url)
517
- // 2.2.2 | tenants + clear_tenant(true) + verify(url)
518
- // 2.2.3 | tenants + clear_tenant(false) + verify(url)
519
- // 2.2.4 | tenants + clear_tenant(false) + verify(url_http)
520
- // 2.2.5 | tenants + clear_tenant(false) + verify(url_http+port)
521
- // 2.2.6 | tenants + clear_tenant(false) + verify(static_string)
522
- // 2.2.7 | tenants + clear_tenant(false) + verify(false)
523
- //
524
- // 2.2.1 PUT /v1/service/testservice + tenant + clear_tenant(true) + verify(url)
525
- it('PUT /v1/service/testservice + tenant + clear_tenant(true) + verify(url)', function(done){ // eslint-disable-line no-undef
526
- var json = {
527
- tenant: 'tenant0',
528
- clear_tenant: true ,
529
- verify: 'https://localhost/testservice/verify'
530
- };
531
- var url = '/v1/service/testservice?' + common.json2url(json);
532
- chai.request(app)
533
- .put(url)
534
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
535
- .set('content-type', 'application/json')
536
- .end(function(err, res){
537
- expect(res).to.have.status(201);
538
- expect(res).to.be.json;
539
- expect(res.body.result).to.be.a('boolean').to.be.true;
540
- expect(res.body.message).to.be.a('null');
541
- done();
542
- });
543
- });
544
- // 2.2.2 PUT /v1/service/testservice + tenant(s) + clear_tenant(true) + verify(url)
545
- it('PUT /v1/service/testservice + tenant(s) + clear_tenant(true) + verify(url)', function(done){ // eslint-disable-line no-undef
546
- var json = {
547
- tenant: ['tenant1'],
548
- clear_tenant: true ,
549
- verify: 'https://localhost/testservice/verify'
550
- };
551
- var url = '/v1/service/testservice?' + common.json2url(json);
552
- chai.request(app)
553
- .put(url)
554
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
555
- .set('content-type', 'application/json')
556
- .end(function(err, res){
557
- expect(res).to.have.status(201);
558
- expect(res).to.be.json;
559
- expect(res.body.result).to.be.a('boolean').to.be.true;
560
- expect(res.body.message).to.be.a('null');
561
- done();
562
- });
563
- });
564
- // 2.2.3 PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(url)
565
- it('PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(url)', function(done){ // eslint-disable-line no-undef
566
- var json = {
567
- tenant: ['test_service_tenant123','test_service_456'],
568
- clear_tenant: false,
569
- verify: 'https://localhost/testservice/verify'
570
- };
571
- var url = '/v1/service/testservice?' + common.json2url(json);
572
- chai.request(app)
573
- .put(url)
574
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
575
- .set('content-type', 'application/json')
576
- .end(function(err, res){
577
- expect(res).to.have.status(201);
578
- expect(res).to.be.json;
579
- expect(res.body.result).to.be.a('boolean').to.be.true;
580
- expect(res.body.message).to.be.a('null');
581
- done();
582
- });
583
- });
584
- // 2.2.4 PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(url_http)
585
- it('PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(url_http)', function(done){ // eslint-disable-line no-undef
586
- var json = {
587
- tenant: ['test_service_tenant123','test_service_456'],
588
- clear_tenant: false,
589
- verify: 'http://localhost/testservice/verify'
590
- };
591
- var url = '/v1/service/testservice?' + common.json2url(json);
592
- chai.request(app)
593
- .put(url)
594
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
595
- .set('content-type', 'application/json')
596
- .end(function(err, res){
597
- expect(res).to.have.status(201);
598
- expect(res).to.be.json;
599
- expect(res.body.result).to.be.a('boolean').to.be.true;
600
- expect(res.body.message).to.be.a('null');
601
- done();
602
- });
603
- });
604
- // 2.2.5 PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(url_http+port)
605
- it('PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(url_http+port)', function(done){ // eslint-disable-line no-undef
606
- var json = {
607
- tenant: ['test_service_tenant123','test_service_456'],
608
- clear_tenant: false,
609
- verify: 'https://localhost:3000/testservice/verify'
610
- };
611
- var url = '/v1/service/testservice?' + common.json2url(json);
612
- chai.request(app)
613
- .put(url)
614
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
615
- .set('content-type', 'application/json')
616
- .end(function(err, res){
617
- expect(res).to.have.status(201);
618
- expect(res).to.be.json;
619
- expect(res.body.result).to.be.a('boolean').to.be.true;
620
- expect(res.body.message).to.be.a('null');
621
- done();
622
- });
623
- });
624
- // 2.2.6 PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(static_string)
625
- it('PUT /v1/service/testservice + tenant(s) + clear_tenant(false) + verify(static_string)', function(done){ // eslint-disable-line no-undef
626
- var json = {
627
- tenant: ['test_service_tenant123','test_service_456'],
628
- clear_tenant: false,
629
- verify: 'testservice_verify_static_string'
630
- };
631
- var url = '/v1/service/testservice?' + common.json2url(json);
632
- chai.request(app)
633
- .put(url)
634
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
635
- .set('content-type', 'application/json')
636
- .end(function(err, res){
637
- expect(res).to.have.status(201);
638
- expect(res).to.be.json;
639
- expect(res.body.result).to.be.a('boolean').to.be.true;
640
- expect(res.body.message).to.be.a('null');
641
- done();
642
- });
643
- });
644
- // 2.2.7 PUT /v1/service/testservice + no tenant + clear_tenant(false) + verify(false)
645
- it('PUT /v1/service/testservice + no tenant + clear_tenant(false) + verify(false)', function(done){ // eslint-disable-line no-undef
646
- var json = {
647
- verify: false
648
- };
649
- var url = '/v1/service/testservice?' + common.json2url(json);
650
- chai.request(app)
651
- .put(url)
652
- .set('x-auth-token', alltokens.scopedtoken.tenant0)
653
- .set('content-type', 'application/json')
654
- .end(function(err, res){
655
- expect(res).to.have.status(201);
656
- expect(res).to.be.json;
657
- expect(res.body.result).to.be.a('boolean').to.be.true;
658
- expect(res.body.message).to.be.a('null');
659
- done();
660
- });
661
- });
662
-
663
- // 3.1 get a service.
664
- // 3.1.1 service
665
- // 3.1.2 service + tenant
666
- //
667
- // 3.1.1 GET /v1/service
668
- it('GET /v1/service. a service', function(done){ // eslint-disable-line no-undef
669
- var url = '/v1/service/testservice';
670
- chai.request(app)
671
- .get(url)
672
- .set('x-auth-token', alltokens.scopedtoken.tenant1)
673
- .set('content-type', 'application/json')
674
- .end(function(err, res){
675
- expect(res).to.have.status(200);
676
- expect(res).to.be.json;
677
- expect(res.body.result).to.be.a('boolean').to.be.true;
678
- expect(res.body.message).to.be.a('null');
679
- done();
680
- });
681
- });
682
- // 3.1.2 GET /v1/service + tenant
683
- it('GET /v1/service. service', function(done){ // eslint-disable-line no-undef
684
- var url = '/v1/service/testservice?tenant=tenant0';
685
- chai.request(app)
686
- .get(url)
687
- .set('x-auth-token', alltokens.scopedtoken.tenant1)
688
- .set('content-type', 'application/json')
689
- .end(function(err, res){
690
- expect(res).to.have.status(200);
691
- expect(res).to.be.json;
692
- expect(res.body.result).to.be.a('boolean').to.be.true;
693
- expect(res.body.message).to.be.a('null');
694
- done();
695
- });
696
- });
697
-
698
- // 4.1 head a service.
699
- // 4.1.1 service
700
- // 4.1.2 service + tenant
701
- //
702
- // 4.1.1 HEAD /v1/service
703
- it('HEAD /v1/service. service', function(done){ // eslint-disable-line no-undef
704
- var url = '/v1/service/testservice';
705
- chai.request(app)
706
- .get(url)
707
- .set('x-auth-token', alltokens.scopedtoken.tenant1)
708
- .set('content-type', 'application/json')
709
- .end(function(err, res){
710
- expect(res).to.have.status(200);
711
- expect(res).to.be.json;
712
- expect(res.body.result).to.be.a('boolean').to.be.true;
713
- expect(res.body.message).to.be.a('null');
714
- done();
715
- });
716
- });
717
- // 4.1.2 HEAD /v1/service + tenant
718
- it('HEAD /v1/service. service + tenant', function(done){ // eslint-disable-line no-undef
719
- var url = '/v1/service/testservice?tenant=tenant0';
720
- chai.request(app)
721
- .get(url)
722
- .set('x-auth-token', alltokens.scopedtoken.tenant1)
723
- .set('content-type', 'application/json')
724
- .end(function(err, res){
725
- expect(res).to.have.status(200);
726
- expect(res).to.be.json;
727
- expect(res.body.result).to.be.a('boolean').to.be.true;
728
- expect(res.body.message).to.be.a('null');
729
- done();
730
- });
731
- });
732
-
733
- // 5.1 delete a service and a tenant.
734
- // 5.1.1 service
735
- // 5.1.2 service + tenant
736
- //
737
- // 5.1.1 delete a tenant of a service.
738
- it('DELETE /v1/service. a tenant of a service.', function(done){ // eslint-disable-line no-undef
739
- var url = '/v1/service/testservice?tenant=tenant0';
740
- chai.request(app)
741
- .delete(url)
742
- .set('x-auth-token', alltokens.scopedtoken.tenant1)
743
- .set('content-type', 'application/json')
744
- .end(function(err, res){
745
- expect(res).to.have.status(204);
746
- done();
747
- });
748
- });
749
- // 5.1.2 delete a service.
750
- it('DELETE /v1/service. a service.', function(done){ // eslint-disable-line no-undef
751
- var url = '/v1/service/testservice';
752
- chai.request(app)
753
- .delete(url)
754
- .set('x-auth-token', alltokens.scopedtoken.tenant1)
755
- .set('content-type', 'application/json')
756
- .end(function(err, res){
757
- expect(res).to.have.status(204);
758
- done();
759
- });
760
- });
761
- });
762
-
763
- /*
764
- * Local variables:
765
- * tab-width: 4
766
- * c-basic-offset: 4
767
- * End:
768
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
769
- * vim<600: noexpandtab sw=4 ts=4
770
- */