mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 17:12:41 +00:00
0972cff660
- URLs are now matched centrally against a whitelist - %-encoded URLs are still handled correctly - Dispatched methods now only handle one specific task - Filler methods (e.g. versionPOST) are no longer required - Unhandled URLs now return 501 Not Implemented rather than 404 Not Found; this removes some ambiguity in the semantics of 404
44 lines
No EOL
1.2 KiB
PHP
44 lines
No EOL
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\Arsse;
|
|
use JKingWeb\Arsse\Rest\Request;
|
|
use JKingWeb\Arsse\Rest\Response;
|
|
|
|
|
|
class TestNCNVersionDiscovery extends \PHPUnit\Framework\TestCase {
|
|
use Test\Tools;
|
|
|
|
function setUp() {
|
|
$this->clearData();
|
|
}
|
|
|
|
function testFetchVersionList() {
|
|
$exp = new Response(200, ['apiLevels' => ['v1-2']]);
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
$req = new Request("GET", "/");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
$req = new Request("GET", "");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
$req = new Request("GET", "/?id=1827");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
}
|
|
|
|
function testUseIncorrectMethod() {
|
|
$exp = new Response(405);
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
$req = new Request("POST", "/");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
}
|
|
|
|
function testUseIncorrectPath() {
|
|
$exp = new Response(501);
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
$req = new Request("GET", "/ook");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
}
|
|
} |