コード例 #1
0
ファイル: BrokerTesterCept.php プロジェクト: lukehwang/sso
<?php

$token = 'hello_world';
$broker = "Api";
$password = '******';
$username = '******';
$I = new ServerApiTester($scenario);
$I->wantTo('login through broker and view user data');
$I->sendServerRequest('getUserInfo');
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
$I->seeResponseEquals('null');
$I->sendServerRequest('attach');
$I->seeResponseIsJson();
$I->sendServerRequest('getUserInfo');
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
$I->seeResponseEquals('null');
$I->sendServerRequest('login', ['password' => $username, 'username' => $password]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson(['token' => $token]);
$I->sendServerRequest('getUserInfo');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['fullname' => 'jackie', 'email' => '*****@*****.**', 'username' => 'admin']);
$I->sendServerRequest('detach');
$I->sendServerRequest('attach');
$I->sendServerRequest('getUserInfo');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['fullname' => 'jackie', 'email' => '*****@*****.**', 'username' => 'admin']);
コード例 #2
0
ファイル: ServerApiCept.php プロジェクト: lukehwang/sso
<?php

$token = 'hello_world';
$broker = "ServerApi";
$checksum = '514ee01d6ed9a88908790683c203e2ac';
$password = '******';
$username = '******';
$I = new ServerApiTester($scenario);
$I->defaultArgs = ['token' => $token, 'broker' => $broker, 'checksum' => $checksum, 'PHPSESSID' => 'SSO-ServerApi-hello_world-0949c41dd2c747f8e1d4bfd85dd2f4d8'];
$I->wantTo('attach session and view user info and logout');
$I->sendServerRequest('attach', ['PHPSESSID' => '']);
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson(['token' => $token]);
$I->sendServerRequest('userInfo');
$I->seeResponseCodeIs(401);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['error' => 'Not logged in']);
$I->sendServerRequest('login', ['password' => 'wrong', 'username' => 'wrong']);
$I->seeResponseCodeIs(401);
$I->seeResponseIsJson(['error' => 'Incorrect credentials']);
$I->sendServerRequest('login', ['password' => $username, 'username' => $password]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson(['token' => $token]);
$I->sendServerRequest('userInfo');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['fullname' => 'jackie', 'email' => '*****@*****.**', 'username' => 'admin']);
$I->sendServerRequest('logout');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();