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.
- package/config/k2hr3-init.sh.templ +4 -4
- package/dist/.gitkeep +0 -0
- package/dist/src/app.js +262 -0
- package/{bin → dist/src/bin}/run.sh +1 -1
- package/dist/src/bin/watcher.js +113 -0
- package/dist/src/bin/www.js +217 -0
- package/dist/src/lib/basicipcheck.js +392 -0
- package/dist/src/lib/cacerts.js +106 -0
- package/dist/src/lib/dbglogging.js +190 -0
- package/dist/src/lib/dummyuserapi.js +719 -0
- package/dist/src/lib/ipwatch.js +354 -0
- package/dist/src/lib/k2hr3acrutil.js +532 -0
- package/dist/src/lib/k2hr3apiutil.js +1444 -0
- package/dist/src/lib/k2hr3cliutil.js +183 -0
- package/dist/src/lib/k2hr3config.js +832 -0
- package/dist/src/lib/k2hr3cryptutil.js +258 -0
- package/dist/src/lib/k2hr3dkc.js +12121 -0
- package/dist/src/lib/k2hr3extdata.js +198 -0
- package/dist/src/lib/k2hr3keys.js +207 -0
- package/dist/src/lib/k2hr3resutil.js +111 -0
- package/dist/src/lib/k2hr3template.js +6546 -0
- package/dist/src/lib/k2hr3tokens.js +2643 -0
- package/dist/src/lib/k2hr3userdata.js +296 -0
- package/dist/src/lib/k8soidc.js +1000 -0
- package/dist/src/lib/openstackapiv2.js +695 -0
- package/dist/src/lib/openstackapiv3.js +932 -0
- package/dist/src/lib/openstackep.js +667 -0
- package/{tests/auto_common.js → dist/src/lib/types.js} +4 -38
- package/dist/src/routes/acr.js +704 -0
- package/dist/src/routes/debugVerify.js +294 -0
- package/dist/src/routes/extdata.js +219 -0
- package/dist/src/routes/list.js +264 -0
- package/dist/src/routes/policy.js +840 -0
- package/dist/src/routes/resource.js +1489 -0
- package/dist/src/routes/role.js +2627 -0
- package/dist/src/routes/service.js +908 -0
- package/dist/src/routes/tenant.js +1141 -0
- package/dist/src/routes/userTokens.js +482 -0
- package/dist/src/routes/userdata.js +212 -0
- package/dist/src/routes/version.js +103 -0
- package/package.json +152 -121
- package/ChangeLog +0 -378
- package/app.js +0 -292
- package/bin/watcher +0 -122
- package/bin/www +0 -180
- package/eslint.config.mjs +0 -68
- package/lib/basicipcheck.js +0 -376
- package/lib/cacerts.js +0 -71
- package/lib/dbglogging.js +0 -151
- package/lib/dummyuserapi.js +0 -766
- package/lib/ipwatch.js +0 -379
- package/lib/k2hr3acrutil.js +0 -516
- package/lib/k2hr3apiutil.js +0 -1494
- package/lib/k2hr3cliutil.js +0 -191
- package/lib/k2hr3config.js +0 -826
- package/lib/k2hr3cryptutil.js +0 -254
- package/lib/k2hr3dkc.js +0 -12632
- package/lib/k2hr3extdata.js +0 -198
- package/lib/k2hr3keys.js +0 -234
- package/lib/k2hr3resutil.js +0 -100
- package/lib/k2hr3template.js +0 -6925
- package/lib/k2hr3tokens.js +0 -2799
- package/lib/k2hr3userdata.js +0 -312
- package/lib/k8soidc.js +0 -1012
- package/lib/openstackapiv2.js +0 -764
- package/lib/openstackapiv3.js +0 -1032
- package/lib/openstackep.js +0 -553
- package/routes/acr.js +0 -738
- package/routes/debugVerify.js +0 -263
- package/routes/extdata.js +0 -232
- package/routes/list.js +0 -270
- package/routes/policy.js +0 -869
- package/routes/resource.js +0 -1441
- package/routes/role.js +0 -2664
- package/routes/service.js +0 -894
- package/routes/tenant.js +0 -1095
- package/routes/userTokens.js +0 -511
- package/routes/userdata.js +0 -218
- package/routes/version.js +0 -108
- package/templ/Dockerfile.templ +0 -71
- package/tests/auto_acr.js +0 -1101
- package/tests/auto_acr_spec.js +0 -79
- package/tests/auto_all_spec.js +0 -142
- package/tests/auto_control_subprocess.sh +0 -243
- package/tests/auto_extdata.js +0 -220
- package/tests/auto_extdata_spec.js +0 -79
- package/tests/auto_init_config_json.sh +0 -275
- package/tests/auto_k2hdkc_server.ini +0 -109
- package/tests/auto_k2hdkc_slave.ini +0 -83
- package/tests/auto_list.js +0 -439
- package/tests/auto_list_spec.js +0 -79
- package/tests/auto_policy.js +0 -1579
- package/tests/auto_policy_spec.js +0 -79
- package/tests/auto_resource.js +0 -10956
- package/tests/auto_resource_spec.js +0 -79
- package/tests/auto_role.js +0 -6150
- package/tests/auto_role_spec.js +0 -79
- package/tests/auto_service.js +0 -770
- package/tests/auto_service_spec.js +0 -79
- package/tests/auto_subprocesses.js +0 -114
- package/tests/auto_template.sh +0 -126
- package/tests/auto_tenant.js +0 -1100
- package/tests/auto_tenant_spec.js +0 -79
- package/tests/auto_token_util.js +0 -219
- package/tests/auto_userdata.js +0 -292
- package/tests/auto_userdata_spec.js +0 -79
- package/tests/auto_usertokens.js +0 -565
- package/tests/auto_usertokens_spec.js +0 -79
- package/tests/auto_version.js +0 -127
- package/tests/auto_version_spec.js +0 -79
- package/tests/auto_watcher.js +0 -157
- package/tests/auto_watcher_spec.js +0 -79
- package/tests/k2hdkc_test.data +0 -986
- package/tests/k2hdkc_test_load.sh +0 -255
- package/tests/k2hr3template_test.js +0 -187
- package/tests/k2hr3template_test.sh +0 -339
- package/tests/k2hr3template_test_async.js +0 -216
- package/tests/k2hr3template_test_template.result +0 -7117
- package/tests/k2hr3template_test_template.txt +0 -3608
- package/tests/k2hr3template_test_vars.js +0 -194
- package/tests/manual_acr_delete.js +0 -143
- package/tests/manual_acr_get.js +0 -297
- package/tests/manual_acr_postput.js +0 -215
- package/tests/manual_allusertenant_get.js +0 -113
- package/tests/manual_extdata_get.js +0 -191
- package/tests/manual_k2hr3keys_get.js +0 -84
- package/tests/manual_list_gethead.js +0 -230
- package/tests/manual_policy_delete.js +0 -132
- package/tests/manual_policy_gethead.js +0 -275
- package/tests/manual_policy_postput.js +0 -297
- package/tests/manual_resource_delete.js +0 -433
- package/tests/manual_resource_gethead.js +0 -423
- package/tests/manual_resource_postput.js +0 -487
- package/tests/manual_role_delete.js +0 -404
- package/tests/manual_role_gethead.js +0 -547
- package/tests/manual_role_postput.js +0 -544
- package/tests/manual_service_delete.js +0 -153
- package/tests/manual_service_gethead.js +0 -178
- package/tests/manual_service_postput.js +0 -348
- package/tests/manual_tenant_delete.js +0 -186
- package/tests/manual_tenant_gethead.js +0 -268
- package/tests/manual_tenant_postput.js +0 -293
- package/tests/manual_test.sh +0 -352
- package/tests/manual_userdata_get.js +0 -173
- package/tests/manual_usertoken_gethead.js +0 -136
- package/tests/manual_usertoken_postput.js +0 -310
- package/tests/manual_version_get.js +0 -127
- package/tests/run_local_test_k2hdkc.sh +0 -174
- package/tests/test.sh +0 -333
package/tests/auto_acr_spec.js
DELETED
|
@@ -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 Dec 19 2017
|
|
17
|
-
* REVISION:
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
var common = require('./auto_common'); // Common objects for Chai
|
|
24
|
-
var chai = common.chai; // 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: ACR', function(){ // eslint-disable-line no-undef
|
|
69
|
-
require('./auto_acr');
|
|
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
|
-
*/
|
package/tests/auto_all_spec.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* K2HR3 REST API
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
|
-
*
|
|
6
|
-
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
|
-
* common management information for the cloud.
|
|
8
|
-
* K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
9
|
-
* These are stored as roles, resources, policies in K2hdkc, and the
|
|
10
|
-
* client system can dynamically read and modify these information.
|
|
11
|
-
*
|
|
12
|
-
* For the full copyright and license information, please view
|
|
13
|
-
* the license file that was distributed with this source code.
|
|
14
|
-
*
|
|
15
|
-
* AUTHOR: Takeshi Nakatani
|
|
16
|
-
* CREATE: Tue Dec 19 2017
|
|
17
|
-
* REVISION:
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
var common = require('./auto_common'); // Common objects for Chai
|
|
24
|
-
var chai = common.chai; // 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
|
-
// Main describe section
|
|
67
|
-
//--------------------------------------------------------------
|
|
68
|
-
describe('ALL K2HR3 API TEST', function(){ // eslint-disable-line no-undef
|
|
69
|
-
//
|
|
70
|
-
// Before in describe section
|
|
71
|
-
//
|
|
72
|
-
before(function(){ // eslint-disable-line no-undef
|
|
73
|
-
// Nothing to do
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
//
|
|
77
|
-
// After in describe section
|
|
78
|
-
//
|
|
79
|
-
after(function(){ // eslint-disable-line no-undef
|
|
80
|
-
// Nothing to do
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
// Sub testing scripts
|
|
85
|
-
//
|
|
86
|
-
describe('SUB API TEST: VERSION', function(){ // eslint-disable-line no-undef
|
|
87
|
-
require('./auto_version');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('SUB API TEST: USER TOKEN', function(){ // eslint-disable-line no-undef
|
|
91
|
-
require('./auto_usertokens');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
describe('SUB API TEST: LIST', function(){ // eslint-disable-line no-undef
|
|
95
|
-
require('./auto_list');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('SUB API TEST: RESOURCE', function(){ // eslint-disable-line no-undef
|
|
99
|
-
require('./auto_resource');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('SUB API TEST: POLICY', function(){ // eslint-disable-line no-undef
|
|
103
|
-
require('./auto_policy');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('SUB API TEST: ROLE', function(){ // eslint-disable-line no-undef
|
|
107
|
-
require('./auto_role');
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('SUB API TEST: TENANT', function(){ // eslint-disable-line no-undef
|
|
111
|
-
require('./auto_tenant');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe('SUB API TEST: ACR', function(){ // eslint-disable-line no-undef
|
|
115
|
-
require('./auto_acr');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe('SUB API TEST: SERVICE', function(){ // eslint-disable-line no-undef
|
|
119
|
-
require('./auto_service');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('SUB API TEST: USERDATA', function(){ // eslint-disable-line no-undef
|
|
123
|
-
require('./auto_userdata');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('SUB API TEST: EXTDATA', function(){ // eslint-disable-line no-undef
|
|
127
|
-
require('./auto_extdata');
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe('SUB PROC TEST: WATCHER', function(){ // eslint-disable-line no-undef
|
|
131
|
-
require('./auto_watcher');
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
/*
|
|
136
|
-
* Local variables:
|
|
137
|
-
* tab-width: 4
|
|
138
|
-
* c-basic-offset: 4
|
|
139
|
-
* End:
|
|
140
|
-
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
141
|
-
* vim<600: noexpandtab sw=4 ts=4
|
|
142
|
-
*/
|
|
@@ -1,243 +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 19 2017
|
|
18
|
-
# REVISION:
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
#----------------------------------------------------------
|
|
22
|
-
# This script starts/stops k2hdkc cluster/chmpx server/
|
|
23
|
-
# chmpx slave processes, and initializes data on k2hdkc for
|
|
24
|
-
# testing.
|
|
25
|
-
#----------------------------------------------------------
|
|
26
|
-
|
|
27
|
-
#==========================================================
|
|
28
|
-
# Common Variables
|
|
29
|
-
#==========================================================
|
|
30
|
-
PRGNAME=$(basename "$0")
|
|
31
|
-
SCRIPTDIR=$(dirname "$0")
|
|
32
|
-
SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd)
|
|
33
|
-
#SRCTOP=$(cd "${SCRIPTDIR}/.." || exit 1; pwd)
|
|
34
|
-
|
|
35
|
-
#==============================================================
|
|
36
|
-
# Utility functions
|
|
37
|
-
#==============================================================
|
|
38
|
-
#
|
|
39
|
-
# Usage
|
|
40
|
-
#
|
|
41
|
-
PrintUsage()
|
|
42
|
-
{
|
|
43
|
-
echo ""
|
|
44
|
-
echo "Usage: $1 [ --help(-h) ] [ --start(-str) | --stop(-stp) ] [--key(-k) <key>] [--interval(-i) <sec>] -- <process> <arg>..."
|
|
45
|
-
echo ""
|
|
46
|
-
echo "Option:"
|
|
47
|
-
echo " --start(-str) : start process"
|
|
48
|
-
echo " --stop(-stp) : stop process"
|
|
49
|
-
echo " --key(-k) <key> : key name for controling process(a part of pid file name)"
|
|
50
|
-
echo " --interval(-i) <sec> : interval second time"
|
|
51
|
-
echo ""
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
#==========================================================
|
|
55
|
-
# Parse options
|
|
56
|
-
#==========================================================
|
|
57
|
-
EXEC_MODE=""
|
|
58
|
-
RUN_INTERVAL=0
|
|
59
|
-
PID_FILENAME_EXT_PART=""
|
|
60
|
-
CHILD_PROCESS_NAME=""
|
|
61
|
-
CHILD_PROCESS_CMD=""
|
|
62
|
-
|
|
63
|
-
while [ $# -ne 0 ]; do
|
|
64
|
-
if [ -z "$1" ]; then
|
|
65
|
-
break
|
|
66
|
-
|
|
67
|
-
elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then
|
|
68
|
-
PrintUsage "${PRGNAME}"
|
|
69
|
-
exit 0
|
|
70
|
-
|
|
71
|
-
elif echo "$1" | grep -q -i -e "^-str$" -e "^--start$"; then
|
|
72
|
-
if [ -n "${EXEC_MODE}" ]; then
|
|
73
|
-
echo "[ERROR] Already run mode(--start(-str) or --stop(-stp) option) is specified."
|
|
74
|
-
exit 1
|
|
75
|
-
fi
|
|
76
|
-
EXEC_MODE="start"
|
|
77
|
-
|
|
78
|
-
elif echo "$1" | grep -q -i -e "^-stp$" -e "^--stop$"; then
|
|
79
|
-
if [ -n "${EXEC_MODE}" ]; then
|
|
80
|
-
echo "[ERROR] Already run mode(--start(-str) or --stop(-stp) option) is specified."
|
|
81
|
-
exit 1
|
|
82
|
-
fi
|
|
83
|
-
EXEC_MODE="stop"
|
|
84
|
-
|
|
85
|
-
elif echo "$1" | grep -q -i -e "^-k$" -e "^--key$"; then
|
|
86
|
-
if [ -n "${PID_FILENAME_EXT_PART}" ]; then
|
|
87
|
-
echo "[ERROR] Already --key(-k) option is specified."
|
|
88
|
-
exit 1
|
|
89
|
-
fi
|
|
90
|
-
shift
|
|
91
|
-
if [ $# -eq 0 ]; then
|
|
92
|
-
echo "[ERROR] --key(-k) option needs parameter"
|
|
93
|
-
exit 1
|
|
94
|
-
fi
|
|
95
|
-
PID_FILENAME_EXT_PART="_$1"
|
|
96
|
-
|
|
97
|
-
elif echo "$1" | grep -q -i -e "^-i$" -e "^-int$" -e "^--interval$"; then
|
|
98
|
-
if [ "${RUN_INTERVAL}" -ne 0 ]; then
|
|
99
|
-
echo "[ERROR] Already --interval(-i) option is specified."
|
|
100
|
-
exit 1
|
|
101
|
-
fi
|
|
102
|
-
shift
|
|
103
|
-
if [ $# -eq 0 ]; then
|
|
104
|
-
echo "[ERROR] --interval(-i) option needs parameter"
|
|
105
|
-
exit 1
|
|
106
|
-
fi
|
|
107
|
-
if echo "$1" | grep -q '[^0-9]'; then
|
|
108
|
-
echo "[ERROR] --interval(-i) option parameter must be number(second)"
|
|
109
|
-
exit 1
|
|
110
|
-
elif [ "$1" -eq 0 ]; then
|
|
111
|
-
echo "[ERROR] --interval(-i) option parameter must be positive number(second)"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
RUN_INTERVAL="$1"
|
|
115
|
-
|
|
116
|
-
elif [ "$1" = "--" ]; then
|
|
117
|
-
#
|
|
118
|
-
# Finish to parse option, rest arguments are command and it's args
|
|
119
|
-
#
|
|
120
|
-
if [ -n "${CHILD_PROCESS_NAME}" ]; then
|
|
121
|
-
echo "[ERROR] Already \"-- <process> <arg>...\" option is specified(${CHILD_PROCESS_CMD})"
|
|
122
|
-
exit 1
|
|
123
|
-
fi
|
|
124
|
-
shift
|
|
125
|
-
if [ -z "$1" ]; then
|
|
126
|
-
echo "[ERROR] \"-- <process> <arg>...\" option need parameter"
|
|
127
|
-
exit 1
|
|
128
|
-
fi
|
|
129
|
-
CHILD_PROCESS_NAME="$1"
|
|
130
|
-
CHILD_PROCESS_CMD="$*"
|
|
131
|
-
break
|
|
132
|
-
|
|
133
|
-
else
|
|
134
|
-
echo "[ERROR] Unknown option $1."
|
|
135
|
-
exit 1
|
|
136
|
-
fi
|
|
137
|
-
shift
|
|
138
|
-
done
|
|
139
|
-
|
|
140
|
-
#
|
|
141
|
-
# Check execute mode
|
|
142
|
-
#
|
|
143
|
-
if [ -z "${EXEC_MODE}" ]; then
|
|
144
|
-
echo "[ERROR] You must specify --start(-str) or --stop(-stp) option."
|
|
145
|
-
exit 1
|
|
146
|
-
fi
|
|
147
|
-
|
|
148
|
-
#
|
|
149
|
-
# Check sub process options
|
|
150
|
-
#
|
|
151
|
-
if [ -z "${CHILD_PROCESS_NAME}" ] || [ -z "${CHILD_PROCESS_CMD}" ]; then
|
|
152
|
-
echo "[ERROR] No sub process and arguments are specified."
|
|
153
|
-
exit 1
|
|
154
|
-
fi
|
|
155
|
-
|
|
156
|
-
#
|
|
157
|
-
# Process pid/log
|
|
158
|
-
#
|
|
159
|
-
CHILD_PROCESS_PIDFILE="/tmp/${PRGNAME}_${CHILD_PROCESS_NAME}${PID_FILENAME_EXT_PART}.pid"
|
|
160
|
-
CHILD_PROCESS_LOGFILE="/tmp/${PRGNAME}_${CHILD_PROCESS_NAME}${PID_FILENAME_EXT_PART}.log"
|
|
161
|
-
|
|
162
|
-
#==========================================================
|
|
163
|
-
# Execute
|
|
164
|
-
#==========================================================
|
|
165
|
-
if [ "${EXEC_MODE}" = "start" ]; then
|
|
166
|
-
#
|
|
167
|
-
# Start Process
|
|
168
|
-
#
|
|
169
|
-
${CHILD_PROCESS_CMD} >"${CHILD_PROCESS_LOGFILE}" 2>&1 &
|
|
170
|
-
CHILD_PROCESS_PID=$!
|
|
171
|
-
|
|
172
|
-
if [ "${RUN_INTERVAL}" -gt 0 ]; then
|
|
173
|
-
sleep "${RUN_INTERVAL}"
|
|
174
|
-
fi
|
|
175
|
-
|
|
176
|
-
# shellcheck disable=SC2009
|
|
177
|
-
if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${CHILD_PROCESS_PID}$" || exit 1 && exit 0 ); then
|
|
178
|
-
echo "[ERROR] Could not start child process : ${CHILD_PROCESS_CMD}"
|
|
179
|
-
exit 1
|
|
180
|
-
fi
|
|
181
|
-
echo "${CHILD_PROCESS_PID}" >"${CHILD_PROCESS_PIDFILE}"
|
|
182
|
-
|
|
183
|
-
echo "[SUCCEED] Start process(${CHILD_PROCESS_PID}) : ${CHILD_PROCESS_CMD}"
|
|
184
|
-
|
|
185
|
-
else
|
|
186
|
-
#
|
|
187
|
-
# Stop Process
|
|
188
|
-
#
|
|
189
|
-
if [ -n "${CHILD_PROCESS_PIDFILE}" ] && [ -f "${CHILD_PROCESS_PIDFILE}" ]; then
|
|
190
|
-
|
|
191
|
-
CHILD_PROCESS_PID="$(tr -d '\n' < "${CHILD_PROCESS_PIDFILE}")"
|
|
192
|
-
|
|
193
|
-
# shellcheck disable=SC2009
|
|
194
|
-
if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${CHILD_PROCESS_PID}$" || exit 1 && exit 0 ); then
|
|
195
|
-
#
|
|
196
|
-
# Try stop
|
|
197
|
-
#
|
|
198
|
-
if ! kill -HUP "${CHILD_PROCESS_PID}"; then
|
|
199
|
-
echo "[WARNING] Failed to stop(HUP) process : ${CHILD_PROCESS_NAME}"
|
|
200
|
-
fi
|
|
201
|
-
if [ "${RUN_INTERVAL}" -gt 0 ]; then
|
|
202
|
-
sleep "${RUN_INTERVAL}"
|
|
203
|
-
fi
|
|
204
|
-
|
|
205
|
-
# shellcheck disable=SC2009
|
|
206
|
-
if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${CHILD_PROCESS_PID}$" || exit 1 && exit 0 ); then
|
|
207
|
-
#
|
|
208
|
-
# Retry stop
|
|
209
|
-
#
|
|
210
|
-
if ! kill -KILL "${CHILD_PROCESS_PID}"; then
|
|
211
|
-
echo "[WARNING] Failed to stop(KILL) process : ${CHILD_PROCESS_NAME}"
|
|
212
|
-
fi
|
|
213
|
-
if [ "${RUN_INTERVAL}" -gt 0 ]; then
|
|
214
|
-
sleep "${RUN_INTERVAL}"
|
|
215
|
-
fi
|
|
216
|
-
|
|
217
|
-
# shellcheck disable=SC2009
|
|
218
|
-
if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${CHILD_PROCESS_PID}$" || exit 1 && exit 0 ); then
|
|
219
|
-
echo "[ERROR] Could not stop process : ${CHILD_PROCESS_NAME}"
|
|
220
|
-
exit 1
|
|
221
|
-
fi
|
|
222
|
-
fi
|
|
223
|
-
|
|
224
|
-
echo "[SUCCEED] Stop process : ${CHILD_PROCESS_NAME}(${CHILD_PROCESS_PID})"
|
|
225
|
-
else
|
|
226
|
-
echo "[SUCCEED] Already stop process : ${CHILD_PROCESS_NAME}(${CHILD_PROCESS_PID})"
|
|
227
|
-
fi
|
|
228
|
-
rm -f "${CHILD_PROCESS_PIDFILE}"
|
|
229
|
-
else
|
|
230
|
-
echo "[SUCCEED] Already stop process, because not found child process pid file : ${CHILD_PROCESS_PIDFILE}"
|
|
231
|
-
fi
|
|
232
|
-
fi
|
|
233
|
-
|
|
234
|
-
exit 0
|
|
235
|
-
|
|
236
|
-
#
|
|
237
|
-
# Local variables:
|
|
238
|
-
# tab-width: 4
|
|
239
|
-
# c-basic-offset: 4
|
|
240
|
-
# End:
|
|
241
|
-
# vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
242
|
-
# vim<600: noexpandtab sw=4 ts=4
|
|
243
|
-
#
|
package/tests/auto_extdata.js
DELETED
|
@@ -1,220 +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: Mon May 18 2020
|
|
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 : EXTDATA', 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/extdata/dummy/<correct path> : get extdata by text status 200', function(done){ // eslint-disable-line no-undef
|
|
68
|
-
var uri = '/v1/extdata/dummy/';
|
|
69
|
-
uri += regparamstr; // path: /v1/extdata/dummy/<correct path>
|
|
70
|
-
var ua = 'dummy-client'; // User-Agent: dummy-client
|
|
71
|
-
|
|
72
|
-
chai.request(app)
|
|
73
|
-
.get(uri)
|
|
74
|
-
.set('content-type', 'application/octet-stream')
|
|
75
|
-
.set('user-agent', ua)
|
|
76
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
77
|
-
.end(function(err, res){
|
|
78
|
-
//console.log(res); // For debugging
|
|
79
|
-
expect(res).to.have.status(200);
|
|
80
|
-
expect(res).to.be.an('object');
|
|
81
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('text/x-shellscript; charset=utf-8'); // 'content-type' is script
|
|
82
|
-
expect(res.body).to.be.an('object').to.be.empty; // body is empty
|
|
83
|
-
expect(res.text).to.be.a('string'); // text is string
|
|
84
|
-
done();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('GET /v1/extdata : get extdata by without uri and path text status 400', function(done){ // eslint-disable-line no-undef
|
|
89
|
-
var uri = '/v1/extdata'; // path: /v1/extdata
|
|
90
|
-
var ua = 'dummy-client'; // User-Agent: dummy-client
|
|
91
|
-
|
|
92
|
-
chai.request(app)
|
|
93
|
-
.get(uri)
|
|
94
|
-
.set('content-type', 'application/octet-stream')
|
|
95
|
-
.set('user-agent', ua)
|
|
96
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
97
|
-
.end(function(err, res){
|
|
98
|
-
expect(res).to.have.status(400);
|
|
99
|
-
expect(res).to.be.an('object');
|
|
100
|
-
expect(res.body).to.be.an('object'); // response body is error json
|
|
101
|
-
expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
|
|
102
|
-
expect(res.body.message).to.be.an('string').to.equal('GET request url does not have extdata path parameter'); // error message
|
|
103
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
|
|
104
|
-
done();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('GET /v1/extdata/dummy : get extdata by without path text status 400', function(done){ // eslint-disable-line no-undef
|
|
109
|
-
var uri = '/v1/extdata/dummy'; // path: /v1/extdata/dummy
|
|
110
|
-
var ua = 'dummy-client'; // User-Agent: dummy-client
|
|
111
|
-
|
|
112
|
-
chai.request(app)
|
|
113
|
-
.get(uri)
|
|
114
|
-
.set('content-type', 'application/octet-stream')
|
|
115
|
-
.set('user-agent', ua)
|
|
116
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
117
|
-
.end(function(err, res){
|
|
118
|
-
expect(res).to.have.status(400);
|
|
119
|
-
expect(res).to.be.an('object');
|
|
120
|
-
expect(res.body).to.be.an('object'); // response body is error json
|
|
121
|
-
expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
|
|
122
|
-
expect(res.body.message).to.be.an('string').to.equal('GET request url does not have extdata path parameter'); // error message
|
|
123
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
|
|
124
|
-
done();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('GET /v1/extdata/dummy/<invalid path> : get extdata by with invalid path text status 400', function(done){ // eslint-disable-line no-undef
|
|
129
|
-
var uri = '/v1/extdata/dummy/';
|
|
130
|
-
uri += 'invalidpath'; // path: /v1/extdata/dummy/<invalid path>
|
|
131
|
-
var ua = 'dummy-client'; // User-Agent: dummy-client
|
|
132
|
-
|
|
133
|
-
chai.request(app)
|
|
134
|
-
.get(uri)
|
|
135
|
-
.set('content-type', 'application/octet-stream')
|
|
136
|
-
.set('user-agent', ua)
|
|
137
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
138
|
-
.end(function(err, res){
|
|
139
|
-
expect(res).to.have.status(400);
|
|
140
|
-
expect(res).to.be.an('object');
|
|
141
|
-
expect(res.body).to.be.an('object'); // response body is error json
|
|
142
|
-
expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
|
|
143
|
-
expect(res.body.message).to.be.an('string').to.equal('GET /extdata/dummy/<path> is invalid'); // error message
|
|
144
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
|
|
145
|
-
done();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('GET /v1/extdata/<invalid uri>/<correct path> : get extdata by with invalid uri text status 400', function(done){// eslint-disable-line no-undef
|
|
150
|
-
var uri = '/v1/extdata/invalid/';
|
|
151
|
-
uri += regparamstr; // path: /v1/extdata/<invalid uri>/<correct path>
|
|
152
|
-
var ua = 'dummy-client'; // User-Agent: dummy-client
|
|
153
|
-
|
|
154
|
-
chai.request(app)
|
|
155
|
-
.get(uri)
|
|
156
|
-
.set('content-type', 'application/octet-stream')
|
|
157
|
-
.set('user-agent', ua)
|
|
158
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
159
|
-
.end(function(err, res){
|
|
160
|
-
expect(res).to.have.status(400);
|
|
161
|
-
expect(res).to.be.an('object');
|
|
162
|
-
expect(res.body).to.be.an('object'); // response body is error json
|
|
163
|
-
expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
|
|
164
|
-
expect(res.body.message).to.be.an('string').to.equal('GET request URL path(invalid) does not exist'); // error message
|
|
165
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
|
|
166
|
-
done();
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('GET /v1/extdata/dummy/<correct path> : get extdata by with invalid user-agent text status 400', function(done){ // eslint-disable-line no-undef
|
|
171
|
-
var uri = '/v1/extdata/dummy/';
|
|
172
|
-
uri += regparamstr; // path: /v1/extdata/dummy/<correct path>
|
|
173
|
-
var ua = 'invalid-client'; // User-Agent: <invalid user-agent>
|
|
174
|
-
|
|
175
|
-
chai.request(app)
|
|
176
|
-
.get(uri)
|
|
177
|
-
.set('user-agent', '')
|
|
178
|
-
.set('content-type', 'application/octet-stream')
|
|
179
|
-
.set('user-agent', ua)
|
|
180
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
181
|
-
.end(function(err, res){
|
|
182
|
-
expect(res).to.have.status(400);
|
|
183
|
-
expect(res).to.be.an('object');
|
|
184
|
-
expect(res.body).to.be.an('object'); // response body is error json
|
|
185
|
-
expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
|
|
186
|
-
expect(res.body.message).to.be.an('string').to.equal('GET request is not allowed from your client');// error message
|
|
187
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
|
|
188
|
-
done();
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('GET /v1/extdata/dummy/<correct path> : get extdata by without user-agent text status 400', function(done){ // eslint-disable-line no-undef
|
|
193
|
-
var uri = '/v1/extdata/dummy/';
|
|
194
|
-
uri += regparamstr; // path: /v1/extdata/dummy/<correct path>
|
|
195
|
-
|
|
196
|
-
chai.request(app)
|
|
197
|
-
.get(uri)
|
|
198
|
-
.set('user-agent', '')
|
|
199
|
-
.set('content-type', 'application/octet-stream')
|
|
200
|
-
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
201
|
-
.end(function(err, res){
|
|
202
|
-
expect(res).to.have.status(400);
|
|
203
|
-
expect(res).to.be.an('object');
|
|
204
|
-
expect(res.body).to.be.an('object'); // response body is error json
|
|
205
|
-
expect(res.body.result).to.be.a('boolean').to.be.false; // result is false
|
|
206
|
-
expect(res.body.message).to.be.an('string').to.equal('GET request is not allowed from your client');// error message
|
|
207
|
-
expect(res.header['content-type']).to.be.a('string').to.equal('application/json; charset=utf-8'); // 'content-type' is json
|
|
208
|
-
done();
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
/*
|
|
214
|
-
* Local variables:
|
|
215
|
-
* tab-width: 4
|
|
216
|
-
* c-basic-offset: 4
|
|
217
|
-
* End:
|
|
218
|
-
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
219
|
-
* vim<600: noexpandtab sw=4 ts=4
|
|
220
|
-
*/
|