Uploading a file with Blackfire Player

By Grégoire Pineau, on Apr 11, 2017

In January, we released the new version of the Blackfire Player. Blackfire Player is a powerful Web Crawling, Web Testing, and Web Scraper application. It provides a nice DSL to crawl HTTP services, assert responses, and extract data from HTML/XML/JSON responses. This blog series gives concrete examples of how the Player features can be used. View other posts:

Blackfire Player integrates with Blackfire in order to automate performance testing, but it can cover a lot more use cases not related to performance management.

Let’s have a look at a use case where we want to upload a file to a remote server.

You might already know security.sensiolabs.org, a website that checks for known vulnerabilities in your project dependencies, thanks to the information stored in composer.lock.

Let’s create a project with a composer.lock which includes some known security issues, and a composer.lock which has no known security issues. The following DSL will simply upload the lock files to security.sensiolabs.org, and check whether the HTTP response contains information about known security issues.

endpoint https://security.sensiolabs.org

scenario
    name "Without security issues"

    visit "/check"

    submit button("Check")
        param lock file('composer.no-issue.lock')

        expect status_code() == 200
        expect css('div.alert.alert-success').text() matches '/Great!/'

scenario
    name "With security issues"

    visit "/check"

    submit button("Check")
        param lock file('composer.with-issue.lock')

        expect status_code() == 200
        expect css('div.alert.alert-error').text() matches '/Caution/'

Try it with you own composer.lock file! Go ahead, install the Blackfire Player, and copy/paste the snippet above in your own .bkf file!

Happy performance testing and scenario playing,

Grégoire Pineau

Grégoire worked as a (Symfony-certified!) developer at Blackfire.io. He's also involved in Symfony development and several other Open Source projects, and is the Swiss Army Knife of DevOps. It would only be him, most of the projects he worked on would be named after savanna animals.