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
package/tests/test.sh DELETED
@@ -1,333 +0,0 @@
1
- #!/bin/sh
2
- #
3
- # K2HR3 REST API
4
- #
5
- # Copyright 2017 Yahoo Japan Corporation.
6
- #
7
- # K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
8
- # common management information for the cloud.
9
- # K2HR3 can dynamically manage information as "who", "what", "operate".
10
- # These are stored as roles, resources, policies in K2hdkc, and the
11
- # client system can dynamically read and modify these information.
12
- #
13
- # For the full copyright and license information, please view
14
- # the license file that was distributed with this source code.
15
- #
16
- # AUTHOR: Takeshi Nakatani
17
- # CREATE: Tue Dec 26 2017
18
- # REVISION:
19
- #
20
-
21
- #==========================================================
22
- # Common Variables
23
- #==========================================================
24
- PRGNAME=$(basename "$0")
25
- SCRIPTDIR=$(dirname "$0")
26
- SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd)
27
- SRCTOP=$(cd "${SCRIPTDIR}/.." || exit 1; pwd)
28
-
29
- #
30
- # Variables
31
- #
32
- COMMAND=""
33
- CMD_PREFIX="auto_"
34
- CMD_SUFFIX="_spec.js"
35
- AUTO_INIT_SH="tests/auto_init_config_json.sh"
36
-
37
- #
38
- # Commands
39
- #
40
- COMMANDS="
41
- all
42
- version
43
- list
44
- usertokens
45
- resource
46
- policy
47
- role
48
- tenant
49
- service
50
- acr
51
- userdata
52
- extdata
53
- watcher
54
- "
55
-
56
- #==============================================================
57
- # Utility functions
58
- #==============================================================
59
- #
60
- # Usage
61
- #
62
- PrintUsage()
63
- {
64
- echo "Usage: $1 [--production(-prod) | --development(-dev)]"
65
- echo " [--logger(-l)]"
66
- echo " [--timeout <ms>]"
67
- echo " [--debuglevel(-d) DBG/MSG/WARN/ERR/(custom debug level)]"
68
- echo " Command"
69
- echo ""
70
- echo "Option:"
71
- echo " --production(-prod) : Set 'production' to NODE_ENV environment (exclusive with the '--development' option)"
72
- echo " --development(-dev) : Set 'development' to NODE_ENV environment (this is default and exclusive with the '--production' option)"
73
- echo " --logger(-l) : Specify when logging by morgan (this can be substituted by setting the 'NODE_LOGGER' environment variable to 'yes' or 'no')"
74
- echo " --timeout(-t) : Specify the mocha timeout in milliseconds mocha sets a timeout of 2000ms by default,"
75
- echo " but this test script currently sets it to 2000ms. This option can be used to change the timeout value."
76
- echo " --debuglevel(-d) : Specify the level of debug output (DBG/MSG/WARN/ERR/custom debug level)"
77
- echo ""
78
- echo "Command:"
79
- echo " all : All API test"
80
- echo " version : Version API test"
81
- echo " list : List API test"
82
- echo " usertokens : User Token API test"
83
- echo " resource : Resource API test"
84
- echo " policy : Policy API test"
85
- echo " role : Role API test"
86
- echo " tenant : Tenant API test"
87
- echo " service : Service API test"
88
- echo " acr : Accessing Cross Role(ACR) API test"
89
- echo " userdata : Get userdata for openstack API test"
90
- echo " extdata : Get extdata for user defined data"
91
- echo " watcher : Watcher sub process test"
92
- echo ""
93
- }
94
-
95
- #
96
- # Check Commands
97
- #
98
- CheckCommands()
99
- {
100
- if [ -n "$1" ]; then
101
- for command in ${COMMANDS}; do
102
- if [ "$1" = "${command}" ]; then
103
- echo "${command}"
104
- return 0
105
- fi
106
- done
107
- fi
108
- echo ""
109
- return 1
110
- }
111
-
112
- #==========================================================
113
- # Parse options
114
- #==========================================================
115
- NODE_ENV_VALUE=""
116
- IS_LOGGING=0
117
- TIMEOUT=""
118
- DEBUG_ENV_LEVEL=0
119
- DEBUG_ENV_CUSTOM=""
120
-
121
- while [ $# -ne 0 ]; do
122
- if [ -z "$1" ]; then
123
- break
124
-
125
- elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then
126
- PrintUsage "${PRGNAME}"
127
- exit 0
128
-
129
- elif echo "$1" | grep -q -i -e "^-prod$" -e "^--production$"; then
130
- if [ -n "${NODE_ENV_VALUE}" ]; then
131
- echo "[ERROR] already specified --production(-prod) or --development(-dev) option"
132
- exit 1
133
- fi
134
- NODE_ENV_VALUE="production"
135
-
136
- elif echo "$1" | grep -q -i -e "^-dev$" -e "^--development$"; then
137
- if [ "${NODE_ENV_VALUE}" != "" ]; then
138
- echo "[ERROR] already specified --production(-prod) or --development(-dev) option"
139
- exit 1
140
- fi
141
- NODE_ENV_VALUE="development"
142
-
143
- elif echo "$1" | grep -q -i -e "^-l$" -e "^--logger$"; then
144
- if [ "${IS_LOGGING}" -eq 1 ]; then
145
- echo "[ERROR] Already --logger(-l) option is set"
146
- exit 1
147
- fi
148
- IS_LOGGING=1
149
-
150
- elif echo "$1" | grep -q -i -e "^-d$" -e "^--debuglevel$"; then
151
- #
152
- # DEBUG option
153
- #
154
- shift
155
- if [ $# -eq 0 ]; then
156
- echo "[ERROR] --debuglevel(-d) option needs parameter(dbg/msg/warn/err/custom debug level)"
157
- exit 1
158
- fi
159
- if echo "$1" | grep -q -i -e "^dbg$" -e "^debug$"; then
160
- if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
161
- echo "[ERROR] --debuglevel(-d) option already is set"
162
- exit 1
163
- fi
164
- DEBUG_ENV_LEVEL=4
165
- elif echo "$1" | grep -q -i -e "^msg$" -e "^message$" -e "^info$"; then
166
- if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
167
- echo "[ERROR] --debuglevel(-d) option already is set"
168
- exit 1
169
- fi
170
- DEBUG_ENV_LEVEL=3
171
- elif echo "$1" | grep -q -i -e "^wan$" -e "^warn$" -e "^warning$"; then
172
- if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
173
- echo "[ERROR] --debuglevel(-d) option already is set"
174
- exit 1
175
- fi
176
- DEBUG_ENV_LEVEL=2
177
- elif echo "$1" | grep -q -i -e "^err$" -e "^error$"; then
178
- if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
179
- echo "[ERROR] --debuglevel(-d) option already is set"
180
- exit 1
181
- fi
182
- DEBUG_ENV_LEVEL=1
183
- else
184
- #
185
- # Custom debug level value
186
- #
187
- if [ -n "${DEBUG_ENV_CUSTOM}" ]; then
188
- DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM},"
189
- fi
190
- DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM}$1"
191
- fi
192
-
193
- elif echo "$1" | grep -q -i -e "^-t$" -e "^--timeout$"; then
194
- #
195
- # timeout option
196
- #
197
- if [ -n "${TIMEOUT}" ]; then
198
- echo "[ERROR] Already --timeout(-t) option is set"
199
- exit 1
200
- fi
201
- shift
202
- if [ $# -eq 0 ]; then
203
- echo "[ERROR] --timeout(-t) option needs parameter(millisecond)"
204
- exit 1
205
- fi
206
- # check number value
207
- if echo "$1" | grep -q '[^0-9]'; then
208
- echo "[ERROR] --timeout(-t) option parameter must be number(millisecond)"
209
- exit 1
210
- fi
211
- TIMEOUT="$1"
212
-
213
- else
214
- #
215
- # Run test command
216
- #
217
- if [ -n "${COMMAND}" ]; then
218
- echo "[ERROR] Already specified command name(${COMMAND}), could not specify multi command $1"
219
- exit 1
220
- fi
221
- if ! COMMAND=$(CheckCommands "$1"); then
222
- echo "[ERROR] $1 is not command name"
223
- exit 1
224
- fi
225
- fi
226
- shift
227
- done
228
-
229
- #
230
- # Check Command
231
- #
232
- if [ -z "${COMMAND}" ]; then
233
- echo "[ERROR] Command name is not specified"
234
- exit 1
235
- fi
236
-
237
- #
238
- # Check timeout
239
- #
240
- if [ -z "${TIMEOUT}" ]; then
241
- TIMEOUT="3000"
242
- fi
243
-
244
- #
245
- # Check NODE_ENV_VALUE
246
- #
247
- if [ -z "${NODE_ENV_VALUE}" ]; then
248
- NODE_ENV_VALUE="development"
249
- fi
250
-
251
- #
252
- # Make NODE_DEBUG environment
253
- #
254
- DEBUG_ENV_PARAM=""
255
- if [ "${DEBUG_ENV_LEVEL}" -ge 4 ]; then
256
- DEBUG_ENV_PARAM="LOGLEVEL_DBG"
257
- elif [ "${DEBUG_ENV_LEVEL}" -ge 3 ]; then
258
- DEBUG_ENV_PARAM="LOGLEVEL_MSG"
259
- elif [ "${DEBUG_ENV_LEVEL}" -ge 2 ]; then
260
- DEBUG_ENV_PARAM="LOGLEVEL_WAN"
261
- elif [ "${DEBUG_ENV_LEVEL}" -ge 1 ]; then
262
- DEBUG_ENV_PARAM="LOGLEVEL_ERR"
263
- else
264
- DEBUG_ENV_PARAM="LOGLEVEL_SILENT"
265
- fi
266
- if [ -n "${DEBUG_ENV_CUSTOM}" ]; then
267
- if [ -n "${DEBUG_ENV_PARAM}" ]; then
268
- DEBUG_ENV_PARAM="${DEBUG_ENV_PARAM},"
269
- fi
270
- DEBUG_ENV_PARAM="${DEBUG_ENV_PARAM}${DEBUG_ENV_CUSTOM}"
271
- fi
272
-
273
- #
274
- # Logging for NODE_LOGGER
275
- #
276
- if [ "${IS_LOGGING}" -eq 1 ]; then
277
- NODE_LOGGER=""
278
- else
279
- if [ -z "${NODE_LOGGER}" ]; then
280
- #
281
- # Nothing to do for default
282
- #
283
- :
284
- elif echo "${NODE_LOGGER}" | grep -q -i -e "^y$" -e "^yes$"; then
285
- NODE_LOGGER=""
286
- elif echo "${NODE_LOGGER}" | grep -q -i -e "^n$" -e "^no$"; then
287
- NODE_LOGGER="no"
288
- else
289
- echo "[WARNING] NODE_LOGGER environment has wrong value(${NODE_LOGGER}), then do logging(default)"
290
- NODE_LOGGER=""
291
- fi
292
- fi
293
-
294
- #==========================================================
295
- # Do work
296
- #==========================================================
297
- cd "${SRCTOP}" || exit 1
298
-
299
- if [ "${DEBUG_ENV_LEVEL}" -ge 4 ]; then
300
- echo "***** RUN *****"
301
- echo "${AUTO_INIT_SH} --set"
302
- echo "NODE_PATH=${NODE_PATH} NODE_ENV=${NODE_ENV_VALUE} NODE_DEBUG=${DEBUG_ENV_PARAM} NODE_LOGGER=${NODE_LOGGER} NODE_CONFIG_DIR= node_modules/.bin/mocha tests/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"
303
- echo "***************"
304
- fi
305
-
306
- if ! "${AUTO_INIT_SH}" --set; then
307
- echo "[ERROR] Could not initialize local.json5(symbolic link to dummy)"
308
- exit 1
309
- fi
310
-
311
- if ! NODE_PATH="${NODE_PATH}" NODE_ENV="${NODE_ENV_VALUE}" NODE_DEBUG="${DEBUG_ENV_PARAM}" NODE_LOGGER="${NODE_LOGGER}" NODE_CONFIG_DIR='' node_modules/.bin/mocha --timeout "${TIMEOUT}" "tests/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"; then
312
- echo "[ERROR] Failed test."
313
- if ! "${AUTO_INIT_SH}" --restore; then
314
- echo "[ERROR] Could not restore local.json5"
315
- fi
316
- exit 1
317
- fi
318
-
319
- if ! "${AUTO_INIT_SH}" --restore; then
320
- echo "[ERROR] Could not restore local.json5"
321
- exit 1
322
- fi
323
-
324
- exit 0
325
-
326
- #
327
- # Local variables:
328
- # tab-width: 4
329
- # c-basic-offset: 4
330
- # End:
331
- # vim600: noexpandtab sw=4 ts=4 fdm=marker
332
- # vim<600: noexpandtab sw=4 ts=4
333
- #