1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00

Test skeleton for IndieAuth

This commit is contained in:
J. King 2019-09-25 08:23:42 -04:00
parent cbd382d768
commit 7958cc6f62
4 changed files with 25 additions and 7 deletions

View file

@ -40,12 +40,12 @@ class REST {
'match' => "/fever/", 'match' => "/fever/",
'strip' => "/fever/", 'strip' => "/fever/",
'class' => REST\Fever\API::class, 'class' => REST\Fever\API::class,
], ],/*
'microsub' => [ // Microsub https://indieweb.org/Microsub 'microsub' => [ // Microsub https://indieweb.org/Microsub
'match' => "/microsub", 'match' => "/microsub",
'strip' => "", 'strip' => "",
'class' => REST\Microsub\API::class, 'class' => REST\Microsub\API::class,
], ],*/
'microsub_auth' => [ // IndieAuth for Microsub https://indieauth.spec.indieweb.org/ 'microsub_auth' => [ // IndieAuth for Microsub https://indieauth.spec.indieweb.org/
'match' => "/u/", 'match' => "/u/",
'strip' => "/u/", 'strip' => "/u/",

View file

@ -20,7 +20,7 @@ class Auth extends \JKingWeb\Arsse\REST\AbstractHandler {
const SCOPES = ["read", "follow", "channels"]; const SCOPES = ["read", "follow", "channels"];
/** The list of the logical functions of this API, with their implementations */ /** The list of the logical functions of this API, with their implementations */
const FUNCTIONS = [ const FUNCTIONS = [
'discovery' => ['GET' => "opDiscovery"], '' => ['GET' => "opDiscovery"],
'auth' => ['GET' => "opLogin", 'POST' => "opCodeVerification"], 'auth' => ['GET' => "opLogin", 'POST' => "opCodeVerification"],
'token' => ['GET' => "opTokenVerification", 'POST' => "opIssueAccessToken"], 'token' => ['GET' => "opTokenVerification", 'POST' => "opIssueAccessToken"],
]; ];
@ -43,9 +43,8 @@ class Auth extends \JKingWeb\Arsse\REST\AbstractHandler {
} }
// gather the query parameters and act on the "f" (function) parameter // gather the query parameters and act on the "f" (function) parameter
$process = $req->getQueryParams()['f'] ?? ""; $process = $req->getQueryParams()['f'] ?? "";
$process = strlen($process) ? $process : "discovery";
$method = $req->getMethod(); $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 function requested needs to exist
// the path should also be empty unless we're doing discovery // the path should also be empty unless we're doing discovery
return new EmptyResponse(404); return new EmptyResponse(404);

View file

@ -0,0 +1,16 @@
<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\REST\Microsub;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\Response\JsonResponse as Response;
use Zend\Diactoros\Response\EmptyResponse;
/** @covers \JKingWeb\Arsse\REST\Microsub\Auth<extended> */
class TestAuth extends \JKingWeb\Arsse\Test\AbstractTest {
}

View file

@ -124,6 +124,9 @@
<file>cases/REST/Fever/TestAPI.php</file> <file>cases/REST/Fever/TestAPI.php</file>
<file>cases/REST/Fever/PDO/TestAPI.php</file> <file>cases/REST/Fever/PDO/TestAPI.php</file>
</testsuite> </testsuite>
<testsuite name="Microsub">
<file>cases/REST/Microsub/TestAuth.php</file>
</testsuite>
<testsuite name="Admin tools"> <testsuite name="Admin tools">
<file>cases/Service/TestService.php</file> <file>cases/Service/TestService.php</file>
<file>cases/CLI/TestCLI.php</file> <file>cases/CLI/TestCLI.php</file>