k2hr3-api 1.0.24 → 1.0.26

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 (42) hide show
  1. package/ChangeLog +12 -0
  2. package/app.js +63 -30
  3. package/bin/run.sh +14 -0
  4. package/config/default.json +3 -2
  5. package/lib/k2hr3config.js +12 -0
  6. package/lib/k2hr3dkc.js +903 -13
  7. package/lib/k2hr3keys.js +1 -0
  8. package/lib/k2hr3tokens.js +147 -60
  9. package/package.json +10 -5
  10. package/routes/tenant.js +1014 -0
  11. package/routes/userTokens.js +77 -126
  12. package/tests/auto_all_spec.js +4 -0
  13. package/tests/auto_tenant.js +989 -0
  14. package/tests/auto_tenant_spec.js +79 -0
  15. package/tests/auto_usertokens.js +6 -6
  16. package/tests/manual_acr_delete.js +1 -0
  17. package/tests/manual_acr_get.js +1 -0
  18. package/tests/manual_acr_postput.js +1 -0
  19. package/tests/manual_allusertenant_get.js +58 -3
  20. package/tests/manual_extdata_get.js +1 -0
  21. package/tests/manual_list_gethead.js +1 -0
  22. package/tests/manual_policy_delete.js +1 -0
  23. package/tests/manual_policy_gethead.js +3 -1
  24. package/tests/manual_policy_postput.js +1 -0
  25. package/tests/manual_resource_delete.js +1 -0
  26. package/tests/manual_resource_gethead.js +1 -0
  27. package/tests/manual_resource_postput.js +1 -0
  28. package/tests/manual_role_delete.js +2 -0
  29. package/tests/manual_role_gethead.js +4 -0
  30. package/tests/manual_role_postput.js +2 -0
  31. package/tests/manual_service_delete.js +1 -0
  32. package/tests/manual_service_gethead.js +1 -0
  33. package/tests/manual_service_postput.js +1 -0
  34. package/tests/manual_tenant_delete.js +152 -0
  35. package/tests/manual_tenant_gethead.js +268 -0
  36. package/tests/manual_tenant_postput.js +293 -0
  37. package/tests/manual_test.sh +21 -7
  38. package/tests/manual_userdata_get.js +1 -0
  39. package/tests/manual_usertoken_gethead.js +1 -0
  40. package/tests/manual_usertoken_postput.js +1 -0
  41. package/tests/manual_version_get.js +1 -0
  42. package/tests/test.sh +2 -0
@@ -0,0 +1,268 @@
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: Mon Jun 3 2023
17
+ * REVISION:
18
+ *
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ var http = require('http');
24
+ var https = require('https');
25
+
26
+ var cacerts = require('../lib/cacerts');
27
+ var apiutil = require('../lib/k2hr3apiutil');
28
+ var cliutil = require('../lib/k2hr3cliutil');
29
+
30
+ // Debug logging objects
31
+ var r3logger = require('../lib/dbglogging');
32
+
33
+ //
34
+ // Hostname and port from env
35
+ //
36
+ var hostname = apiutil.getSafeString(process.env.APIHOST);
37
+ var hostport = apiutil.getSafeString(process.env.APIPORT);
38
+ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
39
+
40
+ //
41
+ // Request API for test
42
+ //
43
+ function getV1Tenant(token, name, is_expand)
44
+ {
45
+ var path;
46
+ var urlarg;
47
+ if(apiutil.isSafeString(name)){
48
+ path = '/v1/tenant/' + name;
49
+ urlarg = '';
50
+ }else{
51
+ path = '/v1/tenant';
52
+ if(is_expand){
53
+ urlarg = encodeURI('?expand=true');
54
+ }else{
55
+ urlarg = encodeURI('?expand=false');
56
+ }
57
+ }
58
+
59
+ var headers = {
60
+ 'Content-Type': 'application/json',
61
+ 'Content-Length': 0,
62
+ 'X-Auth-Token': token
63
+ };
64
+ var options = {
65
+ 'host': hostname,
66
+ 'port': hostport,
67
+ 'path': path + urlarg,
68
+ 'method': 'GET',
69
+ 'headers': headers
70
+ };
71
+
72
+ r3logger.dlog('request options = ' + JSON.stringify(options));
73
+ r3logger.dlog('request headers = ' + JSON.stringify(headers));
74
+
75
+ var httpobj;
76
+ if(is_https){
77
+ if(null !== cacerts.ca){
78
+ options.ca = cacerts.ca;
79
+ }
80
+ options.rejectUnauthorized = false; // always insecure for this manual test
81
+ options.agent = new https.Agent(options);
82
+ httpobj = https;
83
+ }else{
84
+ options.agent = new http.Agent(options);
85
+ httpobj = http;
86
+ }
87
+
88
+ var req = httpobj.request(options, function(res)
89
+ {
90
+ var response = '';
91
+ console.log('RESPONSE CODE = ' + res.statusCode);
92
+ r3logger.dlog('response status = ' + res.statusCode);
93
+ r3logger.dlog('response header = ' + JSON.stringify(res.headers));
94
+ res.setEncoding('utf8');
95
+
96
+ res.on('data', function (chunk)
97
+ {
98
+ r3logger.dlog('response chunk = ' + chunk);
99
+ response += chunk;
100
+ });
101
+
102
+ res.on('end', function(result) // eslint-disable-line no-unused-vars
103
+ {
104
+ r3logger.mlog(r3logger.dump(response)); // response is object(or not)
105
+ console.log('RESPONSE BODY = ' + JSON.stringify(response));
106
+ process.exit(0);
107
+ });
108
+ });
109
+
110
+ req.on('error', function(e)
111
+ {
112
+ r3logger.elog('problem with request: ' + e.message);
113
+ });
114
+ req.end();
115
+ }
116
+
117
+ function headV1Tenant(token, name)
118
+ {
119
+ var headers = {
120
+ 'Content-Type': 'application/json',
121
+ 'Content-Length': 0,
122
+ 'X-Auth-Token': token
123
+ };
124
+ var options = {
125
+ 'host': hostname,
126
+ 'port': hostport,
127
+ 'path': '/v1/tenant/' + name,
128
+ 'method': 'HEAD',
129
+ 'headers': headers
130
+ };
131
+
132
+ r3logger.dlog('request options = ' + JSON.stringify(options));
133
+ r3logger.dlog('request headers = ' + JSON.stringify(headers));
134
+
135
+ var httpobj;
136
+ if(is_https){
137
+ if(null !== cacerts.ca){
138
+ options.ca = cacerts.ca;
139
+ }
140
+ options.rejectUnauthorized = false; // always insecure for this manual test
141
+ options.agent = new https.Agent(options);
142
+ httpobj = https;
143
+ }else{
144
+ options.agent = new http.Agent(options);
145
+ httpobj = http;
146
+ }
147
+
148
+ var req = httpobj.request(options, function(res)
149
+ {
150
+ var response = '';
151
+ console.log('RESPONSE CODE = ' + res.statusCode);
152
+ r3logger.dlog('response status = ' + res.statusCode);
153
+ r3logger.dlog('response header = ' + JSON.stringify(res.headers));
154
+ res.setEncoding('utf8');
155
+
156
+ res.on('data', function (chunk)
157
+ {
158
+ r3logger.dlog('response chunk = ' + chunk);
159
+ response += chunk;
160
+ });
161
+
162
+ res.on('end', function(result) // eslint-disable-line no-unused-vars
163
+ {
164
+ r3logger.mlog(r3logger.dump(response)); // response is object(or not)
165
+ console.log('RESPONSE BODY = ' + JSON.stringify(response));
166
+ process.exit(0);
167
+ });
168
+ });
169
+
170
+ req.on('error', function(e)
171
+ {
172
+ r3logger.elog('problem with request: ' + e.message);
173
+ });
174
+ req.end();
175
+ }
176
+
177
+ //
178
+ // run
179
+ //
180
+ cliutil.getConsoleInput('Method(GET/HEAD) : ', true, false, function(isbreak, method)
181
+ {
182
+ if(isbreak){
183
+ process.exit(0);
184
+ }
185
+ var _method = method;
186
+
187
+ cliutil.getConsoleInput('Unscoped(or Scoped) user token : ', true, false, function(isbreak, token)
188
+ {
189
+ if(isbreak){
190
+ process.exit(0);
191
+ }
192
+ var _token = token;
193
+
194
+ if(apiutil.compareCaseString('get', _method)){
195
+ cliutil.getConsoleInput('Tenant name(null is get tenant list) : ', true, false, function(isbreak, tenant)
196
+ {
197
+ if(isbreak){
198
+ process.exit(0);
199
+ }
200
+
201
+ if(apiutil.isSafeString(tenant)){
202
+ var _tenant = apiutil.getSafeString(tenant);
203
+
204
+ //
205
+ // Run
206
+ //
207
+ getV1Tenant(_token, _tenant, false);
208
+
209
+ }else{
210
+ cliutil.getConsoleInput('Expand tenant list(yes(default)/no) : ', true, false, function(isbreak, expand)
211
+ {
212
+ if(isbreak){
213
+ process.exit(0);
214
+ }
215
+
216
+ var _is_expand;
217
+ if('' === apiutil.getSafeString(expand) || apiutil.compareCaseString('null', apiutil.getSafeString(expand))){
218
+ _is_expand = true;
219
+ }else if(apiutil.compareCaseString('yes', apiutil.getSafeString(expand)) || apiutil.compareCaseString('true', apiutil.getSafeString(expand))){
220
+ _is_expand = true;
221
+ }else if(apiutil.compareCaseString('no', apiutil.getSafeString(expand)) || apiutil.compareCaseString('false', apiutil.getSafeString(expand))){
222
+ _is_expand = false;
223
+ }else{
224
+ console.log('function expand must be empty or yes(true) or no(false) : ' + expand);
225
+ process.exit(0);
226
+ }
227
+
228
+ //
229
+ // Run
230
+ //
231
+ getV1Tenant(_token, null, _is_expand);
232
+ });
233
+ }
234
+ });
235
+
236
+ }else if(apiutil.compareCaseString('head', _method)){
237
+ cliutil.getConsoleInput('Tenant name : ', true, false, function(isbreak, tenant)
238
+ {
239
+ if(isbreak){
240
+ process.exit(0);
241
+ }
242
+
243
+ if(!apiutil.isSafeString(tenant)){
244
+ console.log('method HEAD must specify tenant name');
245
+ process.exit(0);
246
+ }
247
+ var _tenant = apiutil.getSafeString(tenant);
248
+
249
+ //
250
+ // Run
251
+ //
252
+ headV1Tenant(_token, _tenant);
253
+ });
254
+ }else{
255
+ console.log('method must be GET or HEAD : ' + _method);
256
+ process.exit(0);
257
+ }
258
+ });
259
+ });
260
+
261
+ /*
262
+ * Local variables:
263
+ * tab-width: 4
264
+ * c-basic-offset: 4
265
+ * End:
266
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
267
+ * vim<600: noexpandtab sw=4 ts=4
268
+ */
@@ -0,0 +1,293 @@
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: Mon Jun 3 2023
17
+ * REVISION:
18
+ *
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ var http = require('http');
24
+ var https = require('https');
25
+
26
+ var cacerts = require('../lib/cacerts');
27
+ var apiutil = require('../lib/k2hr3apiutil');
28
+ var cliutil = require('../lib/k2hr3cliutil');
29
+
30
+ // Debug logging objects
31
+ var r3logger = require('../lib/dbglogging');
32
+
33
+ //
34
+ // Hostname and port from env
35
+ //
36
+ var hostname = apiutil.getSafeString(process.env.APIHOST);
37
+ var hostport = apiutil.getSafeString(process.env.APIPORT);
38
+ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
39
+
40
+ //
41
+ // Request API for test
42
+ //
43
+ function postputV1Tenant(method, token, is_create, name, desc, display, users, id)
44
+ {
45
+ var strbody = '';
46
+ var headers = {
47
+ 'Content-Type': 'application/json',
48
+ 'X-Auth-Token': token
49
+ };
50
+ var options = {
51
+ 'host': hostname,
52
+ 'port': hostport,
53
+ 'path': '/v1/tenant',
54
+ 'method': method
55
+ };
56
+
57
+ var path;
58
+ if(apiutil.compareCaseString('post', method)){
59
+ var body;
60
+ if(is_create){
61
+ body = {
62
+ 'tenant': {
63
+ 'name': name,
64
+ 'desc': desc,
65
+ 'display': display,
66
+ 'users': users
67
+ }
68
+ };
69
+ path = '/v1/tenant';
70
+ }else{
71
+ body = {
72
+ 'tenant': {
73
+ 'id': id,
74
+ 'desc': desc,
75
+ 'display': display,
76
+ 'users': users,
77
+ }
78
+ };
79
+ path = '/v1/tenant/' + name;
80
+ }
81
+
82
+ strbody = JSON.stringify(body);
83
+ headers['Content-Length'] = strbody.length;
84
+ options.headers = headers;
85
+ options.path = path;
86
+
87
+ }else if(apiutil.compareCaseString('put', method)){
88
+ var urlarg = '';
89
+ var already_set = false;
90
+
91
+ if(is_create){
92
+ path = '/v1/tenant';
93
+ urlarg = '?name=' + name;
94
+ already_set = true;
95
+ }else{
96
+ urlarg = '?id=' + id;
97
+ path = '/v1/tenant/' + name;
98
+ }
99
+ if('' === desc || apiutil.isSafeString(desc)){
100
+ urlarg += already_set ? '&desc=' : '?desc=';
101
+ urlarg += desc;
102
+ already_set = true;
103
+ }
104
+ if('' === display || apiutil.isSafeString(display)){
105
+ urlarg += already_set ? '&display=' : '?display=';
106
+ urlarg += display;
107
+ already_set = true;
108
+ }
109
+ if(!apiutil.isEmptyArray(users)){
110
+ urlarg += already_set ? '&users=' : '?users=';
111
+ urlarg += JSON.stringify(users);
112
+ already_set = true;
113
+ }
114
+
115
+ headers['Content-Length'] = 0;
116
+ options.headers = headers;
117
+ options.path = path + encodeURI(urlarg);
118
+
119
+ }else{
120
+ console.log('method must be POST or PUT : ' + method);
121
+ process.exit(0);
122
+ }
123
+
124
+ r3logger.dlog('request options = ' + JSON.stringify(options));
125
+ r3logger.dlog('request headers = ' + JSON.stringify(headers));
126
+ r3logger.dlog('request body = ' + strbody);
127
+
128
+ var httpobj;
129
+ if(is_https){
130
+ if(null !== cacerts.ca){
131
+ options.ca = cacerts.ca;
132
+ }
133
+ options.rejectUnauthorized = false; // always insecure for this manual test
134
+ options.agent = new https.Agent(options);
135
+ httpobj = https;
136
+ }else{
137
+ options.agent = new http.Agent(options);
138
+ httpobj = http;
139
+ }
140
+
141
+ var req = httpobj.request(options, function(res)
142
+ {
143
+ var response = '';
144
+ console.log('RESPONSE CODE = ' + res.statusCode);
145
+ r3logger.dlog('response status = ' + res.statusCode);
146
+ r3logger.dlog('response header = ' + JSON.stringify(res.headers));
147
+ res.setEncoding('utf8');
148
+
149
+ res.on('data', function (chunk)
150
+ {
151
+ r3logger.dlog('response chunk = ' + chunk);
152
+ response += chunk;
153
+ });
154
+
155
+ res.on('end', function(result) // eslint-disable-line no-unused-vars
156
+ {
157
+ r3logger.mlog(r3logger.dump(response)); // response is object(or not)
158
+ console.log('RESPONSE BODY = ' + JSON.stringify(response));
159
+ process.exit(0);
160
+ });
161
+ });
162
+
163
+ req.on('error', function(e)
164
+ {
165
+ r3logger.elog('problem with request: ' + e.message);
166
+ });
167
+
168
+ // write data to request body
169
+ if('' !== strbody){
170
+ req.write(strbody);
171
+ }
172
+ req.end();
173
+ }
174
+
175
+ //
176
+ // run
177
+ //
178
+ cliutil.getConsoleInput('Method(POST/PUT) : ', true, false, function(isbreak, method)
179
+ {
180
+ if(isbreak){
181
+ process.exit(0);
182
+ }
183
+
184
+ var _method;
185
+ if(apiutil.compareCaseString('post', method)){
186
+ _method = 'POST';
187
+ }else if(apiutil.compareCaseString('put', method)){
188
+ _method = 'PUT';
189
+ }else{
190
+ console.log('method must be POST or PUT : ' + method);
191
+ process.exit(0);
192
+ }
193
+
194
+ cliutil.getConsoleInput('Unscoped(or Scoped) user token : ', true, false, function(isbreak, token)
195
+ {
196
+ if(isbreak){
197
+ process.exit(0);
198
+ }
199
+ var _token = token;
200
+
201
+ cliutil.getConsoleInput('Create or Update tenant(create(default)/update) : ', true, false, function(isbreak, mode)
202
+ {
203
+ if(isbreak){
204
+ process.exit(0);
205
+ }
206
+
207
+ var _is_create;
208
+ if('' === apiutil.getSafeString(mode) || apiutil.compareCaseString('null', apiutil.getSafeString(mode))){
209
+ _is_create = true;
210
+ }else if(apiutil.compareCaseString('create', apiutil.getSafeString(mode))){
211
+ _is_create = true;
212
+ }else if(apiutil.compareCaseString('update', apiutil.getSafeString(mode))){
213
+ _is_create = false;
214
+ }else{
215
+ console.log('function mode must be empty or create or update : ' + mode);
216
+ process.exit(0);
217
+ }
218
+
219
+ cliutil.getConsoleInput('tenant name(if not specify, add prefix local@) : ', true, false, function(isbreak, name)
220
+ {
221
+ if(isbreak){
222
+ process.exit(0);
223
+ }
224
+ var _name = name;
225
+
226
+ cliutil.getConsoleInput('tenant description(allow null) : ', true, false, function(isbreak, desc)
227
+ {
228
+ if(isbreak){
229
+ process.exit(0);
230
+ }
231
+ var _desc = desc;
232
+
233
+ cliutil.getConsoleInput('tenant display name(allow null) : ', true, false, function(isbreak, display)
234
+ {
235
+ if(isbreak){
236
+ process.exit(0);
237
+ }
238
+ var _display = display;
239
+
240
+ cliutil.getConsoleInput('tenant users(input user name separate with ,) : ', true, false, function(isbreak, users)
241
+ {
242
+ if(isbreak){
243
+ process.exit(0);
244
+ }
245
+
246
+ var _users = Array();
247
+ var tmparr = apiutil.getSafeString(users).split(',');
248
+ for(var cnt = 0; cnt < tmparr.length; ++cnt){
249
+ var tmpstr = apiutil.getSafeString(tmparr[cnt].trim());
250
+ if('' !== tmpstr){
251
+ _users.push(tmpstr);
252
+ }
253
+ }
254
+ if(apiutil.isEmptyArray(_users)){
255
+ _users = null;
256
+ }
257
+
258
+ if(_is_create){
259
+ //
260
+ // Create mode
261
+ //
262
+ postputV1Tenant(_method, _token, _is_create, _name, _desc, _display, _users, null);
263
+
264
+ }else{
265
+ // // Update mode
266
+ //
267
+ cliutil.getConsoleInput('tenant id : ', true, false, function(isbreak, id)
268
+ {
269
+ if(isbreak){
270
+ process.exit(0);
271
+ }
272
+ var _id = id;
273
+
274
+ // run
275
+ postputV1Tenant(_method, _token, _is_create, _name, _desc, _display, _users, _id);
276
+ });
277
+ }
278
+ });
279
+ });
280
+ });
281
+ });
282
+ });
283
+ });
284
+ });
285
+
286
+ /*
287
+ * Local variables:
288
+ * tab-width: 4
289
+ * c-basic-offset: 4
290
+ * End:
291
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
292
+ * vim<600: noexpandtab sw=4 ts=4
293
+ */
@@ -49,6 +49,9 @@ COMMANDS="
49
49
  role_delete
50
50
  role_gethead
51
51
  role_postput
52
+ tenant_delete
53
+ tenant_gethead
54
+ tenant_postput
52
55
  service_postput
53
56
  service_gethead
54
57
  service_delete
@@ -72,7 +75,7 @@ PrintUsage()
72
75
  {
73
76
  echo "Usage: $1 [--apihost(-a) hostname]"
74
77
  echo " [--apiport(-p) port]"
75
- echo " [--sec(-s) | --https]"
78
+ echo " [--https | --http]"
76
79
  echo " [--debuglevel(-d) DBG/MSG/WARN/ERR/(custom debug level)]"
77
80
  echo " <Command>"
78
81
  echo ""
@@ -102,6 +105,10 @@ PrintUsage()
102
105
  echo " role_gethead : Get(Head) role(v1)"
103
106
  echo " role_delete : Delete role(v1)"
104
107
  echo ""
108
+ echo " tenant_postput : Post(Put) tenant(v1)"
109
+ echo " tenant_gethead : Get(Head) tenant(v1)"
110
+ echo " tenant_delete : Delete tenant(v1)"
111
+ echo ""
105
112
  echo " service_postput : Post(Put) service(v1)"
106
113
  echo " service_gethead : Get(head) service(v1)"
107
114
  echo " service_delete : Delete service(v1)"
@@ -174,7 +181,7 @@ while [ $# -ne 0 ]; do
174
181
  #
175
182
  # API PORT
176
183
  #
177
- if [ -n "${APIPORT}" ]; then
184
+ if [ "${APIPORT}" -ne 0 ]; then
178
185
  echo "[ERROR] already specified --apiport option"
179
186
  exit 1
180
187
  fi
@@ -192,13 +199,20 @@ while [ $# -ne 0 ]; do
192
199
  fi
193
200
  APIPORT="$1"
194
201
 
195
- elif [ "$1" = "-s" ] || [ "$1" = "-S" ] || [ "$1" = "--sec" ] || [ "$1" = "--SEC" ] || [ "$1" = "--https" ] || [ "$1" = "--HTTPS" ]; then
202
+ elif [ "$1" = "--https" ] || [ "$1" = "--HTTPS" ]; then
196
203
  if [ -n "${HTTPS_ENV}" ]; then
197
- echo "[ERROR] already specified --sec(-s) or --https option"
204
+ echo "[ERROR] already specified --https or --http option"
198
205
  exit 1
199
206
  fi
200
207
  HTTPS_ENV="yes"
201
208
 
209
+ elif [ "$1" = "--http" ] || [ "$1" = "--HTTP" ]; then
210
+ if [ -n "${HTTPS_ENV}" ]; then
211
+ echo "[ERROR] already specified --https or --http option"
212
+ exit 1
213
+ fi
214
+ HTTPS_ENV="no"
215
+
202
216
  elif [ "$1" = "-d" ] || [ "$1" = "-D" ] || [ "$1" = "--debuglevel" ] || [ "$1" = "--DEBUGLEVEL" ]; then
203
217
  #
204
218
  # DEBUG option
@@ -291,7 +305,7 @@ fi
291
305
  #
292
306
  # Check HTTPS
293
307
  #
294
- if [ -n "${HTTPS_ENV}" ]; then
308
+ if [ -z "${HTTPS_ENV}" ]; then
295
309
  HTTPS_ENV="yes"
296
310
  fi
297
311
 
@@ -302,7 +316,7 @@ if [ -z "${APIHOST}" ]; then
302
316
  APIHOST="$(hostname | tr -d '\n')"
303
317
  fi
304
318
  if [ "${APIPORT}" -eq 0 ]; then
305
- if [ -n "${HTTPS_ENV}" ]; then
319
+ if [ "${HTTPS_ENV}" = "yes" ]; then
306
320
  APIPORT=443
307
321
  else
308
322
  APIPORT=3000
@@ -320,7 +334,7 @@ if [ "${DEBUG_ENV_LEVEL}" -ge 4 ]; then
320
334
  echo "***************"
321
335
  fi
322
336
 
323
- if ! NODE_PATH="${NODE_PATH}" NODE_DEBUG="${DEBUG_ENV_PARAM}" APIHOST="${APIHOST}" APIPORT="${APIPORT}" HTTPS_ENV="${HTTPS_ENV}" node "${DEBUG_OPTION}" "tests/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"; then
337
+ if ! /bin/sh -c "NODE_PATH=${NODE_PATH} NODE_DEBUG=${DEBUG_ENV_PARAM} APIHOST=${APIHOST} APIPORT=${APIPORT} HTTPS_ENV=${HTTPS_ENV} node ${DEBUG_OPTION} tests/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"; then
324
338
  EXIT_CODE="$?"
325
339
  echo "[ERROR] Failed to run command with exit code : ${EXIT_CODE}"
326
340
  exit "${EXIT_CODE}"
@@ -76,6 +76,7 @@ function getV1UserData(registerpath, is_gzip)
76
76
  if(null !== cacerts.ca){
77
77
  options.ca = cacerts.ca;
78
78
  }
79
+ options.rejectUnauthorized = false; // always insecure for this manual test
79
80
  options.agent = new https.Agent(options);
80
81
  httpobj = https;
81
82
  }else{
@@ -65,6 +65,7 @@ function headV1UserTokens(token, method)
65
65
  if(null !== cacerts.ca){
66
66
  options.ca = cacerts.ca;
67
67
  }
68
+ options.rejectUnauthorized = false; // always insecure for this manual test
68
69
  options.agent = new https.Agent(options);
69
70
  httpobj = https;
70
71
  }else{
@@ -131,6 +131,7 @@ function postV1UserTokens(method, token, othertoken, user, passwd, tenant)
131
131
  if(null !== cacerts.ca){
132
132
  options.ca = cacerts.ca;
133
133
  }
134
+ options.rejectUnauthorized = false; // always insecure for this manual test
134
135
  options.agent = new https.Agent(options);
135
136
  httpobj = https;
136
137
  }else{
@@ -64,6 +64,7 @@ function getV1Version(is_top)
64
64
  if(null !== cacerts.ca){
65
65
  options.ca = cacerts.ca;
66
66
  }
67
+ options.rejectUnauthorized = false; // always insecure for this manual test
67
68
  options.agent = new https.Agent(options);
68
69
  httpobj = https;
69
70
  }else{
package/tests/test.sh CHANGED
@@ -45,6 +45,7 @@ COMMANDS="
45
45
  resource
46
46
  policy
47
47
  role
48
+ tenant
48
49
  service
49
50
  acr
50
51
  userdata
@@ -82,6 +83,7 @@ PrintUsage()
82
83
  echo " resource : Resource API test"
83
84
  echo " policy : Policy API test"
84
85
  echo " role : Role API test"
86
+ echo " tenant : Tenant API test"
85
87
  echo " service : Service API test"
86
88
  echo " acr : Accessing Cross Role(ACR) API test"
87
89
  echo " userdata : Get userdata for openstack API test"