Initial php8 work

- switch to GD for image work
 - fix issues around jwt
This commit is contained in:
Jonny Barnes 2020-11-28 18:21:29 +00:00
parent 303b0e66ca
commit 6942fc1d32
9 changed files with 370 additions and 337 deletions

View file

@ -5,19 +5,16 @@ namespace Tests\Feature;
use Carbon\Carbon;
use Tests\TestCase;
use Tests\TestToken;
use App\Jobs\ProcessMedia;
use App\Jobs\SendWebMentions;
use App\Models\{Media, Place};
use Illuminate\Http\UploadedFile;
use App\Jobs\SyndicateNoteToTwitter;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Storage;
use MStaack\LaravelPostgis\Geometries\Point;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class MicropubControllerTest extends TestCase
{
use DatabaseTransactions, TestToken;
use DatabaseTransactions;
use TestToken;
/**
* Test a GET request for the micropub endpoint without a token gives a

View file

@ -2,50 +2,47 @@
namespace Tests;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use DateTimeImmutable;
use Lcobucci\JWT\Configuration;
trait TestToken
{
public function getToken()
{
$signer = new Sha256();
$token = (new Builder())
->set('client_id', 'https://quill.p3k.io')
->set('me', 'https://jonnybarnes.localhost')
->set('scope', 'create update')
->set('issued_at', time())
->sign($signer, env('APP_KEY'))
->getToken();
$config = $this->app->make(Configuration::class);
return $token;
return $config->builder()
->issuedAt(new DateTimeImmutable())
->withClaim('client_id', 'https://quill.p3k.io')
->withClaim('me', 'https://jonnybarnes.localhost')
->withClaim('scope', 'create update')
->getToken($config->signer(), $config->signingKey())
->toString();
}
public function getTokenWithIncorrectScope()
{
$signer = new Sha256();
$token = (new Builder())
->set('client_id', 'https://quill.p3k.io')
->set('me', 'https://jonnybarnes.localhost')
->set('scope', 'view') //error here
->set('issued_at', time())
->sign($signer, env('APP_KEY'))
->getToken();
$config = $this->app->make(Configuration::class);
return $token;
return $config->builder()
->issuedAt(new DateTimeImmutable())
->withClaim('client_id', 'https://quill.p3k.io')
->withClaim('me', 'https://jonnybarnes.localhost')
->withClaim('scope', 'view')
->getToken($config->signer(), $config->signingKey())
->toString();
}
public function getTokenWithNoScope()
{
$signer = new Sha256();
$token = (new Builder())
->set('client_id', 'https://quill.p3k.io')
->set('me', 'https://jonnybarnes.localhost')
->set('issued_at', time())
->sign($signer, env('APP_KEY'))
->getToken();
$config = $this->app->make(Configuration::class);
return $token;
return $config->builder()
->issuedAt(new DateTimeImmutable())
->withClaim('client_id', 'https://quill.p3k.io')
->withClaim('me', 'https://jonnybarnes.localhost')
->getToken($config->signer(), $config->signingKey())
->toString();
}
public function getInvalidToken()