Skip to content

Instantly share code, notes, and snippets.

@Taluu
Last active December 10, 2015 22:38
Show Gist options
  • Save Taluu/4504025 to your computer and use it in GitHub Desktop.
Save Taluu/4504025 to your computer and use it in GitHub Desktop.
<?php
class ApiContext
{
//...
/**
* Sends a request with a body and token
* This function is used to pass an array in the JSON. If your data is only simple values, prefer sendRequestWithTokenAndValues
*
* @Given /^I sent a post request (?:on|to) "(?P<url>(?:[^"]|\\")*)" with my token and this body :$/
* @When /^I send a post request (?:on|to) "(?P<url>(?:[^"]|\\")*)" with my token and this body :$/
*
* @param string $method a valid HTTP method
* @param string $url URL to send the request
* @param string|PyStringNode Content to send
*/
public function sendRequestWithTokenAndBody($method, $url,$body) {
$this->getMainContext()->sendRequestWithBody($method, $this->getToken($url), $body); // getToken, ou je sais plus ce que c'est
}
//...
}
Scenario: Try to post a wrong role
Given I have a token with these identifiers :
| email | secret | app_id | hash |
| user@wisembly.com | pass | my_aid_test | 9bac74d1a36021be7eb9246e3c4976879b571ba2 |
When I send a post request on "/api/3/event/behatOther/invitations" with my token and this body :
"""
{"emails":[{"email":"remy@wisembly.com", "role":"66"}]}
"""
Then the JSON key "error[code]" should be equal to "wrong_rigths"
And the response status code should be 403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment