forked from Contrast-Security-OSS/demo-petclinic
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7582251
commit 1b2440e
Showing
9 changed files
with
327 additions
and
7 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
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,56 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('owners', () => { | ||
test('find owner', async ({ page }) => { | ||
await page.goto('/owners/find'); | ||
await page.locator('input[name="lastName"]').fill('davis'); | ||
|
||
await page.locator('button:has-text("Find Owner")').click(); | ||
await expect(page.locator("text=Betty Davis")).toHaveCount(1) | ||
}) | ||
|
||
test('view owner', async ({ page }) => { | ||
await page.goto('/owners/2'); | ||
await expect(page.locator("text=Betty Davis")).toHaveCount(1) | ||
}) | ||
|
||
test('edit owner', async ({ page }) => { | ||
await page.goto('/owners/2'); | ||
await page.locator('a:has-text("Edit Owner")').click(); | ||
await page.locator('button:has-text("Update Owner")').click(); | ||
await expect(page.locator("text=Betty Davis")).toHaveCount(1) | ||
}) | ||
|
||
test('edit pet', async ({ page }) => { | ||
await page.goto('/owners/2/pets/2/edit'); | ||
await page.locator('button:has-text("Update Pet")').click(); | ||
await expect(page.locator("text=Betty Davis")).toHaveCount(1) | ||
}) | ||
|
||
test('add pet', async ({ page }) => { | ||
await page.goto('/owners/2/pets/new'); | ||
await page.locator('input[name="name"]').fill('Rover'); | ||
await page.locator('input[name="birthDate"]').fill('2001-01-01'); | ||
await page.locator('button:has-text("Add Pet")').click(); | ||
await expect(page.locator("text=Rover")).toHaveCount(1) | ||
}) | ||
|
||
test('add owner', async ({ page }) => { | ||
await page.goto('/owners/new'); | ||
await page.locator('input[name="lastName"]').fill('Doe'); | ||
await page.locator('input[name="firstName"]').fill('Jane'); | ||
await page.locator('input[name="address"]').fill('1 Main Street'); | ||
await page.locator('input[name="city"]').fill('Chicago'); | ||
await page.locator('input[name="telephone"]').fill('555947343'); | ||
await page.locator('button:has-text("Add Owner")').click(); | ||
await expect(page.locator("text=Jane Doe")).toHaveCount(1) | ||
}) | ||
|
||
test('add visit', async ({ page }) => { | ||
await page.goto('/owners/2/pets/2/visits/new'); | ||
await page.locator('input[name="description"]').fill('Vaccination'); | ||
await page.locator('button:has-text("Add Visit")').click(); | ||
await expect(page.locator("text=Vaccination")).toHaveCount(1) | ||
}) | ||
|
||
}); |
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,23 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('attacks', () => { | ||
test('find owner', async ({ page }) => { | ||
await page.goto('/owners/find'); | ||
await page.locator('input[name="lastName"]').fill('\' OR \'1\'=\'1'); | ||
|
||
await page.locator('button:has-text("Find Owner")').click(); | ||
await expect(page.locator("text=George Franklin")).toHaveCount(1) | ||
}) | ||
|
||
test('edit owner', async ({ page }) => { | ||
page.on('dialog', async (dialog) => { | ||
expect(dialog.message()).toEqual('1') | ||
await dialog.accept() | ||
}) | ||
|
||
await page.goto('/owners/2'); | ||
await page.locator('a:has-text("Edit Owner")').click(); | ||
await page.locator('input[name="address"]').fill('<script>alert(1)</script>'); | ||
await page.locator('button:has-text("Update Owner")').click(); | ||
}) | ||
}); |
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,15 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('other', () => { | ||
test('error page', async ({ page }) => { | ||
await page.goto('/oups'); | ||
|
||
await expect(page.locator("text=Something happened...")).toHaveCount(1) | ||
}) | ||
|
||
test('visit home page', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
await expect(page.locator("text=Welcome")).toHaveCount(1) | ||
}) | ||
}); |
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,21 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('vets', () => { | ||
test('view as html', async ({ page }) => { | ||
await page.goto('/vets.html'); | ||
|
||
await expect(page.locator("text=James Carter")).toHaveCount(1) | ||
}) | ||
|
||
test('view as xml', async ({ page }) => { | ||
await page.goto('/vets.xml'); | ||
await expect(page).toHaveURL(/.*vets.xml/); | ||
}) | ||
|
||
test('view as json', async ({ page }) => { | ||
await page.goto('/vets.json'); | ||
await expect(page).toHaveURL(/.*vets.json/); | ||
}) | ||
|
||
|
||
}); |
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,22 @@ | ||
{ | ||
"name": "demo-petclinic", | ||
"version": "1.0.0", | ||
"description": "This sample application is based on https://github.com/Contrast-Security-OSS/spring-petclinic", | ||
"scripts": { | ||
"e2e": "npx playwright test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://[email protected]/Contrast-Security-OSS/demo-petclinic.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/Contrast-Security-OSS/demo-petclinic/issues" | ||
}, | ||
"homepage": "https://github.com/Contrast-Security-OSS/demo-petclinic#readme", | ||
"devDependencies": { | ||
"@playwright/test": "^1.25.2" | ||
} | ||
} |
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,107 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
import { devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
const config: PlaywrightTestConfig = { | ||
testDir: './e2e', | ||
/* Maximum time one test can run for. */ | ||
timeout: 30 * 1000, | ||
expect: { | ||
/** | ||
* Maximum time expect() should wait for the condition to be met. | ||
* For example in `await expect(locator).toHaveText();` | ||
*/ | ||
timeout: 5000 | ||
}, | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ | ||
actionTimeout: 0, | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: process.env.BASEURL || 'http://localhost:8080', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
|
||
// { | ||
// name: 'firefox', | ||
// use: { | ||
// ...devices['Desktop Firefox'], | ||
// }, | ||
// }, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { | ||
// ...devices['Desktop Safari'], | ||
// }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { | ||
// ...devices['Pixel 5'], | ||
// }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { | ||
// ...devices['iPhone 12'], | ||
// }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { | ||
// channel: 'msedge', | ||
// }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { | ||
// channel: 'chrome', | ||
// }, | ||
// }, | ||
], | ||
|
||
/* Folder for test artifacts such as screenshots, videos, traces, etc. */ | ||
// outputDir: 'test-results/', | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// port: 3000, | ||
// }, | ||
}; | ||
|
||
export default config; |