mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-28 23:06:37 +01:00
3df690b852
* snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import {
|
|
EndowmentPermissions,
|
|
RestrictedMethods,
|
|
ExcludedSnapEndowments,
|
|
} from '../../../../../shared/constants/permissions';
|
|
import {
|
|
buildSnapEndowmentSpecifications,
|
|
buildSnapRestrictedMethodSpecifications,
|
|
} from './snap-permissions';
|
|
|
|
describe('buildSnapRestrictedMethodSpecifications', () => {
|
|
it('creates valid permission specification objects', () => {
|
|
const hooks = {
|
|
addSnap: () => undefined,
|
|
clearSnapState: () => undefined,
|
|
getMnemonic: () => undefined,
|
|
getSnap: () => undefined,
|
|
getSnapRpcHandler: () => undefined,
|
|
getSnapState: () => undefined,
|
|
updateSnapState: () => undefined,
|
|
};
|
|
|
|
const specifications = buildSnapRestrictedMethodSpecifications(hooks);
|
|
|
|
const allRestrictedMethods = Object.keys(RestrictedMethods);
|
|
Object.keys(specifications).forEach((permissionKey) =>
|
|
expect(allRestrictedMethods).toContain(permissionKey),
|
|
);
|
|
|
|
Object.values(specifications).forEach((specification) => {
|
|
expect(specification).toMatchObject({
|
|
targetName: expect.stringMatching(/^(snap_|wallet_)/u),
|
|
methodImplementation: expect.any(Function),
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('buildSnapEndowmentSpecifications', () => {
|
|
it('creates valid permission specification objects', () => {
|
|
expect(
|
|
Object.keys(buildSnapEndowmentSpecifications()).sort(),
|
|
).toStrictEqual(
|
|
Object.keys(EndowmentPermissions)
|
|
.filter(
|
|
(targetName) =>
|
|
!Object.keys(ExcludedSnapEndowments).includes(targetName),
|
|
)
|
|
.sort(),
|
|
);
|
|
});
|
|
});
|