Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    s3ni0r
    @s3ni0r
    i'm trying to understand how cornichon handles redirects following Http response with status 307
    using a normal apache http client we can specify a redirect policy that can be strict which allows redirect only on some http methods and loose to allow redirect on POST method
    s3ni0r
    @s3ni0r
    in Cornichon i see two HttpClient implementations, one for Akka and the other for Http4s, so my questions are :
    which one is used by default? and is it possible to specify a redirect policy for POST requests on either of these two implementations?
    s3ni0r
    @s3ni0r
    for instance standalone play-ws has a config property for that
    play {
    
      # Configuration for Play WS
      ws {
    
        timeout {
    
          # If non null, the connection timeout, this is how long to wait for a TCP connection to be made
          connection = 2 minutes
    
          # If non null, the idle timeout, this is how long to wait for any IO activity from the remote host
          # while making a request
          idle = 2 minutes
    
          # If non null, the request timeout, this is the maximum amount of time to wait for the whole request
          request = 2 minutes
        }
    
        # Whether redirects should be followed
        followRedirects = true
    
        # Whether the JDK proxy properties should be read
        useProxyProperties = true
    s3ni0r
    @s3ni0r
    Finally it was an issue with Keycloak gatekeeper expecting an encrypted token, the log of gatekeeper was not explicit and kept telling me that the session header was not found in the request, it has nothing to do with cornichon. Thanks!
    Arnaud Gourlay
    @agourlay
    @s3ni0r thank you for the kind words :)
    I am glad you were able to figure out your issue, do you think Cornichon could have made it easier for you to find the root cause?
    Also there is only a single client implementation since a couple of versions which is the http4s one.
    TBH I don't know what the default behaviour is for redirect but in any case I guess we could make it configurable in the future if necessary.
    s3ni0r
    @s3ni0r
    No i don't think Cornichon would have helped with the issue i was facing, and i think we are using an older version of Cornichon that still have two HttpClient implementation, i will upgarde it :).
    s3ni0r
    @s3ni0r

    From : https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
    10.3.8 307 Temporary Redirect
    The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

    The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI.

    If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

    s3ni0r
    @s3ni0r
    @agourlay so yeah, in order to be aligned with the specs, the redirect over post methods should not be implicit but user defined via configuration or code
    here is a post explaining it using Apache httpClient https://www.baeldung.com/httpclient-redirect-on-http-post
    Arnaud Gourlay
    @agourlay
    Thank you for the follow up.
    Just did a quick investigation and I could not find a redirect configuration on the http4s client.
    I recommend that you upgrade to the latest version of cornichon in order document the behaviour again :)
    s3ni0r
    @s3ni0r
    Yeah i finally managed to upgrade to latest 19.0 version, it's all good, thanks a lot again for this awesome library.
    Gabriel Francisco
    @gabfssilva

    @agourlay, sorry for the delay.

    first of all, thanks for all this effort, this library is amazing!

    answering about my concern about deprecating scalatest: how is running the tests inside the IDE going to work from now on? besides that, what about other scalatest goodies?

    Arnaud Gourlay
    @agourlay
    @s3ni0r Happy to hear that. Do not hesitate to create an issue regarding HTTP redirect if you think the library is not doing a good job there.

    @gabfssilva No worries for the delay :)
    Regarding the deprecation of Scalatest and the lost goodies and I can only see:

    • running the tests in the IDE
    • having an HTML report

    Those two things are not something that my team and I are using so it will have to be contributed by the community I guess.
    Do see other goodies missing?
    How unhappy are you about this answer?

    s3ni0r
    @s3ni0r
    @agourlay i don't have the HTTP redirect issue anymore, and it was not related to Cornichon, and regarding @gabfssilva remarks on scalatest and IDE integration, it's true that my team also use the Intellij scalatest integration to run integration tests locally, but it does not bother me as i use sbt instead.
    what i'm facing now as a challenge is to run all integration test in gitlab-ci against neo4j and some Rest Api service, i'm trying to use testcontainers-scala to spin up these two services, but i can't figure out how to integrate it with cornichon to spin them once for all Features and Scenarios.
    s3ni0r
    @s3ni0r
    well, i think i'll have to use this sbt configuration combined with docker/compose image to handle docker instances creation and cleanup in gitlabci
    testOptions in IntegrationTest += Tests.Setup { () => ??? }
    testOptions in IntegrationTest += Tests.Cleanup { () => ?? }
    Arnaud Gourlay
    @agourlay
    I usually recommend separating setting up the env. from running the tests.
    In my build pipeline at work, we have different steps like
    1- setup env. (bash script, docker whatever)
    2- run tests
    3- shutdown env.
    In the future I'd like to offer a global hook for BeforeAllTheThings and this will be easier to do using cornichon-test-framework over the scalatest flavor.
    Something similar to agourlay/cornichon#71 so that one could setup things in the Session in one place.
    For the time being I am afraid you are stuck with the SBT trick you described.
    Or you put all your scenarios in a single feature and use BeforeFeature.
    s3ni0r
    @s3ni0r
    @agourlay Yep, and yeah a BeforeAllTheThings global hook would be a great addition to Cornichon.
    Arnaud Gourlay
    @agourlay
    FYI I finally took the time to look at the HTTP redirect feature.
    As http4s supports it I decided to add it quickly.
    https://github.com/agourlay/cornichon/commit/07ed909bfbf9a852be0f6ff0c92ffd18fe18d535#diff-8a1e382d78e038c177490bbf2922a02aR65
    The next release will ship a new configuration knob called followRedirect which is false by default.
    I used arbitrarily 10 as maxRedirects
    s3ni0r
    @s3ni0r
    @agourlay nice work! Thanks a lot again!
    Arnaud Gourlay
    @agourlay
    Srepfler Srdan
    @schrepfler
    👏👏👏
    s3ni0r
    @s3ni0r
    Hello,
    @agourlay, i would like to discuss an annoying problem i'm facing with transitive dependencies in cornichon 1.19.0
    we are using sangria version 1.4.2, and i've noticed that version 2.0.0-M3 is being pulled and chosen over the 1.4.2 due to cornichon
    in Ivy and Coursier, the default dependency conflict resolver choses the latest version and i was forced to use dependencyOverride to use the wanted sangria version
    we don't have a problem with using the latest version of a transitive dependency, but it need to be a stable one (not an M or RC)
    s3ni0r
    @s3ni0r
    how do you manage that in your production?
    Arnaud Gourlay
    @agourlay
    @s3ni0r the way I fix this is by having the cornichon tests and the production code not sharing their classpath. A.k.a different projects.
    Sangria 2.0.0 was released yesterday, you could try to upgrade your application as well.
    I can also plan a release of 0.19.1 soon as it would ship the dependency update agourlay/cornichon@81eebe7
    s3ni0r
    @s3ni0r
    @agourlay i see, thanks!
    Arnaud Gourlay
    @agourlay
    @s3ni0r this release ships with a stable version of Sangria :point_up:
    s3ni0r
    @s3ni0r
    Great 🥳, thanks!
    Arnaud Gourlay
    @agourlay
    0.19.3 is out with important bug fixes :fire_engine:
    https://github.com/agourlay/cornichon/releases/tag/v0.19.3
    Peter Gerhard
    @peter-gerhard
    Hey, I wanted to set up for contribution: the link to the instructions to build the documentation locally is broken https://github.com/agourlay/cornichon/blob/master/CONTRIBUTING.md
    Arnaud Gourlay
    @agourlay
    @peter-gerhard Good catch :thumbsup:
    I fixed here agourlay/cornichon@8541ad1
    Peter Gerhard
    @peter-gerhard
    This message was deleted
    Arnaud Gourlay
    @agourlay
    0.19.4 is out with new assertions to validate changes in session :tada:
    https://github.com/agourlay/cornichon/releases/tag/v0.19.4
    sahil anand
    @anandsahil
    Hi, I am struggling to find a way to save text/plan body in the session, it always error's out. Is there a way to do it ?
    Arnaud Gourlay
    @agourlay

    @anandsahil this is a bug in the httpDsl which wrongly expects a JSON body in that case.
    In the meantime you could hack the internals using

    And I get("/foo/bar")
    Then I save(s"<${HttpService.lastResponseBodyKey}>" -> "my-plain-text-body" )

    Can you please open a ticket so I do not forget to fix it :)

    sahil anand
    @anandsahil
    yes, I will open a ticket and try to solve it also :-).
    Arnaud Gourlay
    @agourlay
    @anandsahil I found the bug and the fix is rather straight forward (given my knowledge of the internals).
    So either I push my fix or you try to solve it yourself as a learning exercise. :smile:
    Arnaud Gourlay
    @agourlay
    FYI I am trying again to support more than JSON in cornichon.
    I think I finally found an encoding that seems to work without destroying the current DSL.
    Do not hesitate to share ideas, feedback and wishes :grinning:
    agourlay/cornichon#422
    Arnaud Gourlay
    @agourlay
    0.19.5 is out with bug fixes, performance improvements and increased support for non JSON payload :tada:
    https://github.com/agourlay/cornichon/releases/tag/v0.19.5
    Srepfler Srdan
    @schrepfler
    👏👏👏