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

RestEasy returns status code 200 instead of 307 when using Response.temporaryRedirect during test #16070

Closed
s0l0c0ding opened this issue Mar 27, 2021 · 2 comments
Labels
kind/bug Something isn't working triage/invalid This doesn't seem right triage/needs-triage

Comments

@s0l0c0ding
Copy link

Describe the bug

RestEasy returns status code 200 instead of 307 when verifying the Response.temporaryRedirect with RestAssured

Expected behavior

status code 307 should be returned

Actual behavior

a 200 status code is returned

To Reproduce

run the test GreetingResourceTest

in this repo https://github.com/s0l0c0ding/bug-resteasy-restassured

Steps to reproduce the behavior:

  1. controller with endpoint using Response.temporaryRedirect
  2. write a test with restAssured
  3. test will not pass when the expected code is 307

Configuration

no special configuration

Screenshots

(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

Output of uname -a or ver

Linux pc 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

GraalVM version (if different from Java)

Quarkus version or git rev

1.12.2.Final

Build tool

mvn

Additional context

a correct response is given when trying with browser

@s0l0c0ding s0l0c0ding added the kind/bug Something isn't working label Mar 27, 2021
@geoand
Copy link
Contributor

geoand commented Mar 29, 2021

There is no bug in either RESTEasy or RestAssured, it's just how RestAssured behaves - it follows redirects by default.

You can update your test method to

    @Test
    public void testHelloEndpoint() {
        given()
          .config(config().redirect(redirectConfig().followRedirects(false)))
          .when().get("/hello-resteasy")
          .then()
             .statusCode(307);
    }

if you don't want to follow redirects

@geoand geoand closed this as completed Mar 29, 2021
@geoand geoand added the triage/invalid This doesn't seem right label Mar 29, 2021
@s0l0c0ding
Copy link
Author

thanks for the hint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/invalid This doesn't seem right triage/needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants