Skip to content

Commit 9b5af88

Browse files
committed
refactor: add plugin factory keychain test file
Fixes hyperledger-cacti#967 Signed-off-by: Youngone Lee <[email protected]>
1 parent 71e1588 commit 9b5af88

File tree

3 files changed

+84
-4
lines changed
  • packages
    • cactus-plugin-keychain-aws-sm/src/test/typescript/integration
    • cactus-plugin-keychain-azure-kv/src/main/typescript/generated/openapi/typescript-axios
    • cactus-plugin-keychain-google-sm/src/main/typescript/generated/openapi/typescript-axios

3 files changed

+84
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { PluginRegistry } from "@hyperledger/cactus-core";
2+
import {
3+
Configuration,
4+
IPluginFactoryOptions,
5+
PluginImportType,
6+
} from "@hyperledger/cactus-core-api";
7+
import test, { Test } from "tape-promise/tape";
8+
import { PluginFactoryKeychain } from "../../../main/typescript/plugin-factory-keychain";
9+
import {
10+
AwsCredentialType,
11+
PluginKeychainAwsSm,
12+
} from "../../../main/typescript/plugin-keychain-aws-sm";
13+
import { v4 as uuidv4 } from "uuid";
14+
import { PluginKeychainAwsSmRemoteAdapter } from "../../../main/typescript/plugin-keychain-aws-sm-remote-adapter";
15+
16+
test("get,set,has,delete alters state as expected", async (t: Test) => {
17+
const iPluginFactoryOptions1: IPluginFactoryOptions = {
18+
pluginImportType: PluginImportType.Local,
19+
};
20+
21+
const iPluginFactoryOptions2: IPluginFactoryOptions = {
22+
pluginImportType: PluginImportType.Remote,
23+
};
24+
25+
const invalid: IPluginFactoryOptions = {
26+
pluginImportType: (null as unknown) as PluginImportType,
27+
};
28+
29+
const pluginRegistry = new PluginRegistry();
30+
const iPluginKeychainAwsSmOptions = {
31+
pluginRegistry,
32+
instanceId: uuidv4(),
33+
keychainId: uuidv4(),
34+
logLevel: "TRACE",
35+
awsProfile: "true",
36+
awsRegion: "true",
37+
awsEndpoint: "true",
38+
awsAccessKeyId: "true",
39+
awsSecretAccessKey: "true",
40+
awsCredentialType: AwsCredentialType.InMemory,
41+
};
42+
43+
const pluginFactoryKeychain1 = new PluginFactoryKeychain(
44+
iPluginFactoryOptions1,
45+
);
46+
47+
const pluginFactoryKeychain2 = new PluginFactoryKeychain(
48+
iPluginFactoryOptions2,
49+
);
50+
51+
const pluginFactoryKeychain3 = new PluginFactoryKeychain(invalid);
52+
53+
const pluginKeychainAwsSm = await pluginFactoryKeychain1.create(
54+
iPluginKeychainAwsSmOptions,
55+
);
56+
57+
const pluginKeychainAwsSmRemoteAdapter = await pluginFactoryKeychain2.create({
58+
...iPluginKeychainAwsSmOptions,
59+
remoteConfig: new Configuration({ basePath: "true" }),
60+
});
61+
62+
t.true(
63+
pluginKeychainAwsSm instanceof PluginKeychainAwsSm,
64+
"pluginImportType.Local results in pluginKeychainAwsSm",
65+
);
66+
67+
t.true(
68+
pluginKeychainAwsSmRemoteAdapter instanceof
69+
PluginKeychainAwsSmRemoteAdapter,
70+
"pluginImportType.Remote results in pluginKeychainAwsSm",
71+
);
72+
73+
await t.rejects(
74+
pluginFactoryKeychain3.create({
75+
invalid,
76+
}),
77+
);
78+
79+
t.end();
80+
});

packages/cactus-plugin-keychain-azure-kv/src/main/typescript/generated/openapi/typescript-axios/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } fr
2828
*/
2929
export interface GetKeychainEntryRequest {
3030
/**
31-
* The key for the entry to get from the keychain.
31+
* The key for the entry to delete from the keychain.
3232
* @type {string}
3333
* @memberof GetKeychainEntryRequest
3434
*/
@@ -60,7 +60,7 @@ export interface GetKeychainEntryResponse {
6060
*/
6161
export interface SetKeychainEntryRequest {
6262
/**
63-
* The key for the entry to set on the keychain.
63+
* The key for the entry to check on the keychain.
6464
* @type {string}
6565
* @memberof SetKeychainEntryRequest
6666
*/

packages/cactus-plugin-keychain-google-sm/src/main/typescript/generated/openapi/typescript-axios/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } fr
2828
*/
2929
export interface GetKeychainEntryRequest {
3030
/**
31-
* The key for the entry to get from the keychain.
31+
* The key for the entry to delete from the keychain.
3232
* @type {string}
3333
* @memberof GetKeychainEntryRequest
3434
*/
@@ -60,7 +60,7 @@ export interface GetKeychainEntryResponse {
6060
*/
6161
export interface SetKeychainEntryRequest {
6262
/**
63-
* The key for the entry to set on the keychain.
63+
* The key for the entry to check on the keychain.
6464
* @type {string}
6565
* @memberof SetKeychainEntryRequest
6666
*/

0 commit comments

Comments
 (0)