Skip to content

Commit

Permalink
Merge pull request #32 from Leosten/feature/56754
Browse files Browse the repository at this point in the history
[FEATURE#56754] Ajout d'une step logas
  • Loading branch information
Guillaume Dubost authored Jul 27, 2017
2 parents 112c09d + 3c34438 commit de231fa
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/AuthContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,42 @@ public function jeSuisAuthentifieEnTantQue($login, $duration = 1, $roles = "", $
$api_context->setRequest($request);
}

/**
* @Given /^je suis logas en tant que "([^"]*)" avec le compte "([^"]*)" et les roles "([^"]*)"$/
*/
public function jeSuisLogasEnTantQueAvecLeCompteEtLesRoles($logas, $login, $roles)
{
$real_login = [
"id" => 1,
"login" => $login,
"logas" => false,
"groups" => explode(",", $roles),
"login_date" => date("Y-m-d H:i:s"),
];

$identity = [
"id" => 11,
"login" => $logas,
"logas" => $real_login,
"groups" => ["student"],
"login_date" => date("Y-m-d H:i:s"),
];

$identity = base64_encode(json_encode($identity));

$identity = [
"identity" => $identity,
"signature" => self::$rsa->sign($identity),
];

$api_context = $this->getContext('ETNA\FeatureContext\ApiContext');
$request = $api_context->getRequest();

// Set le cookie
$request["cookies"]["authenticator"] = base64_encode(json_encode($identity));
$api_context->setRequest($request);
}

/**
* @BeforeSuite
*/
Expand Down

0 comments on commit de231fa

Please sign in to comment.