-
-
Save Taluu/843e9f424656e0b114f6 to your computer and use it in GitHub Desktop.
behat + travis + basic auth
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
default: | |
context: | |
class : 'features\bootstrap\Context\FeatureContext' | |
parameters: | |
stop_on_failure : false | |
reset_database : false | |
environment : prod | |
debug : false | |
extensions: | |
Behat\MinkExtension\Extension: | |
base_url : 'http://localhost/' | |
sahi: ~ | |
goutte : | |
guzzle_parameters : | |
redirect.disable : true | |
curl.options : | |
CURLOPT_CONNECTTIMEOUT : 0 | |
CURLOPT_TIMEOUT : 900 | |
default_session: goutte | |
javascript_session: sahi | |
browser_name: phantomjs | |
test: | |
context: | |
parameters: | |
stop_on_failure : true | |
reset_database : true | |
environment : test | |
debug : false | |
extensions: | |
Behat\MinkExtension\Extension: | |
base_url : 'http://localhost/app_test.php' | |
dev: | |
context: | |
parameters: | |
reset_database : true | |
environment : dev | |
debug : true | |
extensions: | |
Behat\MinkExtension\Extension: | |
base_url : 'http://localhost/app_dev.php' |
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
default: | |
context: | |
class : 'features\bootstrap\Context\FeatureContext' | |
parameters: | |
stop_on_failure : false | |
reset_database : false | |
environment : prod | |
debug : false | |
extensions: | |
Behat\MinkExtension\Extension: | |
base_url : 'http://localhost/' | |
sahi: ~ | |
goutte : | |
guzzle_parameters : | |
redirect.disable : true | |
curl.options : | |
CURLOPT_CONNECTTIMEOUT : 0 | |
CURLOPT_TIMEOUT : 900 | |
default_session: goutte | |
javascript_session: sahi | |
browser_name: phantomjs | |
travis: | |
context: | |
parameters: | |
stop_on_failure : false | |
reset_database : true | |
environment : test | |
debug : true |
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
Feature: Test things | |
Scenario: Test fucking basic auth | |
Given I am authentified via basic auth with "user@wisembly.com" and "pass" | |
When I go to "/api/3/authentication/whoami" | |
Then print last response |
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 extends BehatContext | |
{ | |
const LOG_NONE = 0; | |
const LOG_TOKEN = 1; | |
const LOG_BASICAUTH = 2; | |
private $token = null; | |
private $method = self::LOG_NONE; // either token, either basic | |
/** | |
* Identifies the user via Basic Authentification mechanism | |
* | |
* @Given /^(?:I )?am authentified via basic auth with "(?P<username>(?:[^"]|\\")+)" and "(?P<password>(?:[^"]|\\")+)"$/ | |
* @When /^(?:I )?am authentificating via basic auth with "(?P<username>(?:[^"]|\\")+)" and "(?P<password>(?:[^"]|\\")+)"$/ | |
* | |
* @param string $user Username | |
* @param string $password Password | |
*/ | |
public function iAmAuthentifiedViaBasicAuthWithAnd($user, $password) | |
{ | |
$this->getMainContext()->getSession()->setBasicAuth($user, $password); | |
$this->method = self::LOG_BASICAUTH; | |
} | |
} |
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
{ | |
"expected": {"success":{"data":{"id":1,"name":"User_firstname User_lastname","avatar":null}}}, | |
"local" : {"success":{"data":{"id":1,"name":"User_firstname User_lastname","avatar":null}}}, | |
"travis" : {"success":{"data":[]}} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment