@verii/vnf-agent-cli 1.1.0-pre.1770078755 → 1.1.0-pre.1770080046
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verii/vnf-agent-cli",
|
|
3
|
-
"version": "1.1.0-pre.
|
|
3
|
+
"version": "1.1.0-pre.1770080046",
|
|
4
4
|
"description": "A CLI application for working with VNF Agents.",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "cross-env NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage **/*.test.js --passWithNoTests",
|
|
12
|
-
"lint": "eslint
|
|
12
|
+
"lint": "eslint .",
|
|
13
13
|
"lint:ci": "eslint . --format json >> eslint-results.json",
|
|
14
|
-
"lint:fix": "eslint --fix
|
|
14
|
+
"lint:fix": "eslint --fix ."
|
|
15
15
|
},
|
|
16
16
|
"author": "Velocity Career Labs",
|
|
17
17
|
"license": "Apache-2.0",
|
|
@@ -19,19 +19,20 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"eslint": "
|
|
23
|
-
"eslint-config-airbnb-
|
|
24
|
-
"eslint-config-prettier": "
|
|
25
|
-
"eslint-plugin-better-mutation": "1.
|
|
22
|
+
"eslint": "9.39.2",
|
|
23
|
+
"eslint-config-airbnb-extended": "3.0.1",
|
|
24
|
+
"eslint-config-prettier": "10.1.8",
|
|
25
|
+
"eslint-plugin-better-mutation": "2.1.0",
|
|
26
26
|
"eslint-plugin-import": "2.32.0",
|
|
27
|
-
"eslint-plugin-prettier": "
|
|
28
|
-
"eslint-watch": "
|
|
27
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
28
|
+
"eslint-watch": "8.0.0",
|
|
29
29
|
"expect": "30.2.0",
|
|
30
|
-
"
|
|
30
|
+
"globals": "16.5.0",
|
|
31
|
+
"prettier": "3.8.1"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"commander": "~13.1.0",
|
|
34
35
|
"lodash": "^4.17.21"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "b095afed30b67c9643860bfddec83169ef8a50b4"
|
|
37
38
|
}
|
|
@@ -8,19 +8,19 @@ program
|
|
|
8
8
|
.usage('[options]')
|
|
9
9
|
.requiredOption(
|
|
10
10
|
'-e, --endpoint <url>',
|
|
11
|
-
'Credential Agent Endpoint to call to execute the issuing'
|
|
11
|
+
'Credential Agent Endpoint to call to execute the issuing',
|
|
12
12
|
)
|
|
13
13
|
.requiredOption(
|
|
14
14
|
'-a, --auth-token <url>',
|
|
15
|
-
'Bearer Auth Token to be used on the Agent API'
|
|
15
|
+
'Bearer Auth Token to be used on the Agent API',
|
|
16
16
|
)
|
|
17
17
|
.option(
|
|
18
18
|
'-d, --did <did>',
|
|
19
|
-
'The did of tenant that should be migrated. Cannot be combined with --all flag'
|
|
19
|
+
'The did of tenant that should be migrated. Cannot be combined with --all flag',
|
|
20
20
|
)
|
|
21
21
|
.option(
|
|
22
22
|
'--all',
|
|
23
|
-
'Runs did migration for all tenants on agent. Cannot be combined with --did flag'
|
|
23
|
+
'Runs did migration for all tenants on agent. Cannot be combined with --did flag',
|
|
24
24
|
)
|
|
25
25
|
.action(async () => {
|
|
26
26
|
const options = program.opts();
|
|
@@ -2,6 +2,7 @@ const { warn } = require('console');
|
|
|
2
2
|
const { filter, flow, groupBy } = require('lodash/fp');
|
|
3
3
|
|
|
4
4
|
const initFetchers = (options) => {
|
|
5
|
+
// eslint-disable-next-line default-param-last
|
|
5
6
|
const initFetch = (pathname, httpVerb = 'GET', body) => {
|
|
6
7
|
return async () => {
|
|
7
8
|
const urlObj = new URL(options.endpoint);
|
|
@@ -55,10 +56,10 @@ const summarize = (preTenants, postTenants, context) => {
|
|
|
55
56
|
const toOperatorUrl = initToOperatorApiUrl(context);
|
|
56
57
|
const refreshedTenants = flow(
|
|
57
58
|
groupBy('id'),
|
|
58
|
-
filter((group) => group[0].did !== group[1].did)
|
|
59
|
+
filter((group) => group[0].did !== group[1].did),
|
|
59
60
|
)([...preTenants, ...postTenants]);
|
|
60
61
|
context.log.info(
|
|
61
|
-
`Refreshed ${refreshedTenants.length} out of ${preTenants.length} tenants\n
|
|
62
|
+
`Refreshed ${refreshedTenants.length} out of ${preTenants.length} tenants\n`,
|
|
62
63
|
);
|
|
63
64
|
for (const refreshedTenant of refreshedTenants) {
|
|
64
65
|
const [preTenant, postTenant] = refreshedTenant;
|
|
@@ -71,7 +72,7 @@ const summarize = (preTenants, postTenants, context) => {
|
|
|
71
72
|
oldUrl: toOperatorUrl(preTenant.did),
|
|
72
73
|
newUrl: toOperatorUrl(postTenant.id),
|
|
73
74
|
},
|
|
74
|
-
'\n'
|
|
75
|
+
'\n',
|
|
75
76
|
);
|
|
76
77
|
}
|
|
77
78
|
};
|
|
@@ -9,7 +9,7 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
9
9
|
return Promise.resolve(
|
|
10
10
|
new Response(JSON.stringify(responseBody), {
|
|
11
11
|
status: statusCode,
|
|
12
|
-
})
|
|
12
|
+
}),
|
|
13
13
|
);
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
17
17
|
let counter = 0;
|
|
18
18
|
return async () => {
|
|
19
19
|
const result = await mockFetch(argsArr[counter][0], argsArr[counter][1]);
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
counter++;
|
|
22
22
|
return result;
|
|
23
23
|
};
|
|
@@ -27,14 +27,14 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
27
27
|
await expect(
|
|
28
28
|
migrateTenantDid({
|
|
29
29
|
options: { did: 'did:foo:bar', all: true },
|
|
30
|
-
})
|
|
30
|
+
}),
|
|
31
31
|
).rejects.toThrow('--did and --all flags may not both be specified.');
|
|
32
32
|
});
|
|
33
33
|
it('should error if neither "did" nor "all" flag is provided', async () => {
|
|
34
34
|
await expect(
|
|
35
35
|
migrateTenantDid({
|
|
36
36
|
options: {},
|
|
37
|
-
})
|
|
37
|
+
}),
|
|
38
38
|
).rejects.toThrow('either --did or --all flag must be specified.');
|
|
39
39
|
});
|
|
40
40
|
it('should error if communication with the agent fails', async () => {
|
|
@@ -48,7 +48,7 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
48
48
|
endpoint: 'http://localhost.test',
|
|
49
49
|
authToken: 'foo',
|
|
50
50
|
},
|
|
51
|
-
})
|
|
51
|
+
}),
|
|
52
52
|
).rejects.toThrow('mock error');
|
|
53
53
|
});
|
|
54
54
|
it('should error if agent returns non-success http status code', async () => {
|
|
@@ -61,8 +61,8 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
61
61
|
message: 'No tenants to refresh',
|
|
62
62
|
statusCode: 400,
|
|
63
63
|
}),
|
|
64
|
-
{ status: 400 }
|
|
65
|
-
)
|
|
64
|
+
{ status: 400 },
|
|
65
|
+
),
|
|
66
66
|
);
|
|
67
67
|
});
|
|
68
68
|
await expect(
|
|
@@ -72,7 +72,7 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
72
72
|
endpoint: 'http://localhost.test',
|
|
73
73
|
authToken: 'foo',
|
|
74
74
|
},
|
|
75
|
-
})
|
|
75
|
+
}),
|
|
76
76
|
).rejects.toThrow('Response status: 400');
|
|
77
77
|
});
|
|
78
78
|
it('should migrate one tenant when "did" flag is specified', async () => {
|
|
@@ -93,7 +93,7 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
93
93
|
options,
|
|
94
94
|
});
|
|
95
95
|
expect(global.fetch.mock.calls.map((call) => call.arguments)).toHaveLength(
|
|
96
|
-
3
|
|
96
|
+
3,
|
|
97
97
|
);
|
|
98
98
|
const fullRefreshUrl = `${options.endpoint}/operator-api/v0.8/tenants/refresh`;
|
|
99
99
|
const fullGetTenantsUrl = `${options.endpoint}/operator-api/v0.8/tenants`;
|
|
@@ -140,7 +140,7 @@ describe('migrate-tenant-did test suite', () => {
|
|
|
140
140
|
options,
|
|
141
141
|
});
|
|
142
142
|
expect(global.fetch.mock.calls.map((call) => call.arguments)).toHaveLength(
|
|
143
|
-
3
|
|
143
|
+
3,
|
|
144
144
|
);
|
|
145
145
|
const fullRefreshUrl = `${options.endpoint}/operator-api/v0.8/tenants/refresh`;
|
|
146
146
|
const fullGetTenantsUrl = `${options.endpoint}/operator-api/v0.8/tenants`;
|