Giter Club home page Giter Club logo

cascade's People

Contributors

robindevilliers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cascade's Issues

How to supply dynamic information

We can provide static information to subsequent steps with @Supplies, like username and password. I wonder is it possible to share dynamic information.

I have an application that returns a random string as CSRF-TOKEN, it is generated by the server side and differs every login. For every subsequent API call, I need to place the token to the header.

@Step
class LoginAsPpManager {

    @Supplies
    def username = "john.doe"

    @Supplies
    def password = "123456"

    ValidatableResponse response

    @When
    void "login"() {
        // @formatter:off
        response = given()
            .parameter("username", username)
            .parameter("password", password)
        .when()
            .post("/login")
        .then()
        // @formatter:on
    }

    @Then
    void "as a user has XXX role"() {
        this.response.statusCode(OK.value())
        def res = response.extract()
        csrfToken = res.cookie("XSRF-TOKEN") // get the token and try to share it to subsequent steps
    }
}

@Step(LoginAsPpManager)
class PlaceOrder {

    ValidatableResponse response

    @Demands
    String csrfToken // get null

    @When
    void "create a motivation"() {
        // @formatter:off
        response = given()
            .header("X-CSRF-TOKEN", csrfToken) // throw NPE
            .body(xxx)
        .when()
            .post("/api/orders")
        .then()
        // @formatter:on

    }

Currently, I have to login in every subsequent step, but the code is boring and it takes extra time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.