From fc19e3bca65acb1305879e2f5f55d4d7e3f154b1 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 27 Jan 2022 17:17:20 +0900 Subject: [PATCH 1/4] =?UTF-8?q?HTTP=5FPROXY=20=E3=81=AF=20playwright.confi?= =?UTF-8?q?g.ts=20=E3=81=A7=E8=A8=AD=E5=AE=9A=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - macOS では環境変数から proxy の情報を渡せないため --- .github/workflows/e2e-tests.yml | 4 ---- .github/workflows/penetration-tests.yml | 2 -- playwright.config.ts | 5 ++++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 0efbb29d95..f20fd3bbd9 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -57,8 +57,6 @@ jobs: - name: Run to E2E testing env: GROUP: ${{ matrix.group }} - HTTPS_PROXY: 'localhost:8090' - HTTP_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 run: yarn test:e2e e2e-tests/${GROUP} @@ -147,8 +145,6 @@ jobs: - name: Run to E2E testing env: - HTTP_PROXY: 'localhost:8090' - HTTPS_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 DB_TYPE: ${{ matrix.db }} diff --git a/.github/workflows/penetration-tests.yml b/.github/workflows/penetration-tests.yml index 9ac0e4f2d8..2d0c0c852a 100644 --- a/.github/workflows/penetration-tests.yml +++ b/.github/workflows/penetration-tests.yml @@ -53,8 +53,6 @@ jobs: - name: Penetration testing env: GROUP: ${{ matrix.group }} - HTTPS_PROXY: 'localhost:8090' - HTTP_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 run: yarn test:attack e2e-tests/${GROUP} diff --git a/playwright.config.ts b/playwright.config.ts index 953028f541..da9591142e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -46,7 +46,10 @@ const config: PlaywrightTestConfig = { screenshot: 'only-on-failure', video: 'retain-on-failure', ignoreHTTPSErrors: true, - acceptDownloads: true + acceptDownloads: true, + proxy: { + server: process.env.HTTP_PROXY ? `http://${process.env.HTTP_PROXY}` : 'http://localhost:8090' + } }, /* Configure projects for major browsers */ From 6cb5cce998750843f9df4b8a6fa92e904dd742f9 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 27 Jan 2022 17:30:20 +0900 Subject: [PATCH 2/4] Fix RequestError: Error: getaddrinfo EAI_AGAIN undefined --- .github/workflows/e2e-tests.yml | 4 ++++ .github/workflows/penetration-tests.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index f20fd3bbd9..0efbb29d95 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -57,6 +57,8 @@ jobs: - name: Run to E2E testing env: GROUP: ${{ matrix.group }} + HTTPS_PROXY: 'localhost:8090' + HTTP_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 run: yarn test:e2e e2e-tests/${GROUP} @@ -145,6 +147,8 @@ jobs: - name: Run to E2E testing env: + HTTP_PROXY: 'localhost:8090' + HTTPS_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 DB_TYPE: ${{ matrix.db }} diff --git a/.github/workflows/penetration-tests.yml b/.github/workflows/penetration-tests.yml index 2d0c0c852a..9ac0e4f2d8 100644 --- a/.github/workflows/penetration-tests.yml +++ b/.github/workflows/penetration-tests.yml @@ -53,6 +53,8 @@ jobs: - name: Penetration testing env: GROUP: ${{ matrix.group }} + HTTPS_PROXY: 'localhost:8090' + HTTP_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 run: yarn test:attack e2e-tests/${GROUP} From 05cc0dc7a196dc584cf4dd1b729704b9f8aee294 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 15 Feb 2022 11:44:06 +0900 Subject: [PATCH 3/4] =?UTF-8?q?playwright.config=20=E3=81=AE=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=82=92=E5=8F=82=E7=85=A7=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e-tests/test/front_guest/entry.test.ts | 5 ++--- e2e-tests/test/front_login/contact.test.ts | 9 +++------ e2e-tests/utils/ZapClient.ts | 5 +++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/e2e-tests/test/front_guest/entry.test.ts b/e2e-tests/test/front_guest/entry.test.ts index 575c6c75cf..3df8bde903 100644 --- a/e2e-tests/test/front_guest/entry.test.ts +++ b/e2e-tests/test/front_guest/entry.test.ts @@ -1,4 +1,5 @@ import { test, expect, chromium, Page, request, APIRequestContext } from '@playwright/test'; +import PlaywrightConfig from '../../../playwright.config'; import * as faker from 'faker/locale/ja'; import * as fakerEN from 'faker/locale/en_US'; import { addYears } from 'date-fns'; @@ -13,9 +14,7 @@ test.describe.serial('会員登録のテストをします', () => { const browser = await chromium.launch(); mailcatcher = await request.newContext({ baseURL: 'http://mailcatcher:1080', - proxy: { - server: process.env.HTTP_PROXY - } + proxy: PlaywrightConfig.use.proxy }); await mailcatcher.delete('/messages'); diff --git a/e2e-tests/test/front_login/contact.test.ts b/e2e-tests/test/front_login/contact.test.ts index a109d1de3c..4649273734 100644 --- a/e2e-tests/test/front_login/contact.test.ts +++ b/e2e-tests/test/front_login/contact.test.ts @@ -1,4 +1,5 @@ import { test, expect, chromium, Page } from '@playwright/test'; +import PlaywrightConfig from '../../../playwright.config'; import { ZapClient, Mode, ContextType, Risk, HttpMessage } from '../../utils/ZapClient'; import { intervalRepeater } from '../../utils/Progress'; const zapClient = new ZapClient(); @@ -7,12 +8,8 @@ const inputNames = [ 'name01', 'name02', 'kana01', 'kana02', 'zip01', 'zip02', 'addr01', 'addr02', 'tel01', 'tel02', 'tel03' ] as const; -type InputName = { - [key in typeof inputNames[number]]?: string -}; -const baseURL = 'https://ec-cube'; -const url = baseURL + '/contact/index.php'; +const url = `${PlaywrightConfig.use.baseURL}/contact/index.php`; test.describe.serial('お問い合わせページのテストをします', () => { let page: Page; @@ -49,7 +46,7 @@ test.describe.serial('お問い合わせページのテストをします', () = }); test('ログイン状態を確認します', async () => { - await page.goto(baseURL); // ログアウトしてしまう場合があるので一旦トップへ遷移する + await page.goto(PlaywrightConfig.use.baseURL); // ログアウトしてしまう場合があるので一旦トップへ遷移する await page.goto(url); await expect(page.locator('#header')).toContainText('ようこそ'); inputNames.forEach(async (name) => expect(page.locator(`input[name=${name}]`)).not.toBeEmpty()); diff --git a/e2e-tests/utils/ZapClient.ts b/e2e-tests/utils/ZapClient.ts index 000f39b62f..8661e087ae 100644 --- a/e2e-tests/utils/ZapClient.ts +++ b/e2e-tests/utils/ZapClient.ts @@ -1,4 +1,5 @@ const ClientApi = require('zaproxy'); +import PlaywrightConfig from '../../playwright.config'; export const Mode = { Safe: 'safe', Protect: 'protect', @@ -76,8 +77,8 @@ export class ZapClient { private proxy: string; private readonly zaproxy; - constructor(proxy?: string, apiKey?: string | null) { - this.proxy = proxy != undefined ? proxy : `http://${process.env.HTTP_PROXY}`; + constructor(proxy?: string | null, apiKey?: string | null) { + this.proxy = proxy ?? PlaywrightConfig.use.proxy.server; this.apiKey = apiKey != undefined ? apiKey : null; this.zaproxy = new ClientApi({ apiKey: this.apiKey, From 73990497c8079ed3c2423f2fdfe9d3a9c9e72fcc Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 15 Feb 2022 13:40:30 +0900 Subject: [PATCH 4/4] =?UTF-8?q?playwright.config=20=E3=81=AE=20proxy=20?= =?UTF-8?q?=E3=82=92=E5=8F=82=E7=85=A7=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e-tests/test/front_login/shopping.test.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/e2e-tests/test/front_login/shopping.test.ts b/e2e-tests/test/front_login/shopping.test.ts index 0a44a2f9a1..e978d1aaa8 100644 --- a/e2e-tests/test/front_login/shopping.test.ts +++ b/e2e-tests/test/front_login/shopping.test.ts @@ -1,5 +1,5 @@ import { test, expect, chromium, Page, request, APIRequestContext } from '@playwright/test'; - +import PlaywrightConfig from '../../../playwright.config'; import { ZapClient, Mode, ContextType } from '../../utils/ZapClient'; const zapClient = new ZapClient(); @@ -18,11 +18,9 @@ test.describe.serial('購入フロー(ログイン)のテストをします', () expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy(); } const browser = await chromium.launch(); - mailcatcher = await request.newContext({ + mailcatcher = await request.newContext({ baseURL: 'http://mailcatcher:1080', - proxy: { - server: process.env.HTTP_PROXY - } + proxy: PlaywrightConfig.use.proxy }); await mailcatcher.delete('/messages');