mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Fix tests
This commit is contained in:
parent
aa57227097
commit
cef061f6cd
1 changed files with 6 additions and 3 deletions
|
@ -314,6 +314,9 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$server['HTTP_CONTENT_TYPE'] = "application/json";
|
$server['HTTP_CONTENT_TYPE'] = "application/json";
|
||||||
}
|
}
|
||||||
$req = new ServerRequest($server, [], $url, $method, "php://memory");
|
$req = new ServerRequest($server, [], $url, $method, "php://memory");
|
||||||
|
if (Arsse::$user->auth()) {
|
||||||
|
$req = $req->withAttribute("authenticated", true)->withAttribute("authenticatedUser", "john.doe@example.com");
|
||||||
|
}
|
||||||
foreach($headers as $key => $value) {
|
foreach($headers as $key => $value) {
|
||||||
if (!is_null($value)) {
|
if (!is_null($value)) {
|
||||||
$req = $req->withHeader($key, $value);
|
$req = $req->withHeader($key, $value);
|
||||||
|
@ -340,7 +343,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
Arsse::$conf = new Conf();
|
Arsse::$conf = new Conf();
|
||||||
// create a mock user manager
|
// create a mock user manager
|
||||||
Arsse::$user = Phake::mock(User::class);
|
Arsse::$user = Phake::mock(User::class);
|
||||||
Phake::when(Arsse::$user)->authHTTP->thenReturn(true);
|
Phake::when(Arsse::$user)->auth->thenReturn(true);
|
||||||
Phake::when(Arsse::$user)->rightsGet->thenReturn(100);
|
Phake::when(Arsse::$user)->rightsGet->thenReturn(100);
|
||||||
Arsse::$user->id = "john.doe@example.com";
|
Arsse::$user->id = "john.doe@example.com";
|
||||||
// create a mock database interface
|
// create a mock database interface
|
||||||
|
@ -354,8 +357,8 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSendAuthenticationChallenge() {
|
public function testSendAuthenticationChallenge() {
|
||||||
Phake::when(Arsse::$user)->authHTTP->thenReturn(false);
|
Phake::when(Arsse::$user)->auth->thenReturn(false);
|
||||||
$exp = new EmptyResponse(401, ['WWW-Authenticate' => 'Basic realm="'.V1_2::REALM.'"']);
|
$exp = new EmptyResponse(401);
|
||||||
$this->assertMessage($exp, $this->req("GET", "/"));
|
$this->assertMessage($exp, $this->req("GET", "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue