Skip to content

Commit

Permalink
refactor: add plugin factory keychain test file
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeyoungone committed Aug 4, 2021
1 parent 71e1588 commit 9fde86c
Showing 1 changed file with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { PluginRegistry } from "@hyperledger/cactus-core";
import {
Configuration,
IPluginFactoryOptions,
PluginImportType,
} from "@hyperledger/cactus-core-api";
import test, { Test } from "tape-promise/tape";
import { PluginFactoryKeychain } from "../../../main/typescript/plugin-factory-keychain";
import {
AwsCredentialType,
PluginKeychainAwsSm,
} from "../../../main/typescript/plugin-keychain-aws-sm";
import { v4 as uuidv4 } from "uuid";
import { PluginKeychainAwsSmRemoteAdapter } from "../../../main/typescript/plugin-keychain-aws-sm-remote-adapter";

test("get,set,has,delete alters state as expected", async (t: Test) => {
const iPluginFactoryOptions1: IPluginFactoryOptions = {
pluginImportType: PluginImportType.Local,
};

const iPluginFactoryOptions2: IPluginFactoryOptions = {
pluginImportType: PluginImportType.Remote,
};

const pluginRegistry = new PluginRegistry();
const iPluginKeychainAwsSmOptions = {
pluginRegistry,
instanceId: uuidv4(),
keychainId: uuidv4(),
logLevel: "TRACE",
awsProfile: "true",
awsRegion: "true",
awsEndpoint: "true",
awsAccessKeyId: "true",
awsSecretAccessKey: "true",
awsCredentialType: AwsCredentialType.InMemory,
};

const pluginFactoryKeychain1 = new PluginFactoryKeychain(
iPluginFactoryOptions1,
);

const pluginFactoryKeychain2 = new PluginFactoryKeychain(
iPluginFactoryOptions2,
);

const pluginKeychainAwsSm = await pluginFactoryKeychain1.create(
iPluginKeychainAwsSmOptions,
);

const pluginKeychainAwsSmRemoteAdapter = await pluginFactoryKeychain2.create({
...iPluginKeychainAwsSmOptions,
remoteConfig: new Configuration({ basePath: "true" }),
});

t.true(
pluginKeychainAwsSm instanceof PluginKeychainAwsSm,
"pluginImportType.Local results in pluginKeychainAwsSm",
);

t.true(
pluginKeychainAwsSmRemoteAdapter instanceof
PluginKeychainAwsSmRemoteAdapter,
"pluginImportType.Remote results in pluginKeychainAwsSm",
);

t.end();
});

0 comments on commit 9fde86c

Please sign in to comment.