Skip to content

Commit

Permalink
Merge pull request #4 from stem/master
Browse files Browse the repository at this point in the history
Utilisation de behat 3
  • Loading branch information
albanv committed Oct 29, 2014
2 parents 48339d8 + b3cd002 commit 717ca41
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 37 deletions.
20 changes: 10 additions & 10 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#behat.yml
# behat.yml
default:
formatter:
name: progress
parameters:
decorated: true
verbose: false
time: true
language: fr
output_path: null
multiline_auth: true
autoload:
"": tests/bootstrap

suites:
default:
paths:
- tests/features
formatters:
progress: true
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "etna/auth-service-provider",
"description": "Authenticator Service Provider",
"keywords": ["authenticator", "silex"],
"license": "proprietary",
"license": "MIT",
"authors": [
{
"name": "ETNA",
Expand All @@ -16,16 +16,16 @@
"etna/php-rsa": "0.x"
},
"require-dev": {
"behat/behat": "2.x@stable"
},
"config": {
"bin-dir": "bin"
"behat/behat": "~3.0"
},
"autoload": {
"psr-4": {
"ETNA\\Silex\\Provider\\Auth\\": "src"
}
},
"scripts": {
"test": "behat"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Behat\Behat\Context\BehatContext;
use Behat\Behat\Context\ClosuredContextInterface;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\TranslatedContextInterface;
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
Expand All @@ -13,19 +13,8 @@
/**
* Features context.
*/
class FeatureContext extends BehatContext
class FeatureContext implements Context
{
/**
* Initializes context.
* Every scenario gets it's own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters)
{
// Initialize your context here
}

/**
* @BeforeSuite
*/
Expand Down Expand Up @@ -138,7 +127,7 @@ public function addAuthenticatorCookie($identity, $private_key)
if ($identity === null && json_last_error()) {
throw new Exception("JSON decode error");
}

if (!openssl_sign(base64_encode(json_encode($identity)), $signature, $private_key)) {
throw new \Exception("Error signing cookie");
}
Expand All @@ -147,7 +136,7 @@ public function addAuthenticatorCookie($identity, $private_key)
"identity" => base64_encode(json_encode($identity)),
"signature" => base64_encode($signature),
];

$this->request->cookies->set("authenticator", base64_encode(json_encode($identity)));
}

Expand Down Expand Up @@ -190,15 +179,15 @@ public function jeSuisAuthentifie($user = false)
public function jeSuisAuthentifieEnTantQueDepuis($login, $login_date)
{
$this->jeSuisAuthentifie(true);

if ($login !== $this->user->login) {
throw new Exception("\$req->login devrait être '{$login}'");
}

if ($login_date !== $this->user->login_date) {
throw new Exception("\$req->login_date devrait être '{$login_date}'");
}

if (false !== $this->user->logas) {
throw new Exception("\$req->logas devrait être 'false'");
}
Expand All @@ -211,15 +200,15 @@ public function jeSuisAuthentifieEnTantQueDepuis($login, $login_date)
public function jeSuisLogasEnTantQueDepuis($login, $login_date)
{
$this->jeSuisAuthentifie(true);

if ($login !== $this->user->login) {
throw new Exception("\$req->login devrait être '{$login}'");
}

if ($login_date !== $this->user->login_date) {
throw new Exception("\$req->login_date devrait être '{$login_date}'");
}

if (false === $this->user->logas) {
throw new Exception("\$req->logas ne devrait pas être 'false'");
}
Expand All @@ -233,7 +222,7 @@ public function enVraiJeSuisDepuis($login, $login_date)
if ($login !== $this->user->logas->login) {
throw new Exception("\$req->logas->login devrait être '{$login}'");
}

if ($login_date !== $this->user->logas->login_date) {
throw new Exception("\$req->logas->login_date devrait être '{$login_date}'");
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 717ca41

Please sign in to comment.