@sudoplatform/sudo-common 7.1.2 → 7.1.3
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/lib/configurationManager/defaultConfigurationManager.js +3 -5
- package/package.json +2 -3
- package/.babelrc +0 -10
- package/.eslintrc.js +0 -91
- package/.gitignore +0 -14
- package/.gitlab-ci.yml +0 -101
- package/.npmignore +0 -1
- package/.prettierignore +0 -3
- package/.prettierrc.js +0 -7
- package/.publisher.json +0 -7
- package/.vscode/settings.json +0 -5
- package/.yarn/releases/yarn-1.22.19.cjs +0 -147529
- package/.yarnrc +0 -5
- package/bin/outdated-with-suppression.sh +0 -203
- package/bin/suppress-audit.sh +0 -15
- package/bin/suppress-outdated.sh +0 -60
- package/bin/yarn-audit-with-suppression.sh +0 -19
- package/dependencies-report.json +0 -640
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -57
- package/docs/assets/main.js +0 -54
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1224
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/AccountLockedError.html +0 -163
- package/docs/classes/AuthenticationError.html +0 -169
- package/docs/classes/Base64.html +0 -245
- package/docs/classes/Buffer.html +0 -158
- package/docs/classes/ConfigurationNotSetError.html +0 -164
- package/docs/classes/ConfigurationSetNotFoundError.html +0 -168
- package/docs/classes/DecodeError.html +0 -168
- package/docs/classes/DefaultConfigurationManager.html +0 -213
- package/docs/classes/DefaultLogger.html +0 -291
- package/docs/classes/DefaultSudoKeyArchive.html +0 -363
- package/docs/classes/DefaultSudoKeyManager.html +0 -814
- package/docs/classes/FatalError.html +0 -169
- package/docs/classes/IllegalArgumentError.html +0 -168
- package/docs/classes/IllegalStateError.html +0 -169
- package/docs/classes/InsufficientEntitlementsError.html +0 -164
- package/docs/classes/InvalidOwnershipProofError.html +0 -163
- package/docs/classes/InvalidTokenError.html +0 -163
- package/docs/classes/KeyArchiveDecodingError.html +0 -168
- package/docs/classes/KeyArchiveIncorrectPasswordError.html +0 -168
- package/docs/classes/KeyArchiveMissingError.html +0 -168
- package/docs/classes/KeyArchiveNoPasswordRequiredError.html +0 -168
- package/docs/classes/KeyArchivePasswordRequiredError.html +0 -168
- package/docs/classes/KeyArchiveTypeError.html +0 -168
- package/docs/classes/KeyArchiveUnknownKeyTypeError.html +0 -168
- package/docs/classes/KeyArchiveVersionError.html +0 -168
- package/docs/classes/KeyNotFoundError.html +0 -168
- package/docs/classes/KeyStoreNotExportableError.html +0 -168
- package/docs/classes/LimitExceededError.html +0 -164
- package/docs/classes/NoEntitlementsError.html +0 -163
- package/docs/classes/NotAuthorizedError.html +0 -169
- package/docs/classes/NotRegisteredError.html +0 -168
- package/docs/classes/NotSignedInError.html +0 -164
- package/docs/classes/OperationNotImplementedError.html +0 -168
- package/docs/classes/RegisterError.html +0 -169
- package/docs/classes/RequestFailedError.html +0 -189
- package/docs/classes/ServiceError.html +0 -170
- package/docs/classes/SignOutError.html +0 -168
- package/docs/classes/SudoCryptoProviderDefaults.html +0 -106
- package/docs/classes/UnknownGraphQLError.html +0 -169
- package/docs/classes/UnrecognizedAlgorithmError.html +0 -168
- package/docs/classes/UserNotConfirmedError.html +0 -164
- package/docs/classes/VersionMismatchError.html +0 -166
- package/docs/enums/CachePolicy.html +0 -72
- package/docs/enums/EncryptionAlgorithm.html +0 -80
- package/docs/enums/KeyArchiveKeyType.html +0 -86
- package/docs/enums/KeyDataKeyFormat.html +0 -92
- package/docs/enums/KeyDataKeyType.html +0 -85
- package/docs/enums/ListOperationResultStatus.html +0 -85
- package/docs/enums/PublicKeyFormat.html +0 -68
- package/docs/functions/isAppSyncNetworkError.html +0 -147
- package/docs/functions/isInsecureKeyArchive.html +0 -147
- package/docs/functions/isSecureKeyArchive.html +0 -147
- package/docs/functions/isUnrecognizedKeyArchive.html +0 -147
- package/docs/functions/keyArchiveInfoFromKeyData.html +0 -147
- package/docs/functions/keyArchiveKeyTypeFromKeyDataKeyType.html +0 -147
- package/docs/functions/mapGraphQLToClientError.html +0 -154
- package/docs/functions/mapNetworkErrorToClientError.html +0 -154
- package/docs/index.html +0 -146
- package/docs/interfaces/AsymmetricEncryptionOptions.html +0 -68
- package/docs/interfaces/BooleanFilter.html +0 -75
- package/docs/interfaces/ConfigurationManager.html +0 -200
- package/docs/interfaces/KeyData.html +0 -106
- package/docs/interfaces/ListOperationFailureResult.html +0 -76
- package/docs/interfaces/ListOperationPartialResult.html +0 -102
- package/docs/interfaces/ListOperationSuccessResult.html +0 -90
- package/docs/interfaces/ListOutput.html +0 -80
- package/docs/interfaces/Logger.html +0 -251
- package/docs/interfaces/Owner.html +0 -72
- package/docs/interfaces/PublicKey.html +0 -72
- package/docs/interfaces/ServiceCompatibilityInfo.html +0 -110
- package/docs/interfaces/StringFilter.html +0 -82
- package/docs/interfaces/SudoCryptoProvider.html +0 -865
- package/docs/interfaces/SudoKeyArchive.html +0 -257
- package/docs/interfaces/SudoKeyManager.html +0 -848
- package/docs/interfaces/SymmetricEncryptionOptions.html +0 -75
- package/docs/interfaces/ValidationResult.html +0 -83
- package/docs/modules.html +0 -248
- package/docs/types/AppSyncError.html +0 -138
- package/docs/types/AppSyncNetworkError.html +0 -138
- package/docs/types/InsecureKeyArchive.html +0 -138
- package/docs/types/KeyArchive.html +0 -138
- package/docs/types/KeyArchiveKeyInfo.html +0 -154
- package/docs/types/KeyArchiveKeyInfoDecoded.html +0 -138
- package/docs/types/ListOperationResult.html +0 -148
- package/docs/types/SecureKeyArchive.html +0 -138
- package/docs/types/Subset.html +0 -144
- package/docs/types/UnrecognizedKeyArchive.html +0 -138
- package/docs/variables/CURRENT_ARCHIVE_VERSION.html +0 -138
- package/docs/variables/InsecureKeyArchiveCodec.html +0 -138
- package/docs/variables/InsecureKeyArchiveType.html +0 -138
- package/docs/variables/KeyArchiveCodec.html +0 -138
- package/docs/variables/KeyArchiveKeyInfoArrayCodec.html +0 -138
- package/docs/variables/KeyArchiveKeyInfoCodec.html +0 -138
- package/docs/variables/KeyArchiveKeyTypeCodec.html +0 -138
- package/docs/variables/SecureKeyArchiveCodec.html +0 -138
- package/docs/variables/SecureKeyArchiveType.html +0 -138
- package/docs/variables/UnrecognizedKeyArchiveCodec.html +0 -138
- package/github/.babelrc +0 -10
- package/github/.eslintrc.js +0 -91
- package/github/.gitignore +0 -14
- package/github/.gitlab-ci.yml +0 -101
- package/github/.npmignore +0 -1
- package/github/.prettierignore +0 -3
- package/github/.prettierrc.js +0 -7
- package/github/.publisher.json +0 -7
- package/github/.vscode/settings.json +0 -5
- package/github/.yarn/releases/yarn-1.22.19.cjs +0 -147529
- package/github/.yarnrc +0 -5
- package/github/CHANGELOG.md +0 -51
- package/github/README.md +0 -8
- package/github/bin/outdated-with-suppression.sh +0 -203
- package/github/bin/suppress-audit.sh +0 -15
- package/github/bin/suppress-outdated.sh +0 -60
- package/github/bin/yarn-audit-with-suppression.sh +0 -19
- package/github/docs/.nojekyll +0 -1
- package/github/docs/assets/highlight.css +0 -57
- package/github/docs/assets/main.js +0 -54
- package/github/docs/assets/search.js +0 -1
- package/github/docs/assets/style.css +0 -1224
- package/github/docs/assets/widgets.png +0 -0
- package/github/docs/assets/widgets@2x.png +0 -0
- package/github/docs/classes/AccountLockedError.html +0 -163
- package/github/docs/classes/AuthenticationError.html +0 -169
- package/github/docs/classes/Base64.html +0 -245
- package/github/docs/classes/Buffer.html +0 -158
- package/github/docs/classes/ConfigurationNotSetError.html +0 -164
- package/github/docs/classes/ConfigurationSetNotFoundError.html +0 -168
- package/github/docs/classes/DecodeError.html +0 -168
- package/github/docs/classes/DefaultConfigurationManager.html +0 -213
- package/github/docs/classes/DefaultLogger.html +0 -291
- package/github/docs/classes/DefaultSudoKeyArchive.html +0 -363
- package/github/docs/classes/DefaultSudoKeyManager.html +0 -814
- package/github/docs/classes/FatalError.html +0 -169
- package/github/docs/classes/IllegalArgumentError.html +0 -168
- package/github/docs/classes/IllegalStateError.html +0 -169
- package/github/docs/classes/InsufficientEntitlementsError.html +0 -164
- package/github/docs/classes/InvalidOwnershipProofError.html +0 -163
- package/github/docs/classes/InvalidTokenError.html +0 -163
- package/github/docs/classes/KeyArchiveDecodingError.html +0 -168
- package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +0 -168
- package/github/docs/classes/KeyArchiveMissingError.html +0 -168
- package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +0 -168
- package/github/docs/classes/KeyArchivePasswordRequiredError.html +0 -168
- package/github/docs/classes/KeyArchiveTypeError.html +0 -168
- package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +0 -168
- package/github/docs/classes/KeyArchiveVersionError.html +0 -168
- package/github/docs/classes/KeyNotFoundError.html +0 -168
- package/github/docs/classes/KeyStoreNotExportableError.html +0 -168
- package/github/docs/classes/LimitExceededError.html +0 -164
- package/github/docs/classes/NoEntitlementsError.html +0 -163
- package/github/docs/classes/NotAuthorizedError.html +0 -169
- package/github/docs/classes/NotRegisteredError.html +0 -168
- package/github/docs/classes/NotSignedInError.html +0 -164
- package/github/docs/classes/OperationNotImplementedError.html +0 -168
- package/github/docs/classes/RegisterError.html +0 -169
- package/github/docs/classes/RequestFailedError.html +0 -189
- package/github/docs/classes/ServiceError.html +0 -170
- package/github/docs/classes/SignOutError.html +0 -168
- package/github/docs/classes/SudoCryptoProviderDefaults.html +0 -106
- package/github/docs/classes/UnknownGraphQLError.html +0 -169
- package/github/docs/classes/UnrecognizedAlgorithmError.html +0 -168
- package/github/docs/classes/UserNotConfirmedError.html +0 -164
- package/github/docs/classes/VersionMismatchError.html +0 -166
- package/github/docs/enums/CachePolicy.html +0 -72
- package/github/docs/enums/EncryptionAlgorithm.html +0 -80
- package/github/docs/enums/KeyArchiveKeyType.html +0 -86
- package/github/docs/enums/KeyDataKeyFormat.html +0 -92
- package/github/docs/enums/KeyDataKeyType.html +0 -85
- package/github/docs/enums/ListOperationResultStatus.html +0 -85
- package/github/docs/enums/PublicKeyFormat.html +0 -68
- package/github/docs/functions/isAppSyncNetworkError.html +0 -147
- package/github/docs/functions/isInsecureKeyArchive.html +0 -147
- package/github/docs/functions/isSecureKeyArchive.html +0 -147
- package/github/docs/functions/isUnrecognizedKeyArchive.html +0 -147
- package/github/docs/functions/keyArchiveInfoFromKeyData.html +0 -147
- package/github/docs/functions/keyArchiveKeyTypeFromKeyDataKeyType.html +0 -147
- package/github/docs/functions/mapGraphQLToClientError.html +0 -154
- package/github/docs/functions/mapNetworkErrorToClientError.html +0 -154
- package/github/docs/index.html +0 -146
- package/github/docs/interfaces/AsymmetricEncryptionOptions.html +0 -68
- package/github/docs/interfaces/BooleanFilter.html +0 -75
- package/github/docs/interfaces/ConfigurationManager.html +0 -200
- package/github/docs/interfaces/KeyData.html +0 -106
- package/github/docs/interfaces/ListOperationFailureResult.html +0 -76
- package/github/docs/interfaces/ListOperationPartialResult.html +0 -102
- package/github/docs/interfaces/ListOperationSuccessResult.html +0 -90
- package/github/docs/interfaces/ListOutput.html +0 -80
- package/github/docs/interfaces/Logger.html +0 -251
- package/github/docs/interfaces/Owner.html +0 -72
- package/github/docs/interfaces/PublicKey.html +0 -72
- package/github/docs/interfaces/ServiceCompatibilityInfo.html +0 -110
- package/github/docs/interfaces/StringFilter.html +0 -82
- package/github/docs/interfaces/SudoCryptoProvider.html +0 -865
- package/github/docs/interfaces/SudoKeyArchive.html +0 -257
- package/github/docs/interfaces/SudoKeyManager.html +0 -848
- package/github/docs/interfaces/SymmetricEncryptionOptions.html +0 -75
- package/github/docs/interfaces/ValidationResult.html +0 -83
- package/github/docs/modules.html +0 -248
- package/github/docs/types/AppSyncError.html +0 -138
- package/github/docs/types/AppSyncNetworkError.html +0 -138
- package/github/docs/types/InsecureKeyArchive.html +0 -138
- package/github/docs/types/KeyArchive.html +0 -138
- package/github/docs/types/KeyArchiveKeyInfo.html +0 -154
- package/github/docs/types/KeyArchiveKeyInfoDecoded.html +0 -138
- package/github/docs/types/ListOperationResult.html +0 -148
- package/github/docs/types/SecureKeyArchive.html +0 -138
- package/github/docs/types/Subset.html +0 -144
- package/github/docs/types/UnrecognizedKeyArchive.html +0 -138
- package/github/docs/variables/CURRENT_ARCHIVE_VERSION.html +0 -138
- package/github/docs/variables/InsecureKeyArchiveCodec.html +0 -138
- package/github/docs/variables/InsecureKeyArchiveType.html +0 -138
- package/github/docs/variables/KeyArchiveCodec.html +0 -138
- package/github/docs/variables/KeyArchiveKeyInfoArrayCodec.html +0 -138
- package/github/docs/variables/KeyArchiveKeyInfoCodec.html +0 -138
- package/github/docs/variables/KeyArchiveKeyTypeCodec.html +0 -138
- package/github/docs/variables/SecureKeyArchiveCodec.html +0 -138
- package/github/docs/variables/SecureKeyArchiveType.html +0 -138
- package/github/docs/variables/UnrecognizedKeyArchiveCodec.html +0 -138
- package/github/jest.config.json +0 -14
- package/github/package.json +0 -91
- package/github/src/configurationManager/defaultConfigurationManager.ts +0 -281
- package/github/src/errors/error.ts +0 -469
- package/github/src/index.ts +0 -8
- package/github/src/logging/bunyanLogger.ts +0 -47
- package/github/src/logging/logger.ts +0 -164
- package/github/src/sudoKeyArchive/index.ts +0 -4
- package/github/src/sudoKeyArchive/keyArchive.ts +0 -120
- package/github/src/sudoKeyArchive/keyInfo.ts +0 -47
- package/github/src/sudoKeyArchive/keyType.ts +0 -50
- package/github/src/sudoKeyArchive/sudoKeyArchive.ts +0 -591
- package/github/src/sudoKeyManager/index.ts +0 -4
- package/github/src/sudoKeyManager/keyData.ts +0 -60
- package/github/src/sudoKeyManager/publicKey.ts +0 -9
- package/github/src/sudoKeyManager/sudoCryptoProvider.ts +0 -416
- package/github/src/sudoKeyManager/sudoKeyManager.ts +0 -609
- package/github/src/types/types.ts +0 -129
- package/github/src/utils/base64.ts +0 -75
- package/github/src/utils/buffer.ts +0 -39
- package/github/test/integration/defaultConfigurationManager.spec.ts +0 -85
- package/github/test/matchers.ts +0 -122
- package/github/test/unit/configurationManager/defaultConfigurationManager.spec.ts +0 -506
- package/github/test/unit/errors/error.spec.ts +0 -115
- package/github/test/unit/keyType.spec.ts +0 -54
- package/github/test/unit/logging/logger.spec.ts +0 -182
- package/github/test/unit/sudoKeyArchive.spec.ts +0 -1609
- package/github/test/unit/sudoKeyManager.spec.ts +0 -1045
- package/github/test/unit/utils/base64.spec.ts +0 -45
- package/github/test/unit/utils/buffer.spec.ts +0 -45
- package/github/test/unit/utils/listOperationResult.spec.ts +0 -84
- package/github/tsconfig.json +0 -20
- package/github/tsconfig.test.json +0 -7
- package/github/yarn.lock +0 -5922
- package/jest.config.json +0 -14
- package/src/configurationManager/defaultConfigurationManager.ts +0 -281
- package/src/errors/error.ts +0 -469
- package/src/index.ts +0 -8
- package/src/logging/bunyanLogger.ts +0 -47
- package/src/logging/logger.ts +0 -164
- package/src/sudoKeyArchive/index.ts +0 -4
- package/src/sudoKeyArchive/keyArchive.ts +0 -120
- package/src/sudoKeyArchive/keyInfo.ts +0 -47
- package/src/sudoKeyArchive/keyType.ts +0 -50
- package/src/sudoKeyArchive/sudoKeyArchive.ts +0 -591
- package/src/sudoKeyManager/index.ts +0 -4
- package/src/sudoKeyManager/keyData.ts +0 -60
- package/src/sudoKeyManager/publicKey.ts +0 -9
- package/src/sudoKeyManager/sudoCryptoProvider.ts +0 -416
- package/src/sudoKeyManager/sudoKeyManager.ts +0 -609
- package/src/types/types.ts +0 -129
- package/src/utils/base64.ts +0 -75
- package/src/utils/buffer.ts +0 -39
- package/test/integration/defaultConfigurationManager.spec.ts +0 -85
- package/test/matchers.ts +0 -122
- package/test/unit/configurationManager/defaultConfigurationManager.spec.ts +0 -506
- package/test/unit/errors/error.spec.ts +0 -115
- package/test/unit/keyType.spec.ts +0 -54
- package/test/unit/logging/logger.spec.ts +0 -182
- package/test/unit/sudoKeyArchive.spec.ts +0 -1609
- package/test/unit/sudoKeyManager.spec.ts +0 -1045
- package/test/unit/utils/base64.spec.ts +0 -45
- package/test/unit/utils/buffer.spec.ts +0 -45
- package/test/unit/utils/listOperationResult.spec.ts +0 -84
- package/tsconfig.json +0 -20
- package/tsconfig.test.json +0 -7
- package/yarn.lock +0 -5922
|
@@ -1,1045 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
anything,
|
|
3
|
-
capture,
|
|
4
|
-
instance,
|
|
5
|
-
mock,
|
|
6
|
-
reset,
|
|
7
|
-
verify,
|
|
8
|
-
when,
|
|
9
|
-
} from 'ts-mockito'
|
|
10
|
-
import {
|
|
11
|
-
KeyData,
|
|
12
|
-
KeyDataKeyFormat,
|
|
13
|
-
KeyDataKeyType,
|
|
14
|
-
} from '../../src/sudoKeyManager/keyData'
|
|
15
|
-
import { PublicKey, PublicKeyFormat } from '../../src/sudoKeyManager/publicKey'
|
|
16
|
-
import { SudoCryptoProvider } from '../../src/sudoKeyManager/sudoCryptoProvider'
|
|
17
|
-
import { DefaultSudoKeyManager } from '../../src/sudoKeyManager/sudoKeyManager'
|
|
18
|
-
import { EncryptionAlgorithm } from '../../src/types/types'
|
|
19
|
-
import { Buffer as BufferUtil } from '../../src/utils/buffer'
|
|
20
|
-
|
|
21
|
-
const sudoCryptoProviderMock: SudoCryptoProvider = mock()
|
|
22
|
-
|
|
23
|
-
const sudoKeyManager = new DefaultSudoKeyManager(
|
|
24
|
-
instance(sudoCryptoProviderMock),
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
reset(sudoCryptoProviderMock)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
describe('DefaultSudoKeyManager', () => {
|
|
32
|
-
const encrypted = BufferUtil.fromString('encrypted')
|
|
33
|
-
const iv = BufferUtil.fromString('iv')
|
|
34
|
-
const salt = BufferUtil.fromString('salt')
|
|
35
|
-
const decrypted = BufferUtil.fromString('decrypted')
|
|
36
|
-
const symmetricKey = BufferUtil.fromString('14A9B3C3540142A11E70ACBB1BD8969F')
|
|
37
|
-
const hash = BufferUtil.fromString('hash')
|
|
38
|
-
const data = BufferUtil.fromString('data')
|
|
39
|
-
const privateKey = BufferUtil.fromString('privateKey')
|
|
40
|
-
const publicKey: PublicKey = {
|
|
41
|
-
keyData: BufferUtil.fromString('publickey'),
|
|
42
|
-
keyFormat: PublicKeyFormat.SPKI,
|
|
43
|
-
}
|
|
44
|
-
const password = BufferUtil.fromString('password')
|
|
45
|
-
const serviceName = 'service-name'
|
|
46
|
-
const namespace = 'name-space'
|
|
47
|
-
|
|
48
|
-
beforeEach(() => {
|
|
49
|
-
when(sudoCryptoProviderMock.getNamespace()).thenReturn(namespace)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
describe('namespace', () => {
|
|
53
|
-
it('calls provider correctly when accessing namespace', () => {
|
|
54
|
-
when(sudoCryptoProviderMock.getNamespace()).thenReturn(namespace)
|
|
55
|
-
|
|
56
|
-
expect(sudoKeyManager.namespace).toEqual(namespace)
|
|
57
|
-
|
|
58
|
-
verify(sudoCryptoProviderMock.getNamespace()).once()
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('serviceName', () => {
|
|
63
|
-
it('calls provider correctly when accessing service name', () => {
|
|
64
|
-
when(sudoCryptoProviderMock.getServiceName()).thenReturn(serviceName)
|
|
65
|
-
|
|
66
|
-
expect(sudoKeyManager.serviceName).toEqual(serviceName)
|
|
67
|
-
|
|
68
|
-
verify(sudoCryptoProviderMock.getServiceName()).once()
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
describe('addPassword', () => {
|
|
73
|
-
it('calls provider correctly when adding password', async () => {
|
|
74
|
-
when(
|
|
75
|
-
sudoCryptoProviderMock.addPassword(anything(), anything()),
|
|
76
|
-
).thenResolve()
|
|
77
|
-
|
|
78
|
-
await expect(
|
|
79
|
-
sudoKeyManager.addPassword(password, 'VpnPassword'),
|
|
80
|
-
).resolves.toBeUndefined()
|
|
81
|
-
const [actualPassword, actualKey] = capture(
|
|
82
|
-
sudoCryptoProviderMock.addPassword,
|
|
83
|
-
).first()
|
|
84
|
-
expect(actualPassword).toStrictEqual(password)
|
|
85
|
-
expect(actualKey).toStrictEqual('VpnPassword')
|
|
86
|
-
|
|
87
|
-
verify(sudoCryptoProviderMock.addPassword(anything(), anything())).once()
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
describe('addSymmetricKey', () => {
|
|
92
|
-
it('calls provider correctly when adding a symmetric key', async () => {
|
|
93
|
-
when(
|
|
94
|
-
sudoCryptoProviderMock.addSymmetricKey(anything(), anything()),
|
|
95
|
-
).thenResolve()
|
|
96
|
-
|
|
97
|
-
await expect(
|
|
98
|
-
sudoKeyManager.addSymmetricKey(symmetricKey, 'VpnSymmetric'),
|
|
99
|
-
).resolves.toBeUndefined()
|
|
100
|
-
const [actualKey, actualKeyName] = capture(
|
|
101
|
-
sudoCryptoProviderMock.addSymmetricKey,
|
|
102
|
-
).first()
|
|
103
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
104
|
-
expect(actualKeyName).toStrictEqual('VpnSymmetric')
|
|
105
|
-
|
|
106
|
-
verify(
|
|
107
|
-
sudoCryptoProviderMock.addSymmetricKey(anything(), anything()),
|
|
108
|
-
).once()
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
describe('getPassword', () => {
|
|
113
|
-
it('should call crypto provider getPassword', async () => {
|
|
114
|
-
when(sudoCryptoProviderMock.getPassword(anything())).thenResolve(password)
|
|
115
|
-
|
|
116
|
-
await expect(sudoKeyManager.getPassword('VpnPassword')).resolves.toEqual(
|
|
117
|
-
password,
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
const [actualKey] = capture(sudoCryptoProviderMock.getPassword).first()
|
|
121
|
-
expect(actualKey).toStrictEqual('VpnPassword')
|
|
122
|
-
|
|
123
|
-
verify(sudoCryptoProviderMock.getPassword(anything())).once()
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
describe('deletePassword', () => {
|
|
128
|
-
it('should call crypto provider deletePassword', async () => {
|
|
129
|
-
when(sudoCryptoProviderMock.deletePassword(anything())).thenResolve()
|
|
130
|
-
|
|
131
|
-
await expect(
|
|
132
|
-
sudoKeyManager.deletePassword('VpnPassword'),
|
|
133
|
-
).resolves.toBeUndefined()
|
|
134
|
-
const [actualKey] = capture(sudoCryptoProviderMock.deletePassword).first()
|
|
135
|
-
expect(actualKey).toStrictEqual('VpnPassword')
|
|
136
|
-
|
|
137
|
-
verify(sudoCryptoProviderMock.deletePassword(anything())).once()
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
describe('updatePassword', () => {
|
|
142
|
-
it('should call crypto provider updatePassword', async () => {
|
|
143
|
-
when(
|
|
144
|
-
sudoCryptoProviderMock.updatePassword(anything(), anything()),
|
|
145
|
-
).thenResolve()
|
|
146
|
-
|
|
147
|
-
await expect(
|
|
148
|
-
sudoKeyManager.updatePassword(password, 'VpnPassword'),
|
|
149
|
-
).resolves.toBeUndefined()
|
|
150
|
-
const [actualKey, actualKeyName] = capture(
|
|
151
|
-
sudoCryptoProviderMock.updatePassword,
|
|
152
|
-
).first()
|
|
153
|
-
expect(actualKeyName).toStrictEqual('VpnPassword')
|
|
154
|
-
expect(actualKey).toStrictEqual(password)
|
|
155
|
-
|
|
156
|
-
verify(
|
|
157
|
-
sudoCryptoProviderMock.updatePassword(anything(), anything()),
|
|
158
|
-
).once()
|
|
159
|
-
})
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
describe('getSymmetricKey', () => {
|
|
163
|
-
it('should call crypto provider getSymmetricKey', async () => {
|
|
164
|
-
when(sudoCryptoProviderMock.getSymmetricKey(anything())).thenResolve(
|
|
165
|
-
symmetricKey,
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
await expect(sudoKeyManager.getSymmetricKey('VpnKey')).resolves.toEqual(
|
|
169
|
-
symmetricKey,
|
|
170
|
-
)
|
|
171
|
-
const [actualKey] = capture(
|
|
172
|
-
sudoCryptoProviderMock.getSymmetricKey,
|
|
173
|
-
).first()
|
|
174
|
-
expect(actualKey).toStrictEqual('VpnKey')
|
|
175
|
-
|
|
176
|
-
verify(sudoCryptoProviderMock.getSymmetricKey(anything())).once()
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
describe('doesSymmetricKeyExist', () => {
|
|
181
|
-
it('should call crypto provider doesSymmetricKeyExist', async () => {
|
|
182
|
-
when(
|
|
183
|
-
sudoCryptoProviderMock.doesSymmetricKeyExist(anything()),
|
|
184
|
-
).thenResolve(true)
|
|
185
|
-
|
|
186
|
-
await expect(
|
|
187
|
-
sudoKeyManager.doesSymmetricKeyExist('VpnKey'),
|
|
188
|
-
).resolves.toEqual(true)
|
|
189
|
-
const [actualKey] = capture(
|
|
190
|
-
sudoCryptoProviderMock.doesSymmetricKeyExist,
|
|
191
|
-
).first()
|
|
192
|
-
expect(actualKey).toStrictEqual('VpnKey')
|
|
193
|
-
|
|
194
|
-
verify(sudoCryptoProviderMock.doesSymmetricKeyExist(anything())).once()
|
|
195
|
-
})
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
describe('deleteSymmetricKey', () => {
|
|
199
|
-
it('should call crypto provider deleteSymmetricKey', async () => {
|
|
200
|
-
when(sudoCryptoProviderMock.deleteSymmetricKey(anything())).thenResolve()
|
|
201
|
-
|
|
202
|
-
await expect(
|
|
203
|
-
sudoKeyManager.deleteSymmetricKey('VpnKey'),
|
|
204
|
-
).resolves.toBeUndefined()
|
|
205
|
-
const [actualKey] = capture(
|
|
206
|
-
sudoCryptoProviderMock.deleteSymmetricKey,
|
|
207
|
-
).first()
|
|
208
|
-
expect(actualKey).toStrictEqual('VpnKey')
|
|
209
|
-
|
|
210
|
-
verify(sudoCryptoProviderMock.deleteSymmetricKey(anything())).once()
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
describe('generateKeyPair', () => {
|
|
215
|
-
it('should call crypto provider generateKeyPair', async () => {
|
|
216
|
-
when(sudoCryptoProviderMock.generateKeyPair(anything())).thenResolve()
|
|
217
|
-
|
|
218
|
-
await expect(
|
|
219
|
-
sudoKeyManager.generateKeyPair('VpnKeyPair'),
|
|
220
|
-
).resolves.toBeUndefined()
|
|
221
|
-
const [actualKey] = capture(
|
|
222
|
-
sudoCryptoProviderMock.generateKeyPair,
|
|
223
|
-
).first()
|
|
224
|
-
expect(actualKey).toStrictEqual('VpnKeyPair')
|
|
225
|
-
|
|
226
|
-
verify(sudoCryptoProviderMock.generateKeyPair(anything())).once()
|
|
227
|
-
})
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
describe('deleteKeyPair', () => {
|
|
231
|
-
it('should call crypto provider deleteKeyPair', async () => {
|
|
232
|
-
when(sudoCryptoProviderMock.deleteKeyPair(anything())).thenResolve()
|
|
233
|
-
|
|
234
|
-
await expect(
|
|
235
|
-
sudoKeyManager.deleteKeyPair('KeyPair'),
|
|
236
|
-
).resolves.toBeUndefined()
|
|
237
|
-
const [actualKey] = capture(sudoCryptoProviderMock.deleteKeyPair).first()
|
|
238
|
-
expect(actualKey).toStrictEqual('KeyPair')
|
|
239
|
-
|
|
240
|
-
verify(sudoCryptoProviderMock.deleteKeyPair(anything())).once()
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
describe('addPrivateKey', () => {
|
|
245
|
-
it('should call crypto provider addPrivateKey', async () => {
|
|
246
|
-
when(
|
|
247
|
-
sudoCryptoProviderMock.addPrivateKey(anything(), anything()),
|
|
248
|
-
).thenResolve()
|
|
249
|
-
|
|
250
|
-
await expect(
|
|
251
|
-
sudoKeyManager.addPrivateKey(privateKey, 'VpnKeyPair'),
|
|
252
|
-
).resolves.toBeUndefined()
|
|
253
|
-
const [actualKey, actualKeyName] = capture(
|
|
254
|
-
sudoCryptoProviderMock.addPrivateKey,
|
|
255
|
-
).first()
|
|
256
|
-
expect(actualKey).toStrictEqual(privateKey)
|
|
257
|
-
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
258
|
-
|
|
259
|
-
verify(
|
|
260
|
-
sudoCryptoProviderMock.addPrivateKey(anything(), anything()),
|
|
261
|
-
).once()
|
|
262
|
-
})
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
describe('getPrivateKey', () => {
|
|
266
|
-
it('should call crypto provider getPrivateKey', async () => {
|
|
267
|
-
when(sudoCryptoProviderMock.getPrivateKey(anything())).thenResolve(
|
|
268
|
-
privateKey,
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
await expect(sudoKeyManager.getPrivateKey('VpnKeyPair')).resolves.toEqual(
|
|
272
|
-
privateKey,
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
const [actualKeyName] = capture(
|
|
276
|
-
sudoCryptoProviderMock.getPrivateKey,
|
|
277
|
-
).first()
|
|
278
|
-
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
279
|
-
|
|
280
|
-
verify(sudoCryptoProviderMock.getPrivateKey(anything())).once()
|
|
281
|
-
})
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
describe('doesPrivateKeyExist', () => {
|
|
285
|
-
it('should call crypto provider doesPrivateKeyExist', async () => {
|
|
286
|
-
when(sudoCryptoProviderMock.doesPrivateKeyExist(anything())).thenResolve(
|
|
287
|
-
true,
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
await expect(
|
|
291
|
-
sudoKeyManager.doesPrivateKeyExist('VpnKeyPair'),
|
|
292
|
-
).resolves.toBeTruthy()
|
|
293
|
-
|
|
294
|
-
const [actualKeyName] = capture(
|
|
295
|
-
sudoCryptoProviderMock.doesPrivateKeyExist,
|
|
296
|
-
).first()
|
|
297
|
-
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
298
|
-
|
|
299
|
-
verify(sudoCryptoProviderMock.doesPrivateKeyExist(anything())).once()
|
|
300
|
-
})
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
describe('addPublicKey', () => {
|
|
304
|
-
it('should call crypto provider addPublicKey', async () => {
|
|
305
|
-
when(
|
|
306
|
-
sudoCryptoProviderMock.addPublicKey(anything(), anything()),
|
|
307
|
-
).thenResolve()
|
|
308
|
-
|
|
309
|
-
await expect(
|
|
310
|
-
sudoKeyManager.addPublicKey(publicKey.keyData, 'VpnKeyPair'),
|
|
311
|
-
).resolves.toBeUndefined()
|
|
312
|
-
const [actualKey, actualKeyName] = capture(
|
|
313
|
-
sudoCryptoProviderMock.addPublicKey,
|
|
314
|
-
).first()
|
|
315
|
-
expect(actualKey).toStrictEqual(publicKey.keyData)
|
|
316
|
-
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
317
|
-
|
|
318
|
-
verify(sudoCryptoProviderMock.addPublicKey(anything(), anything())).once()
|
|
319
|
-
})
|
|
320
|
-
})
|
|
321
|
-
|
|
322
|
-
describe('getPublicKey', () => {
|
|
323
|
-
it('should call crypto provider getPublicKey', async () => {
|
|
324
|
-
when(sudoCryptoProviderMock.getPublicKey(anything())).thenResolve(
|
|
325
|
-
publicKey,
|
|
326
|
-
)
|
|
327
|
-
|
|
328
|
-
await expect(sudoKeyManager.getPublicKey('VpnKeyPair')).resolves.toEqual(
|
|
329
|
-
publicKey,
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
const [actualKeyName] = capture(
|
|
333
|
-
sudoCryptoProviderMock.getPublicKey,
|
|
334
|
-
).first()
|
|
335
|
-
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
336
|
-
|
|
337
|
-
verify(sudoCryptoProviderMock.getPublicKey(anything())).once()
|
|
338
|
-
})
|
|
339
|
-
})
|
|
340
|
-
|
|
341
|
-
describe('removeAllKeys', () => {
|
|
342
|
-
it('should call crypto provider removeAllKeys', async () => {
|
|
343
|
-
when(sudoCryptoProviderMock.removeAllKeys()).thenResolve()
|
|
344
|
-
await sudoKeyManager.removeAllKeys()
|
|
345
|
-
verify(sudoCryptoProviderMock.removeAllKeys()).once()
|
|
346
|
-
})
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
describe('encryptWithSymmetricKeyName', () => {
|
|
350
|
-
it('should call crypto provider encryptWithSymmetricKeyName without iv or algorithm', async () => {
|
|
351
|
-
when(
|
|
352
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
353
|
-
anything(),
|
|
354
|
-
anything(),
|
|
355
|
-
anything(),
|
|
356
|
-
),
|
|
357
|
-
).thenResolve(encrypted)
|
|
358
|
-
|
|
359
|
-
await sudoKeyManager.encryptWithSymmetricKeyName('VpnKey', decrypted)
|
|
360
|
-
|
|
361
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
362
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName,
|
|
363
|
-
).first()
|
|
364
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
365
|
-
expect(actualData).toStrictEqual(decrypted)
|
|
366
|
-
expect(actualOptions).toBeUndefined()
|
|
367
|
-
|
|
368
|
-
verify(
|
|
369
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
370
|
-
anything(),
|
|
371
|
-
anything(),
|
|
372
|
-
anything(),
|
|
373
|
-
),
|
|
374
|
-
).once()
|
|
375
|
-
})
|
|
376
|
-
|
|
377
|
-
it('should call crypto provider encryptWithSymmetricKeyName with iv and no algorithm', async () => {
|
|
378
|
-
when(
|
|
379
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
380
|
-
anything(),
|
|
381
|
-
anything(),
|
|
382
|
-
anything(),
|
|
383
|
-
),
|
|
384
|
-
).thenResolve(encrypted)
|
|
385
|
-
|
|
386
|
-
await sudoKeyManager.encryptWithSymmetricKeyName('VpnKey', decrypted, {
|
|
387
|
-
iv,
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
391
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName,
|
|
392
|
-
).first()
|
|
393
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
394
|
-
expect(actualData).toStrictEqual(decrypted)
|
|
395
|
-
expect(actualOptions).toBeDefined()
|
|
396
|
-
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
397
|
-
expect(actualOptions!.algorithm).toBeUndefined()
|
|
398
|
-
|
|
399
|
-
verify(
|
|
400
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
401
|
-
anything(),
|
|
402
|
-
anything(),
|
|
403
|
-
anything(),
|
|
404
|
-
),
|
|
405
|
-
).once()
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
it('should call crypto provider encryptWithSymmetricKeyName with iv and algorithm', async () => {
|
|
409
|
-
when(
|
|
410
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
411
|
-
anything(),
|
|
412
|
-
anything(),
|
|
413
|
-
anything(),
|
|
414
|
-
),
|
|
415
|
-
).thenResolve(encrypted)
|
|
416
|
-
|
|
417
|
-
const options = {
|
|
418
|
-
iv,
|
|
419
|
-
algorithm: EncryptionAlgorithm.AesCbcPkcs7Padding,
|
|
420
|
-
}
|
|
421
|
-
await sudoKeyManager.encryptWithSymmetricKeyName(
|
|
422
|
-
'VpnKey',
|
|
423
|
-
decrypted,
|
|
424
|
-
options,
|
|
425
|
-
)
|
|
426
|
-
|
|
427
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
428
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName,
|
|
429
|
-
).first()
|
|
430
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
431
|
-
expect(actualData).toStrictEqual(decrypted)
|
|
432
|
-
expect(actualOptions).toBeDefined()
|
|
433
|
-
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
434
|
-
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
435
|
-
|
|
436
|
-
verify(
|
|
437
|
-
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
438
|
-
anything(),
|
|
439
|
-
anything(),
|
|
440
|
-
anything(),
|
|
441
|
-
),
|
|
442
|
-
).once()
|
|
443
|
-
})
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
describe('encryptWithSymmetricKey', () => {
|
|
447
|
-
it('should call crypto provider encryptWithSymmetricKey without iv or algorithm', async () => {
|
|
448
|
-
when(
|
|
449
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
450
|
-
anything(),
|
|
451
|
-
anything(),
|
|
452
|
-
anything(),
|
|
453
|
-
),
|
|
454
|
-
).thenResolve(decrypted)
|
|
455
|
-
|
|
456
|
-
await expect(
|
|
457
|
-
sudoKeyManager.encryptWithSymmetricKey(symmetricKey, encrypted),
|
|
458
|
-
).resolves.toEqual(decrypted)
|
|
459
|
-
|
|
460
|
-
const [actualKey, actualData, actualOptions] = capture(
|
|
461
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey,
|
|
462
|
-
).first()
|
|
463
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
464
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
465
|
-
expect(actualOptions).toBeUndefined()
|
|
466
|
-
|
|
467
|
-
verify(
|
|
468
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
469
|
-
anything(),
|
|
470
|
-
anything(),
|
|
471
|
-
anything(),
|
|
472
|
-
),
|
|
473
|
-
).once()
|
|
474
|
-
})
|
|
475
|
-
|
|
476
|
-
it('should call crypto provider encryptWithSymmetricKey with iv and no algorithm', async () => {
|
|
477
|
-
when(
|
|
478
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
479
|
-
anything(),
|
|
480
|
-
anything(),
|
|
481
|
-
anything(),
|
|
482
|
-
),
|
|
483
|
-
).thenResolve(decrypted)
|
|
484
|
-
|
|
485
|
-
await expect(
|
|
486
|
-
sudoKeyManager.encryptWithSymmetricKey(symmetricKey, encrypted, { iv }),
|
|
487
|
-
).resolves.toEqual(decrypted)
|
|
488
|
-
|
|
489
|
-
const [actualKey, actualData, actualOptions] = capture(
|
|
490
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey,
|
|
491
|
-
).first()
|
|
492
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
493
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
494
|
-
expect(actualOptions).toBeDefined()
|
|
495
|
-
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
496
|
-
expect(actualOptions!.algorithm).toBeUndefined()
|
|
497
|
-
|
|
498
|
-
verify(
|
|
499
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
500
|
-
anything(),
|
|
501
|
-
anything(),
|
|
502
|
-
anything(),
|
|
503
|
-
),
|
|
504
|
-
).once()
|
|
505
|
-
})
|
|
506
|
-
|
|
507
|
-
it('should call crypto provider encryptWithSymmetricKey with algorithm and no iv', async () => {
|
|
508
|
-
when(
|
|
509
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
510
|
-
anything(),
|
|
511
|
-
anything(),
|
|
512
|
-
anything(),
|
|
513
|
-
),
|
|
514
|
-
).thenResolve(decrypted)
|
|
515
|
-
|
|
516
|
-
const options = {
|
|
517
|
-
algorithm: EncryptionAlgorithm.AesCbcPkcs7Padding,
|
|
518
|
-
}
|
|
519
|
-
await expect(
|
|
520
|
-
sudoKeyManager.encryptWithSymmetricKey(
|
|
521
|
-
symmetricKey,
|
|
522
|
-
encrypted,
|
|
523
|
-
options,
|
|
524
|
-
),
|
|
525
|
-
).resolves.toEqual(decrypted)
|
|
526
|
-
|
|
527
|
-
const [actualKey, actualData, actualOptions] = capture(
|
|
528
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey,
|
|
529
|
-
).first()
|
|
530
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
531
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
532
|
-
expect(actualOptions).toBeDefined()
|
|
533
|
-
expect(actualOptions!.iv).toBeUndefined()
|
|
534
|
-
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
535
|
-
|
|
536
|
-
verify(
|
|
537
|
-
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
538
|
-
anything(),
|
|
539
|
-
anything(),
|
|
540
|
-
anything(),
|
|
541
|
-
),
|
|
542
|
-
).once()
|
|
543
|
-
})
|
|
544
|
-
})
|
|
545
|
-
|
|
546
|
-
describe('decryptWithSymmetricKeyName', () => {
|
|
547
|
-
it('should call crypto provider decryptWithSymmetricKeyName without iv and algorithm', async () => {
|
|
548
|
-
when(
|
|
549
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
550
|
-
anything(),
|
|
551
|
-
anything(),
|
|
552
|
-
anything(),
|
|
553
|
-
),
|
|
554
|
-
).thenResolve(decrypted)
|
|
555
|
-
|
|
556
|
-
await expect(
|
|
557
|
-
sudoKeyManager.decryptWithSymmetricKeyName('VpnKey', encrypted),
|
|
558
|
-
).resolves.toEqual(decrypted)
|
|
559
|
-
|
|
560
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
561
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName,
|
|
562
|
-
).first()
|
|
563
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
564
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
565
|
-
expect(actualOptions).toBeUndefined()
|
|
566
|
-
|
|
567
|
-
verify(
|
|
568
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
569
|
-
anything(),
|
|
570
|
-
anything(),
|
|
571
|
-
anything(),
|
|
572
|
-
),
|
|
573
|
-
).once()
|
|
574
|
-
})
|
|
575
|
-
|
|
576
|
-
it('should call crypto provider decryptWithSymmetricKeyName with iv and no algorithm', async () => {
|
|
577
|
-
when(
|
|
578
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
579
|
-
anything(),
|
|
580
|
-
anything(),
|
|
581
|
-
anything(),
|
|
582
|
-
),
|
|
583
|
-
).thenResolve(decrypted)
|
|
584
|
-
|
|
585
|
-
const options = {
|
|
586
|
-
iv,
|
|
587
|
-
}
|
|
588
|
-
await expect(
|
|
589
|
-
sudoKeyManager.decryptWithSymmetricKeyName(
|
|
590
|
-
'VpnKey',
|
|
591
|
-
encrypted,
|
|
592
|
-
options,
|
|
593
|
-
),
|
|
594
|
-
).resolves.toEqual(decrypted)
|
|
595
|
-
|
|
596
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
597
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName,
|
|
598
|
-
).first()
|
|
599
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
600
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
601
|
-
expect(actualOptions).toBeDefined()
|
|
602
|
-
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
603
|
-
expect(actualOptions!.algorithm).toBeUndefined()
|
|
604
|
-
|
|
605
|
-
verify(
|
|
606
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
607
|
-
anything(),
|
|
608
|
-
anything(),
|
|
609
|
-
anything(),
|
|
610
|
-
),
|
|
611
|
-
).once()
|
|
612
|
-
})
|
|
613
|
-
|
|
614
|
-
it('should call crypto provider decryptWithSymmetricKeyName with iv and algorithm', async () => {
|
|
615
|
-
when(
|
|
616
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
617
|
-
anything(),
|
|
618
|
-
anything(),
|
|
619
|
-
anything(),
|
|
620
|
-
),
|
|
621
|
-
).thenResolve(decrypted)
|
|
622
|
-
|
|
623
|
-
const options = {
|
|
624
|
-
iv,
|
|
625
|
-
algorithm: EncryptionAlgorithm.AesCbcPkcs7Padding,
|
|
626
|
-
}
|
|
627
|
-
await expect(
|
|
628
|
-
sudoKeyManager.decryptWithSymmetricKeyName(
|
|
629
|
-
'VpnKey',
|
|
630
|
-
encrypted,
|
|
631
|
-
options,
|
|
632
|
-
),
|
|
633
|
-
).resolves.toEqual(decrypted)
|
|
634
|
-
|
|
635
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
636
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName,
|
|
637
|
-
).first()
|
|
638
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
639
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
640
|
-
expect(actualOptions).toBeDefined()
|
|
641
|
-
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
642
|
-
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
643
|
-
|
|
644
|
-
verify(
|
|
645
|
-
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
646
|
-
anything(),
|
|
647
|
-
anything(),
|
|
648
|
-
anything(),
|
|
649
|
-
),
|
|
650
|
-
).once()
|
|
651
|
-
})
|
|
652
|
-
})
|
|
653
|
-
|
|
654
|
-
describe('decryptWithSymmetricKey', () => {
|
|
655
|
-
it('should call crypto provider decryptWithSymmetricKey without iv or algorithm', async () => {
|
|
656
|
-
when(
|
|
657
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
658
|
-
anything(),
|
|
659
|
-
anything(),
|
|
660
|
-
anything(),
|
|
661
|
-
),
|
|
662
|
-
).thenResolve(decrypted)
|
|
663
|
-
|
|
664
|
-
await expect(
|
|
665
|
-
sudoKeyManager.decryptWithSymmetricKey(symmetricKey, encrypted),
|
|
666
|
-
).resolves.toEqual(decrypted)
|
|
667
|
-
|
|
668
|
-
const [actualKey, actualData, actualOptions] = capture(
|
|
669
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey,
|
|
670
|
-
).first()
|
|
671
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
672
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
673
|
-
expect(actualOptions).toBeUndefined()
|
|
674
|
-
|
|
675
|
-
verify(
|
|
676
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
677
|
-
anything(),
|
|
678
|
-
anything(),
|
|
679
|
-
anything(),
|
|
680
|
-
),
|
|
681
|
-
).once()
|
|
682
|
-
})
|
|
683
|
-
|
|
684
|
-
it('should call crypto provider decryptWithSymmetricKey with iv and no algorithm', async () => {
|
|
685
|
-
when(
|
|
686
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
687
|
-
anything(),
|
|
688
|
-
anything(),
|
|
689
|
-
anything(),
|
|
690
|
-
),
|
|
691
|
-
).thenResolve(decrypted)
|
|
692
|
-
|
|
693
|
-
const options = {
|
|
694
|
-
iv,
|
|
695
|
-
}
|
|
696
|
-
await expect(
|
|
697
|
-
sudoKeyManager.decryptWithSymmetricKey(
|
|
698
|
-
symmetricKey,
|
|
699
|
-
encrypted,
|
|
700
|
-
options,
|
|
701
|
-
),
|
|
702
|
-
).resolves.toEqual(decrypted)
|
|
703
|
-
|
|
704
|
-
const [actualKey, actualData, actualOptions] = capture(
|
|
705
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey,
|
|
706
|
-
).first()
|
|
707
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
708
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
709
|
-
expect(actualOptions).toBeDefined()
|
|
710
|
-
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
711
|
-
expect(actualOptions!.algorithm).toBeUndefined()
|
|
712
|
-
|
|
713
|
-
verify(
|
|
714
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
715
|
-
anything(),
|
|
716
|
-
anything(),
|
|
717
|
-
anything(),
|
|
718
|
-
),
|
|
719
|
-
).once()
|
|
720
|
-
})
|
|
721
|
-
|
|
722
|
-
it('should call crypto provider decryptWithSymmetricKey with iv and algorithm', async () => {
|
|
723
|
-
when(
|
|
724
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
725
|
-
anything(),
|
|
726
|
-
anything(),
|
|
727
|
-
anything(),
|
|
728
|
-
),
|
|
729
|
-
).thenResolve(decrypted)
|
|
730
|
-
|
|
731
|
-
const options = {
|
|
732
|
-
iv,
|
|
733
|
-
algorithm: EncryptionAlgorithm.AesCbcPkcs7Padding,
|
|
734
|
-
}
|
|
735
|
-
await expect(
|
|
736
|
-
sudoKeyManager.decryptWithSymmetricKey(
|
|
737
|
-
symmetricKey,
|
|
738
|
-
encrypted,
|
|
739
|
-
options,
|
|
740
|
-
),
|
|
741
|
-
).resolves.toEqual(decrypted)
|
|
742
|
-
|
|
743
|
-
const [actualKey, actualData, actualOptions] = capture(
|
|
744
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey,
|
|
745
|
-
).first()
|
|
746
|
-
expect(actualKey).toStrictEqual(symmetricKey)
|
|
747
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
748
|
-
expect(actualOptions).toBeDefined()
|
|
749
|
-
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
750
|
-
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
751
|
-
|
|
752
|
-
verify(
|
|
753
|
-
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
754
|
-
anything(),
|
|
755
|
-
anything(),
|
|
756
|
-
anything(),
|
|
757
|
-
),
|
|
758
|
-
).once()
|
|
759
|
-
})
|
|
760
|
-
})
|
|
761
|
-
|
|
762
|
-
describe('encryptWithPublicKey', () => {
|
|
763
|
-
it('should call crypto provider encryptWithPublicKey', async () => {
|
|
764
|
-
when(
|
|
765
|
-
sudoCryptoProviderMock.encryptWithPublicKey(
|
|
766
|
-
anything(),
|
|
767
|
-
anything(),
|
|
768
|
-
anything(),
|
|
769
|
-
),
|
|
770
|
-
).thenResolve(encrypted)
|
|
771
|
-
|
|
772
|
-
await expect(
|
|
773
|
-
sudoKeyManager.encryptWithPublicKey('VpnKey', decrypted),
|
|
774
|
-
).resolves.toEqual(encrypted)
|
|
775
|
-
|
|
776
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
777
|
-
sudoCryptoProviderMock.encryptWithPublicKey,
|
|
778
|
-
).first()
|
|
779
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
780
|
-
expect(actualData).toStrictEqual(decrypted)
|
|
781
|
-
expect(actualOptions).toBeUndefined()
|
|
782
|
-
|
|
783
|
-
verify(
|
|
784
|
-
sudoCryptoProviderMock.encryptWithPublicKey(
|
|
785
|
-
anything(),
|
|
786
|
-
anything(),
|
|
787
|
-
anything(),
|
|
788
|
-
),
|
|
789
|
-
).once()
|
|
790
|
-
})
|
|
791
|
-
|
|
792
|
-
it('should call crypto provider encryptWithPublicKey with algorithm', async () => {
|
|
793
|
-
when(
|
|
794
|
-
sudoCryptoProviderMock.encryptWithPublicKey(
|
|
795
|
-
anything(),
|
|
796
|
-
anything(),
|
|
797
|
-
anything(),
|
|
798
|
-
),
|
|
799
|
-
).thenResolve(encrypted)
|
|
800
|
-
|
|
801
|
-
const options = {
|
|
802
|
-
algorithm: EncryptionAlgorithm.RsaOaepSha1,
|
|
803
|
-
}
|
|
804
|
-
await expect(
|
|
805
|
-
sudoKeyManager.encryptWithPublicKey('VpnKey', decrypted, options),
|
|
806
|
-
).resolves.toEqual(encrypted)
|
|
807
|
-
|
|
808
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
809
|
-
sudoCryptoProviderMock.encryptWithPublicKey,
|
|
810
|
-
).first()
|
|
811
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
812
|
-
expect(actualData).toStrictEqual(decrypted)
|
|
813
|
-
expect(actualOptions).toBeDefined()
|
|
814
|
-
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
815
|
-
|
|
816
|
-
verify(
|
|
817
|
-
sudoCryptoProviderMock.encryptWithPublicKey(
|
|
818
|
-
anything(),
|
|
819
|
-
anything(),
|
|
820
|
-
anything(),
|
|
821
|
-
),
|
|
822
|
-
).once()
|
|
823
|
-
})
|
|
824
|
-
})
|
|
825
|
-
|
|
826
|
-
describe('decryptWithPrivateKey', () => {
|
|
827
|
-
it('should call crypto provider decryptWithPrivateKey', async () => {
|
|
828
|
-
when(
|
|
829
|
-
sudoCryptoProviderMock.decryptWithPrivateKey(
|
|
830
|
-
anything(),
|
|
831
|
-
anything(),
|
|
832
|
-
anything(),
|
|
833
|
-
),
|
|
834
|
-
).thenResolve(decrypted)
|
|
835
|
-
|
|
836
|
-
await expect(
|
|
837
|
-
sudoKeyManager.decryptWithPrivateKey('VpnKey', encrypted),
|
|
838
|
-
).resolves.toEqual(decrypted)
|
|
839
|
-
|
|
840
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
841
|
-
sudoCryptoProviderMock.decryptWithPrivateKey,
|
|
842
|
-
).first()
|
|
843
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
844
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
845
|
-
expect(actualOptions).toBeUndefined()
|
|
846
|
-
|
|
847
|
-
verify(
|
|
848
|
-
sudoCryptoProviderMock.decryptWithPrivateKey(
|
|
849
|
-
anything(),
|
|
850
|
-
anything(),
|
|
851
|
-
anything(),
|
|
852
|
-
),
|
|
853
|
-
).once()
|
|
854
|
-
})
|
|
855
|
-
|
|
856
|
-
it('should call crypto provider decryptWithPrivateKey with algorithm', async () => {
|
|
857
|
-
when(
|
|
858
|
-
sudoCryptoProviderMock.decryptWithPrivateKey(
|
|
859
|
-
anything(),
|
|
860
|
-
anything(),
|
|
861
|
-
anything(),
|
|
862
|
-
),
|
|
863
|
-
).thenResolve(decrypted)
|
|
864
|
-
|
|
865
|
-
const options = {
|
|
866
|
-
algorithm: EncryptionAlgorithm.RsaOaepSha1,
|
|
867
|
-
}
|
|
868
|
-
await expect(
|
|
869
|
-
sudoKeyManager.decryptWithPrivateKey('VpnKey', encrypted, options),
|
|
870
|
-
).resolves.toEqual(decrypted)
|
|
871
|
-
|
|
872
|
-
const [actualKeyName, actualData, actualOptions] = capture(
|
|
873
|
-
sudoCryptoProviderMock.decryptWithPrivateKey,
|
|
874
|
-
).first()
|
|
875
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
876
|
-
expect(actualData).toStrictEqual(encrypted)
|
|
877
|
-
expect(actualOptions).toBeDefined()
|
|
878
|
-
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
879
|
-
|
|
880
|
-
verify(
|
|
881
|
-
sudoCryptoProviderMock.decryptWithPrivateKey(
|
|
882
|
-
anything(),
|
|
883
|
-
anything(),
|
|
884
|
-
anything(),
|
|
885
|
-
),
|
|
886
|
-
).once()
|
|
887
|
-
})
|
|
888
|
-
})
|
|
889
|
-
|
|
890
|
-
describe('generateSymmetricKey', () => {
|
|
891
|
-
it('should call crypto provider generateSymmetricKey', async () => {
|
|
892
|
-
when(
|
|
893
|
-
sudoCryptoProviderMock.generateSymmetricKey(anything()),
|
|
894
|
-
).thenResolve()
|
|
895
|
-
|
|
896
|
-
await expect(
|
|
897
|
-
sudoKeyManager.generateSymmetricKey('VpnKey'),
|
|
898
|
-
).resolves.toBeUndefined()
|
|
899
|
-
|
|
900
|
-
const [actualKeyName] = capture(
|
|
901
|
-
sudoCryptoProviderMock.generateSymmetricKey,
|
|
902
|
-
).first()
|
|
903
|
-
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
904
|
-
|
|
905
|
-
verify(sudoCryptoProviderMock.generateSymmetricKey(anything())).once()
|
|
906
|
-
})
|
|
907
|
-
})
|
|
908
|
-
|
|
909
|
-
describe('generateSymmetricKeyFromPassword', () => {
|
|
910
|
-
it('should call crypto provider generateSymmetricKeyFromPassword without options', async () => {
|
|
911
|
-
when(
|
|
912
|
-
sudoCryptoProviderMock.generateSymmetricKeyFromPassword(
|
|
913
|
-
anything(),
|
|
914
|
-
anything(),
|
|
915
|
-
anything(),
|
|
916
|
-
),
|
|
917
|
-
).thenResolve(symmetricKey)
|
|
918
|
-
|
|
919
|
-
await expect(
|
|
920
|
-
sudoKeyManager.generateSymmetricKeyFromPassword(password, salt),
|
|
921
|
-
).resolves.toEqual(symmetricKey)
|
|
922
|
-
|
|
923
|
-
const [actualPassword, actualSalt, actualOptions] = capture(
|
|
924
|
-
sudoCryptoProviderMock.generateSymmetricKeyFromPassword,
|
|
925
|
-
).first()
|
|
926
|
-
expect(actualPassword).toStrictEqual(password)
|
|
927
|
-
expect(actualSalt).toStrictEqual(salt)
|
|
928
|
-
expect(actualOptions).toBeUndefined()
|
|
929
|
-
|
|
930
|
-
verify(
|
|
931
|
-
sudoCryptoProviderMock.generateSymmetricKeyFromPassword(
|
|
932
|
-
anything(),
|
|
933
|
-
anything(),
|
|
934
|
-
anything(),
|
|
935
|
-
),
|
|
936
|
-
).once()
|
|
937
|
-
})
|
|
938
|
-
})
|
|
939
|
-
|
|
940
|
-
describe('generateHash', () => {
|
|
941
|
-
it('should call crypto provider generateHash', async () => {
|
|
942
|
-
when(sudoCryptoProviderMock.generateHash(anything())).thenResolve(hash)
|
|
943
|
-
|
|
944
|
-
await expect(sudoKeyManager.generateHash(data)).resolves.toEqual(hash)
|
|
945
|
-
|
|
946
|
-
const [actualData] = capture(sudoCryptoProviderMock.generateHash).first()
|
|
947
|
-
expect(actualData).toStrictEqual(data)
|
|
948
|
-
|
|
949
|
-
verify(sudoCryptoProviderMock.generateHash(anything())).once()
|
|
950
|
-
})
|
|
951
|
-
})
|
|
952
|
-
|
|
953
|
-
describe('generateRandomData', () => {
|
|
954
|
-
it('should call crypto provider generateRandomData', async () => {
|
|
955
|
-
when(sudoCryptoProviderMock.generateRandomData(anything())).thenResolve(
|
|
956
|
-
new Uint8Array(),
|
|
957
|
-
)
|
|
958
|
-
|
|
959
|
-
const size = 100
|
|
960
|
-
await sudoKeyManager.generateRandomData(size)
|
|
961
|
-
|
|
962
|
-
const [actualSize] = capture(
|
|
963
|
-
sudoCryptoProviderMock.generateRandomData,
|
|
964
|
-
).first()
|
|
965
|
-
expect(actualSize).toStrictEqual(size)
|
|
966
|
-
|
|
967
|
-
verify(sudoCryptoProviderMock.generateRandomData(anything())).once()
|
|
968
|
-
})
|
|
969
|
-
})
|
|
970
|
-
|
|
971
|
-
describe('exportKeys', () => {
|
|
972
|
-
const keyData: KeyData[] = [
|
|
973
|
-
{
|
|
974
|
-
name: 'password',
|
|
975
|
-
type: KeyDataKeyType.Password,
|
|
976
|
-
data: password,
|
|
977
|
-
namespace,
|
|
978
|
-
format: KeyDataKeyFormat.Raw,
|
|
979
|
-
},
|
|
980
|
-
{
|
|
981
|
-
name: 'symmetric',
|
|
982
|
-
type: KeyDataKeyType.SymmetricKey,
|
|
983
|
-
data: symmetricKey,
|
|
984
|
-
namespace,
|
|
985
|
-
format: KeyDataKeyFormat.Raw,
|
|
986
|
-
},
|
|
987
|
-
{
|
|
988
|
-
name: 'private',
|
|
989
|
-
type: KeyDataKeyType.RSAPrivateKey,
|
|
990
|
-
data: privateKey,
|
|
991
|
-
namespace,
|
|
992
|
-
format: KeyDataKeyFormat.PKCS8,
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
name: 'public',
|
|
996
|
-
type: KeyDataKeyType.RSAPublicKey,
|
|
997
|
-
data: publicKey.keyData,
|
|
998
|
-
namespace,
|
|
999
|
-
format: KeyDataKeyFormat.SPKI,
|
|
1000
|
-
},
|
|
1001
|
-
]
|
|
1002
|
-
|
|
1003
|
-
const exportedKeyData: KeyData[] = [
|
|
1004
|
-
{
|
|
1005
|
-
name: 'password',
|
|
1006
|
-
type: KeyDataKeyType.Password,
|
|
1007
|
-
data: password,
|
|
1008
|
-
namespace,
|
|
1009
|
-
format: KeyDataKeyFormat.Raw,
|
|
1010
|
-
},
|
|
1011
|
-
{
|
|
1012
|
-
name: 'symmetric',
|
|
1013
|
-
type: KeyDataKeyType.SymmetricKey,
|
|
1014
|
-
data: symmetricKey,
|
|
1015
|
-
namespace,
|
|
1016
|
-
format: KeyDataKeyFormat.Raw,
|
|
1017
|
-
},
|
|
1018
|
-
{
|
|
1019
|
-
name: 'private',
|
|
1020
|
-
type: KeyDataKeyType.RSAPrivateKey,
|
|
1021
|
-
data: privateKey,
|
|
1022
|
-
namespace,
|
|
1023
|
-
format: KeyDataKeyFormat.PKCS8,
|
|
1024
|
-
},
|
|
1025
|
-
{
|
|
1026
|
-
name: 'public',
|
|
1027
|
-
type: KeyDataKeyType.RSAPublicKey,
|
|
1028
|
-
data: publicKey.keyData,
|
|
1029
|
-
namespace,
|
|
1030
|
-
format: KeyDataKeyFormat.SPKI,
|
|
1031
|
-
},
|
|
1032
|
-
]
|
|
1033
|
-
|
|
1034
|
-
it('should call crypto provider exportKeys', async () => {
|
|
1035
|
-
when(sudoCryptoProviderMock.exportKeys()).thenResolve(keyData)
|
|
1036
|
-
|
|
1037
|
-
const actualExportedKeyData = await sudoKeyManager.exportKeys()
|
|
1038
|
-
|
|
1039
|
-
expect(actualExportedKeyData).toHaveLength(exportedKeyData.length)
|
|
1040
|
-
actualExportedKeyData.forEach((k) =>
|
|
1041
|
-
expect(exportedKeyData).toContainEqual(k),
|
|
1042
|
-
)
|
|
1043
|
-
})
|
|
1044
|
-
})
|
|
1045
|
-
})
|