k2hr3-api 1.0.41 → 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 -372
  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,79 +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; // 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: TENANT', function(){ // eslint-disable-line no-undef
69
- require('./auto_tenant');
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
- */
@@ -1,219 +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
- //
24
- // Using token functions directly
25
- //
26
- var r3token = require('../lib/k2hr3tokens');
27
- var apiutil = require('../lib/k2hr3apiutil');
28
-
29
- //
30
- // All tokens for test
31
- //
32
- // alltoken = {
33
- // username: 'dummyuser'
34
- // unscopedtoken: 'U=<token>', : for 'dummyuser'
35
- // scopedtoken: {
36
- // tenant0: 'U=<token>', : for 'tenant0'
37
- // tenant1: 'U=<token>', : for 'tenant1'
38
- // }
39
- // roletoken: {
40
- // tenant0_k2hr3_entest_str_role_01: 'R=<token>', : for yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_01
41
- // tenant0_k2hr3_entest_obj_role_01: 'R=<token>', : for yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_01
42
- // tenant0_k2hr3_entest_str_role_02: 'R=<token>', : for yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_01/k2hr3_entest_str_role_02
43
- // tenant0_k2hr3_entest_obj_role_02: 'R=<token>', : for yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_01/k2hr3_entest_obj_role_02
44
- // tenant0_k2hr3_entest_str_role_03: 'R=<token>', : for yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_03
45
- // tenant0_k2hr3_entest_obj_role_03: 'R=<token>', : for yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_03
46
- // tenant0_test_service_tenant: 'R=<token>' : for yrn:yahoo:::tenant0:role:test_service_tenant
47
- // tenant1_test_service_owner: 'R=<token>' : for yrn:yahoo:::tenant1:role:test_service_owner
48
- // }
49
- // }
50
- //
51
- // [NOTE]
52
- // yrn:yahoo:testservice::tenant0:role:acr-role does not support role-token, because this role is service-role.
53
- //
54
- function clearAllToken(alltoken)
55
- {
56
- var scopedtoken = {
57
- tenant0: null,
58
- tenant1: null
59
- };
60
- var roletoken = {
61
- tenant0_k2hr3_entest_str_role_01: null,
62
- tenant0_k2hr3_entest_obj_role_01: null,
63
- tenant0_k2hr3_entest_str_role_02: null,
64
- tenant0_k2hr3_entest_obj_role_02: null,
65
- tenant0_k2hr3_entest_str_role_03: null,
66
- tenant0_k2hr3_entest_obj_role_03: null,
67
- tenant0_test_service_tenant: null,
68
- tenant1_test_service_owner: null
69
- };
70
- alltoken.username = 'dummyuser';
71
- alltoken.unscopedtoken = null;
72
- alltoken.scopedtoken = scopedtoken;
73
- alltoken.roletoken = roletoken;
74
- }
75
-
76
- //
77
- // Before function : create all tokens for test data in k2hdkc
78
- //
79
- exports.before = function(parentobj, alltoken, done)
80
- {
81
- var _parentobj = parentobj;
82
- var _alltoken = alltoken;
83
- var _done = done; // eslint-disable-line no-unused-vars
84
- var _buptimeout = _parentobj.timeout(10000);
85
-
86
- // clear
87
- clearAllToken(_alltoken);
88
-
89
- // Get unscoped token
90
- r3token.getUserToken('dummyuser', null, null, function(error, token)
91
- {
92
- if(null !== error){
93
- clearAllToken(_alltoken);
94
- _parentobj.timeout(_buptimeout);
95
- done();
96
- return;
97
- }
98
- alltoken.unscopedtoken = 'U=' + token;
99
-
100
- // Get scoped token for tenant0
101
- r3token.getUserToken('dummyuser', null, 'tenant0', function(error, token)
102
- {
103
- if(null !== error){
104
- clearAllToken(_alltoken);
105
- _parentobj.timeout(_buptimeout);
106
- done();
107
- return;
108
- }
109
- alltoken.scopedtoken.tenant0 = 'U=' + token;
110
-
111
- // Get scoped token for tenant1
112
- r3token.getUserToken('dummyuser', null, 'tenant1', function(error, token)
113
- {
114
- if(null !== error){
115
- clearAllToken(_alltoken);
116
- _parentobj.timeout(_buptimeout);
117
- done();
118
- return;
119
- }
120
- alltoken.scopedtoken.tenant1 = 'U=' + token;
121
-
122
- var result;
123
- var expire = 24 * 60 * 60; // expire is 24H
124
-
125
- // Get role token for yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_01
126
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_01', expire);
127
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
128
- clearAllToken(_alltoken);
129
- _parentobj.timeout(_buptimeout);
130
- done();
131
- return;
132
- }
133
- alltoken.roletoken.tenant0_k2hr3_entest_str_role_01 = 'R=' + result.token;
134
-
135
- // Get role token for yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_01
136
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_01', expire);
137
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
138
- clearAllToken(_alltoken);
139
- _parentobj.timeout(_buptimeout);
140
- done();
141
- return;
142
- }
143
- alltoken.roletoken.tenant0_k2hr3_entest_obj_role_01 = 'R=' + result.token;
144
-
145
- // Get role token for yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_01/k2hr3_entest_str_role_02
146
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_01/k2hr3_entest_str_role_02', expire);
147
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
148
- clearAllToken(_alltoken);
149
- _parentobj.timeout(_buptimeout);
150
- done();
151
- return;
152
- }
153
- alltoken.roletoken.tenant0_k2hr3_entest_str_role_02 = 'R=' + result.token;
154
-
155
- // Get role token for yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_01/k2hr3_entest_obj_role_02
156
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_01/k2hr3_entest_obj_role_02', expire);
157
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
158
- clearAllToken(_alltoken);
159
- _parentobj.timeout(_buptimeout);
160
- done();
161
- return;
162
- }
163
- alltoken.roletoken.tenant0_k2hr3_entest_obj_role_02 = 'R=' + result.token;
164
-
165
- // Get role token for yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_03
166
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:k2hr3_entest_str_role_03', expire);
167
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
168
- clearAllToken(_alltoken);
169
- _parentobj.timeout(_buptimeout);
170
- done();
171
- return;
172
- }
173
- alltoken.roletoken.tenant0_k2hr3_entest_str_role_03 = 'R=' + result.token;
174
-
175
- // Get role token for yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_03
176
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:k2hr3_entest_obj_role_03', expire);
177
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
178
- clearAllToken(_alltoken);
179
- _parentobj.timeout(_buptimeout);
180
- done();
181
- return;
182
- }
183
- alltoken.roletoken.tenant0_k2hr3_entest_obj_role_03 = 'R=' + result.token;
184
-
185
- // Get role token for yrn:yahoo:::tenant0:role:test_service_tenant
186
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant0', 'yrn:yahoo:::tenant0:role:test_service_tenant', expire);
187
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
188
- clearAllToken(_alltoken);
189
- _parentobj.timeout(_buptimeout);
190
- done();
191
- return;
192
- }
193
- alltoken.roletoken.tenant0_test_service_tenant = 'R=' + result.token;
194
-
195
- // Get role token for yrn:yahoo:::tenant1:role:test_service_owner
196
- result = r3token.getRoleTokenByUser('dummyuser', 'tenant1', 'yrn:yahoo:::tenant1:role:test_service_owner', expire);
197
- if(!apiutil.isSafeEntity(result) || !apiutil.isSafeEntity(result.result) || false === result.result){
198
- clearAllToken(_alltoken);
199
- _parentobj.timeout(_buptimeout);
200
- done();
201
- return;
202
- }
203
- alltoken.roletoken.tenant1_test_service_owner = 'R=' + result.token;
204
-
205
- _parentobj.timeout(_buptimeout);
206
- done();
207
- });
208
- });
209
- });
210
- };
211
-
212
- /*
213
- * Local variables:
214
- * tab-width: 4
215
- * c-basic-offset: 4
216
- * End:
217
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
218
- * vim<600: noexpandtab sw=4 ts=4
219
- */
@@ -1,292 +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 Oct 9 2018
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
- var r3userdata = require('../lib/k2hr3userdata'); // for url path
31
-
32
- //--------------------------------------------------------------
33
- // Main describe section
34
- //--------------------------------------------------------------
35
- describe('API : USERDATA', function(){ // eslint-disable-line no-undef
36
- //
37
- // Common data
38
- //
39
- var alltokens = {};
40
- var regparamstr = '';
41
-
42
- //
43
- // Before in describe section
44
- //
45
- before(function(done){ // eslint-disable-line no-undef
46
- // Nothing to do
47
- tokenutil.before(this, alltokens, done);
48
-
49
- // [NOTE]
50
- // Using 'tenant0_k2hr3_entest_str_role_01' role for all test.
51
- //
52
- var regparamobj = {
53
- role: 'tenant0_k2hr3_entest_str_role_01',
54
- token: alltokens.roletoken.tenant0_k2hr3_entest_str_role_01
55
- };
56
- var udproc = new r3userdata.userdataProcess;
57
- regparamstr = udproc.encryptRoleInfo(regparamobj);
58
- });
59
-
60
- //
61
- // After in describe section
62
- //
63
- after(function(){ // eslint-disable-line no-undef
64
- // Nothing to do
65
- });
66
-
67
- it('GET /v1/userdata/<correct path> : get userdata by text status 200', function(done){ // eslint-disable-line no-undef
68
- var uri = '/v1/userdata/';
69
- uri += regparamstr; // path: /v1/userdata/<correct path>
70
-
71
- chai.request(app)
72
- .get(uri)
73
- .set('content-type', 'application/octet-stream')
74
- .set('user-agent', 'Cloud-Init')
75
- .set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
76
- .end(function(err, res){
77
- //console.log(res); // For debugging
78
- expect(res).to.have.status(200);
79
- expect(res).to.be.an('object');
80
- expect(res.body).to.be.an('object').to.be.empty; // body is empty because it must be 'application/json'
81
- expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
82
- expect(res.files).to.be.an('object'); // response has some files from 'multipart/mixed'
83
- expect(res.files[null]).to.be.an('object'); // check only first(null) position( [TODO] checking another )
84
- expect(res.files[null].size).to.be.a('number'); // file has size member
85
- expect(res.files[null].filepath).to.be.an('string').to.not.empty; // file has temporary path
86
- expect(res.files[null].originalFilename).to.be.an('string').to.not.empty; // file has real name
87
- expect(res.files[null].mimetype).to.be.an('string').to.not.empty; // file is set 'content-type'
88
- done();
89
- });
90
- });
91
-
92
- it('GET /v1/userdata/<invalid path> : get userdata by with invalidpath text status 200', function(done){ // eslint-disable-line no-undef
93
- // [NOTE]
94
- // Invalid path case returns 200 and returns error script.
95
- //
96
- var uri = '/v1/userdata/';
97
- uri += 'invalidpath'; // path: /v1/userdata/<invalid path>
98
-
99
- chai.request(app)
100
- .get(uri)
101
- .set('content-type', 'application/octet-stream')
102
- .set('user-agent', 'Cloud-Init')
103
- .set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
104
- .end(function(err, res){
105
- expect(res).to.have.status(200);
106
- expect(res).to.be.an('object');
107
- expect(res.body).to.be.an('object').to.be.empty; // body is empty because it must be 'application/json'
108
- expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
109
- expect(res.files).to.be.an('object'); // response has some files from 'multipart/mixed'
110
- expect(res.files[null]).to.be.an('object'); // check only first(null) position( [TODO] checking another )
111
- expect(res.files[null].size).to.be.a('number'); // file has size member
112
- expect(res.files[null].filepath).to.be.an('string').to.not.empty; // file has temporary path
113
- expect(res.files[null].originalFilename).to.be.an('string').to.not.empty; // file has real name
114
- expect(res.files[null].mimetype).to.be.an('string').to.not.empty; // file is set 'content-type'
115
- done();
116
- });
117
- });
118
-
119
- it('GET /v1/userdata/<invalid path> : get userdata by without content-type text status 200', function(done){ // eslint-disable-line no-undef
120
- // [NOTE]
121
- // Invalid path case returns 200 and returns error script.
122
- //
123
- var uri = '/v1/userdata/';
124
- uri += 'invalidpath'; // path: /v1/userdata/<invalid path>
125
-
126
- chai.request(app)
127
- .get(uri)
128
- .set('user-agent', 'Cloud-Init')
129
- .set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
130
- .end(function(err, res){
131
- expect(res).to.have.status(200);
132
- expect(res).to.be.an('object');
133
- expect(res.body).to.be.an('object').to.be.empty; // body is empty because it must be 'application/json'
134
- expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
135
- expect(res.files).to.be.an('object'); // response has some files from 'multipart/mixed'
136
- expect(res.files[null]).to.be.an('object'); // check only first(null) position( [TODO] checking another )
137
- expect(res.files[null].size).to.be.a('number'); // file has size member
138
- expect(res.files[null].filepath).to.be.an('string').to.not.empty; // file has temporary path
139
- expect(res.files[null].originalFilename).to.be.an('string').to.not.empty; // file has real name
140
- expect(res.files[null].mimetype).to.be.an('string').to.not.empty; // file is set 'content-type'
141
- done();
142
- });
143
- });
144
-
145
- it('GET /v1/userdata/<correct path> : get userdata without user-agent by text status 400', function(done){ // eslint-disable-line no-undef
146
- var uri = '/v1/userdata/';
147
- uri += regparamstr; // path: /v1/userdata/<correct path>
148
-
149
- chai.request(app)
150
- .get(uri)
151
- .set('user-agent', '')
152
- .set('content-type', 'application/octet-stream')
153
- .set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
154
- .end(function(err, res){
155
- expect(res).to.have.status(400);
156
- expect(res).to.be.an('object');
157
- expect(res.body).to.be.an('object'); // response body is error json
158
- expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
159
- expect(res.body.message).to.be.an('string').to.equal('GET request is not allowed from your client');// error message
160
- expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
161
- done();
162
- });
163
- });
164
-
165
- it('GET /v1/userdata/<correct path> : get userdata without any header by text status 400', function(done){ // eslint-disable-line no-undef
166
- var uri = '/v1/userdata/';
167
- uri += regparamstr; // path: /v1/userdata/<correct path>
168
-
169
- chai.request(app)
170
- .get(uri)
171
- .set('user-agent', '')
172
- .set('accept-encoding', '') // Chai send gzip encoding as default, thus we set ''
173
- .end(function(err, res){
174
- expect(res).to.have.status(400);
175
- expect(res).to.be.an('object');
176
- expect(res.body).to.be.an('object'); // response body is error json
177
- expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
178
- expect(res.body.message).to.be.an('string').to.equal('GET request is not allowed from your client');// error message
179
- expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
180
- done();
181
- });
182
- });
183
-
184
- it('GET /v1/userdata/<correct path> : get userdata by gzip status 200', function(done){ // eslint-disable-line no-undef
185
- var uri = '/v1/userdata/';
186
- uri += regparamstr; // path: /v1/userdata/<correct path>
187
-
188
- chai.request(app)
189
- .get(uri)
190
- .set('content-type', 'application/octet-stream')
191
- .set('user-agent', 'Cloud-Init')
192
- .set('accept-encoding', 'gzip')
193
- .end(function(err, res){
194
- expect(res).to.have.status(200);
195
- expect(res).to.be.an('object');
196
- expect(res.body).be.instanceof(Buffer); // body is empty because it must be 'application/json'
197
- expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
198
- expect(res.files).to.be.a('undefined'); // files is empty because it must be 'text/plain'
199
- expect(res.header).to.be.an('object'); // check response header
200
- expect(res.header['content-type']).to.be.a('string').to.equal('application/zip'); // 'content-type'
201
- expect(res.header['content-encoding']).to.be.a('string').to.equal('gzip'); // 'content-encoding'
202
- expect(res.header['content-transfer-encoding']).to.be.a('string').to.equal('binary'); // 'content-transfer-encoding'
203
- expect(res.header['content-disposition']).to.be.a('string').to.not.empty; // 'content-disposition'
204
- expect(res.header['content-length']).to.be.a('string').to.not.empty; // 'content-length'
205
- done();
206
- });
207
- });
208
-
209
- it('GET /v1/userdata/<invalid path> : get userdata with invalidpath by gzip status 200', function(done){ // eslint-disable-line no-undef
210
- // [NOTE]
211
- // Invalid path case returns 200 and returns error script.
212
- //
213
- var uri = '/v1/userdata/';
214
- uri += 'invalidpath'; // path: /v1/userdata/<invalid path>
215
-
216
- chai.request(app)
217
- .get(uri)
218
- .set('content-type', 'application/octet-stream')
219
- .set('user-agent', 'Cloud-Init')
220
- .set('accept-encoding', 'gzip')
221
- .end(function(err, res){
222
- expect(res).to.have.status(200);
223
- expect(res).to.be.an('object');
224
- expect(res.body).be.instanceof(Buffer); // body is empty because it must be 'application/json'
225
- expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
226
- expect(res.files).to.be.a('undefined'); // files is empty because it must be 'text/plain'
227
- expect(res.header).to.be.an('object'); // check response header
228
- expect(res.header['content-type']).to.be.a('string').to.equal('application/zip'); // 'content-type'
229
- expect(res.header['content-encoding']).to.be.a('string').to.equal('gzip'); // 'content-encoding'
230
- expect(res.header['content-transfer-encoding']).to.be.a('string').to.equal('binary'); // 'content-transfer-encoding'
231
- expect(res.header['content-disposition']).to.be.a('string').to.not.empty; // 'content-disposition'
232
- expect(res.header['content-length']).to.be.a('string').to.not.empty; // 'content-length'
233
- done();
234
- });
235
- });
236
-
237
- it('GET /v1/userdata/<invalid path> : get userdata without content-type by gzip status 200', function(done){ // eslint-disable-line no-undef
238
- // [NOTE]
239
- // Invalid path case returns 200 and returns error script.
240
- //
241
- var uri = '/v1/userdata/';
242
- uri += 'invalidpath'; // path: /v1/userdata/<invalid path>
243
-
244
- chai.request(app)
245
- .get(uri)
246
- .set('user-agent', 'Cloud-Init')
247
- .set('accept-encoding', 'gzip')
248
- .end(function(err, res){
249
- expect(res).to.have.status(200);
250
- expect(res).to.be.an('object');
251
- expect(res.body).be.instanceof(Buffer); // body is empty because it must be 'application/json'
252
- expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
253
- expect(res.files).to.be.a('undefined'); // files is empty because it must be 'text/plain'
254
- expect(res.header).to.be.an('object'); // check response header
255
- expect(res.header['content-type']).to.be.a('string').to.equal('application/zip'); // 'content-type'
256
- expect(res.header['content-encoding']).to.be.a('string').to.equal('gzip'); // 'content-encoding'
257
- expect(res.header['content-transfer-encoding']).to.be.a('string').to.equal('binary'); // 'content-transfer-encoding'
258
- expect(res.header['content-disposition']).to.be.a('string').to.not.empty; // 'content-disposition'
259
- expect(res.header['content-length']).to.be.a('string').to.not.empty; // 'content-length'
260
- done();
261
- });
262
- });
263
-
264
- it('GET /v1/userdata/<correct path> : get userdata without user-agent by gzip status 400', function(done){ // eslint-disable-line no-undef
265
- var uri = '/v1/userdata/';
266
- uri += regparamstr; // path: /v1/userdata/<correct path>
267
-
268
- chai.request(app)
269
- .get(uri)
270
- .set('user-agent', '')
271
- .set('content-type', 'application/octet-stream')
272
- .set('accept-encoding', 'gzip')
273
- .end(function(err, res){
274
- expect(res).to.have.status(400);
275
- expect(res).to.be.an('object');
276
- expect(res.body).to.be.an('object'); // response body is error json
277
- expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
278
- expect(res.body.message).to.be.an('string').to.equal('GET request is not allowed from your client');// error message
279
- expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
280
- done();
281
- });
282
- });
283
- });
284
-
285
- /*
286
- * Local variables:
287
- * tab-width: 4
288
- * c-basic-offset: 4
289
- * End:
290
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
291
- * vim<600: noexpandtab sw=4 ts=4
292
- */
@@ -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: Tue Oct 9 2018
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: USERDATA', function(){ // eslint-disable-line no-undef
69
- require('./auto_userdata');
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
- */