Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ご注文確認→完了ページのテストを追加 #549

Merged
merged 2 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/penetration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
- 'test/front_login/cart/cart_delete.test.ts'
- 'test/front_login/shopping/shopping_deliv.test.ts'
- 'test/front_login/shopping/shopping_payment.test.ts'
- 'test/front_login/shopping/shopping_confirm.test.ts'
- 'test/front_login/shopping/shopping_complete.test.ts'

steps:
- name: Checkout
Expand Down
14 changes: 14 additions & 0 deletions e2e-tests/fixtures/shopping_payment.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { test as base } from './shopping_deliv.fixture';
import { ShoppingPaymentPage } from '../pages/shopping/payment.page';

export const test = base.extend({
page: async ({ page }, use) => {
const paymentPage = new ShoppingPaymentPage(page);
await paymentPage.goto();
await paymentPage.fillOut();
await paymentPage.gotoNext();
use(page);
}
});

export { expect } from '@playwright/test';
35 changes: 35 additions & 0 deletions e2e-tests/test/front_login/shopping/shopping_complete.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import PlaywrightConfig from '../../../../playwright.config';
import { ZapClient, ContextType, Risk } from '../../../utils/ZapClient';
import { intervalRepeater } from '../../../utils/Progress';
const zapClient = new ZapClient();

const url = `${PlaywrightConfig.use.baseURL}/shopping/complete.php`;

// ご注文確認画面へ進むフィクスチャ
import { test, expect } from '../../../fixtures/shopping_payment.fixture';

test.describe.serial('ご注文完了画面のテストをします', () => {
test.beforeAll(async () => {
await zapClient.startSession(ContextType.FrontLogin, 'front_login_shopping_complete')
.then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy());
});

test('ご注文完了画面へ遷移します', async ({ page }) => {
await page.click('[alt=ご注文完了ページへ]');
await expect(page.locator('h2.title')).toContainText('ご注文完了');
});

test.describe('テストを実行します[GET] @attack', () => {
let scanId: number;
test('アクティブスキャンを実行します', async ({ page }) => {
await page.goto(url);
scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'GET');
await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page);
});

test('結果を確認します', async () => {
await zapClient.getAlerts(url, 0, 1, Risk.High)
.then(alerts => expect(alerts).toEqual([]));
});
});
});
57 changes: 57 additions & 0 deletions e2e-tests/test/front_login/shopping/shopping_confirm.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import PlaywrightConfig from '../../../../playwright.config';
import { ZapClient, ContextType, Risk } from '../../../utils/ZapClient';
import { intervalRepeater } from '../../../utils/Progress';
const zapClient = new ZapClient();

const url = `${PlaywrightConfig.use.baseURL}/shopping/confirm.php`;

// ご注文確認画面へ進むフィクスチャ
import { test, expect } from '../../../fixtures/shopping_payment.fixture';

test.describe.serial('ご注文確認画面のテストをします', () => {
test.beforeAll(async () => {
await zapClient.startSession(ContextType.FrontLogin, 'front_login_shopping_confirm')
.then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy());
});

test('ご注文確認画面へ遷移します', async ({ page }) => {
await expect(page.locator('h2.title')).toContainText('入力内容のご確認');
await expect(page).toHaveURL(/confirm\.php/);
});

test.describe('テストを実行します[GET] @attack', () => {
let scanId: number;
test('アクティブスキャンを実行します', async ({ page }) => {
await page.goto(url);
scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'GET');
await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page);
});

test('結果を確認します', async () => {
await zapClient.getAlerts(url, 0, 1, Risk.High)
.then(alerts => expect(alerts).toEqual([]));
});
});

test('注文完了ページへ遷移します', async ({ page }) => {
await page.click('[alt=ご注文完了ページへ]');
await expect(page.locator('h2.title')).toContainText('ご注文完了');
});

test.describe('注文完了ページへ進むテストを実行します[POST] @attack', () => {
let scanId: number;
test('アクティブスキャンを実行します', async ({ page }) => {
await page.click('[alt=ご注文完了ページへ]');
const message = await zapClient.getLastMessage(url);
expect(message.requestHeader).toContain(`POST ${url}`);
expect(message.responseHeader).toContain('HTTP/1.1 302 Found');
scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', message.requestBody);
await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page);
});

test('結果を確認します', async () => {
await zapClient.getAlerts(url, 0, 1, Risk.High)
.then(alerts => expect(alerts).toEqual([]));
});
});
});