We don’t need the complexity of S3. Sepcifically the complexity of managing my own AWS account, flysystem made the Laravel side easy. A command is added to copy the the S3 files over to local storage.
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use DateTimeImmutable;
|
|
use Lcobucci\JWT\Configuration;
|
|
|
|
trait TestToken
|
|
{
|
|
public function getToken(): string
|
|
{
|
|
$config = $this->app->make(Configuration::class);
|
|
|
|
return $config->builder()
|
|
->issuedAt(new DateTimeImmutable)
|
|
->withClaim('client_id', 'https://quill.p3k.io')
|
|
->withClaim('me', 'http://jonnybarnes.localhost')
|
|
->withClaim('scope', ['create', 'update'])
|
|
->getToken($config->signer(), $config->signingKey())
|
|
->toString();
|
|
}
|
|
|
|
public function getTokenWithIncorrectScope(): string
|
|
{
|
|
$config = $this->app->make(Configuration::class);
|
|
|
|
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()
|
|
{
|
|
$config = $this->app->make(Configuration::class);
|
|
|
|
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()
|
|
{
|
|
$token = $this->getToken();
|
|
|
|
return substr($token, 0, -5);
|
|
}
|
|
}
|