pestphp / pestphp/pest

[Bug]: Browser Plugin: Randomized port breaks callbacks

Open
#1,670 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
11.7k
Forks
538
Avg merge
4d 11h
Merged PRs (30d)
8

Description

What Happened

I have a laravel app that has integrations with Keycloak and Stripe. These both use APP_URL in their config, and I don't have much leeway to change this (how the config is set);

APP_URL=http://localhost:8000

# ...

KEYCLOAK_REDIRECT_URI="${APP_URL}/login/callback"

Such values are resolved to http://localhost:8000 during tests, but when the browser testing occurs, the url for the site is http://127.0.0.1:{random port}. This breaks integrations as the url is obviously wrong.

What's more, my stripe development container is configured to use localhost:8000 for webhooks, and can't easily adapt to different ports.

Given the stripe container itself is given a specific callback, it needs a consistent host/port.

AFAICT, there isn't an easy way to resolve this... I just need to make sure the resulting server run by pest has a consistent port, ideally 8000. I would also accept needing to run php artisan serve myself as a prereq, though obviously less ideal

I realize that this will preempt the capability of parallel testing, but I need tests at all to run, which I can't do if the callbacks are broken.

I also have found that I can enforce the visit() method to go to an instance I stand up, but this is less ideal as it looses the test integrations (specific test db, etc).

How to Reproduce

Laravel app using Checkout/Stripe, trying to use Stripe, specifically webhooks

Sample Repository

No response

Pest Version

4.7.2

PHP Version

8.3

Operation System

Linux

Notes

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the browser plugin's server startup and port allocation behavior, then reproduce the issue in a Laravel app using Pest 4.7.2, PHP 8.3, and Stripe webhooks. Done means browser tests can use a consistent host and port for callbacks while retaining Pest's test integrations, with the parallel-testing limitation addressed or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.