From 7958cc6f62ef391655aab1c8e245016a9d23c956 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 25 Sep 2019 08:23:42 -0400 Subject: [PATCH] Test skeleton for IndieAuth --- lib/REST.php | 4 ++-- lib/REST/Microsub/Auth.php | 9 ++++----- tests/cases/REST/Microsub/TestAuth.php | 16 ++++++++++++++++ tests/phpunit.dist.xml | 3 +++ 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 tests/cases/REST/Microsub/TestAuth.php diff --git a/lib/REST.php b/lib/REST.php index fa2b1ec4..d7d64857 100644 --- a/lib/REST.php +++ b/lib/REST.php @@ -40,12 +40,12 @@ class REST { 'match' => "/fever/", 'strip' => "/fever/", 'class' => REST\Fever\API::class, - ], + ],/* 'microsub' => [ // Microsub https://indieweb.org/Microsub 'match' => "/microsub", 'strip' => "", 'class' => REST\Microsub\API::class, - ], + ],*/ 'microsub_auth' => [ // IndieAuth for Microsub https://indieauth.spec.indieweb.org/ 'match' => "/u/", 'strip' => "/u/", diff --git a/lib/REST/Microsub/Auth.php b/lib/REST/Microsub/Auth.php index 203a9470..ebc006e4 100644 --- a/lib/REST/Microsub/Auth.php +++ b/lib/REST/Microsub/Auth.php @@ -20,9 +20,9 @@ class Auth extends \JKingWeb\Arsse\REST\AbstractHandler { const SCOPES = ["read", "follow", "channels"]; /** The list of the logical functions of this API, with their implementations */ const FUNCTIONS = [ - 'discovery' => ['GET' => "opDiscovery"], - 'auth' => ['GET' => "opLogin", 'POST' => "opCodeVerification"], - 'token' => ['GET' => "opTokenVerification", 'POST' => "opIssueAccessToken"], + '' => ['GET' => "opDiscovery"], + 'auth' => ['GET' => "opLogin", 'POST' => "opCodeVerification"], + 'token' => ['GET' => "opTokenVerification", 'POST' => "opIssueAccessToken"], ]; /** The minimal set of reserved URL characters which must be escaped when comparing user ID URLs */ const USERNAME_ESCAPES = [ @@ -43,9 +43,8 @@ class Auth extends \JKingWeb\Arsse\REST\AbstractHandler { } // gather the query parameters and act on the "f" (function) parameter $process = $req->getQueryParams()['f'] ?? ""; - $process = strlen($process) ? $process : "discovery"; $method = $req->getMethod(); - if (isset(self::FUNCTIONS[$process]) || ($process === "discovery" && !strlen($path)) || ($process !== "discovery" && strlen($path))) { + if (isset(self::FUNCTIONS[$process]) || ($process === "" && !strlen($path)) || ($process !== "" && strlen($path))) { // the function requested needs to exist // the path should also be empty unless we're doing discovery return new EmptyResponse(404); diff --git a/tests/cases/REST/Microsub/TestAuth.php b/tests/cases/REST/Microsub/TestAuth.php new file mode 100644 index 00000000..f4eb5797 --- /dev/null +++ b/tests/cases/REST/Microsub/TestAuth.php @@ -0,0 +1,16 @@ + */ +class TestAuth extends \JKingWeb\Arsse\Test\AbstractTest { +} diff --git a/tests/phpunit.dist.xml b/tests/phpunit.dist.xml index cae3734f..d116d3e2 100644 --- a/tests/phpunit.dist.xml +++ b/tests/phpunit.dist.xml @@ -124,6 +124,9 @@ cases/REST/Fever/TestAPI.php cases/REST/Fever/PDO/TestAPI.php + + cases/REST/Microsub/TestAuth.php + cases/Service/TestService.php cases/CLI/TestCLI.php