-
Notifications
You must be signed in to change notification settings - Fork 8
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
5 changed files
with
47 additions
and
6 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,38 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { resetScenarios } from './resetHelper'; | ||
import { TEST_IDS } from '../src/client/testIDs'; | ||
import { BOT_FIREWALL_COPY } from '../src/pages/bot-firewall/botFirewallCopy'; | ||
|
||
test.describe('Bot Firewall Demo', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/coupon-fraud'); | ||
await resetScenarios(page); | ||
}); | ||
|
||
test('Should display bot visit a allow blocking IP address', async ({ page }) => { | ||
// Record bot visit in web-scraping page | ||
await page.goto('/web-scraping', { waitUntil: 'networkidle' }); | ||
await expect(page.getByTestId(TEST_IDS.common.alert)).toContainText('Malicious bot detected'); | ||
|
||
// Check bot visit record and block IP | ||
await page.goto('/bot-firewall', { waitUntil: 'networkidle' }); | ||
await page.getByRole('button', { name: BOT_FIREWALL_COPY.blockIp }).first().click(); | ||
await page.getByText('was blocked in the application firewall').waitFor(); | ||
await page.waitForTimeout(5000); | ||
|
||
// Try to visit web-scraping page, should be blocked by Cloudflare | ||
await page.goto('https://staging.fingerprinthub.com/web-scraping', { waitUntil: 'networkidle' }); | ||
await page.getByRole('heading', { name: 'Sorry, you have been blocked' }).waitFor(); | ||
|
||
// Unblock IP | ||
await page.goto('/bot-firewall', { waitUntil: 'networkidle' }); | ||
await page.getByRole('button', { name: BOT_FIREWALL_COPY.unblockIp }).first().click(); | ||
await page.getByText('was unblocked in the application firewall').waitFor(); | ||
await page.waitForTimeout(5000); | ||
|
||
// Try to visit web-scraping page, should be allowed again | ||
await page.goto('https://staging.fingerprinthub.com/web-scraping', { waitUntil: 'networkidle' }); | ||
await page.reload({ waitUntil: 'networkidle' }); | ||
await expect(page.getByTestId(TEST_IDS.common.alert)).toContainText('Malicious bot detected'); | ||
}); | ||
}); |
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
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
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,4 @@ | ||
export const BOT_FIREWALL_COPY = { | ||
blockIp: 'Block this IP', | ||
unblockIp: 'Unblock', | ||
} as const; |
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