From 147826213b67f41af9df3508f8cf01103c90f562 Mon Sep 17 00:00:00 2001 From: Shigeyoshi Date: Thu, 24 Feb 2022 13:28:18 +0900 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=94=BB=E9=9D=A2>=E3=82=B3?= =?UTF-8?q?=E3=83=B3=E3=83=86=E3=83=B3=E3=83=84=E7=AE=A1=E7=90=86>?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E7=AE=A1=E7=90=86=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/penetration-test.yml | 1 + .../test/admin/content_page.test.ts | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 zap/selenium/ci/TypeScript/test/admin/content_page.test.ts diff --git a/.github/workflows/penetration-test.yml b/.github/workflows/penetration-test.yml index 018d107aef3..97cf16a20b1 100644 --- a/.github/workflows/penetration-test.yml +++ b/.github/workflows/penetration-test.yml @@ -15,6 +15,7 @@ jobs: - 'test/front_login/contact.test.ts' - 'test/front_guest/contact.test.ts' - 'test/admin/order_mail.test.ts' + - 'test/admin/content_page.test.ts' steps: - name: Checkout diff --git a/zap/selenium/ci/TypeScript/test/admin/content_page.test.ts b/zap/selenium/ci/TypeScript/test/admin/content_page.test.ts new file mode 100644 index 00000000000..389dd677ebb --- /dev/null +++ b/zap/selenium/ci/TypeScript/test/admin/content_page.test.ts @@ -0,0 +1,47 @@ +import { test, expect, chromium, Page } from '@playwright/test'; +import { intervalRepeater } from '../../utils/Progress'; +import { ZapClient, Mode, ContextType, Risk, HttpMessage } from '../../utils/ZapClient'; +const zapClient = new ZapClient('http://127.0.0.1:8090'); + +const baseURL = 'https://ec-cube/admin'; +const url = baseURL + '/content/page'; + +test.describe.serial('ページ管理>コンテンツ管理のテストをします', () => { + let page: Page; + test.beforeAll(async () => { + await zapClient.setMode(Mode.Protect); + await zapClient.newSession('/zap/wrk/sessions/admin_content_page', true); + await zapClient.importContext(ContextType.Admin); + + if (!await zapClient.isForcedUserModeEnabled()) { + await zapClient.setForcedUserModeEnabled(); + expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy(); + } + const browser = await chromium.launch(); + page = await browser.newPage(); + await page.goto(url); + }); + + test('管理画面>ページ管理>コンテンツ管理を表示します', async () => { + await expect(page).toHaveTitle(/コンテンツ管理 ページ管理/); + }); + + test('タイトルを確認します', async () => { + await page.textContent('.c-pageTitle__title') + .then(title => expect(title).toContain('ページ管理')); + }); + + test.describe('テストを実行します[GET] @attack', () => { + let scanId: number; + test('アクティブスキャンを実行します', async () => { + scanId = await zapClient.activeScanAsUser(url, 2, 55, 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([])); + }); + }); +}); +