2022-11-22 13:07:08 +01:00
|
|
|
import { endowmentPermissionBuilders } from '@metamask/snaps-controllers';
|
2022-02-15 01:02:51 +01:00
|
|
|
import { restrictedMethodPermissionBuilders } from '@metamask/rpc-methods';
|
2022-03-14 20:37:19 +01:00
|
|
|
import {
|
|
|
|
EndowmentPermissions,
|
2022-10-07 10:02:35 +02:00
|
|
|
ExcludedSnapEndowments,
|
2022-03-14 20:37:19 +01:00
|
|
|
ExcludedSnapPermissions,
|
|
|
|
RestrictedMethods,
|
|
|
|
} from './permissions';
|
2022-02-15 01:02:51 +01:00
|
|
|
|
|
|
|
describe('EndowmentPermissions', () => {
|
|
|
|
it('has the expected permission keys', () => {
|
2023-05-02 14:51:16 +02:00
|
|
|
// Since long-running is fenced out this causes problems with the test, we re-add it here.
|
2022-02-15 01:02:51 +01:00
|
|
|
expect(Object.keys(EndowmentPermissions).sort()).toStrictEqual(
|
2023-05-02 14:51:16 +02:00
|
|
|
[
|
|
|
|
'endowment:long-running',
|
|
|
|
...Object.keys(endowmentPermissionBuilders).filter(
|
2023-06-05 13:51:19 +02:00
|
|
|
(targetName) =>
|
|
|
|
!Object.keys(ExcludedSnapEndowments).includes(targetName),
|
2023-05-02 14:51:16 +02:00
|
|
|
),
|
|
|
|
].sort(),
|
2022-02-15 01:02:51 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('RestrictedMethods', () => {
|
|
|
|
it('has the expected permission keys', () => {
|
|
|
|
expect(Object.keys(RestrictedMethods).sort()).toStrictEqual(
|
|
|
|
[
|
|
|
|
'eth_accounts',
|
2022-03-14 20:37:19 +01:00
|
|
|
...Object.keys(restrictedMethodPermissionBuilders).filter(
|
2023-06-05 13:51:19 +02:00
|
|
|
(targetName) =>
|
|
|
|
!Object.keys(ExcludedSnapPermissions).includes(targetName),
|
2022-03-14 20:37:19 +01:00
|
|
|
),
|
2022-02-15 01:02:51 +01:00
|
|
|
].sort(),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|