Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact-PHP <=9.x.x - setRequestFilter doesn't seem to append anything to the request #196

Open
mattias-persson opened this issue Apr 26, 2021 · 6 comments

Comments

@mattias-persson
Copy link

Trying the setRequestFilter feature but it doesn't append any headers in the request. My test looks just like the example in the documentation:

/** @test */
public function remarketed_orders()
{
    $config = new VerifierConfig();
    $config
        ->setProviderName('my-provider') // Providers name to fetch.
        ->setProviderVersion('1.0.0') // Providers version.
        ->setProviderBaseUrl(new Uri('my-url')) // URL of the Provider.
        ->setBrokerUri(new Uri('my-broker-uri')) // URL of the Pact Broker to publish results.
        ->setBrokerToken('my-token')
        ->setPublishResults(false) // Flag the verifier service to publish the results to the Pact Broker.
        ->setEnablePending(true) // Flag to enable pending pacts feature (check pact docs for further info)
        ->setIncludeWipPactSince('2020-01-30') //Start date of WIP Pacts (check pact docs for further info)
        ->setRequestFilter(
            function (RequestInterface $r) {
                return $r->withHeader('MY_SPECIAL_HEADER', 'my special value');
            }
        );

    // Verify that all consumers of 'someProvider' are valid.
    $verifier = new Verifier($config);
    $verifier->verify('my-consumer');

    // This will not be reached if the PACT verifier throws an error, otherwise it was successful.
    $this->assertTrue(true, 'Pact Verification has failed.');
}

I've been digging around the code a bit and can't see that the verify method actually adds any request filters. I've also tried the verify method and I've tried using withAddedHeader instead of withHeader. Nothing seems to work.

@siad007 I saw that you built the feature initially, maybe you have any clues?

@siad007
Copy link
Contributor

siad007 commented Apr 26, 2021

@mattias-persson I will have a look ASAP - hopefully today in the evening!

@siad007
Copy link
Contributor

siad007 commented Apr 26, 2021

@mattias-persson after some investigation on your problem, it seems related to the guzzle dependency.
I just found a very similar issue on their bug tracker here
pact-php does not make any magic here, just pass the callback to the guzzle handler stack. Will also have a look in the guzzle code, if I have some more time in the next days.

@mattias-persson
Copy link
Author

@siad007 Appreciate it!

@ALTELMA
Copy link

ALTELMA commented Mar 21, 2022

Any updates on this issue? I facing the same problem on this.

@cfmack
Copy link
Collaborator

cfmack commented Mar 21, 2022

@ALTELMA , as said007 mentioned, it's a Guzzle bug. If you want to explore updating the Guzzle versions to see if it helps your issue, we accept pull requests.

@ALTELMA
Copy link

ALTELMA commented Mar 21, 2022

@cfmack Thanks for a quick reply. That's means requestFilter never work anymore, right? In my opinion should remove from an example.

@YOU54F YOU54F changed the title setRequestFilter doesn't seem to append anything to the request Pact-PHP <=9.x.x : setRequestFilter doesn't seem to append anything to the request May 16, 2024
@YOU54F YOU54F changed the title Pact-PHP <=9.x.x : setRequestFilter doesn't seem to append anything to the request Pact-PHP <=9.x.x - setRequestFilter doesn't seem to append anything to the request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants