mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
Verify even in exceptional cases
This commit is contained in:
parent
07122b524a
commit
3b28634447
1 changed files with 11 additions and 8 deletions
|
@ -81,7 +81,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider provideAuthenticationRequests */
|
/** @dataProvider provideAuthenticationRequests */
|
||||||
public function testAuthenticateAUser(bool $httpRequired, bool $tokenEnforced, string $httpUser = null, array $dataPost, array $dataGet, ResponseInterface $exp) {
|
public function testAuthenticateAUserToken(bool $httpRequired, bool $tokenEnforced, string $httpUser = null, array $dataPost, array $dataGet, ResponseInterface $exp) {
|
||||||
self::setConf([
|
self::setConf([
|
||||||
'userHTTPAuthRequired' => $httpRequired,
|
'userHTTPAuthRequired' => $httpRequired,
|
||||||
'userSessionEnforced' => $tokenEnforced,
|
'userSessionEnforced' => $tokenEnforced,
|
||||||
|
@ -144,14 +144,17 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
return $id ?? "RANDOM_TOKEN";
|
return $id ?? "RANDOM_TOKEN";
|
||||||
});
|
});
|
||||||
\Phake::when(Arsse::$db)->tokenCreate("john.doe@example.org", $this->anything(), $this->anything())->thenThrow(new UserException("doesNotExist"));
|
\Phake::when(Arsse::$db)->tokenCreate("john.doe@example.org", $this->anything(), $this->anything())->thenThrow(new UserException("doesNotExist"));
|
||||||
if ($exp instanceof \JKingWeb\Arsse\AbstractException) {
|
try {
|
||||||
$this->assertException($exp);
|
if ($exp instanceof \JKingWeb\Arsse\AbstractException) {
|
||||||
API::userRegister($user, $password);
|
$this->assertException($exp);
|
||||||
} else {
|
API::userRegister($user, $password);
|
||||||
$this->assertSame($exp, API::userRegister($user, $password));
|
} else {
|
||||||
|
$this->assertSame($exp, API::userRegister($user, $password));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
\Phake::verify(Arsse::$db)->tokenRevoke($user, "fever.login");
|
||||||
|
\Phake::verify(Arsse::$db)->tokenCreate($user, "fever.login", md5($user.":".($password ?? "RANDOM_PASSWORD")));
|
||||||
}
|
}
|
||||||
\Phake::verify(Arsse::$db)->tokenRevoke($user, "fever.login");
|
|
||||||
\Phake::verify(Arsse::$db)->tokenCreate($user, "fever.login", md5($user.":".($password ?? "RANDOM_PASSWORD")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function providePasswordCreations() {
|
public function providePasswordCreations() {
|
||||||
|
|
Loading…
Reference in a new issue