Skip to content

Commit

Permalink
Log redaction
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Hoops <9974641+jfelixh@users.noreply.github.com>
  • Loading branch information
jfelixh committed Jun 12, 2024
1 parent 70d5a38 commit b1de0cc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 23 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Playwright Tests
on:
push:
branches: [main, master]
branches: ["main"]
pull_request:
branches: [main, master]
branches: ["main"]
jobs:
test:
timeout-minutes: 60
Expand All @@ -22,9 +22,3 @@ jobs:
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npm run test:e2e
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
2 changes: 0 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
hydra-migrate:
image: oryd/hydra:v2.2.0
Expand Down
8 changes: 5 additions & 3 deletions vclogin/__tests__/e2e/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ test.describe("Login Page", () => {

await expect(
page.getByRole("heading", { name: "SSI-to-OIDC Bridge" }),
).toBeVisible();
).toBeVisible({ timeout: 15000 });
});

test("has CTA", async ({ page }) => {
await page.goto(url + "/login?login_challenge=challenge123");

await expect(page.getByRole("heading", { name: /Scan/i })).toBeVisible();
await expect(page.getByRole("heading", { name: /Scan/i })).toBeVisible({
timeout: 15000,
});
});

test("has QR Code", async ({ page }) => {
await page.goto(url + "/login?login_challenge=challenge123");

await expect(page.locator("canvas")).toBeVisible();
await expect(page.locator("canvas")).toBeVisible({ timeout: 15000 });
});
});
1 change: 1 addition & 0 deletions vclogin/config/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import pino from "pino";

export const logger = pino({
level: process.env.NODE_ENV === "production" ? "info" : "debug",
redact: ["req.query.*", "res.headers.*"],
});
20 changes: 19 additions & 1 deletion vclogin/middleware/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@

import { logger } from "@/config/logger";
import { NextApiRequest, NextApiResponse } from "next";
import pino from "pino";
import { pinoHttp } from "pino-http";

const loggerHttp = pinoHttp({ logger: logger });
const loggerHttp = pinoHttp({
logger: logger,
serializers: {
req: pino.stdSerializers.wrapRequestSerializer((r) => {
return {
id: r.id,
method: r.method,
url: r.url.split("?")[0],
query: r.query,
headers: {
host: r.raw.headers.host,
"user-agent": r.raw.headers["user-agent"],
referer: r.raw.headers.referer,
},
};
}),
},
});

export const withLogging = (
handler: (a: NextApiRequest, b: NextApiResponse) => Promise<void>,
Expand Down
2 changes: 1 addition & 1 deletion vclogin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "NODE_OPTIONS='-r next-logger' next start",
"lint": "next lint",
"test": "jest --coverage",
"test:e2e": "npx playwright test --project='chromium'"
"test:e2e": "npx playwright test"
},
"dependencies": {
"@material-tailwind/react": "^2.0.3",
Expand Down
16 changes: 8 additions & 8 deletions vclogin/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export default defineConfig({
use: { ...devices["Desktop Chrome"] },
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
//{
// name: "firefox",
// use: { ...devices["Desktop Firefox"] },
//},

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
//{
// name: "webkit",
// use: { ...devices["Desktop Safari"] },
//},

/* Test against mobile viewports. */
// {
Expand Down

0 comments on commit b1de0cc

Please sign in to comment.