-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
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,82 @@ | ||
import { testWithMetaMask } from '../testWithMetaMask' | ||
import { createDataTestSelector } from '../../../src/utils/selectors/createDataTestSelector' | ||
import { getNotificationPageAndWaitForLoad } from '../../../src/utils/getNotificationPageAndWaitForLoad' | ||
|
||
const test = testWithMetaMask | ||
|
||
const { describe, expect } = test | ||
|
||
const PPOM_ERROR = 'This is a deceptive request' | ||
const PPOM_WARNING = 'Request may not be safe' | ||
|
||
describe('using PPOM security mechanism', () => { | ||
test('should prevent malicious ETH transfer', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousRawEthButton').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_ERROR | ||
) | ||
}) | ||
|
||
test('should prevent malicious ERC20 transfer', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousERC20TransferButton').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_WARNING | ||
) | ||
}) | ||
|
||
test('should prevent malicious ERC20 approval', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousApprovalButton').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_WARNING | ||
) | ||
}) | ||
|
||
test('should prevent malicious approval for all', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousSetApprovalForAll').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_WARNING | ||
) | ||
}) | ||
|
||
test('should prevent malicious permit', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousPermit').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_ERROR | ||
) | ||
}) | ||
|
||
test('should prevent malicious trade order', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousTradeOrder').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_ERROR | ||
) | ||
}) | ||
|
||
test('should prevent malicious seaport', async ({ context, page, metamask }) => { | ||
await page.locator('#maliciousSeaport').click() | ||
|
||
const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId!) | ||
|
||
await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( | ||
PPOM_ERROR | ||
) | ||
}) | ||
}) |
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