Last active
December 10, 2015 22:38
-
-
Save Taluu/4504025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} | |
//... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Try to post a wrong role | |
Given I have a token with these identifiers : | |
| email | secret | app_id | hash | | |
| [email protected] | 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":"[email protected]", "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