mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 01:38:14 -04:00
test(playwright): Add Docker and Podman support (#433)
* test(playwright): Add support to run tests in Docker/Podman * fix command name Co-authored-by: Xe Iaso <me@xeiaso.net> Signed-off-by: Henri Vasserman <henv@hot.ee> * up the pw version as it is in package.json * add convenience npm scripts * chore: changelog update Also removed a period from my other item. * chore: fix spelling Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Henri Vasserman <henv@hot.ee> Signed-off-by: Xe Iaso <me@xeiaso.net> Co-authored-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
092b80ba55
commit
22ada6251f
5
.github/actions/spelling/expect.txt
vendored
5
.github/actions/spelling/expect.txt
vendored
@ -117,6 +117,7 @@ loadbalancer
|
||||
lol
|
||||
maintainership
|
||||
malware
|
||||
mcr
|
||||
memes
|
||||
mimi
|
||||
minica
|
||||
@ -141,10 +142,13 @@ pids
|
||||
pipefail
|
||||
pki
|
||||
podkova
|
||||
podman
|
||||
prebaked
|
||||
privkey
|
||||
promauto
|
||||
promhttp
|
||||
pwcmd
|
||||
pwuser
|
||||
qwant
|
||||
qwantbot
|
||||
rac
|
||||
@ -196,6 +200,7 @@ webpage
|
||||
websecure
|
||||
websites
|
||||
workaround
|
||||
workdir
|
||||
xcaddy
|
||||
Xeact
|
||||
xeiaso
|
||||
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Add `check-spelling` for spell checking
|
||||
- Add `--target-insecure-skip-verify` flag/envvar to allow Anubis to hit a self-signed HTTPS backend.
|
||||
- Minor adjustments to FreeBSD rc.d script to allow for more flexible configuration.
|
||||
- Added Podman and Docker support for running Playwright tests
|
||||
|
||||
## v1.18.0: Varis zos Galvus
|
||||
|
||||
@ -69,7 +70,7 @@ Other changes:
|
||||
- Use CSS variables to deduplicate styles
|
||||
- Fixed native packages not containing the stdlib and botPolicies.yaml
|
||||
- Change import syntax to allow multi-level imports
|
||||
- Changed the startup logging to use JSON formatting as all the other logs do.
|
||||
- Changed the startup logging to use JSON formatting as all the other logs do
|
||||
- Added the ability to do [expression matching with CEL](./admin/configuration/expressions.mdx)
|
||||
- Add a warning for clients that don't store cookies
|
||||
- Disable Open Graph passthrough by default ([#435](https://github.com/TecharoHQ/anubis/issues/435))
|
||||
|
@ -38,6 +38,7 @@ var (
|
||||
playwrightServer = flag.String("playwright", "ws://localhost:9001", "Playwright server URL")
|
||||
playwrightMaxTime = flag.Duration("playwright-max-time", 5*time.Second, "maximum time for Playwright requests")
|
||||
playwrightMaxHardTime = flag.Duration("playwright-max-hard-time", 5*time.Minute, "maximum time for hard Playwright requests")
|
||||
playwrightRunner = flag.String("playwright-runner", "npx", "how to start Playwright, can be: none,npx,docker,podman")
|
||||
|
||||
testCases = []testCase{
|
||||
{
|
||||
@ -98,7 +99,7 @@ const (
|
||||
actionChallenge action = "CHALLENGE"
|
||||
|
||||
placeholderIP = "fd11:5ee:bad:c0de::"
|
||||
playwrightVersion = "1.51.1"
|
||||
playwrightVersion = "1.52.0"
|
||||
)
|
||||
|
||||
type action string
|
||||
@ -111,11 +112,11 @@ type testCase struct {
|
||||
isHard bool
|
||||
}
|
||||
|
||||
func doesNPXExist(t *testing.T) {
|
||||
func doesCommandExist(t *testing.T, command string) {
|
||||
t.Helper()
|
||||
|
||||
if _, err := exec.LookPath("npx"); err != nil {
|
||||
t.Skipf("npx not found in PATH, skipping integration smoke testing: %v", err)
|
||||
if _, err := exec.LookPath(command); err != nil {
|
||||
t.Skipf("%s not found in PATH, skipping integration smoke testing: %v", command, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,13 +171,30 @@ func daemonize(t *testing.T, command string) {
|
||||
func startPlaywright(t *testing.T) {
|
||||
t.Helper()
|
||||
|
||||
if os.Getenv("CI") == "true" {
|
||||
run(t, fmt.Sprintf("npx --yes playwright@%s install --with-deps", playwrightVersion))
|
||||
} else {
|
||||
run(t, fmt.Sprintf("npx --yes playwright@%s install", playwrightVersion))
|
||||
}
|
||||
if *playwrightRunner == "npx" {
|
||||
doesCommandExist(t, "npx")
|
||||
|
||||
daemonize(t, fmt.Sprintf("npx --yes playwright@%s run-server --port %d", playwrightVersion, *playwrightPort))
|
||||
if os.Getenv("CI") == "true" {
|
||||
run(t, fmt.Sprintf("npx --yes playwright@%s install --with-deps", playwrightVersion))
|
||||
} else {
|
||||
run(t, fmt.Sprintf("npx --yes playwright@%s install", playwrightVersion))
|
||||
}
|
||||
|
||||
daemonize(t, fmt.Sprintf("npx --yes playwright@%s run-server --port %d", playwrightVersion, *playwrightPort))
|
||||
} else if *playwrightRunner == "docker" || *playwrightRunner == "podman" {
|
||||
doesCommandExist(t, *playwrightRunner)
|
||||
|
||||
// docs: https://playwright.dev/docs/docker
|
||||
pwcmd := fmt.Sprintf("npx -y playwright@%s run-server --port %d --host 0.0.0.0", playwrightVersion, *playwrightPort)
|
||||
container := run(t, fmt.Sprintf("%s run -d --ipc=host --user pwuser --workdir /home/pwuser --net=host mcr.microsoft.com/playwright:v%s-noble /bin/sh -c \"%s\"", *playwrightRunner, playwrightVersion, pwcmd))
|
||||
t.Cleanup(func() {
|
||||
run(t, fmt.Sprintf("%s rm --force %s", *playwrightRunner, container))
|
||||
})
|
||||
} else if *playwrightRunner == "none" {
|
||||
t.Log("not starting Playwright, assuming it is already running")
|
||||
} else {
|
||||
t.Skipf("unknown runner: %s, skipping", *playwrightRunner)
|
||||
}
|
||||
|
||||
for {
|
||||
if _, err := http.Get(fmt.Sprintf("http://localhost:%d", *playwrightPort)); err != nil {
|
||||
@ -196,7 +214,6 @@ func TestPlaywrightBrowser(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
doesNPXExist(t)
|
||||
startPlaywright(t)
|
||||
|
||||
pw := setupPlaywright(t)
|
||||
@ -274,7 +291,6 @@ func TestPlaywrightWithBasePrefix(t *testing.T) {
|
||||
|
||||
t.Skip("NOTE(Xe)\\ these tests require HTTPS support in #364")
|
||||
|
||||
doesNPXExist(t)
|
||||
startPlaywright(t)
|
||||
|
||||
pw := setupPlaywright(t)
|
||||
|
@ -6,6 +6,8 @@
|
||||
"scripts": {
|
||||
"test": "npm run assets && go test ./...",
|
||||
"test:integration": "npm run assets && go test -v ./internal/test",
|
||||
"test:integration:podman": "npm run assets && go test -v ./internal/test --playwright-runner=podman",
|
||||
"test:integration:docker": "npm run assets && go test -v ./internal/test --playwright-runner=docker",
|
||||
"assets": "go generate ./... && ./web/build.sh && ./xess/build.sh",
|
||||
"build": "npm run assets && go build -o ./var/anubis ./cmd/anubis",
|
||||
"dev": "npm run assets && go run ./cmd/anubis --use-remote-address",
|
||||
|
Loading…
x
Reference in New Issue
Block a user