Uploading a file with Blackfire Player
Let’s have a look at a use case on the file upload capacities of Blackfire Player. We’ll see how to check security dependencies by uploading a composer.lock file to security.sensiolabs.org
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,