Skip to content

HTTP Server ignores status code for response #616

Closed

Description

@svettwer

Citrus Version
2.8.0

Expected behavior
Citrus HTTP Server responds with the configured status code.

Actual behavior
Citrus HTTP Server always returns with 200.

Test case sample

public class TestServerStatusCodeIT extends TestNGCitrusTestRunner {

    @Autowired
    private HttpClient httpClient;

    @Autowired
    private HttpServer httpServer;

    @Test
    @CitrusTest
    public void testStatusCode() {
        http(action -> action.client(httpClient)
                    .send()
                    .post());

        http(action -> action.server(httpServer)
                .receive()
                .post());

        http(action -> action.server(httpServer)
                .respond()
                .status(HttpStatus.FORBIDDEN));

        http(action -> action.client(httpClient)
                .receive()
                .response(HttpStatus.FORBIDDEN));

    }
}

This tests fails with the error message:

5:40:30.651 [main] ERROR com.consol.citrus.report.LoggingReporter - TEST FAILED TodoListIT.testGet <com.consol.citrus.samples.todolist> Nested exception is: 
com.consol.citrus.exceptions.TestCaseFailedException: Validation failed: Values not equal for header element 'citrus_http_status_code', expected '403' but was '200'

The test also fails with the following server configurations

http(action -> action.server(httpServer)
                .respond()
                .statusCode(403));
http(action -> action.server(httpServer)
                .respond(HttpStatus.FORBIDDEN))

BR,
Sven

Activity

  1. added
    bug
    on Jan 29, 2019
  2. christophd commented on Mar 7, 2019

    @christophd
    Member

    @svettwer you simply need to add a fork option to the client call otherwise you will always hit the timeout on the server and the default behavior for the timeout is 200 OK

  3. svettwer commented on Mar 7, 2019

    @svettwer
    ContributorAuthor

    Should I have been that blind? 🤦‍♂️

  4. svettwer commented on Mar 7, 2019

    @svettwer
    ContributorAuthor

    Gosh! 😩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugprio-medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions