forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add plugin factory keychain test file
Fixes hyperledger-cacti#967
- Loading branch information
1 parent
71e1588
commit 9fde86c
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...us-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |