k2hr3-api 1.0.11 → 1.0.12

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 (121) hide show
  1. package/ChangeLog +18 -0
  2. package/app.js +7 -4
  3. package/bin/run.sh +218 -172
  4. package/bin/watcher +7 -4
  5. package/bin/www +7 -4
  6. package/config/default.json +7 -4
  7. package/config/development.json +7 -4
  8. package/config/dummyuser.json +8 -5
  9. package/config/extdata-dummy.sh.templ +12 -9
  10. package/config/k2hr3-cloud-config.txt.templ +7 -4
  11. package/config/k2hr3-init-error.sh.templ +8 -5
  12. package/config/k2hr3-init.sh.templ +127 -207
  13. package/config/keystone_v2.json +7 -4
  14. package/config/keystone_v3.json +7 -4
  15. package/lib/basicipcheck.js +7 -4
  16. package/lib/cacerts.js +7 -4
  17. package/lib/dbglogging.js +7 -4
  18. package/lib/dummyuserapi.js +7 -4
  19. package/lib/ipwatch.js +7 -4
  20. package/lib/k2hr3acrutil.js +7 -5
  21. package/lib/k2hr3apiutil.js +7 -4
  22. package/lib/k2hr3cliutil.js +7 -4
  23. package/lib/k2hr3config.js +7 -4
  24. package/lib/k2hr3cryptutil.js +7 -4
  25. package/lib/k2hr3dkc.js +7 -4
  26. package/lib/k2hr3extdata.js +7 -4
  27. package/lib/k2hr3keys.js +7 -4
  28. package/lib/k2hr3resutil.js +7 -4
  29. package/lib/k2hr3template.js +7 -4
  30. package/lib/k2hr3tokens.js +7 -4
  31. package/lib/k2hr3userdata.js +8 -5
  32. package/lib/k8soidc.js +1 -1
  33. package/lib/openstackapiv2.js +7 -4
  34. package/lib/openstackapiv3.js +7 -4
  35. package/lib/openstackep.js +7 -4
  36. package/package.json +73 -72
  37. package/routes/acr.js +7 -4
  38. package/routes/debugVerify.js +7 -4
  39. package/routes/extdata.js +7 -4
  40. package/routes/list.js +7 -4
  41. package/routes/policy.js +7 -4
  42. package/routes/resource.js +7 -4
  43. package/routes/role.js +7 -4
  44. package/routes/service.js +7 -4
  45. package/routes/userTokens.js +7 -4
  46. package/routes/userdata.js +7 -4
  47. package/routes/version.js +7 -4
  48. package/templ/Dockerfile.templ +35 -52
  49. package/{test → tests}/auto_acr.js +7 -4
  50. package/{test → tests}/auto_acr_spec.js +7 -4
  51. package/{test → tests}/auto_all_spec.js +7 -4
  52. package/{test → tests}/auto_common.js +7 -4
  53. package/tests/auto_control_subprocess.sh +239 -0
  54. package/{test → tests}/auto_extdata.js +7 -4
  55. package/{test → tests}/auto_extdata_spec.js +7 -4
  56. package/tests/auto_init_config_json.sh +275 -0
  57. package/{test → tests}/auto_k2hdkc_server.ini +7 -4
  58. package/{test → tests}/auto_k2hdkc_slave.ini +7 -4
  59. package/{test → tests}/auto_list.js +7 -4
  60. package/{test → tests}/auto_list_spec.js +7 -4
  61. package/{test → tests}/auto_policy.js +7 -4
  62. package/{test → tests}/auto_policy_spec.js +7 -4
  63. package/{test → tests}/auto_resource.js +7 -4
  64. package/{test → tests}/auto_resource_spec.js +7 -4
  65. package/{test → tests}/auto_role.js +7 -4
  66. package/{test → tests}/auto_role_spec.js +7 -4
  67. package/{test → tests}/auto_service.js +7 -4
  68. package/{test → tests}/auto_service_spec.js +7 -4
  69. package/{test → tests}/auto_subprocesses.js +14 -11
  70. package/tests/auto_template.sh +126 -0
  71. package/{test → tests}/auto_token_util.js +7 -4
  72. package/{test → tests}/auto_userdata.js +7 -4
  73. package/{test → tests}/auto_userdata_spec.js +7 -4
  74. package/{test → tests}/auto_usertokens.js +7 -4
  75. package/{test → tests}/auto_usertokens_spec.js +7 -4
  76. package/{test → tests}/auto_version.js +7 -4
  77. package/{test → tests}/auto_version_spec.js +7 -4
  78. package/{test → tests}/auto_watcher.js +7 -4
  79. package/{test → tests}/auto_watcher_spec.js +7 -4
  80. package/{test → tests}/k2hdkc_test.data +7 -4
  81. package/tests/k2hdkc_test_load.sh +255 -0
  82. package/{test → tests}/k2hr3template_test.js +7 -4
  83. package/tests/k2hr3template_test.sh +339 -0
  84. package/{test → tests}/k2hr3template_test_async.js +7 -4
  85. package/{test → tests}/k2hr3template_test_template.result +14 -8
  86. package/{test → tests}/k2hr3template_test_template.txt +7 -4
  87. package/{test → tests}/k2hr3template_test_vars.js +7 -4
  88. package/{test → tests}/manual_acr_delete.js +7 -4
  89. package/{test → tests}/manual_acr_get.js +7 -4
  90. package/{test → tests}/manual_acr_postput.js +7 -4
  91. package/{test → tests}/manual_allusertenant_get.js +7 -4
  92. package/{test → tests}/manual_extdata_get.js +7 -4
  93. package/{test → tests}/manual_k2hr3keys_get.js +7 -4
  94. package/{test → tests}/manual_list_gethead.js +7 -4
  95. package/{test → tests}/manual_policy_delete.js +7 -4
  96. package/{test → tests}/manual_policy_gethead.js +7 -4
  97. package/{test → tests}/manual_policy_postput.js +7 -4
  98. package/{test → tests}/manual_resource_delete.js +7 -4
  99. package/{test → tests}/manual_resource_gethead.js +7 -4
  100. package/{test → tests}/manual_resource_postput.js +7 -4
  101. package/{test → tests}/manual_role_delete.js +7 -4
  102. package/{test → tests}/manual_role_gethead.js +7 -4
  103. package/{test → tests}/manual_role_postput.js +7 -4
  104. package/{test → tests}/manual_service_delete.js +7 -4
  105. package/{test → tests}/manual_service_gethead.js +7 -4
  106. package/{test → tests}/manual_service_postput.js +7 -4
  107. package/tests/manual_test.sh +338 -0
  108. package/{test → tests}/manual_userdata_get.js +7 -4
  109. package/{test → tests}/manual_usertoken_gethead.js +7 -4
  110. package/{test → tests}/manual_usertoken_postput.js +7 -4
  111. package/{test → tests}/manual_version_get.js +7 -4
  112. package/tests/run_local_test_k2hdkc.sh +174 -0
  113. package/tests/test.sh +331 -0
  114. package/test/auto_control_subprocess.sh +0 -170
  115. package/test/auto_init_config_json.sh +0 -246
  116. package/test/auto_template.sh +0 -127
  117. package/test/auto_test.sh +0 -321
  118. package/test/k2hdkc_test_load.sh +0 -198
  119. package/test/k2hr3template_test.sh +0 -296
  120. package/test/manual_test.sh +0 -321
  121. package/test/run_local_test_k2hdkc.sh +0 -154
@@ -1,246 +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: Mon Dec 25 2017
18
- # REVISION:
19
- #
20
-
21
- #
22
- # This script is checking/creating/Restoring config/local.json(and local-development.json) for test environment
23
- #
24
-
25
- #
26
- # Common
27
- #
28
- CMDLINE_PROCESS_NAME=$0
29
- CMDLINE_ALL_PARAM=$@
30
- PROGRAM_NAME=`basename ${CMDLINE_PROCESS_NAME}`
31
- MYSCRIPTDIR=`dirname ${CMDLINE_PROCESS_NAME}`
32
- MYSCRIPTDIR=`cd ${MYSCRIPTDIR}; pwd`
33
- SRCTOP=`cd ${MYSCRIPTDIR}/..; pwd`
34
-
35
- CONFIGDIR=${SRCTOP}/config
36
- LOCALJSON=${CONFIGDIR}/local.json
37
- LOCALJSON_BUP=${CONFIGDIR}/local.json_AUTOTEST_BUP
38
- LOCALDEVELOPJSON=${CONFIGDIR}/local-development.json
39
- LOCALDEVELOPJSON_BUP=${CONFIGDIR}/local-development.json_AUTOTEST_BUP
40
- DUMMYJSON=${CONFIGDIR}/dummyuser.json
41
-
42
- #
43
- # Check options
44
- #
45
- PROC_MODE_RESTORE=0
46
-
47
- while [ $# -ne 0 ]; do
48
- if [ "X$1" = "X" ]; then
49
- break
50
-
51
- elif [ "X$1" = "X--help" -o "X$1" = "X--HELP" -o "X$1" = "X-h" -o "X$1" = "X-H" ]; then
52
- echo "Usage: ${PROGRAM_NAME} [-set(default) | -restore] [--help(-h)]"
53
- exit 0
54
-
55
- elif [ "X$1" = "X-set" -o "X$1" = "X-SET" ]; then
56
- PROC_MODE_RESTORE=0
57
-
58
- elif [ "X$1" = "X-restore" -o "X$1" = "X-RESTORE" ]; then
59
- PROC_MODE_RESTORE=1
60
-
61
- else
62
- echo "[ERROR] Unknown option $1"
63
- exit 1
64
- fi
65
-
66
- shift
67
- done
68
-
69
- #
70
- # Run
71
- #
72
- if [ ${PROC_MODE_RESTORE} -ne 1 ]; then
73
- #
74
- # Set/Create Mode
75
- #
76
-
77
- #
78
- # Check local.json
79
- #
80
- if [ -f ${LOCALJSON} ]; then
81
- if [ ! -L ${LOCALJSON} ]; then
82
- echo "[ERROR] ${LOCALJSON} is existed as real file."
83
- exit 1
84
- fi
85
- SLINK_FILE=`readlink ${LOCALJSON}`
86
- if [ $? -ne 0 ]; then
87
- echo "[ERROR] Could not read link as ${LOCALJSON}"
88
- exit 1
89
- fi
90
- if [ "X${SLINK_FILE}" = "X${DUMMYJSON}" ]; then
91
- #
92
- # local.json is already linked to dummyuser.json
93
- #
94
- echo "[INFO] Already ${LOCALJSON} file is linked ${DUMMYJSON}"
95
-
96
- else
97
- #
98
- # Make backup and create new symbolic link file
99
- #
100
- if [ -f ${LOCALJSON_BUP} ]; then
101
- echo "[ERROR] Could not rename file ${LOCALJSON} to ${LOCALJSON_BUP}, because ${LOCALJSON_BUP} already exists."
102
- exit 1
103
- fi
104
-
105
- # rename
106
- mv ${LOCALJSON} ${LOCALJSON_BUP} >/dev/null 2>&1
107
- if [ $? -ne 0 ]; then
108
- echo "[ERROR] Could not rename file ${LOCALJSON} to ${LOCALJSON_BUP}"
109
- exit 1
110
- fi
111
-
112
- #
113
- # Make symbolic link local.json
114
- #
115
- ln -s ${DUMMYJSON} ${LOCALJSON} >/dev/null 2>&1
116
- if [ $? -ne 0 ]; then
117
- echo "[ERROR] Could not create symbolic file ${DUMMYJSON} to ${LOCALJSON}"
118
- exit 1
119
- fi
120
- fi
121
- else
122
- #
123
- # There is no local.json, thus only make symbolic link local.json
124
- #
125
- ln -s ${DUMMYJSON} ${LOCALJSON} >/dev/null 2>&1
126
- if [ $? -ne 0 ]; then
127
- echo "[ERROR] Could not create symbolic file ${DUMMYJSON} to ${LOCALJSON}"
128
- exit 1
129
- fi
130
- fi
131
-
132
- #
133
- # Check local-development.json
134
- #
135
- if [ -f ${LOCALDEVELOPJSON} ]; then
136
- if [ -f ${LOCALDEVELOPJSON_BUP} ]; then
137
- echo "[ERROR] Could not rename file ${LOCALDEVELOPJSON} to ${LOCALDEVELOPJSON_BUP}, because ${LOCALDEVELOPJSON_BUP} already exists."
138
- exit 1
139
- fi
140
-
141
- # rename
142
- mv ${LOCALDEVELOPJSON} ${LOCALDEVELOPJSON_BUP} >/dev/null 2>&1
143
- if [ $? -ne 0 ]; then
144
- echo "[ERROR] Could not rename file ${LOCALDEVELOPJSON} to ${LOCALDEVELOPJSON_BUP}"
145
- exit 1
146
- fi
147
- fi
148
-
149
- else
150
- #
151
- # Restore Mode
152
- #
153
-
154
- #
155
- # Restore local.json
156
- #
157
- if [ ! -f ${LOCALJSON_BUP} ]; then
158
- if [ -f ${LOCALJSON} ]; then
159
- if [ ! -L ${LOCALJSON} ]; then
160
- echo "[WARNING] Not found ${LOCALJSON_BUP} and exists ${LOCALJSON} as real file, so nothing to do"
161
- else
162
- #
163
- # local.json is symbolic link
164
- #
165
- SLINK_FILE=`readlink ${LOCALJSON}`
166
- if [ $? -ne 0 ]; then
167
- echo "[ERROR] Could not read link as ${LOCALJSON}"
168
- exit 1
169
- fi
170
-
171
- if [ "X${SLINK_FILE}" = "X${DUMMYJSON}" ]; then
172
- #
173
- # local.json is linked to dummyuser.json
174
- #
175
- rm -f ${LOCALJSON} >/dev/null 2>&1
176
- if [ $? -ne 0 ]; then
177
- echo "[ERROR] Could not remove file ${LOCALJSON}"
178
- exit 1
179
- fi
180
- else
181
- #
182
- # local.json is not linked to dummyuser.json
183
- #
184
- echo "[WARNING] Not found ${LOCALJSON_BUP} and exists ${LOCALJSON} as symbolic link, but it is not linking to dummyuser.json"
185
- fi
186
- fi
187
- else
188
- echo "[WARNING] Not found ${LOCALJSON_BUP} and ${LOCALJSON}."
189
- fi
190
- else
191
- if [ -f ${LOCALJSON} ]; then
192
- if [ ! -L ${LOCALJSON} ]; then
193
- echo "[WARNING] ${LOCALJSON} is not created by ${PROGRAM_NAME} program, because it is not symbolic link."
194
- else
195
- SLINK_FILE=`readlink ${LOCALJSON}`
196
- if [ $? -ne 0 ]; then
197
- echo "[ERROR] Could not read link as ${LOCALJSON}"
198
- exit 1
199
- fi
200
- if [ "X${SLINK_FILE}" != "X${DUMMYJSON}" ]; then
201
- echo "[WARNING] ${LOCALJSON} is not created by ${PROGRAM_NAME} program, because it is not symbolic link to ${DUMMYJSON}."
202
- else
203
- # remove
204
- rm -f ${LOCALJSON} >/dev/null 2>&1
205
- if [ $? -ne 0 ]; then
206
- echo "[ERROR] Could not remove file ${LOCALJSON}"
207
- exit 1
208
- fi
209
- fi
210
- fi
211
- fi
212
-
213
- # rename
214
- mv ${LOCALJSON_BUP} ${LOCALJSON} >/dev/null 2>&1
215
- if [ $? -ne 0 ]; then
216
- echo "[ERROR] Could not rename file ${LOCALJSON_BUP} to ${LOCALJSON}"
217
- exit 1
218
- fi
219
- fi
220
-
221
- #
222
- # Restore local-development.json
223
- #
224
- if [ ! -f ${LOCALDEVELOPJSON_BUP} ]; then
225
- echo "[INFO] Not found ${LOCALDEVELOPJSON_BUP}, skip restoring ${LOCALDEVELOPJSON}."
226
- else
227
- if [ -f ${LOCALDEVELOPJSON} ]; then
228
- echo "[WARNING] ${LOCALDEVELOPJSON} already exists, could not restoring from ${LOCALDEVELOPJSON_BUP}."
229
- else
230
- # rename
231
- mv ${LOCALDEVELOPJSON_BUP} ${LOCALDEVELOPJSON} >/dev/null 2>&1
232
- if [ $? -ne 0 ]; then
233
- echo "[ERROR] Could not rename file ${LOCALDEVELOPJSON_BUP} to ${LOCALDEVELOPJSON}"
234
- exit 1
235
- fi
236
- fi
237
- fi
238
- fi
239
-
240
- exit 0
241
-
242
- #
243
- # VIM modelines
244
- #
245
- # vim:set ts=4 fenc=utf-8:
246
- #
@@ -1,127 +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: Wed Jan 17 2018
18
- # REVISION:
19
- #
20
-
21
- #
22
- # Common
23
- #
24
- PROGRAM_NAME=`basename $0`
25
- MYSCRIPTDIR=`dirname $0`
26
- MYSCRIPTDIR=`cd ${MYSCRIPTDIR}; pwd`
27
- SRCTOP=`cd ${MYSCRIPTDIR}/..; pwd`
28
-
29
- #
30
- # Parameters
31
- #
32
- TEST_PROGRAM=${SRCTOP}/test/k2hr3template_test.sh
33
- VARS_FILE=${SRCTOP}/test/k2hr3template_test_vars.js
34
- TEMPL_FILE=${SRCTOP}/test/k2hr3template_test_template.txt
35
- SUCCESS_FILE=${SRCTOP}/test/k2hr3template_test_template.result
36
- EXPANDED_FILE=/tmp/k2hr3template_test_template.result
37
-
38
- #
39
- # Usage
40
- #
41
- PrintUsage()
42
- {
43
- echo "Usage: $1 [--debuglevel(-d) DBG/MSG/WARN/ERR/(custom debug level)] [--async(-a)]"
44
- echo ""
45
- }
46
-
47
- #
48
- # Parse arguments
49
- #
50
- DEBUG_OPTION=""
51
- DEBUG_ENV_DBG=0
52
- ASYNC_OPTION=""
53
-
54
- while [ $# -ne 0 ]; do
55
- if [ "X$1" = "X" ]; then
56
- break
57
-
58
- elif [ "X$1" = "X--help" -o "X$1" = "X--HELP" -o "X$1" = "X-h" -o "X$1" = "X-H" ]; then
59
- PrintUsage ${PROGRAM_NAME}
60
- exit 0
61
-
62
- elif [ "X$1" = "X--debuglevel" -o "X$1" = "X--DEBUGLEVEL" -o "X$1" = "X-d" -o "X$1" = "X-D" ]; then
63
- #
64
- # DEBUG option
65
- #
66
- shift
67
- if [ $# -eq 0 ]; then
68
- echo "ERROR: --debuglevel(-d) option needs parameter(dbg/msg/warn/err)"
69
- exit 1
70
- fi
71
- if [ "X$DEBUG_OPTION" != "X" ]; then
72
- echo "ERROR: already specified --debuglevel(-d) option"
73
- exit 1
74
- fi
75
-
76
- if [ "X$1" = "Xdbg" -o "X$1" = "XDBG" -o "X$1" = "Xdebug" -o "X$1" = "XDEBUG" ]; then
77
- DEBUG_ENV_DBG=1
78
- fi
79
- DEBUG_OPTION="-d $1"
80
-
81
- elif [ "X$1" = "X--async" -o "X$1" = "X--ASYNC" -o "X$1" = "X-a" -o "X$1" = "X-A" ]; then
82
- if [ "X$ASYNC_OPTION" != "X" ]; then
83
- echo "ERROR: already specified --async(-a) option"
84
- exit 1
85
- fi
86
- ASYNC_OPTION="--async"
87
-
88
- else
89
- echo "ERROR: unknown option \"$1\""
90
- echo ""
91
- PrintUsage ${PROGRAM_NAME}
92
- exit 0
93
- fi
94
-
95
- shift
96
- done
97
-
98
- #
99
- # Executing
100
- #
101
- if [ ${DEBUG_ENV_DBG} -eq 1 ]; then
102
- echo "***** Run(execute template engine) *****"
103
- echo "${TEST_PROGRAM} -v ${VARS_FILE} -t ${TEMPL_FILE} ${ASYNC_OPTION} > ${EXPANDED_FILE}"
104
- echo ""
105
- fi
106
- ${TEST_PROGRAM} -v ${VARS_FILE} -t ${TEMPL_FILE} ${ASYNC_OPTION} > ${EXPANDED_FILE}
107
- if [ $? -ne 0 ]; then
108
- exit $?
109
- fi
110
-
111
- if [ ${DEBUG_ENV_DBG} -eq 1 ]; then
112
- echo "***** Run(compare result) *****"
113
- echo "diff ${EXPANDED_FILE} ${SUCCESS_FILE}"
114
- echo ""
115
- fi
116
- diff ${EXPANDED_FILE} ${SUCCESS_FILE}
117
- if [ $? -ne 0 ]; then
118
- exit $?
119
- fi
120
-
121
- exit 0
122
-
123
- #
124
- # VIM modelines
125
- #
126
- # vim:set ts=4 fenc=utf-8:
127
- #
package/test/auto_test.sh DELETED
@@ -1,321 +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
23
- #
24
- PROGRAM_NAME=`basename $0`
25
- MYSCRIPTDIR=`dirname $0`
26
- MYSCRIPTDIR=`cd ${MYSCRIPTDIR}; pwd`
27
- SRCTOP=`cd ${MYSCRIPTDIR}/..; pwd`
28
- COMMAND=""
29
- CMD_PREFIX="auto_"
30
- CMD_SUFFIX="_spec.js"
31
-
32
- #
33
- # Commands
34
- #
35
- COMMANDS="
36
- all
37
- version
38
- list
39
- usertokens
40
- resource
41
- policy
42
- role
43
- service
44
- acr
45
- userdata
46
- extdata
47
- watcher
48
- "
49
-
50
- CheckCommands()
51
- {
52
- for command in ${COMMANDS}; do
53
- if [ "X$1" = "X${command}" ]; then
54
- echo ${command}
55
- return
56
- fi
57
- done
58
- echo ""
59
- }
60
-
61
- PrintUsage()
62
- {
63
- echo "Usage: $1 [--production | --development(default)]"
64
- echo " [--logger(-l)]"
65
- echo " [--timeout <ms>]"
66
- echo " [--debuglevel(-d) DBG/MSG/WARN/ERR/(custom debug level)]"
67
- echo " Command"
68
- echo ""
69
- echo "Option: --production : Set 'production' to NODE_ENV environment"
70
- echo " (exclusive with the '--development' option)"
71
- echo " --development : Set 'development' to NODE_ENV environment"
72
- echo " (This option is default and exclusive with"
73
- echo " the '--production' option)"
74
- echo " --logger(-l) : Specify when logging by morgan"
75
- echo " (This can be substituted by setting the"
76
- echo " 'NODE_LOGGER' environment variable to 'yes'"
77
- echo " or 'no')"
78
- echo " --timeout(-t) : Specify the mocha timeout in milliseconds"
79
- echo " mocha sets a timeout of 2000ms by default,"
80
- echo " but this test script currently sets it to"
81
- echo " 2000ms. This option can be used to change"
82
- echo " the timeout value."
83
- echo " --debuglevel(-d) : Specify the level of debug output."
84
- echo " (DBG/MSG/WARN/ERR/custom debug level)"
85
- echo ""
86
- echo "Command: all : All API test"
87
- echo " version : Version API test"
88
- echo " list : List API test"
89
- echo " usertokens : User Token API test"
90
- echo " resource : Resource API test"
91
- echo " policy : Policy API test"
92
- echo " role : Role API test"
93
- echo " service : Service API test"
94
- echo " acr : Accessing Cross Role(ACR) API test"
95
- echo " userdata : Get userdata for openstack API test"
96
- echo " extdata : Get extdata for user defined data"
97
- echo " watcher : Watcher sub process test"
98
- echo ""
99
- }
100
-
101
- #
102
- # Parse arguments
103
- #
104
- NODE_ENV_VALUE=""
105
- DEBUG_ENV_CUSTOM=""
106
- DEBUG_ENV_LEVEL=0
107
- IS_LOGGING=""
108
- TIMEOUT="2000"
109
-
110
- while [ $# -ne 0 ]; do
111
- if [ "X$1" = "X" ]; then
112
- break
113
-
114
- elif [ "X$1" = "X--help" -o "X$1" = "X--HELP" -o "X$1" = "X-h" -o "X$1" = "X-H" ]; then
115
- PrintUsage ${PROGRAM_NAME}
116
- exit 0
117
-
118
- elif [ "X$1" = "X--production" -o "X$1" = "X--PRODUCTION" ]; then
119
- if [ "X${NODE_ENV_VALUE}" != "X" ]; then
120
- echo "ERROR: already specified --production or --development option"
121
- exit 1
122
- fi
123
- NODE_ENV_VALUE="production"
124
-
125
- elif [ "X$1" = "X--development" -o "X$1" = "X--DEVELOPMENT" ]; then
126
- if [ "X${NODE_ENV_VALUE}" != "X" ]; then
127
- echo "ERROR: already specified --production or --development option"
128
- exit 1
129
- fi
130
- NODE_ENV_VALUE="development"
131
-
132
- elif [ "X$1" = "X--logger" -o "X$1" = "X--LOGGER" -o "X$1" = "X-l" -o "X$1" = "X-L" ]; then
133
- if [ "X${IS_LOGGING}" != "X" ]; then
134
- echo "ERROR: --logger(-l) option already is set"
135
- exit 1
136
- fi
137
- IS_LOGGING="yes"
138
-
139
- elif [ "X$1" = "X--debuglevel" -o "X$1" = "X--DEBUGLEVEL" -o "X$1" = "X-d" -o "X$1" = "X-D" ]; then
140
- #
141
- # DEBUG option
142
- #
143
- shift
144
- if [ $# -eq 0 ]; then
145
- echo "ERROR: --debuglevel(-d) option needs parameter(dbg/msg/warn/err)"
146
- exit 1
147
- fi
148
-
149
- if [ "X$1" = "Xdbg" -o "X$1" = "XDBG" -o "X$1" = "Xdebug" -o "X$1" = "XDEBUG" ]; then
150
- if [ ${DEBUG_ENV_LEVEL} -ne 0 ]; then
151
- echo "ERROR: --debuglevel(-d) option already is set"
152
- exit 1
153
- fi
154
- if [ ${DEBUG_ENV_LEVEL} -lt 4 ]; then
155
- DEBUG_ENV_LEVEL=4
156
- fi
157
-
158
- elif [ "X$1" = "Xmsg" -o "X$1" = "XMSG" -o "X$1" = "Xmessage" -o "X$1" = "XMESSAGE" -o "X$1" = "Xinfo" -o "X$1" = "XINFO" ]; then
159
- if [ ${DEBUG_ENV_LEVEL} -ne 0 ]; then
160
- echo "ERROR: --debuglevel(-d) option already is set"
161
- exit 1
162
- fi
163
- if [ ${DEBUG_ENV_LEVEL} -lt 3 ]; then
164
- DEBUG_ENV_LEVEL=3
165
- fi
166
-
167
- elif [ "X$1" = "Xwarn" -o "X$1" = "XWARN" -o "X$1" = "Xwarning" -o "X$1" = "XWARNING" ]; then
168
- if [ ${DEBUG_ENV_LEVEL} -ne 0 ]; then
169
- echo "ERROR: --debuglevel(-d) option already is set"
170
- exit 1
171
- fi
172
- if [ ${DEBUG_ENV_LEVEL} -lt 2 ]; then
173
- DEBUG_ENV_LEVEL=2
174
- fi
175
-
176
- elif [ "X$1" = "Xerr" -o "X$1" = "XERR" -o "X$1" = "Xerror" -o "X$1" = "XERROR" ]; then
177
- if [ ${DEBUG_ENV_LEVEL} -ne 0 ]; then
178
- echo "ERROR: --debuglevel(-d) option already is set"
179
- exit 1
180
- fi
181
- if [ ${DEBUG_ENV_LEVEL} -lt 1 ]; then
182
- DEBUG_ENV_LEVEL=1
183
- fi
184
-
185
- else
186
- if [ "X${DEBUG_ENV_CUSTOM}" != "X" ]; then
187
- DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM},"
188
- fi
189
- DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM}$1"
190
- fi
191
-
192
- elif [ "X$1" = "X--timeout" -o "X$1" = "X--TIMEOUT" -o "X$1" = "X-t" -o "X$1" = "X-T" ]; then
193
- #
194
- # timeout option
195
- #
196
- shift
197
- if [ $# -eq 0 ]; then
198
- echo "ERROR: --timeout(-t) option needs parameter(millisecond)"
199
- exit 1
200
- fi
201
-
202
- # check number value
203
- expr "$1" + 1 >/dev/null 2>&1
204
- if [ $? -ge 2 ]; then
205
- echo "ERROR: --timeout(-t) parameter($1) must be number value"
206
- exit 1
207
- fi
208
- TIMEOUT=$1
209
-
210
- else
211
- #
212
- # Run test command
213
- #
214
- if [ "X${COMMAND}" != "X" ]; then
215
- echo "ERROR: Already specified command name(${COMMAND}), could not specify multi command $1"
216
- exit 1
217
- fi
218
-
219
- COMMAND=`CheckCommands $1`
220
- if [ "X${COMMAND}" = "X" ]; then
221
- echo "ERROR: $1 is not command name"
222
- exit 1
223
- fi
224
- fi
225
-
226
- shift
227
- done
228
-
229
- #
230
- # Command
231
- #
232
- if [ "X${COMMAND}" = "X" ]; then
233
- echo "ERROR: command name is not specified"
234
- echo ""
235
- PrintUsage ${PROGRAM_NAME}
236
- exit 1
237
- fi
238
-
239
- #
240
- # NODE_ENV_VALUE
241
- #
242
- if [ "X${NODE_ENV_VALUE}" = "X" ]; then
243
- NODE_ENV_VALUE="development"
244
- fi
245
-
246
- #
247
- # Make NODE_DEBUG environment
248
- #
249
- DEBUG_ENV_PARAM=""
250
- if [ ${DEBUG_ENV_LEVEL} -ge 4 ]; then
251
- DEBUG_ENV_PARAM="LOGLEVEL_DBG"
252
- elif [ ${DEBUG_ENV_LEVEL} -ge 3 ]; then
253
- DEBUG_ENV_PARAM="LOGLEVEL_MSG"
254
- elif [ ${DEBUG_ENV_LEVEL} -ge 2 ]; then
255
- DEBUG_ENV_PARAM="LOGLEVEL_WAN"
256
- elif [ ${DEBUG_ENV_LEVEL} -ge 1 ]; then
257
- DEBUG_ENV_PARAM="LOGLEVEL_ERR"
258
- else
259
- DEBUG_ENV_PARAM="LOGLEVEL_SILENT"
260
- fi
261
-
262
- if [ "X${DEBUG_ENV_CUSTOM}" != "X" ]; then
263
- if [ "X${DEBUG_ENV_PARAM}" != "X" ]; then
264
- DEBUG_ENV_PARAM="${DEBUG_ENV_PARAM},"
265
- fi
266
- DEBUG_ENV_PARAM="${DEBUG_ENV_PARAM}${DEBUG_ENV_CUSTOM}"
267
- fi
268
-
269
- #
270
- # Logging for NODE_LOGGER
271
- #
272
- if [ "X${IS_LOGGING}" = "Xyes" ]; then
273
- NODE_LOGGER=""
274
- else
275
- if [ "X${NODE_LOGGER}" = "Xyes" ]; then
276
- NODE_LOGGER=""
277
- elif [ "X${NODE_LOGGER}" = "Xno" ]; then
278
- NODE_LOGGER="no"
279
- elif [ "X${NODE_LOGGER}" != "X" ]; then
280
- echo "WARNING: NODE_LOGGER environment has wrong value(${NODE_LOGGER}), then do logging(default)"
281
- NODE_LOGGER=""
282
- fi
283
- fi
284
-
285
- #
286
- # Executing(current at SRCTOP)
287
- #
288
- cd ${SRCTOP}
289
- if [ ${DEBUG_ENV_LEVEL} -ge 4 ]; then
290
- echo "***** RUN *****"
291
- echo "test/auto_init_config_json.sh"
292
- 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 test/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"
293
- echo "***************"
294
- fi
295
-
296
- test/auto_init_config_json.sh
297
- if [ $? -ne 0 ]; then
298
- echo "ERROR: Could not initialize local.json(symbolic link to dummy)"
299
- exit 1
300
- fi
301
-
302
- 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} test/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}
303
- if [ $? -ne 0 ]; then
304
- echo "ERROR: The test failed."
305
- test/auto_init_config_json.sh -restore
306
- exit 1
307
- fi
308
-
309
- test/auto_init_config_json.sh -restore
310
- if [ $? -ne 0 ]; then
311
- echo "ERROR: Could not restore local.json"
312
- exit 1
313
- fi
314
-
315
- exit 0
316
-
317
- #
318
- # VIM modelines
319
- #
320
- # vim:set ts=4 fenc=utf-8:
321
- #