StydeNet / enlighten

Enlighten your APIs with auto-generated documentation
MIT License
575 stars 32 forks source link

followingRedirect can not record first reponse #35

Closed smartymoon closed 4 years ago

smartymoon commented 4 years ago

Describe the bug

i want to record redirect request after 302. there are an exception happend.

$this->actingAs($this->user)->followingRedirects()->put('reset_password', [
            'XDEBUG_SESSION_START' => 19226,
            'origin_password' => '654321',
            'password_confirmation' => '123456',
            'password' => '123456'
        ]);

making some change in HttpExampleCreatorMiddleware

 public function terminate($request, $response)
    {
        if ($response instanceof TestResponse) {
            $response = $response->baseResponse;
        }
        $this->httpExampleCreator->saveHttpResponseData($request, $response);
    }

i got that

Error : Call to a member function update() on null
 /Users/lee/Code/Sites/support/trump/vendor/styde/enlighten/src/TestExample.php:132

after three 3 hours study of code and watching 2020 US election

I give up

To Reproduce make a 302 request in test and add followingRedirects method

Expected behavior record two reqest completly

Screenshots 截屏2020-11-04 下午5 34 15

Additional context I love this package

sileence commented 4 years ago

@smartymoon hello! I have no tried Enlighten with the following redirect option, I'll do that as soon as I can and will let you know how it goes and if I can reproduce & fix the issue.

sileence commented 4 years ago

@smartymoon the fix is already in dev and will be deployed soon. Thanks for reporting the issue :)

sileence commented 4 years ago

@smartymoon deployed in 0.4.

smartymoon commented 4 years ago

@sileence It is me who should say thank you. thank you for this package, thank you for fix this. this package help me a lot

sileence commented 4 years ago

You’re welcome, @XinBa

Is this behavior ok? I was just thinking I should follow all the redirects but show only the first request and the last response. What do you think?

On Fri, 6 Nov 2020 at 09:16, XinBa notifications@github.com wrote:

@sileence https://github.com/sileence It is me who should say thank you. thank you for this package, thank you for fix this. this package help me a lot

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/StydeNet/enlighten/issues/35#issuecomment-722969920, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZ7WVHMGELVSSONAW3VOLSOO5GNANCNFSM4TJ2ARWA .

sileence commented 4 years ago

@smartymoon we just pushed a new patch release (0.4.1) it improves this behaviour by saving all the requests with their corresponding responses

request 1 -> response 1 request 2 -> response 2 request 3 -> response 3

From 0.5.0 you'll be able to see if a request/response is following the redirect from a previous request/response.

smartymoon commented 4 years ago

@sileence I have try dev branch, it works, thank you

sileence commented 4 years ago

@smartymoon great! you can also start using ^0.4 if you want :)