Compare commits
16 commits
Author | SHA1 | Date | |
---|---|---|---|
07db68882b | |||
1dfa17abca | |||
f2025b801b | |||
4e7b911fe9 | |||
cf6e65cc03 | |||
13786584a2 | |||
70e5b9bec7 | |||
84383ecd31 | |||
1d59d57c2e | |||
6d867fcc71 | |||
43447ac47b | |||
d7da42b626 | |||
d80e8164c8 | |||
7dd85a3988 | |||
37a8e4bba8 | |||
9abe4a6110 |
134 changed files with 3192 additions and 3946 deletions
|
@ -12,7 +12,9 @@ APP_FALLBACK_LOCALE=en
|
||||||
APP_FAKER_LOCALE=en_US
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
APP_MAINTENANCE_DRIVER=file
|
APP_MAINTENANCE_DRIVER=file
|
||||||
APP_MAINTENANCE_STORE=database
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
BCRYPT_ROUNDS=12
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ FILESYSTEM_DISK=local
|
||||||
QUEUE_CONNECTION=database
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
CACHE_STORE=database
|
CACHE_STORE=database
|
||||||
CACHE_PREFIX=
|
# CACHE_PREFIX=
|
||||||
|
|
||||||
MEMCACHED_HOST=127.0.0.1
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
@ -49,6 +51,7 @@ REDIS_PASSWORD=null
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
MAIL_MAILER=log
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
MAIL_HOST=127.0.0.1
|
MAIL_HOST=127.0.0.1
|
||||||
MAIL_PORT=2525
|
MAIL_PORT=2525
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME=null
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -21,3 +21,5 @@ yarn-error.log
|
||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
ray.php
|
ray.php
|
||||||
|
/public/gpg.key
|
||||||
|
/public/assets/img/favicon.png
|
||||||
|
|
5
.phpactor.json
Normal file
5
.phpactor.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"$schema": "/Users/jonny/git/phpactor/phpactor.schema.json",
|
||||||
|
"language_server_phpstan.enabled": false,
|
||||||
|
"language_server_psalm.enabled": true
|
||||||
|
}
|
69
app/Console/Commands/CopyMediaToLocal.php
Normal file
69
app/Console/Commands/CopyMediaToLocal.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Media;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class CopyMediaToLocal extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'app:copy-media-to-local';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Copy any historic media saved to S3 to the local filesystem';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
// Load all the Media records
|
||||||
|
$media = Media::all();
|
||||||
|
|
||||||
|
// Loop through each media record and copy the file from S3 to the local filesystem
|
||||||
|
foreach ($media as $mediaItem) {
|
||||||
|
$filename = $mediaItem->path;
|
||||||
|
|
||||||
|
$this->info('Processing: ' . $filename);
|
||||||
|
|
||||||
|
// If the file is already saved locally skip to next one
|
||||||
|
if (Storage::disk('local')->exists('public/' . $filename)) {
|
||||||
|
$this->info('File already exists locally, skipping');
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the file from S3 to the local filesystem
|
||||||
|
if (! Storage::disk('s3')->exists($filename)) {
|
||||||
|
$this->error('File does not exist on S3');
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$contents = Storage::disk('s3')->get($filename);
|
||||||
|
Storage::disk('local')->put('public/' . $filename, $contents);
|
||||||
|
|
||||||
|
// Copy -medium and -small versions if they exist
|
||||||
|
$filenameParts = explode('.', $filename);
|
||||||
|
$extension = array_pop($filenameParts);
|
||||||
|
$basename = trim(implode('.', $filenameParts), '.');
|
||||||
|
$mediumFilename = $basename . '-medium.' . $extension;
|
||||||
|
$smallFilename = $basename . '-small.' . $extension;
|
||||||
|
if (Storage::disk('s3')->exists($mediumFilename)) {
|
||||||
|
Storage::disk('local')->put('public/' . $mediumFilename, Storage::disk('s3')->get($mediumFilename));
|
||||||
|
}
|
||||||
|
if (Storage::disk('s3')->exists($smallFilename)) {
|
||||||
|
Storage::disk('local')->put('public/' . $smallFilename, Storage::disk('s3')->get($smallFilename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,7 +40,7 @@ class ContactsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(): RedirectResponse
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
$contact = new Contact();
|
$contact = new Contact;
|
||||||
$contact->name = request()->input('name');
|
$contact->name = request()->input('name');
|
||||||
$contact->nick = request()->input('nick');
|
$contact->nick = request()->input('nick');
|
||||||
$contact->homepage = request()->input('homepage');
|
$contact->homepage = request()->input('homepage');
|
||||||
|
@ -79,7 +79,7 @@ class ContactsController extends Controller
|
||||||
if (request()->hasFile('avatar') && (request()->input('homepage') != '')) {
|
if (request()->hasFile('avatar') && (request()->input('homepage') != '')) {
|
||||||
$dir = parse_url(request()->input('homepage'), PHP_URL_HOST);
|
$dir = parse_url(request()->input('homepage'), PHP_URL_HOST);
|
||||||
$destination = public_path() . '/assets/profile-images/' . $dir;
|
$destination = public_path() . '/assets/profile-images/' . $dir;
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem;
|
||||||
if ($filesystem->isDirectory($destination) === false) {
|
if ($filesystem->isDirectory($destination) === false) {
|
||||||
$filesystem->makeDirectory($destination);
|
$filesystem->makeDirectory($destination);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ class ContactsController extends Controller
|
||||||
}
|
}
|
||||||
if ($avatar !== null) {
|
if ($avatar !== null) {
|
||||||
$directory = public_path() . '/assets/profile-images/' . parse_url($contact->homepage, PHP_URL_HOST);
|
$directory = public_path() . '/assets/profile-images/' . parse_url($contact->homepage, PHP_URL_HOST);
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem;
|
||||||
if ($filesystem->isDirectory($directory) === false) {
|
if ($filesystem->isDirectory($directory) === false) {
|
||||||
$filesystem->makeDirectory($directory);
|
$filesystem->makeDirectory($directory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ class PasskeysController extends Controller
|
||||||
throw new WebAuthnException('No public key credential request options found');
|
throw new WebAuthnException('No public key credential request options found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$attestationStatementSupportManager = new AttestationStatementSupportManager();
|
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport());
|
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||||
|
|
||||||
$webauthnSerializer = (new WebauthnSerializerFactory(
|
$webauthnSerializer = (new WebauthnSerializerFactory(
|
||||||
$attestationStatementSupportManager
|
$attestationStatementSupportManager
|
||||||
|
@ -133,12 +133,12 @@ class PasskeysController extends Controller
|
||||||
throw new WebAuthnException('Invalid response type');
|
throw new WebAuthnException('Invalid response type');
|
||||||
}
|
}
|
||||||
|
|
||||||
$algorithmManager = new Manager();
|
$algorithmManager = new Manager;
|
||||||
$algorithmManager->add(new Ed25519());
|
$algorithmManager->add(new Ed25519);
|
||||||
$algorithmManager->add(new ES256());
|
$algorithmManager->add(new ES256);
|
||||||
$algorithmManager->add(new RS256());
|
$algorithmManager->add(new RS256);
|
||||||
|
|
||||||
$ceremonyStepManagerFactory = new CeremonyStepManagerFactory();
|
$ceremonyStepManagerFactory = new CeremonyStepManagerFactory;
|
||||||
$ceremonyStepManagerFactory->setAlgorithmManager($algorithmManager);
|
$ceremonyStepManagerFactory->setAlgorithmManager($algorithmManager);
|
||||||
$ceremonyStepManagerFactory->setAttestationStatementSupportManager(
|
$ceremonyStepManagerFactory->setAttestationStatementSupportManager(
|
||||||
$attestationStatementSupportManager
|
$attestationStatementSupportManager
|
||||||
|
@ -206,8 +206,8 @@ class PasskeysController extends Controller
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$attestationStatementSupportManager = new AttestationStatementSupportManager();
|
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport());
|
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||||
|
|
||||||
$webauthnSerializer = (new WebauthnSerializerFactory(
|
$webauthnSerializer = (new WebauthnSerializerFactory(
|
||||||
$attestationStatementSupportManager
|
$attestationStatementSupportManager
|
||||||
|
@ -240,15 +240,15 @@ class PasskeysController extends Controller
|
||||||
'json'
|
'json'
|
||||||
);
|
);
|
||||||
|
|
||||||
$algorithmManager = new Manager();
|
$algorithmManager = new Manager;
|
||||||
$algorithmManager->add(new Ed25519());
|
$algorithmManager->add(new Ed25519);
|
||||||
$algorithmManager->add(new ES256());
|
$algorithmManager->add(new ES256);
|
||||||
$algorithmManager->add(new RS256());
|
$algorithmManager->add(new RS256);
|
||||||
|
|
||||||
$attestationStatementSupportManager = new AttestationStatementSupportManager();
|
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport());
|
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||||
|
|
||||||
$ceremonyStepManagerFactory = new CeremonyStepManagerFactory();
|
$ceremonyStepManagerFactory = new CeremonyStepManagerFactory;
|
||||||
$ceremonyStepManagerFactory->setAlgorithmManager($algorithmManager);
|
$ceremonyStepManagerFactory->setAlgorithmManager($algorithmManager);
|
||||||
$ceremonyStepManagerFactory->setAttestationStatementSupportManager(
|
$ceremonyStepManagerFactory->setAttestationStatementSupportManager(
|
||||||
$attestationStatementSupportManager
|
$attestationStatementSupportManager
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ContactsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem;
|
||||||
$contacts = Contact::all();
|
$contacts = Contact::all();
|
||||||
foreach ($contacts as $contact) {
|
foreach ($contacts as $contact) {
|
||||||
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
||||||
|
@ -40,7 +40,7 @@ class ContactsController extends Controller
|
||||||
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
||||||
$file = public_path() . '/assets/profile-images/' . $contact->homepageHost . '/image';
|
$file = public_path() . '/assets/profile-images/' . $contact->homepageHost . '/image';
|
||||||
|
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem;
|
||||||
$image = ($filesystem->exists($file)) ?
|
$image = ($filesystem->exists($file)) ?
|
||||||
'/assets/profile-images/' . $contact->homepageHost . '/image'
|
'/assets/profile-images/' . $contact->homepageHost . '/image'
|
||||||
:
|
:
|
||||||
|
|
|
@ -53,13 +53,13 @@ class MicropubController extends Controller
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure|CannotDecodeContent) {
|
} catch (RequiredConstraintsViolated|InvalidTokenStructure|CannotDecodeContent) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->invalidTokenResponse();
|
return $micropubResponses->invalidTokenResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tokenData->claims()->has('scope') === false) {
|
if ($tokenData->claims()->has('scope') === false) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->tokenHasNoScopeResponse();
|
return $micropubResponses->tokenHasNoScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class MicropubController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array('create', $scopes)) {
|
if (! in_array('create', $scopes)) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->insufficientScopeResponse();
|
return $micropubResponses->insufficientScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class MicropubController extends Controller
|
||||||
$scopes = explode(' ', $scopes);
|
$scopes = explode(' ', $scopes);
|
||||||
}
|
}
|
||||||
if (! in_array('create', $scopes)) {
|
if (! in_array('create', $scopes)) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->insufficientScopeResponse();
|
return $micropubResponses->insufficientScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class MicropubController extends Controller
|
||||||
$scopes = explode(' ', $scopes);
|
$scopes = explode(' ', $scopes);
|
||||||
}
|
}
|
||||||
if (! in_array('update', $scopes)) {
|
if (! in_array('update', $scopes)) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->insufficientScopeResponse();
|
return $micropubResponses->insufficientScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ class MicropubController extends Controller
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
||||||
return (new MicropubResponses())->invalidTokenResponse();
|
return (new MicropubResponses)->invalidTokenResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->input('q') === 'syndicate-to') {
|
if ($request->input('q') === 'syndicate-to') {
|
||||||
|
|
|
@ -39,13 +39,13 @@ class MicropubMediaController extends Controller
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->invalidTokenResponse();
|
return $micropubResponses->invalidTokenResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tokenData->claims()->has('scope') === false) {
|
if ($tokenData->claims()->has('scope') === false) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->tokenHasNoScopeResponse();
|
return $micropubResponses->tokenHasNoScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ class MicropubMediaController extends Controller
|
||||||
$scopes = explode(' ', $scopes);
|
$scopes = explode(' ', $scopes);
|
||||||
}
|
}
|
||||||
if (! in_array('create', $scopes)) {
|
if (! in_array('create', $scopes)) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->insufficientScopeResponse();
|
return $micropubResponses->insufficientScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -111,13 +111,13 @@ class MicropubMediaController extends Controller
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->invalidTokenResponse();
|
return $micropubResponses->invalidTokenResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tokenData->claims()->has('scope') === false) {
|
if ($tokenData->claims()->has('scope') === false) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->tokenHasNoScopeResponse();
|
return $micropubResponses->tokenHasNoScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ class MicropubMediaController extends Controller
|
||||||
$scopes = explode(' ', $scopes);
|
$scopes = explode(' ', $scopes);
|
||||||
}
|
}
|
||||||
if (! in_array('create', $scopes)) {
|
if (! in_array('create', $scopes)) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses;
|
||||||
|
|
||||||
return $micropubResponses->insufficientScopeResponse();
|
return $micropubResponses->insufficientScopeResponse();
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,10 @@ class MicropubMediaController extends Controller
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->file('file')->isValid() === false) {
|
/** @var UploadedFile $file */
|
||||||
|
$file = $request->file('file');
|
||||||
|
|
||||||
|
if ($file->isValid() === false) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'response' => 'error',
|
'response' => 'error',
|
||||||
'error' => 'invalid_request',
|
'error' => 'invalid_request',
|
||||||
|
@ -148,7 +151,7 @@ class MicropubMediaController extends Controller
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = $this->saveFile($request->file('file'));
|
$filename = Storage::disk('local')->putFile('media', $file);
|
||||||
|
|
||||||
/** @var ImageManager $manager */
|
/** @var ImageManager $manager */
|
||||||
$manager = resolve(ImageManager::class);
|
$manager = resolve(ImageManager::class);
|
||||||
|
@ -162,18 +165,11 @@ class MicropubMediaController extends Controller
|
||||||
|
|
||||||
$media = Media::create([
|
$media = Media::create([
|
||||||
'token' => $request->bearerToken(),
|
'token' => $request->bearerToken(),
|
||||||
'path' => 'media/' . $filename,
|
'path' => $filename,
|
||||||
'type' => $this->getFileTypeFromMimeType($request->file('file')->getMimeType()),
|
'type' => $this->getFileTypeFromMimeType($request->file('file')->getMimeType()),
|
||||||
'image_widths' => $width,
|
'image_widths' => $width,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// put the file on S3 initially, the ProcessMedia job may edit this
|
|
||||||
Storage::disk('s3')->putFileAs(
|
|
||||||
'media',
|
|
||||||
new File(storage_path('app') . '/' . $filename),
|
|
||||||
$filename
|
|
||||||
);
|
|
||||||
|
|
||||||
ProcessMedia::dispatch($filename);
|
ProcessMedia::dispatch($filename);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
@ -237,7 +233,7 @@ class MicropubMediaController extends Controller
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function saveFile(UploadedFile $file): string
|
private function saveFileToLocal(UploadedFile $file): string
|
||||||
{
|
{
|
||||||
$filename = Uuid::uuid4()->toString() . '.' . $file->extension();
|
$filename = Uuid::uuid4()->toString() . '.' . $file->extension();
|
||||||
Storage::disk('local')->putFileAs('', $file, $filename);
|
Storage::disk('local')->putFileAs('', $file, $filename);
|
||||||
|
|
|
@ -67,7 +67,7 @@ class NotesController extends Controller
|
||||||
*/
|
*/
|
||||||
public function redirect(int $decId): RedirectResponse
|
public function redirect(int $decId): RedirectResponse
|
||||||
{
|
{
|
||||||
return redirect(config('app.url') . '/notes/' . (new Numbers())->numto60($decId));
|
return redirect(config('app.url') . '/notes/' . (new Numbers)->numto60($decId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,7 +38,7 @@ class DownloadWebMention implements ShouldQueue
|
||||||
// 4XX and 5XX responses should get Guzzle to throw an exception,
|
// 4XX and 5XX responses should get Guzzle to throw an exception,
|
||||||
// Laravel should catch and retry these automatically.
|
// Laravel should catch and retry these automatically.
|
||||||
if ($response->getStatusCode() === 200) {
|
if ($response->getStatusCode() === 200) {
|
||||||
$filesystem = new FileSystem();
|
$filesystem = new FileSystem;
|
||||||
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
||||||
// backup file first
|
// backup file first
|
||||||
$filenameBackup = $filename . '.' . date('Y-m-d') . '.backup';
|
$filenameBackup = $filename . '.' . date('Y-m-d') . '.backup';
|
||||||
|
|
|
@ -32,35 +32,38 @@ class ProcessMedia implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function handle(ImageManager $manager): void
|
public function handle(ImageManager $manager): void
|
||||||
{
|
{
|
||||||
//open file
|
// Load file
|
||||||
|
$file = Storage::disk('local')->get('media/' . $this->filename);
|
||||||
|
|
||||||
|
// Open file
|
||||||
try {
|
try {
|
||||||
$image = $manager->read(storage_path('app') . '/' . $this->filename);
|
$image = $manager->read($file);
|
||||||
} catch (DecoderException) {
|
} catch (DecoderException) {
|
||||||
// not an image; delete file and end job
|
// not an image; delete file and end job
|
||||||
unlink(storage_path('app') . '/' . $this->filename);
|
Storage::disk('local')->delete('media/' . $this->filename);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//create smaller versions if necessary
|
|
||||||
|
// Save the file publicly
|
||||||
|
Storage::disk('public')->put('media/' . $this->filename, $file);
|
||||||
|
|
||||||
|
// Create smaller versions if necessary
|
||||||
if ($image->width() > 1000) {
|
if ($image->width() > 1000) {
|
||||||
$filenameParts = explode('.', $this->filename);
|
$filenameParts = explode('.', $this->filename);
|
||||||
$extension = array_pop($filenameParts);
|
$extension = array_pop($filenameParts);
|
||||||
// the following achieves this data flow
|
// the following achieves this data flow
|
||||||
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
|
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
|
||||||
$basename = ltrim(array_reduce($filenameParts, function ($carry, $item) {
|
$basename = trim(implode('.', $filenameParts), '.');
|
||||||
return $carry . '.' . $item;
|
|
||||||
}, ''), '.');
|
$medium = $image->resize(width: 1000);
|
||||||
$medium = $image->resize(1000, null, function ($constraint) {
|
Storage::disk('public')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
||||||
$constraint->aspectRatio();
|
|
||||||
});
|
$small = $image->resize(width: 500);
|
||||||
Storage::disk('s3')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
Storage::disk('public')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
||||||
$small = $image->resize(500, null, function ($constraint) {
|
|
||||||
$constraint->aspectRatio();
|
|
||||||
});
|
|
||||||
Storage::disk('s3')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we can delete the locally saved image
|
// Now we can delete the locally saved image
|
||||||
unlink(storage_path('app') . '/' . $this->filename);
|
Storage::disk('local')->delete('media/' . $this->filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class ProcessWebMention implements ShouldQueue
|
||||||
try {
|
try {
|
||||||
$response = $guzzle->request('GET', $this->source);
|
$response = $guzzle->request('GET', $this->source);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
throw new RemoteContentNotFoundException();
|
throw new RemoteContentNotFoundException;
|
||||||
}
|
}
|
||||||
$this->saveRemoteContent((string) $response->getBody(), $this->source);
|
$this->saveRemoteContent((string) $response->getBody(), $this->source);
|
||||||
$microformats = Mf2\parse((string) $response->getBody(), $this->source);
|
$microformats = Mf2\parse((string) $response->getBody(), $this->source);
|
||||||
|
@ -85,7 +85,7 @@ class ProcessWebMention implements ShouldQueue
|
||||||
}// foreach
|
}// foreach
|
||||||
|
|
||||||
// no webmention in the db so create new one
|
// no webmention in the db so create new one
|
||||||
$webmention = new WebMention();
|
$webmention = new WebMention;
|
||||||
$type = $parser->getMentionType($microformats); // throw error here?
|
$type = $parser->getMentionType($microformats); // throw error here?
|
||||||
dispatch(new SaveProfileImage($microformats));
|
dispatch(new SaveProfileImage($microformats));
|
||||||
$webmention->source = $this->source;
|
$webmention->source = $this->source;
|
||||||
|
|
|
@ -108,7 +108,7 @@ class SendWebMentions implements ShouldQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
$urls = [];
|
$urls = [];
|
||||||
$dom = new \DOMDocument();
|
$dom = new \DOMDocument;
|
||||||
$dom->loadHTML($html);
|
$dom->loadHTML($html);
|
||||||
$anchors = $dom->getElementsByTagName('a');
|
$anchors = $dom->getElementsByTagName('a');
|
||||||
foreach ($anchors as $anchor) {
|
foreach ($anchors as $anchor) {
|
||||||
|
|
|
@ -58,10 +58,10 @@ class Article extends Model
|
||||||
{
|
{
|
||||||
return Attribute::get(
|
return Attribute::get(
|
||||||
get: function () {
|
get: function () {
|
||||||
$environment = new Environment();
|
$environment = new Environment;
|
||||||
$environment->addExtension(new CommonMarkCoreExtension());
|
$environment->addExtension(new CommonMarkCoreExtension);
|
||||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
|
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer);
|
||||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());
|
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer);
|
||||||
$markdownConverter = new MarkdownConverter($environment);
|
$markdownConverter = new MarkdownConverter($environment);
|
||||||
|
|
||||||
return $markdownConverter->convert($this->main)->getContent();
|
return $markdownConverter->convert($this->main)->getContent();
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Media extends Model
|
||||||
return $attributes['path'];
|
return $attributes['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return config('filesystems.disks.s3.url') . '/' . $attributes['path'];
|
return config('app.url') . '/storage/' . $attributes['path'];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class Media extends Model
|
||||||
$basename = $this->getBasename($path);
|
$basename = $this->getBasename($path);
|
||||||
$extension = $this->getExtension($path);
|
$extension = $this->getExtension($path);
|
||||||
|
|
||||||
return config('filesystems.disks.s3.url') . '/' . $basename . '-' . $size . '.' . $extension;
|
return config('app.url') . '/storage/' . $basename . '-' . $size . '.' . $extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBasename(string $path): string
|
private function getBasename(string $path): string
|
||||||
|
|
|
@ -271,7 +271,7 @@ class Note extends Model
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($oEmbed->httpstatus >= 400) {
|
if ($oEmbed->httpstatus >= 400) {
|
||||||
throw new Exception();
|
throw new Exception;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -388,18 +388,18 @@ class Note extends Model
|
||||||
'mentions_handle' => [
|
'mentions_handle' => [
|
||||||
'prefix' => '@',
|
'prefix' => '@',
|
||||||
'pattern' => '([\w@.])+(\b)',
|
'pattern' => '([\w@.])+(\b)',
|
||||||
'generator' => new MentionGenerator(),
|
'generator' => new MentionGenerator,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$environment = new Environment($config);
|
$environment = new Environment($config);
|
||||||
$environment->addExtension(new CommonMarkCoreExtension());
|
$environment->addExtension(new CommonMarkCoreExtension);
|
||||||
$environment->addExtension(new AutolinkExtension());
|
$environment->addExtension(new AutolinkExtension);
|
||||||
$environment->addExtension(new MentionExtension());
|
$environment->addExtension(new MentionExtension);
|
||||||
$environment->addRenderer(Mention::class, new MentionRenderer());
|
$environment->addRenderer(Mention::class, new MentionRenderer);
|
||||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
|
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer);
|
||||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());
|
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer);
|
||||||
$markdownConverter = new MarkdownConverter($environment);
|
$markdownConverter = new MarkdownConverter($environment);
|
||||||
|
|
||||||
return $markdownConverter->convert($note)->getContent();
|
return $markdownConverter->convert($note)->getContent();
|
||||||
|
|
|
@ -42,7 +42,7 @@ class WebMention extends Model
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$authorship = new Authorship();
|
$authorship = new Authorship;
|
||||||
$hCard = $authorship->findAuthor(json_decode($attributes['mf2'], true));
|
$hCard = $authorship->findAuthor(json_decode($attributes['mf2'], true));
|
||||||
|
|
||||||
if ($hCard === false) {
|
if ($hCard === false) {
|
||||||
|
@ -140,7 +140,7 @@ class WebMention extends Model
|
||||||
return $profile_image;
|
return $profile_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem;
|
||||||
if ($filesystem->exists(public_path() . '/assets/profile-images/' . $host . '/image')) {
|
if ($filesystem->exists(public_path() . '/assets/profile-images/' . $host . '/image')) {
|
||||||
return '/assets/profile-images/' . $host . '/image';
|
return '/assets/profile-images/' . $host . '/image';
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,9 +88,9 @@ class AppServiceProvider extends ServiceProvider
|
||||||
$this->app->bind('Lcobucci\JWT\Configuration', function () {
|
$this->app->bind('Lcobucci\JWT\Configuration', function () {
|
||||||
$key = InMemory::plainText(config('app.key'));
|
$key = InMemory::plainText(config('app.key'));
|
||||||
|
|
||||||
$config = Configuration::forSymmetricSigner(new Sha256(), $key);
|
$config = Configuration::forSymmetricSigner(new Sha256, $key);
|
||||||
|
|
||||||
$config->setValidationConstraints(new SignedWith(new Sha256(), $key));
|
$config->setValidationConstraints(new SignedWith(new Sha256, $key));
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
// Configure HtmlSanitizer
|
// Configure HtmlSanitizer
|
||||||
$this->app->bind(HtmlSanitizer::class, function () {
|
$this->app->bind(HtmlSanitizer::class, function () {
|
||||||
return new HtmlSanitizer(
|
return new HtmlSanitizer(
|
||||||
(new HtmlSanitizerConfig())
|
(new HtmlSanitizerConfig)
|
||||||
->allowSafeElements()
|
->allowSafeElements()
|
||||||
->forceAttribute('a', 'rel', 'noopener nofollow')
|
->forceAttribute('a', 'rel', 'noopener nofollow')
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,7 +62,7 @@ class BookmarkService extends Service
|
||||||
$response = $client->request('GET', 'https://web.archive.org/save/' . $url);
|
$response = $client->request('GET', 'https://web.archive.org/save/' . $url);
|
||||||
} catch (ClientException $e) {
|
} catch (ClientException $e) {
|
||||||
// throw an exception to be caught
|
// throw an exception to be caught
|
||||||
throw new InternetArchiveException();
|
throw new InternetArchiveException;
|
||||||
}
|
}
|
||||||
if ($response->hasHeader('Content-Location')) {
|
if ($response->hasHeader('Content-Location')) {
|
||||||
if (Str::startsWith(Arr::get($response->getHeader('Content-Location'), 0), '/web')) {
|
if (Str::startsWith(Arr::get($response->getHeader('Content-Location'), 0), '/web')) {
|
||||||
|
@ -71,6 +71,6 @@ class BookmarkService extends Service
|
||||||
}
|
}
|
||||||
|
|
||||||
// throw an exception to be caught
|
// throw an exception to be caught
|
||||||
throw new InternetArchiveException();
|
throw new InternetArchiveException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ class UpdateService
|
||||||
if ($property === 'photo') {
|
if ($property === 'photo') {
|
||||||
foreach ($value as $photoURL) {
|
foreach ($value as $photoURL) {
|
||||||
if (Str::startsWith($photoURL, 'https://')) {
|
if (Str::startsWith($photoURL, 'https://')) {
|
||||||
$media = new Media();
|
$media = new Media;
|
||||||
$media->path = $photoURL;
|
$media->path = $photoURL;
|
||||||
$media->type = 'image';
|
$media->type = 'image';
|
||||||
$media->save();
|
$media->save();
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PlaceService
|
||||||
$data['latitude'] = $matches[0][0];
|
$data['latitude'] = $matches[0][0];
|
||||||
$data['longitude'] = $matches[0][1];
|
$data['longitude'] = $matches[0][1];
|
||||||
}
|
}
|
||||||
$place = new Place();
|
$place = new Place;
|
||||||
$place->name = $data['name'];
|
$place->name = $data['name'];
|
||||||
$place->description = $data['description'];
|
$place->description = $data['description'];
|
||||||
$place->latitude = $data['latitude'];
|
$place->latitude = $data['latitude'];
|
||||||
|
@ -53,7 +53,7 @@ class PlaceService
|
||||||
if (Arr::has($checkin, 'properties.latitude') === false) {
|
if (Arr::has($checkin, 'properties.latitude') === false) {
|
||||||
throw new \InvalidArgumentException('Missing required longitude/latitude');
|
throw new \InvalidArgumentException('Missing required longitude/latitude');
|
||||||
}
|
}
|
||||||
$place = new Place();
|
$place = new Place;
|
||||||
$place->name = Arr::get($checkin, 'properties.name.0');
|
$place->name = Arr::get($checkin, 'properties.name.0');
|
||||||
$place->external_urls = Arr::get($checkin, 'properties.url.0');
|
$place->external_urls = Arr::get($checkin, 'properties.url.0');
|
||||||
$place->latitude = Arr::get($checkin, 'properties.latitude.0');
|
$place->latitude = Arr::get($checkin, 'properties.latitude.0');
|
||||||
|
|
|
@ -19,7 +19,7 @@ class TokenService
|
||||||
$config = resolve(Configuration::class);
|
$config = resolve(Configuration::class);
|
||||||
|
|
||||||
$token = $config->builder()
|
$token = $config->builder()
|
||||||
->issuedAt(new DateTimeImmutable())
|
->issuedAt(new DateTimeImmutable)
|
||||||
->withClaim('client_id', $data['client_id'])
|
->withClaim('client_id', $data['client_id'])
|
||||||
->withClaim('me', $data['me'])
|
->withClaim('me', $data['me'])
|
||||||
->withClaim('scope', $data['scope'])
|
->withClaim('scope', $data['scope'])
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://getcomposer.org/schema.json",
|
||||||
"name": "jonnybarnes/jonnybarnes.uk",
|
"name": "jonnybarnes/jonnybarnes.uk",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "The code for jonnybarnes.uk, based on Laravel 10",
|
"description": "The code for jonnybarnes.uk, based on Laravel 11",
|
||||||
"keywords": ["laravel", "framework", "indieweb"],
|
"keywords": ["laravel", "framework", "indieweb"],
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -11,14 +12,14 @@
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-pgsql": "*",
|
"ext-pgsql": "*",
|
||||||
"ext-sodium": "*",
|
"ext-sodium": "*",
|
||||||
"cviebrock/eloquent-sluggable": "^11.0",
|
"cviebrock/eloquent-sluggable": "^12.0",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"indieauth/client": "^1.1",
|
"indieauth/client": "^1.1",
|
||||||
"intervention/image": "^3",
|
"intervention/image": "^3",
|
||||||
"jonnybarnes/indieweb": "~0.2",
|
"jonnybarnes/indieweb": "~0.2",
|
||||||
"jonnybarnes/webmentions-parser": "~0.5",
|
"jonnybarnes/webmentions-parser": "~0.5",
|
||||||
"jublonet/codebird-php": "4.0.0-beta.1",
|
"jublonet/codebird-php": "4.0.0-beta.1",
|
||||||
"laravel/framework": "^11.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/horizon": "^5.0",
|
"laravel/horizon": "^5.0",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/scout": "^10.1",
|
"laravel/scout": "^10.1",
|
||||||
|
@ -40,16 +41,15 @@
|
||||||
"barryvdh/laravel-ide-helper": "^3.0",
|
"barryvdh/laravel-ide-helper": "^3.0",
|
||||||
"fakerphp/faker": "^1.9.2",
|
"fakerphp/faker": "^1.9.2",
|
||||||
"laravel/dusk": "^8.0",
|
"laravel/dusk": "^8.0",
|
||||||
|
"laravel/pail": "^1.2",
|
||||||
"laravel/pint": "^1.0",
|
"laravel/pint": "^1.0",
|
||||||
"laravel/sail": "^1.18",
|
"laravel/sail": "^1.18",
|
||||||
"mockery/mockery": "^1.4.4",
|
"mockery/mockery": "^1.4.4",
|
||||||
"nunomaduro/collision": "^8.1",
|
"nunomaduro/collision": "^8.1",
|
||||||
"openai-php/client": "^0.10.1",
|
"openai-php/client": "^0.10.1",
|
||||||
"phpunit/php-code-coverage": "^10.0",
|
"phpunit/php-code-coverage": "^11.0",
|
||||||
"phpunit/phpunit": "^10.1",
|
"phpunit/phpunit": "^11.0",
|
||||||
"psalm/plugin-laravel": "^2.8",
|
"spatie/laravel-ray": "^1.12"
|
||||||
"spatie/laravel-ray": "^1.12",
|
|
||||||
"vimeo/psalm": "^5.0"
|
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -78,7 +78,13 @@
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
],
|
],
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
"@php artisan key:generate --ansi"
|
"@php artisan key:generate --ansi",
|
||||||
|
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||||
|
"@php artisan migrate --graceful --ansi"
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
|
|
4106
composer.lock
generated
4106
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -65,7 +65,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -37,6 +37,9 @@ return [
|
||||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||||
|
'busy_timeout' => null,
|
||||||
|
'journal_mode' => null,
|
||||||
|
'synchronous' => null,
|
||||||
],
|
],
|
||||||
|
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
|
@ -145,6 +148,7 @@ return [
|
||||||
'options' => [
|
'options' => [
|
||||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||||
|
'persistent' => env('REDIS_PERSISTENT', false),
|
||||||
],
|
],
|
||||||
|
|
||||||
'default' => [
|
'default' => [
|
||||||
|
|
|
@ -32,8 +32,10 @@ return [
|
||||||
|
|
||||||
'local' => [
|
'local' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app'),
|
'root' => storage_path('app/private'),
|
||||||
|
'serve' => true,
|
||||||
'throw' => false,
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
'public' => [
|
'public' => [
|
||||||
|
@ -42,6 +44,7 @@ return [
|
||||||
'url' => env('APP_URL').'/storage',
|
'url' => env('APP_URL').'/storage',
|
||||||
'visibility' => 'public',
|
'visibility' => 'public',
|
||||||
'throw' => false,
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
's3' => [
|
's3' => [
|
||||||
|
@ -54,6 +57,7 @@ return [
|
||||||
'endpoint' => env('AWS_ENDPOINT'),
|
'endpoint' => env('AWS_ENDPOINT'),
|
||||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||||
'throw' => false,
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
|
@ -38,14 +38,14 @@ return [
|
||||||
|
|
||||||
'smtp' => [
|
'smtp' => [
|
||||||
'transport' => 'smtp',
|
'transport' => 'smtp',
|
||||||
|
'scheme' => env('MAIL_SCHEME'),
|
||||||
'url' => env('MAIL_URL'),
|
'url' => env('MAIL_URL'),
|
||||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||||
'port' => env('MAIL_PORT', 2525),
|
'port' => env('MAIL_PORT', 2525),
|
||||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
|
||||||
'username' => env('MAIL_USERNAME'),
|
'username' => env('MAIL_USERNAME'),
|
||||||
'password' => env('MAIL_PASSWORD'),
|
'password' => env('MAIL_PASSWORD'),
|
||||||
'timeout' => null,
|
'timeout' => null,
|
||||||
'local_domain' => env('MAIL_EHLO_DOMAIN'),
|
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||||
],
|
],
|
||||||
|
|
||||||
'ses' => [
|
'ses' => [
|
||||||
|
|
|
@ -32,7 +32,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||||
|
|
||||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ContactsTableSeeder extends Seeder
|
||||||
'homepage' => 'https://aaronparecki.com',
|
'homepage' => 'https://aaronparecki.com',
|
||||||
'facebook' => '123456',
|
'facebook' => '123456',
|
||||||
]);
|
]);
|
||||||
$fs = new FileSystem();
|
$fs = new FileSystem;
|
||||||
if (! $fs->exists(public_path('assets/profile-images/aaronparecki.com'))) {
|
if (! $fs->exists(public_path('assets/profile-images/aaronparecki.com'))) {
|
||||||
$fs->makeDirectory(public_path('assets/profile-images/aaronparecki.com'));
|
$fs->makeDirectory(public_path('assets/profile-images/aaronparecki.com'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class LikesTableSeeder extends Seeder
|
||||||
Like::factory(10)->create();
|
Like::factory(10)->create();
|
||||||
|
|
||||||
$now = Carbon::now()->subDays(rand(3, 6));
|
$now = Carbon::now()->subDays(rand(3, 6));
|
||||||
$faker = new Generator();
|
$faker = new Generator;
|
||||||
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
|
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
|
||||||
$faker->addProvider(new \Faker\Provider\Lorem($faker));
|
$faker->addProvider(new \Faker\Provider\Lorem($faker));
|
||||||
$faker->addProvider(new \Faker\Provider\Internet($faker));
|
$faker->addProvider(new \Faker\Provider\Internet($faker));
|
||||||
|
|
|
@ -154,7 +154,7 @@ class NotesTableSeeder extends Seeder
|
||||||
->update(['updated_at' => $now->toDateTimeString()]);
|
->update(['updated_at' => $now->toDateTimeString()]);
|
||||||
|
|
||||||
$now = Carbon::now()->subHours(5);
|
$now = Carbon::now()->subHours(5);
|
||||||
$noteJustCheckin = new Note();
|
$noteJustCheckin = new Note;
|
||||||
$noteJustCheckin->setCreatedAt($now);
|
$noteJustCheckin->setCreatedAt($now);
|
||||||
$place = Place::find(1);
|
$place = Place::find(1);
|
||||||
$noteJustCheckin->place()->associate($place);
|
$noteJustCheckin->place()->associate($place);
|
||||||
|
@ -164,12 +164,12 @@ class NotesTableSeeder extends Seeder
|
||||||
->update(['updated_at' => $now->toDateTimeString()]);
|
->update(['updated_at' => $now->toDateTimeString()]);
|
||||||
|
|
||||||
$now = Carbon::now()->subHours(4);
|
$now = Carbon::now()->subHours(4);
|
||||||
$media = new Media();
|
$media = new Media;
|
||||||
$media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg';
|
$media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg';
|
||||||
$media->type = 'image';
|
$media->type = 'image';
|
||||||
$media->image_widths = '3648';
|
$media->image_widths = '3648';
|
||||||
$media->save();
|
$media->save();
|
||||||
$noteWithOnlyImage = new Note();
|
$noteWithOnlyImage = new Note;
|
||||||
$noteWithOnlyImage->setCreatedAt($now);
|
$noteWithOnlyImage->setCreatedAt($now);
|
||||||
$noteWithOnlyImage->setUpdatedAt($now);
|
$noteWithOnlyImage->setUpdatedAt($now);
|
||||||
$noteWithOnlyImage->save();
|
$noteWithOnlyImage->save();
|
||||||
|
|
|
@ -14,7 +14,7 @@ class PlacesTableSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$place = new Place();
|
$place = new Place;
|
||||||
$place->name = 'The Bridgewater Pub';
|
$place->name = 'The Bridgewater Pub';
|
||||||
$place->description = 'A lovely local pub with a decent selection of cask ales';
|
$place->description = 'A lovely local pub with a decent selection of cask ales';
|
||||||
$place->latitude = 53.4983;
|
$place->latitude = 53.4983;
|
||||||
|
|
|
@ -41,5 +41,14 @@ class WebMentionsTableSeeder extends Seeder
|
||||||
'type' => 'repost-of',
|
'type' => 'repost-of',
|
||||||
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["https://barryfrost.com/reposts/1"], "name": ["Kagi is the best"], "author": [{"type": ["h-card"], "value": "Barry Frost", "properties": {"url": ["https://barryfrost.com/"], "name": ["Barry Frost"], "photo": ["https://barryfrost.com/barryfrost.jpg"]}}], "content": [{"html": "Kagi is the Best", "value": "Kagi is the Best"}], "published": ["' . date(DATE_W3C) . '"], "u-repost-of": ["' . config('app.url') . '/notes/C"]}}]}',
|
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["https://barryfrost.com/reposts/1"], "name": ["Kagi is the best"], "author": [{"type": ["h-card"], "value": "Barry Frost", "properties": {"url": ["https://barryfrost.com/"], "name": ["Barry Frost"], "photo": ["https://barryfrost.com/barryfrost.jpg"]}}], "content": [{"html": "Kagi is the Best", "value": "Kagi is the Best"}], "published": ["' . date(DATE_W3C) . '"], "u-repost-of": ["' . config('app.url') . '/notes/C"]}}]}',
|
||||||
]);
|
]);
|
||||||
|
// WebMention like from Bluesky
|
||||||
|
WebMention::create([
|
||||||
|
'source' => 'https://brid.gy/like/bluesky/did:plc:n3jhgiq2ykctnpgzlm6p6b25/at%253A%252F%252Fdid%253Aplc%253An3jhgiq2ykctnpgzlm6p6b25%252Fapp.bsky.feed.post%252F3lalppbcyuc2w/did%253Aplc%253Aia23nh3t37r2lydmmqsixrps',
|
||||||
|
'target' => config('app.url') . '/notes/B',
|
||||||
|
'commentable_id' => '11',
|
||||||
|
'commentable_type' => 'App\Models\Note',
|
||||||
|
'type' => 'like-of',
|
||||||
|
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"uid": ["tag:bsky.app,2013:at://did:plc:n3jhgiq2ykctnpgzlm6p6b25/app.bsky.feed.post/3lalppbcyuc2w_liked_by_did:plc:ia23nh3t37r2lydmmqsixrps"], "url": ["https://bsky.app/profile/jonnybarnes.uk/post/3lalppbcyuc2w#liked_by_did:plc:ia23nh3t37r2lydmmqsixrps"], "name": [""], "author": [{"type": ["h-card"], "value": "bsky.app/profile/little... littledawg13.bsky.social", "properties": {"uid": ["tag:bsky.app,2013:did:plc:ia23nh3t37r2lydmmqsixrps"], "url": ["https://bsky.app/profile/littledawg13.bsky.social", "https://bsky.app/profile/did:plc:ia23nh3t37r2lydmmqsixrps"], "photo": [{"alt": "", "value": "https://cdn.bsky.app/img/avatar/plain/did:plc:ia23nh3t37r2lydmmqsixrps/bafkreifh7ydbyq7qe4maorornocksfnahijxqgx2i5zvvyq6y4i4mydfau@jpeg"}], "nickname": ["littledawg13.bsky.social"]}}], "like-of": ["https://bsky.app/profile/jonnybarnes.uk/post/3lalppbcyuc2w", "http://jonnybarnes.localhost/notes/B"]}}], "rel-urls": []}',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1535
package-lock.json
generated
1535
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -7,11 +7,11 @@
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.6.0",
|
"@eslint/js": "^9.6.0",
|
||||||
"@stylistic/eslint-plugin": "^2.3.0",
|
"@stylistic/eslint-plugin": "^3.0.0",
|
||||||
"eslint": "^9.7.0",
|
"eslint": "^9.7.0",
|
||||||
"globals": "^15.8.0",
|
"globals": "^15.8.0",
|
||||||
"stylelint": "^16.7.0",
|
"stylelint": "^16.7.0",
|
||||||
"stylelint-config-standard": "^36.0.1"
|
"stylelint-config-standard": "^37.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"eslint": "eslint public/assets/js/*.js",
|
"eslint": "eslint public/assets/js/*.js",
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<env name="CACHE_STORE" value="array"/>
|
<env name="CACHE_STORE" value="array"/>
|
||||||
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
||||||
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
||||||
<env name="DB_DATABASE" value="jbukdev_testing"/>
|
<env name="DB_DATABASE" value="jbuk_dev_testing"/>
|
||||||
<env name="MAIL_MAILER" value="array"/>
|
<env name="MAIL_MAILER" value="array"/>
|
||||||
<env name="PULSE_ENABLED" value="false"/>
|
<env name="PULSE_ENABLED" value="false"/>
|
||||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
|
|
BIN
public/assets/css/app.css.zst
Normal file
BIN
public/assets/css/app.css.zst
Normal file
Binary file not shown.
Binary file not shown.
BIN
public/assets/css/colours.css.zst
Normal file
BIN
public/assets/css/colours.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/content.css.zst
Normal file
BIN
public/assets/css/content.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/fonts.css.zst
Normal file
BIN
public/assets/css/fonts.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/h-card.css.zst
Normal file
BIN
public/assets/css/h-card.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/indieauth.css.zst
Normal file
BIN
public/assets/css/indieauth.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/layout.css.zst
Normal file
BIN
public/assets/css/layout.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/notes.css.zst
Normal file
BIN
public/assets/css/notes.css.zst
Normal file
Binary file not shown.
BIN
public/assets/css/variables.css.zst
Normal file
BIN
public/assets/css/variables.css.zst
Normal file
Binary file not shown.
Binary file not shown.
BIN
public/assets/frontend/is-land.js.zst
Normal file
BIN
public/assets/frontend/is-land.js.zst
Normal file
Binary file not shown.
Binary file not shown.
BIN
public/assets/frontend/snow-fall.js.zst
Normal file
BIN
public/assets/frontend/snow-fall.js.zst
Normal file
Binary file not shown.
BIN
public/assets/highlight/zenburn.css.zst
Normal file
BIN
public/assets/highlight/zenburn.css.zst
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 395 B |
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
Before Width: | Height: | Size: 33 KiB |
|
@ -1,21 +0,0 @@
|
||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
|
|
||||||
mG8EV0W04xMFK4EEACIDAwSZOjA8NdI6UvbI/Sqw8LfpckfDXMuiowrVgcANjhDr
|
|
||||||
vQtvr0bYm7RnNlbiuwTQHQ064H3pwjJJYC12I5B6q1Is7h4PYzU4/ahtisb03U/Q
|
|
||||||
ThDDuWxDKQq2hcyfrNI02KO0I0pvbm55IEJhcm5lcyA8am9ubnlAam9ubnliYXJu
|
|
||||||
ZXMudWs+iLYEExMKAD4CGwMFCwkIBwMFFQoJCAsFFgMCAQACHgECF4AWIQSEGbWh
|
|
||||||
2ITK9LCvj7MbLHavsWyFmwUCWSgPSgUJA8ON5wAKCRAbLHavsWyFm9hAAX9ymfnT
|
|
||||||
CUQDBqHmSR+YJ7RkNNFRdq4J1ABsvaRnpRynIE60dde1WqX62CvOkQDyY3sBgLJp
|
|
||||||
3KCNjB9VRoHHL3Gk1X78gxntU01wP+oYotA7tJescf34oM4CfzHoz4UdUTPK3Iif
|
|
||||||
BBMTCgAnBQJXRbTjAhsDBQkB4TOABQsJCAcDBRUKCQgLBRYDAgEAAh4BAheAAAoJ
|
|
||||||
EBssdq+xbIWb0qwBfijJLkE/QUH7iAASLDtD3pUGs13TUynrzl2n8NdOnwmJTDdB
|
|
||||||
6eFT5+XxAgmuw+o28wF+MMEqzf+ELqjEyk/DZaZ3Kg9cJQAm3ybc0wFKy/kqQ2HY
|
|
||||||
TaFwEG3dAyfFDddkuaDEuHMEV0W04xIFK4EEACIDAwR0mRtrTq604CFiA8OdQR77
|
|
||||||
AVc8lRrNxFPwo7uJWsIEPBNVTHasC4OCXAvGgm9bPggQUNoOQ4fUCNmAgsVeGpYQ
|
|
||||||
/b67m0ydqjcrHpd0fIRbK5kyWYvYPRsZ6mTgiKosrZIDAQkJiJ4EGBMKACYCGwwW
|
|
||||||
IQSEGbWh2ITK9LCvj7MbLHavsWyFmwUCWSgPZQUJA8OOAgAKCRAbLHavsWyFm1fN
|
|
||||||
AYDMf1p4GegE1FHiUZo4m4Y5iQfbxT9Nmlgaopbmq+BxJRwPMxVzJOvKXo4DiUd0
|
|
||||||
nncBgOJUJ8esy6WGw+lUfkfvRNkhPw9CVt1GifjG4axGHGaDyDQdFdRcIeFyu0Fs
|
|
||||||
7HsLmg==
|
|
||||||
=sdL6
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
|
BIN
public/assets/js/app.js.zst
Normal file
BIN
public/assets/js/app.js.zst
Normal file
Binary file not shown.
BIN
public/assets/js/auth.js.zst
Normal file
BIN
public/assets/js/auth.js.zst
Normal file
Binary file not shown.
|
@ -1,55 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Contracts\Http\Kernel;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
define('LARAVEL_START', microtime(true));
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
/*
|
// Determine if the application is in maintenance mode...
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Check If The Application Is Under Maintenance
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| If the application is in maintenance / demo mode via the "down" command
|
|
||||||
| we will load this file so that any pre-rendered content can be shown
|
|
||||||
| instead of starting the framework, which could cause an exception.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
||||||
require $maintenance;
|
require $maintenance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Register the Composer autoloader...
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Register The Auto Loader
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Composer provides a convenient, automatically generated class loader for
|
|
||||||
| this application. We just need to utilize it! We'll simply require it
|
|
||||||
| into the script here so we don't need to manually load our classes.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
require __DIR__.'/../vendor/autoload.php';
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
/*
|
// Bootstrap Laravel and handle the request...
|
||||||
|--------------------------------------------------------------------------
|
/** @var Application $app */
|
||||||
| Run The Application
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Once we have the application, we can handle the incoming request using
|
|
||||||
| the application's HTTP kernel. Then, we will send the response back
|
|
||||||
| to this client's browser, allowing them to enjoy our application.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||||
|
|
||||||
$kernel = $app->make(Kernel::class);
|
$app->handleRequest(Request::capture());
|
||||||
|
|
||||||
$response = $kernel->handle(
|
|
||||||
$request = Request::capture()
|
|
||||||
)->send();
|
|
||||||
|
|
||||||
$kernel->terminate($request, $response);
|
|
||||||
|
|
|
@ -19,8 +19,12 @@
|
||||||
<link rel="token_endpoint" href="{{ route('indieauth.token') }}">
|
<link rel="token_endpoint" href="{{ route('indieauth.token') }}">
|
||||||
<link rel="micropub" href="{{ route('micropub-endpoint') }}">
|
<link rel="micropub" href="{{ route('micropub-endpoint') }}">
|
||||||
<link rel="webmention" href="{{ config('app.url') }}/webmention">
|
<link rel="webmention" href="{{ config('app.url') }}/webmention">
|
||||||
<link rel="shortcut icon" href="{{ config('app.url') }}/assets/img/memoji-orange-bg-small-fs8.png">
|
@if (File::exists(public_path('assets/img/favicon.png')))
|
||||||
<link rel="pgpkey" href="/assets/jonnybarnes-public-key-ecc.asc">
|
<link rel="icon" href="{{ config('app.url') }}/assets/img/favicon.png">
|
||||||
|
@endif
|
||||||
|
@if (File::exists(public_path('gpg.key')))
|
||||||
|
<link rel="pgpkey" href="{{ config('app.url')}}/gpg.key">
|
||||||
|
@endif
|
||||||
</head>
|
</head>
|
||||||
<body class="grid">
|
<body class="grid">
|
||||||
<header id="site-header">
|
<header id="site-header">
|
||||||
|
@ -68,6 +72,16 @@
|
||||||
<!--scripts go here when needed-->
|
<!--scripts go here when needed-->
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script type="module" src="/assets/js/app.js"></script>
|
<script type="module" src="/assets/js/app.js"></script>
|
||||||
|
|
||||||
|
<!-- Snow fall -->
|
||||||
|
<script type="module" src="/assets/frontend/is-land.js"></script>
|
||||||
|
<script type="module" src="/assets/frontend/snow-fall.js"></script>
|
||||||
|
<is-land on:media="(prefers-reduced-motion: no-preference)">
|
||||||
|
<snow-fall
|
||||||
|
count="240"
|
||||||
|
style="--snow-fall-color: rebeccapurple; --snow-fall-size: 8px"
|
||||||
|
></snow-fall>
|
||||||
|
</is-land>
|
||||||
@show
|
@show
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
@if (array_key_exists('photo', $reply['author']['properties']))
|
@if (array_key_exists('photo', $reply['author']['properties']))
|
||||||
<img src="{{ $reply['author']['properties']['photo'][0] }}" alt="" class="photo u-photo logo">
|
<img src="{{ $reply['author']['properties']['photo'][0] }}" alt="" class="photo u-photo logo">
|
||||||
@endif
|
@endif
|
||||||
<span class="fn">{{ $reply['author']['properties']['name'][0] }}</span>
|
<span class="fn">{{ $reply['author']['properties']['name'][0] ?? $reply['author']['properties']['nickname'][0] ?? 'unknown' }}</span>
|
||||||
</a>
|
</a>
|
||||||
@else
|
@else
|
||||||
Unknown author
|
Unknown author
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
return ($webmention->type === 'like-of');
|
return ($webmention->type === 'like-of');
|
||||||
}) as $like)
|
}) as $like)
|
||||||
<a href="{{ $like['author']['properties']['url'][0] }}">
|
<a href="{{ $like['author']['properties']['url'][0] }}">
|
||||||
<img src="{{ $like['author']['properties']['photo'][0] }}" alt="profile picture of {{ $like['author']['properties']['name'][0] }}" class="like-photo">
|
<img src="{{ $like['author']['properties']['photo'][0] }}" alt="profile picture of {{ $like['author']['properties']['name'][0] ?? $like['author']['properties']['nickname'][0] ?? 'unknown' }}" class="like-photo">
|
||||||
</a>
|
</a>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
return ($webmention->type == 'repost-of');
|
return ($webmention->type == 'repost-of');
|
||||||
}) as $repost)
|
}) as $repost)
|
||||||
<a href="{{ $repost['source'] }}">
|
<a href="{{ $repost['source'] }}">
|
||||||
<img src="{{ $repost['author']['properties']['photo'][0] }}" alt="{{ $repost['author']['properties']['name'][0] }} reposted this at {{ $repost['published'] }}">
|
<img src="{{ $repost['author']['properties']['photo'][0] }}" alt="{{ $repost['author']['properties']['name'][0] ?? $repost['author']['properties']['nickname'][0] ?? 'unknown' }} reposted this at {{ $repost['published'] }}">
|
||||||
</a>
|
</a>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,16 +1,41 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
if ! type brotli &> /dev/null; then
|
if ! (( $+commands[fd] )) &> /dev/null; then
|
||||||
|
echo "fd not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! (( $+commands[brotli] )) &> /dev/null; then
|
||||||
echo "brotli not installed"
|
echo "brotli not installed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for file in ./public/assets/css/*.css
|
if ! (( $+commands[zstd] )) &> /dev/null; then
|
||||||
do
|
echo "zstd not installed"
|
||||||
brotli --force --quality=11 --output=$file.br -- $file
|
exit 1
|
||||||
done
|
fi
|
||||||
|
|
||||||
for file in ./public/assets/js/*.js
|
# Make .br files
|
||||||
do
|
fd --extension css --extension js --search-path ./public/assets --type f --exec brotli --force --best --output={}.br {}
|
||||||
brotli --force --quality=11 --output=$file.br -- $file
|
# Make .zst files
|
||||||
|
fd --extension css --extension js --search-path ./public/assets --type f --exec zstd --quiet --force --ultra -22 --exclude-compressed {} -o {}.zst
|
||||||
|
|
||||||
|
# Remove files that actually got bigger!
|
||||||
|
fd --extension br --extension zst --search-path ./public/assets --type f --exec sh -c '
|
||||||
|
for file; do
|
||||||
|
src="${file%.br}"
|
||||||
|
src="${src%.zst}"
|
||||||
|
if [ -f "$src" ]; then
|
||||||
|
# Get file sizes using stat with cross-platform compatibility
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
file_size=$(stat -f%z "$file")
|
||||||
|
src_size=$(stat -f%z "$src")
|
||||||
|
else
|
||||||
|
file_size=$(stat -c%s "$file")
|
||||||
|
src_size=$(stat -c%s "$src")
|
||||||
|
fi
|
||||||
|
# Compare sizes and rm compressed file if larger than the source
|
||||||
|
[ "$file_size" -ge "$src_size" ] && rm "$file"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
' _ {}
|
||||||
|
|
1
storage/app/.gitignore
vendored
1
storage/app/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
*
|
*
|
||||||
|
!private/
|
||||||
!public/
|
!public/
|
||||||
!.gitignore
|
!.gitignore
|
||||||
|
|
2
storage/app/private/.gitignore
vendored
Normal file
2
storage/app/private/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -12,7 +12,7 @@ class ExampleTest extends DuskTestCase
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testBasicExample()
|
public function test_basic_example()
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
$browser->visit('/')
|
$browser->visit('/')
|
||||||
|
|
|
@ -32,7 +32,7 @@ abstract class DuskTestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
$desiredCapabilities = DesiredCapabilities::chrome();
|
$desiredCapabilities = DesiredCapabilities::chrome();
|
||||||
|
|
||||||
$options = new ChromeOptions();
|
$options = new ChromeOptions;
|
||||||
$options->addArguments([
|
$options->addArguments([
|
||||||
'headless',
|
'headless',
|
||||||
'disable-gpu',
|
'disable-gpu',
|
||||||
|
|
|
@ -6,13 +6,14 @@ namespace Tests\Feature\Admin;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class AdminHomeControllerTest extends TestCase
|
class AdminHomeControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminHomepageLoads(): void
|
public function adminHomepageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
|
|
@ -5,25 +5,26 @@ declare(strict_types=1);
|
||||||
namespace Tests\Feature\Admin;
|
namespace Tests\Feature\Admin;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class AdminTest extends TestCase
|
class AdminTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminPageRedirectsUnauthorisedUsersToLoginPage(): void
|
public function adminPageRedirectsUnauthorisedUsersToLoginPage(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/admin');
|
$response = $this->get('/admin');
|
||||||
$response->assertRedirect('/login');
|
$response->assertRedirect('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function loginPageLoads(): void
|
public function loginPageLoads(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/login');
|
$response = $this->get('/login');
|
||||||
$response->assertViewIs('login');
|
$response->assertViewIs('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function loginAttemptWithBadCredentialsFails(): void
|
public function loginAttemptWithBadCredentialsFails(): void
|
||||||
{
|
{
|
||||||
$response = $this->post('/login', [
|
$response = $this->post('/login', [
|
||||||
|
@ -33,7 +34,7 @@ class AdminTest extends TestCase
|
||||||
$response->assertRedirect('/login');
|
$response->assertRedirect('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function loginSucceeds(): void
|
public function loginSucceeds(): void
|
||||||
{
|
{
|
||||||
User::factory([
|
User::factory([
|
||||||
|
@ -49,7 +50,7 @@ class AdminTest extends TestCase
|
||||||
$response->assertRedirect('/admin');
|
$response->assertRedirect('/admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function whenLoggedInRedirectsToAdminPage(): void
|
public function whenLoggedInRedirectsToAdminPage(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
@ -57,14 +58,14 @@ class AdminTest extends TestCase
|
||||||
$response->assertRedirect('/');
|
$response->assertRedirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function loggedOutUsersSimplyRedirected(): void
|
public function loggedOutUsersSimplyRedirected(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/logout');
|
$response = $this->get('/logout');
|
||||||
$response->assertRedirect('/');
|
$response->assertRedirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function loggedInUsersShownLogoutForm(): void
|
public function loggedInUsersShownLogoutForm(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
@ -72,7 +73,7 @@ class AdminTest extends TestCase
|
||||||
$response->assertViewIs('logout');
|
$response->assertViewIs('logout');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function loggedInUsersCanLogout(): void
|
public function loggedInUsersCanLogout(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\User;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ArticlesTest extends TestCase
|
class ArticlesTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminArticlesPageLoads(): void
|
public function adminArticlesPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -25,7 +26,7 @@ class ArticlesTest extends TestCase
|
||||||
$response->assertSeeText('Select article to edit:');
|
$response->assertSeeText('Select article to edit:');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanLoadFormToCreateArticle(): void
|
public function adminCanLoadFormToCreateArticle(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -35,7 +36,7 @@ class ArticlesTest extends TestCase
|
||||||
$response->assertSeeText('Title (URL)');
|
$response->assertSeeText('Title (URL)');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function admiNCanCreateNewArticle(): void
|
public function admiNCanCreateNewArticle(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -48,7 +49,7 @@ class ArticlesTest extends TestCase
|
||||||
$this->assertDatabaseHas('articles', ['title' => 'Test Title']);
|
$this->assertDatabaseHas('articles', ['title' => 'Test Title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateNewArticleWithFile(): void
|
public function adminCanCreateNewArticleWithFile(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -73,7 +74,7 @@ class ArticlesTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function articleCanLoadFormToEditArticle(): void
|
public function articleCanLoadFormToEditArticle(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -86,7 +87,7 @@ class ArticlesTest extends TestCase
|
||||||
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
|
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanEditArticle(): void
|
public function adminCanEditArticle(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -104,7 +105,7 @@ class ArticlesTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanDeleteArticle(): void
|
public function adminCanDeleteArticle(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
|
||||||
use App\Models\Bio;
|
use App\Models\Bio;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class BioTest extends TestCase
|
class BioTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminBiosPageLoads(): void
|
public function adminBiosPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -23,7 +24,7 @@ class BioTest extends TestCase
|
||||||
$response->assertSeeText('Edit bio');
|
$response->assertSeeText('Edit bio');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateBio(): void
|
public function adminCanCreateBio(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -36,7 +37,7 @@ class BioTest extends TestCase
|
||||||
$this->assertDatabaseHas('bios', ['content' => 'Bio content']);
|
$this->assertDatabaseHas('bios', ['content' => 'Bio content']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanLoadExistingBio(): void
|
public function adminCanLoadExistingBio(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -49,7 +50,7 @@ class BioTest extends TestCase
|
||||||
$response->assertSeeText('This is <em>my</em> bio. It uses <strong>HTML</strong>.');
|
$response->assertSeeText('This is <em>my</em> bio. It uses <strong>HTML</strong>.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanEditBio(): void
|
public function adminCanEditBio(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
|
||||||
use App\Models\MicropubClient;
|
use App\Models\MicropubClient;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ClientsTest extends TestCase
|
class ClientsTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function clientsPageLoads(): void
|
public function clientsPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -23,7 +24,7 @@ class ClientsTest extends TestCase
|
||||||
$response->assertSeeText('Clients');
|
$response->assertSeeText('Clients');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanLoadFormToCreateClient(): void
|
public function adminCanLoadFormToCreateClient(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -33,7 +34,7 @@ class ClientsTest extends TestCase
|
||||||
$response->assertSeeText('New Client');
|
$response->assertSeeText('New Client');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateNewClient(): void
|
public function adminCanCreateNewClient(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -49,7 +50,7 @@ class ClientsTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanLoadEditFormForClient(): void
|
public function adminCanLoadEditFormForClient(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -62,7 +63,7 @@ class ClientsTest extends TestCase
|
||||||
$response->assertSee('https://jbl5.dev/notes/new');
|
$response->assertSee('https://jbl5.dev/notes/new');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanEditClient(): void
|
public function adminCanEditClient(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -80,7 +81,7 @@ class ClientsTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanDeleteClient(): void
|
public function adminCanDeleteClient(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
|
|
@ -12,6 +12,7 @@ use GuzzleHttp\HandlerStack;
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ContactsTest extends TestCase
|
class ContactsTest extends TestCase
|
||||||
|
@ -27,7 +28,7 @@ class ContactsTest extends TestCase
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function contactIndexPageLoads(): void
|
public function contactIndexPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -36,7 +37,7 @@ class ContactsTest extends TestCase
|
||||||
$response->assertViewIs('admin.contacts.index');
|
$response->assertViewIs('admin.contacts.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function contactCreatePageLoads(): void
|
public function contactCreatePageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -45,7 +46,7 @@ class ContactsTest extends TestCase
|
||||||
$response->assertViewIs('admin.contacts.create');
|
$response->assertViewIs('admin.contacts.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateNewContact(): void
|
public function adminCanCreateNewContact(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -62,7 +63,7 @@ class ContactsTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanSeeFormToEditContact(): void
|
public function adminCanSeeFormToEditContact(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -72,7 +73,7 @@ class ContactsTest extends TestCase
|
||||||
$response->assertViewIs('admin.contacts.edit');
|
$response->assertViewIs('admin.contacts.edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanUpdateContact(): void
|
public function adminCanUpdateContact(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -91,7 +92,7 @@ class ContactsTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanEditContactAndUploadAvatar(): void
|
public function adminCanEditContactAndUploadAvatar(): void
|
||||||
{
|
{
|
||||||
copy(__DIR__ . '/../../aaron.png', sys_get_temp_dir() . '/tantek.png');
|
copy(__DIR__ . '/../../aaron.png', sys_get_temp_dir() . '/tantek.png');
|
||||||
|
@ -114,7 +115,7 @@ class ContactsTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanDeleteContact(): void
|
public function adminCanDeleteContact(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -132,7 +133,7 @@ class ContactsTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanTriggerRetrievalOfRemoteAvatar(): void
|
public function adminCanTriggerRetrievalOfRemoteAvatar(): void
|
||||||
{
|
{
|
||||||
$html = <<<'HTML'
|
$html = <<<'HTML'
|
||||||
|
@ -161,7 +162,7 @@ class ContactsTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function gettingRemoteAvatarFailsGracefullyWithRemoteNotFound(): void
|
public function gettingRemoteAvatarFailsGracefullyWithRemoteNotFound(): void
|
||||||
{
|
{
|
||||||
$mock = new MockHandler([
|
$mock = new MockHandler([
|
||||||
|
@ -178,7 +179,7 @@ class ContactsTest extends TestCase
|
||||||
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
|
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function gettingRemoteAvatarFailsGracefullyWithRemoteError(): void
|
public function gettingRemoteAvatarFailsGracefullyWithRemoteError(): void
|
||||||
{
|
{
|
||||||
$html = <<<'HTML'
|
$html = <<<'HTML'
|
||||||
|
@ -201,7 +202,7 @@ class ContactsTest extends TestCase
|
||||||
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
|
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function gettingRemoteAvatarFailsGracefullyForContactWithNoHompage(): void
|
public function gettingRemoteAvatarFailsGracefullyForContactWithNoHompage(): void
|
||||||
{
|
{
|
||||||
$contact = Contact::create([
|
$contact = Contact::create([
|
||||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\Like;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class LikesTest extends TestCase
|
class LikesTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likesPageLoads(): void
|
public function likesPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -25,7 +26,7 @@ class LikesTest extends TestCase
|
||||||
$response->assertSeeText('Likes');
|
$response->assertSeeText('Likes');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likeCreateFormLoads(): void
|
public function likeCreateFormLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -35,7 +36,7 @@ class LikesTest extends TestCase
|
||||||
$response->assertSeeText('New Like');
|
$response->assertSeeText('New Like');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateLike(): void
|
public function adminCanCreateLike(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -51,7 +52,7 @@ class LikesTest extends TestCase
|
||||||
Queue::assertPushed(ProcessLike::class);
|
Queue::assertPushed(ProcessLike::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likeEditFormLoads(): void
|
public function likeEditFormLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -62,7 +63,7 @@ class LikesTest extends TestCase
|
||||||
$response->assertSee('Edit Like');
|
$response->assertSee('Edit Like');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanEditLike(): void
|
public function adminCanEditLike(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -80,7 +81,7 @@ class LikesTest extends TestCase
|
||||||
Queue::assertPushed(ProcessLike::class);
|
Queue::assertPushed(ProcessLike::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanDeleteLike(): void
|
public function adminCanDeleteLike(): void
|
||||||
{
|
{
|
||||||
$like = Like::factory()->create();
|
$like = Like::factory()->create();
|
||||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\Note;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class NotesTest extends TestCase
|
class NotesTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function notesPageLoads(): void
|
public function notesPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -24,7 +25,7 @@ class NotesTest extends TestCase
|
||||||
$response->assertViewIs('admin.notes.index');
|
$response->assertViewIs('admin.notes.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function noteCreatePageLoads(): void
|
public function noteCreatePageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -33,7 +34,7 @@ class NotesTest extends TestCase
|
||||||
$response->assertViewIs('admin.notes.create');
|
$response->assertViewIs('admin.notes.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateNewNote(): void
|
public function adminCanCreateNewNote(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -47,7 +48,7 @@ class NotesTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function noteEditFormLoads(): void
|
public function noteEditFormLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -57,7 +58,7 @@ class NotesTest extends TestCase
|
||||||
$response->assertViewIs('admin.notes.edit');
|
$response->assertViewIs('admin.notes.edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanEditNote(): void
|
public function adminCanEditNote(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -76,7 +77,7 @@ class NotesTest extends TestCase
|
||||||
Queue::assertPushed(SendWebMentions::class);
|
Queue::assertPushed(SendWebMentions::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanDeleteNote(): void
|
public function adminCanDeleteNote(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
|
|
@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
|
||||||
use App\Models\Place;
|
use App\Models\Place;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class PlacesTest extends TestCase
|
class PlacesTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function placesPageLoads(): void
|
public function placesPageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -22,7 +23,7 @@ class PlacesTest extends TestCase
|
||||||
$response->assertViewIs('admin.places.index');
|
$response->assertViewIs('admin.places.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function createPlacePageLoads(): void
|
public function createPlacePageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -31,7 +32,7 @@ class PlacesTest extends TestCase
|
||||||
$response->assertViewIs('admin.places.create');
|
$response->assertViewIs('admin.places.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanCreateNewPlace(): void
|
public function adminCanCreateNewPlace(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -48,7 +49,7 @@ class PlacesTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function editPlacePageLoads(): void
|
public function editPlacePageLoads(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
@ -58,7 +59,7 @@ class PlacesTest extends TestCase
|
||||||
$response->assertViewIs('admin.places.edit');
|
$response->assertViewIs('admin.places.edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function adminCanUpdatePlace(): void
|
public function adminCanUpdatePlace(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->make();
|
$user = User::factory()->make();
|
||||||
|
|
|
@ -7,20 +7,21 @@ namespace Tests\Feature;
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ArticlesTest extends TestCase
|
class ArticlesTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function articlesPageLoads(): void
|
public function articlesPageLoads(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/blog');
|
$response = $this->get('/blog');
|
||||||
$response->assertViewIs('articles.index');
|
$response->assertViewIs('articles.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function singleArticlePageLoads()
|
public function singleArticlePageLoads()
|
||||||
{
|
{
|
||||||
$article = Article::factory()->create();
|
$article = Article::factory()->create();
|
||||||
|
@ -28,7 +29,7 @@ class ArticlesTest extends TestCase
|
||||||
$response->assertViewIs('articles.show');
|
$response->assertViewIs('articles.show');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function wrongDateInUrlRedirectsToCorrectDate()
|
public function wrongDateInUrlRedirectsToCorrectDate()
|
||||||
{
|
{
|
||||||
$article = Article::factory()->create();
|
$article = Article::factory()->create();
|
||||||
|
@ -36,7 +37,7 @@ class ArticlesTest extends TestCase
|
||||||
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/' . $article->titleurl);
|
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/' . $article->titleurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function oldUrlsWithIdAreRedirected()
|
public function oldUrlsWithIdAreRedirected()
|
||||||
{
|
{
|
||||||
$article = Article::factory()->create();
|
$article = Article::factory()->create();
|
||||||
|
@ -45,21 +46,21 @@ class ArticlesTest extends TestCase
|
||||||
$response->assertRedirect($article->link);
|
$response->assertRedirect($article->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function unknownSlugGetsNotFoundResponse()
|
public function unknownSlugGetsNotFoundResponse()
|
||||||
{
|
{
|
||||||
$response = $this->get('/blog/' . date('Y') . '/' . date('m') . '/unknown-slug');
|
$response = $this->get('/blog/' . date('Y') . '/' . date('m') . '/unknown-slug');
|
||||||
$response->assertNotFound();
|
$response->assertNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function unknownArticleIdGetsNotFoundResponse()
|
public function unknownArticleIdGetsNotFoundResponse()
|
||||||
{
|
{
|
||||||
$response = $this->get('/blog/s/22');
|
$response = $this->get('/blog/s/22');
|
||||||
$response->assertNotFound();
|
$response->assertNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function someUrlsDoNotParseCorrectly(): void
|
public function someUrlsDoNotParseCorrectly(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/blog/feed.js');
|
$response = $this->get('/blog/feed.js');
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Jobs\ProcessBookmark;
|
||||||
use App\Models\Bookmark;
|
use App\Models\Bookmark;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -15,14 +16,14 @@ class BookmarksTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase, TestToken;
|
use RefreshDatabase, TestToken;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function bookmarksPageLoadsWithoutError(): void
|
public function bookmarksPageLoadsWithoutError(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/bookmarks');
|
$response = $this->get('/bookmarks');
|
||||||
$response->assertViewIs('bookmarks.index');
|
$response->assertViewIs('bookmarks.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function singleBookmarkPageLoadsWithoutError(): void
|
public function singleBookmarkPageLoadsWithoutError(): void
|
||||||
{
|
{
|
||||||
$bookmark = Bookmark::factory()->create();
|
$bookmark = Bookmark::factory()->create();
|
||||||
|
@ -30,7 +31,7 @@ class BookmarksTest extends TestCase
|
||||||
$response->assertViewIs('bookmarks.show');
|
$response->assertViewIs('bookmarks.show');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function whenBookmarkIsAddedUsingHttpSyntaxCheckJobToTakeScreenshotIsInvoked(): void
|
public function whenBookmarkIsAddedUsingHttpSyntaxCheckJobToTakeScreenshotIsInvoked(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -48,7 +49,7 @@ class BookmarksTest extends TestCase
|
||||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function whenBookmarkIsAddedUsingJsonSyntaxCheckJobToTakeScreenshotIsInvoked(): void
|
public function whenBookmarkIsAddedUsingJsonSyntaxCheckJobToTakeScreenshotIsInvoked(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -68,7 +69,7 @@ class BookmarksTest extends TestCase
|
||||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function whenTheBookmarkIsCreatedCheckNecessaryTagsAreAlsoCreated(): void
|
public function whenTheBookmarkIsCreatedCheckNecessaryTagsAreAlsoCreated(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ContactsTest extends TestCase
|
class ContactsTest extends TestCase
|
||||||
|
@ -14,9 +15,8 @@ class ContactsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the `/contacts` page gives a good response.
|
* Check the `/contacts` page gives a good response.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function contactsPageLoadsWithoutError(): void
|
public function contactsPageLoadsWithoutError(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/contacts');
|
$response = $this->get('/contacts');
|
||||||
|
@ -25,9 +25,8 @@ class ContactsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test an individual contact page with default profile image.
|
* Test an individual contact page with default profile image.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function contactPageShouldFallbackToDefaultProfilePic(): void
|
public function contactPageShouldFallbackToDefaultProfilePic(): void
|
||||||
{
|
{
|
||||||
Contact::factory()->create([
|
Contact::factory()->create([
|
||||||
|
@ -39,9 +38,8 @@ class ContactsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test an individual contact page with a specific profile image.
|
* Test an individual contact page with a specific profile image.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function contactPageShouldUseSpecificProfilePicIfPresent(): void
|
public function contactPageShouldUseSpecificProfilePicIfPresent(): void
|
||||||
{
|
{
|
||||||
Contact::factory()->create([
|
Contact::factory()->create([
|
||||||
|
@ -52,7 +50,7 @@ class ContactsTest extends TestCase
|
||||||
$response->assertViewHas('image', '/assets/profile-images/aaronparecki.com/image');
|
$response->assertViewHas('image', '/assets/profile-images/aaronparecki.com/image');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function unknownContactReturnsNotFoundResponse(): void
|
public function unknownContactReturnsNotFoundResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/contacts/unknown');
|
$response = $this->get('/contacts/unknown');
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ class CorsHeadersTest extends TestCase
|
||||||
{
|
{
|
||||||
use TestToken;
|
use TestToken;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function checkCorsHeadersOnMediaEndpoint(): void
|
public function checkCorsHeadersOnMediaEndpoint(): void
|
||||||
{
|
{
|
||||||
$response = $this->call(
|
$response = $this->call(
|
||||||
|
@ -25,7 +26,7 @@ class CorsHeadersTest extends TestCase
|
||||||
$response->assertHeader('Access-Control-Allow-Origin', '*');
|
$response->assertHeader('Access-Control-Allow-Origin', '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function checkForNoCorsHeaderOnNonMediaEndpointLinks(): void
|
public function checkForNoCorsHeaderOnNonMediaEndpointLinks(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/blog');
|
$response = $this->get('/blog');
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Models\Article;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use App\Models\Place;
|
use App\Models\Place;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class FeedsTest extends TestCase
|
class FeedsTest extends TestCase
|
||||||
|
@ -16,9 +17,8 @@ class FeedsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the blog RSS feed.
|
* Test the blog RSS feed.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function blogRssFeedIsPresent(): void
|
public function blogRssFeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Article::factory()->count(3)->create();
|
Article::factory()->count(3)->create();
|
||||||
|
@ -29,9 +29,8 @@ class FeedsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the notes RSS feed.
|
* Test the notes RSS feed.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function notesRssFeedIsPresent(): void
|
public function notesRssFeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Note::factory()->count(3)->create();
|
Note::factory()->count(3)->create();
|
||||||
|
@ -42,9 +41,8 @@ class FeedsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the blog RSS feed.
|
* Test the blog RSS feed.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function blogAtomFeedIsPresent(): void
|
public function blogAtomFeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Article::factory()->count(3)->create();
|
Article::factory()->count(3)->create();
|
||||||
|
@ -53,7 +51,7 @@ class FeedsTest extends TestCase
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function blogJf2FeedIsPresent(): void
|
public function blogJf2FeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Article::factory()->count(3)->create();
|
Article::factory()->count(3)->create();
|
||||||
|
@ -77,9 +75,8 @@ class FeedsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the notes RSS feed.
|
* Test the notes RSS feed.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function notesAtomFeedIsPresent(): void
|
public function notesAtomFeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Note::factory()->count(3)->create();
|
Note::factory()->count(3)->create();
|
||||||
|
@ -90,9 +87,8 @@ class FeedsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the blog JSON feed.
|
* Test the blog JSON feed.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function blogJsonFeedIsPresent(): void
|
public function blogJsonFeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Article::factory()->count(3)->create();
|
Article::factory()->count(3)->create();
|
||||||
|
@ -103,9 +99,8 @@ class FeedsTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the notes JSON feed.
|
* Test the notes JSON feed.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function notesJsonFeedIsPresent(): void
|
public function notesJsonFeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Note::factory()->count(3)->create();
|
Note::factory()->count(3)->create();
|
||||||
|
@ -114,7 +109,7 @@ class FeedsTest extends TestCase
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function notesJf2FeedIsPresent(): void
|
public function notesJf2FeedIsPresent(): void
|
||||||
{
|
{
|
||||||
Note::factory()->count(3)->create();
|
Note::factory()->count(3)->create();
|
||||||
|
@ -139,9 +134,8 @@ class FeedsTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Each JSON feed item must have one of `content_text` or `content_html`,
|
* Each JSON feed item must have one of `content_text` or `content_html`,
|
||||||
* and whichever one they have can’t be `null`.
|
* and whichever one they have can’t be `null`.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function jsonFeedsHaveRequiredAttributes(): void
|
public function jsonFeedsHaveRequiredAttributes(): void
|
||||||
{
|
{
|
||||||
Note::factory()->count(3)->create();
|
Note::factory()->count(3)->create();
|
||||||
|
@ -161,7 +155,7 @@ class FeedsTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function jsonNoteFeedLoadsPlaceDataWithoutLazyLoading(): void
|
public function jsonNoteFeedLoadsPlaceDataWithoutLazyLoading(): void
|
||||||
{
|
{
|
||||||
$place = Place::factory()->create();
|
$place = Place::factory()->create();
|
||||||
|
|
|
@ -7,13 +7,14 @@ use App\Models\Bookmark;
|
||||||
use App\Models\Like;
|
use App\Models\Like;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class FrontPageTest extends TestCase
|
class FrontPageTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function frontPageLoadsAllContent(): void
|
public function frontPageLoadsAllContent(): void
|
||||||
{
|
{
|
||||||
Note::factory()->create(['note' => 'Note 1']);
|
Note::factory()->create(['note' => 'Note 1']);
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class HorizonTest extends TestCase
|
class HorizonTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Horizon has its own test suite, here we just test it has been installed successfully.
|
* Horizon has its own test suite, here we just test it has been installed successfully.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function horizonIsInstalled(): void
|
public function horizonIsInstalled(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create([
|
$user = User::factory()->create([
|
||||||
|
|
|
@ -14,6 +14,7 @@ use GuzzleHttp\Psr7\Response;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -22,14 +23,14 @@ class LikesTest extends TestCase
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
use TestToken;
|
use TestToken;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likesPageHasCorrectView(): void
|
public function likesPageHasCorrectView(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/likes');
|
$response = $this->get('/likes');
|
||||||
$response->assertViewIs('likes.index');
|
$response->assertViewIs('likes.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function singleLikePageHasCorrectView(): void
|
public function singleLikePageHasCorrectView(): void
|
||||||
{
|
{
|
||||||
$like = Like::factory()->create();
|
$like = Like::factory()->create();
|
||||||
|
@ -37,7 +38,7 @@ class LikesTest extends TestCase
|
||||||
$response->assertViewIs('likes.show');
|
$response->assertViewIs('likes.show');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function checkLikeCreatedFromMicropubApiRequests(): void
|
public function checkLikeCreatedFromMicropubApiRequests(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -57,7 +58,7 @@ class LikesTest extends TestCase
|
||||||
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function checkLikeCreatedFromMicropubWebRequests(): void
|
public function checkLikeCreatedFromMicropubWebRequests(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -75,10 +76,10 @@ class LikesTest extends TestCase
|
||||||
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likeWithSimpleAuthor(): void
|
public function likeWithSimpleAuthor(): void
|
||||||
{
|
{
|
||||||
$like = new Like();
|
$like = new Like;
|
||||||
$like->url = 'http://example.org/note/id';
|
$like->url = 'http://example.org/note/id';
|
||||||
$like->save();
|
$like->save();
|
||||||
$id = $like->id;
|
$id = $like->id;
|
||||||
|
@ -107,17 +108,17 @@ class LikesTest extends TestCase
|
||||||
$this->app->bind(Client::class, function () use ($client) {
|
$this->app->bind(Client::class, function () use ($client) {
|
||||||
return $client;
|
return $client;
|
||||||
});
|
});
|
||||||
$authorship = new Authorship();
|
$authorship = new Authorship;
|
||||||
|
|
||||||
$job->handle($client, $authorship);
|
$job->handle($client, $authorship);
|
||||||
|
|
||||||
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
|
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likeWithHCard(): void
|
public function likeWithHCard(): void
|
||||||
{
|
{
|
||||||
$like = new Like();
|
$like = new Like;
|
||||||
$like->url = 'http://example.org/note/id';
|
$like->url = 'http://example.org/note/id';
|
||||||
$like->save();
|
$like->save();
|
||||||
$id = $like->id;
|
$id = $like->id;
|
||||||
|
@ -150,17 +151,17 @@ class LikesTest extends TestCase
|
||||||
$this->app->bind(Client::class, function () use ($client) {
|
$this->app->bind(Client::class, function () use ($client) {
|
||||||
return $client;
|
return $client;
|
||||||
});
|
});
|
||||||
$authorship = new Authorship();
|
$authorship = new Authorship;
|
||||||
|
|
||||||
$job->handle($client, $authorship);
|
$job->handle($client, $authorship);
|
||||||
|
|
||||||
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
|
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likeWithoutMicroformats(): void
|
public function likeWithoutMicroformats(): void
|
||||||
{
|
{
|
||||||
$like = new Like();
|
$like = new Like;
|
||||||
$like->url = 'http://example.org/note/id';
|
$like->url = 'http://example.org/note/id';
|
||||||
$like->save();
|
$like->save();
|
||||||
$id = $like->id;
|
$id = $like->id;
|
||||||
|
@ -186,17 +187,17 @@ class LikesTest extends TestCase
|
||||||
$this->app->bind(Client::class, function () use ($client) {
|
$this->app->bind(Client::class, function () use ($client) {
|
||||||
return $client;
|
return $client;
|
||||||
});
|
});
|
||||||
$authorship = new Authorship();
|
$authorship = new Authorship;
|
||||||
|
|
||||||
$job->handle($client, $authorship);
|
$job->handle($client, $authorship);
|
||||||
|
|
||||||
$this->assertNull(Like::find($id)->author_name);
|
$this->assertNull(Like::find($id)->author_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function likeThatIsATweet(): void
|
public function likeThatIsATweet(): void
|
||||||
{
|
{
|
||||||
$like = new Like();
|
$like = new Like;
|
||||||
$like->url = 'https://twitter.com/jonnybarnes/status/1050823255123251200';
|
$like->url = 'https://twitter.com/jonnybarnes/status/1050823255123251200';
|
||||||
$like->save();
|
$like->save();
|
||||||
$id = $like->id;
|
$id = $like->id;
|
||||||
|
@ -219,24 +220,23 @@ class LikesTest extends TestCase
|
||||||
'author_url' => 'https://twitter.com/jonnybarnes',
|
'author_url' => 'https://twitter.com/jonnybarnes',
|
||||||
'html' => '<div>HTML of the tweet embed</div>',
|
'html' => '<div>HTML of the tweet embed</div>',
|
||||||
];
|
];
|
||||||
$codebirdMock = $this->getMockBuilder(Codebird::class)
|
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
|
||||||
->addMethods(['statuses_oembed'])
|
$codebirdMock->method('__call')
|
||||||
->getMock();
|
->with('statuses_oembed', $this->anything())
|
||||||
$codebirdMock->method('statuses_oembed')
|
|
||||||
->willReturn($info);
|
->willReturn($info);
|
||||||
$this->app->instance(Codebird::class, $codebirdMock);
|
$this->app->instance(Codebird::class, $codebirdMock);
|
||||||
|
|
||||||
$authorship = new Authorship();
|
$authorship = new Authorship;
|
||||||
|
|
||||||
$job->handle($client, $authorship);
|
$job->handle($client, $authorship);
|
||||||
|
|
||||||
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
|
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function noErrorForFailureToPosseWithBridgy(): void
|
public function noErrorForFailureToPosseWithBridgy(): void
|
||||||
{
|
{
|
||||||
$like = new Like();
|
$like = new Like;
|
||||||
$like->url = 'https://twitter.com/jonnybarnes/status/1050823255123251200';
|
$like->url = 'https://twitter.com/jonnybarnes/status/1050823255123251200';
|
||||||
$like->save();
|
$like->save();
|
||||||
$id = $like->id;
|
$id = $like->id;
|
||||||
|
@ -257,21 +257,20 @@ class LikesTest extends TestCase
|
||||||
'author_url' => 'https://twitter.com/jonnybarnes',
|
'author_url' => 'https://twitter.com/jonnybarnes',
|
||||||
'html' => '<div>HTML of the tweet embed</div>',
|
'html' => '<div>HTML of the tweet embed</div>',
|
||||||
];
|
];
|
||||||
$codebirdMock = $this->getMockBuilder(Codebird::class)
|
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
|
||||||
->addMethods(['statuses_oembed'])
|
$codebirdMock->method('__call')
|
||||||
->getMock();
|
->with('statuses_oembed', $this->anything())
|
||||||
$codebirdMock->method('statuses_oembed')
|
|
||||||
->willReturn($info);
|
->willReturn($info);
|
||||||
$this->app->instance(Codebird::class, $codebirdMock);
|
$this->app->instance(Codebird::class, $codebirdMock);
|
||||||
|
|
||||||
$authorship = new Authorship();
|
$authorship = new Authorship;
|
||||||
|
|
||||||
$job->handle($client, $authorship);
|
$job->handle($client, $authorship);
|
||||||
|
|
||||||
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
|
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function unknownLikeGivesNotFoundResponse(): void
|
public function unknownLikeGivesNotFoundResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/likes/202');
|
$response = $this->get('/likes/202');
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Carbon\Carbon;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ class MicropubControllerTest extends TestCase
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
use TestToken;
|
use TestToken;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubGetRequestWithoutTokenReturnsErrorResponse(): void
|
public function micropubGetRequestWithoutTokenReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/api/post');
|
$response = $this->get('/api/post');
|
||||||
|
@ -31,7 +32,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$response->assertJsonFragment(['error_description' => 'No access token was provided in the request']);
|
$response->assertJsonFragment(['error_description' => 'No access token was provided in the request']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubGetRequestWithoutValidTokenReturnsErrorResponse(): void
|
public function micropubGetRequestWithoutValidTokenReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer abc123']);
|
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer abc123']);
|
||||||
|
@ -42,9 +43,8 @@ class MicropubControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test a GET request for the micropub endpoint with a valid token gives a
|
* Test a GET request for the micropub endpoint with a valid token gives a
|
||||||
* 200 response. Check token information is also returned in the response.
|
* 200 response. Check token information is also returned in the response.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubGetRequestWithValidTokenReturnsOkResponse(): void
|
public function micropubGetRequestWithValidTokenReturnsOkResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
|
@ -52,14 +52,14 @@ class MicropubControllerTest extends TestCase
|
||||||
$response->assertJsonFragment(['response' => 'token']);
|
$response->assertJsonFragment(['response' => 'token']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientsCanRequestSyndicationTargetsCanBeEmpty(): void
|
public function micropubClientsCanRequestSyndicationTargetsCanBeEmpty(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/api/post?q=syndicate-to', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$response = $this->get('/api/post?q=syndicate-to', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
$response->assertJsonFragment(['syndicate-to' => []]);
|
$response->assertJsonFragment(['syndicate-to' => []]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientsCanRequestSyndicationTargetsPopulatesFromModel(): void
|
public function micropubClientsCanRequestSyndicationTargetsPopulatesFromModel(): void
|
||||||
{
|
{
|
||||||
$syndicationTarget = SyndicationTarget::factory()->create();
|
$syndicationTarget = SyndicationTarget::factory()->create();
|
||||||
|
@ -67,7 +67,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$response->assertJsonFragment(['uid' => $syndicationTarget->uid]);
|
$response->assertJsonFragment(['uid' => $syndicationTarget->uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientsCanRequestKnownNearbyPlaces(): void
|
public function micropubClientsCanRequestKnownNearbyPlaces(): void
|
||||||
{
|
{
|
||||||
Place::factory()->create([
|
Place::factory()->create([
|
||||||
|
@ -80,8 +80,6 @@ class MicropubControllerTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @todo Add uncertainty parameter
|
* @todo Add uncertainty parameter
|
||||||
*
|
*
|
||||||
public function micropubClientsCanRequestKnownNearbyPlacesWithUncertaintyParameter(): void
|
public function micropubClientsCanRequestKnownNearbyPlacesWithUncertaintyParameter(): void
|
||||||
|
@ -89,22 +87,21 @@ class MicropubControllerTest extends TestCase
|
||||||
$response = $this->get('/api/post?q=geo:53.5,-2.38', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$response = $this->get('/api/post?q=geo:53.5,-2.38', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
$response->assertJson(['places' => [['slug' => 'the-bridgewater-pub']]]);
|
$response->assertJson(['places' => [['slug' => 'the-bridgewater-pub']]]);
|
||||||
}*/
|
}*/
|
||||||
|
#[Test]
|
||||||
/** @test */
|
|
||||||
public function returnEmptyResultWhenMicropubClientRequestsKnownNearbyPlaces(): void
|
public function returnEmptyResultWhenMicropubClientRequestsKnownNearbyPlaces(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/api/post?q=geo:1.23,4.56', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$response = $this->get('/api/post?q=geo:1.23,4.56', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
$response->assertJson(['places' => []]);
|
$response->assertJson(['places' => []]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientCanRequestEndpointConfig(): void
|
public function micropubClientCanRequestEndpointConfig(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/api/post?q=config', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$response = $this->get('/api/post?q=config', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
$response->assertJsonFragment(['media-endpoint' => route('media-endpoint')]);
|
$response->assertJsonFragment(['media-endpoint' => route('media-endpoint')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientCanCreateNewNote(): void
|
public function micropubClientCanCreateNewNote(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -123,7 +120,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$this->assertDatabaseHas('notes', ['note' => $note]);
|
$this->assertDatabaseHas('notes', ['note' => $note]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientCanRequestTheNewNoteIsSyndicatedToMastodonAndBluesky(): void
|
public function micropubClientCanRequestTheNewNoteIsSyndicatedToMastodonAndBluesky(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -157,7 +154,7 @@ class MicropubControllerTest extends TestCase
|
||||||
Queue::assertPushed(SyndicateNoteToBluesky::class);
|
Queue::assertPushed(SyndicateNoteToBluesky::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientsCanCreateNewPlaces(): void
|
public function micropubClientsCanCreateNewPlaces(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -173,7 +170,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
|
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientsCanCreateNewPlacesWithOldLocationSyntax(): void
|
public function micropubClientsCanCreateNewPlacesWithOldLocationSyntax(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -190,7 +187,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
|
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientWebRequestWithInvalidTokenReturnsErrorResponse(): void
|
public function micropubClientWebRequestWithInvalidTokenReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -205,7 +202,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$response->assertJson(['error' => 'invalid_token']);
|
$response->assertJson(['error' => 'invalid_token']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientWebRequestWithTokenWithoutAnyScopesReturnsErrorResponse(): void
|
public function micropubClientWebRequestWithTokenWithoutAnyScopesReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -220,7 +217,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$response->assertJson(['error_description' => 'The provided token has no scopes']);
|
$response->assertJson(['error_description' => 'The provided token has no scopes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientWebRequestWithTokenWithoutCreateScopesReturnsErrorResponse(): void
|
public function micropubClientWebRequestWithTokenWithoutCreateScopesReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -238,9 +235,8 @@ class MicropubControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a valid micropub requests using JSON syntax creates a new note.
|
* Test a valid micropub requests using JSON syntax creates a new note.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesNewNote(): void
|
public function micropubClientApiRequestCreatesNewNote(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -286,12 +282,11 @@ class MicropubControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test a valid micropub requests using JSON syntax creates a new note with
|
* Test a valid micropub requests using JSON syntax creates a new note with
|
||||||
* existing self-created place.
|
* existing self-created place.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesNewNoteWithExistingPlaceInLocationData(): void
|
public function micropubClientApiRequestCreatesNewNoteWithExistingPlaceInLocationData(): void
|
||||||
{
|
{
|
||||||
$place = new Place();
|
$place = new Place;
|
||||||
$place->name = 'Test Place';
|
$place->name = 'Test Place';
|
||||||
$place->latitude = 1.23;
|
$place->latitude = 1.23;
|
||||||
$place->longitude = 4.56;
|
$place->longitude = 4.56;
|
||||||
|
@ -317,9 +312,8 @@ class MicropubControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test a valid micropub requests using JSON syntax creates a new note with
|
* Test a valid micropub requests using JSON syntax creates a new note with
|
||||||
* a new place defined in the location block.
|
* a new place defined in the location block.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesNewNoteWithNewPlaceInLocationData(): void
|
public function micropubClientApiRequestCreatesNewNoteWithNewPlaceInLocationData(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -353,9 +347,8 @@ class MicropubControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test a valid micropub requests using JSON syntax creates a new note without
|
* Test a valid micropub requests using JSON syntax creates a new note without
|
||||||
* a new place defined in the location block if there is missing data.
|
* a new place defined in the location block if there is missing data.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesNewNoteWithoutNewPlaceInLocationData(): void
|
public function micropubClientApiRequestCreatesNewNoteWithoutNewPlaceInLocationData(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -387,9 +380,8 @@ class MicropubControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test a micropub requests using JSON syntax without a token returns an
|
* Test a micropub requests using JSON syntax without a token returns an
|
||||||
* error. Also check the message.
|
* error. Also check the message.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubClientApiRequestWithoutTokenReturnsError(): void
|
public function micropubClientApiRequestWithoutTokenReturnsError(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -414,9 +406,8 @@ class MicropubControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test a micropub requests using JSON syntax without a valid token returns
|
* Test a micropub requests using JSON syntax without a valid token returns
|
||||||
* an error. Also check the message.
|
* an error. Also check the message.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function micropubClientApiRequestWithTokenWithInsufficientPermissionReturnsError(): void
|
public function micropubClientApiRequestWithTokenWithInsufficientPermissionReturnsError(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -439,7 +430,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(401);
|
->assertStatus(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestForUnsupportedPostTypeReturnsError(): void
|
public function micropubClientApiRequestForUnsupportedPostTypeReturnsError(): void
|
||||||
{
|
{
|
||||||
$response = $this->postJson(
|
$response = $this->postJson(
|
||||||
|
@ -460,7 +451,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(500);
|
->assertStatus(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesNewPlace(): void
|
public function micropubClientApiRequestCreatesNewPlace(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -480,7 +471,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(201);
|
->assertStatus(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesNewPlaceWithUncertaintyParameter(): void
|
public function micropubClientApiRequestCreatesNewPlaceWithUncertaintyParameter(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -500,7 +491,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(201);
|
->assertStatus(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestUpdatesExistingNote(): void
|
public function micropubClientApiRequestUpdatesExistingNote(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -520,7 +511,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestUpdatesNoteSyndicationLinks(): void
|
public function micropubClientApiRequestUpdatesNoteSyndicationLinks(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -547,7 +538,7 @@ class MicropubControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestAddsImageToNote(): void
|
public function micropubClientApiRequestAddsImageToNote(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -570,7 +561,7 @@ class MicropubControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonNoteModel(): void
|
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonNoteModel(): void
|
||||||
{
|
{
|
||||||
$response = $this->postJson(
|
$response = $this->postJson(
|
||||||
|
@ -589,7 +580,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(500);
|
->assertStatus(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonExistingNote(): void
|
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonExistingNote(): void
|
||||||
{
|
{
|
||||||
$response = $this->postJson(
|
$response = $this->postJson(
|
||||||
|
@ -608,7 +599,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(404);
|
->assertStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestReturnsErrorWhenTryingToUpdateUnsupportedProperty(): void
|
public function micropubClientApiRequestReturnsErrorWhenTryingToUpdateUnsupportedProperty(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -628,7 +619,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertStatus(500);
|
->assertStatus(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestWithTokenWithInsufficientScopeReturnsError(): void
|
public function micropubClientApiRequestWithTokenWithInsufficientScopeReturnsError(): void
|
||||||
{
|
{
|
||||||
$response = $this->postJson(
|
$response = $this->postJson(
|
||||||
|
@ -647,7 +638,7 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertJson(['error' => 'insufficient_scope']);
|
->assertJson(['error' => 'insufficient_scope']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestCanReplaceNoteSyndicationTargets(): void
|
public function micropubClientApiRequestCanReplaceNoteSyndicationTargets(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -674,7 +665,7 @@ class MicropubControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientWebRequestCanEncodeTokenWithinTheForm(): void
|
public function micropubClientWebRequestCanEncodeTokenWithinTheForm(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
@ -692,7 +683,7 @@ class MicropubControllerTest extends TestCase
|
||||||
$this->assertDatabaseHas('notes', ['note' => $note]);
|
$this->assertDatabaseHas('notes', ['note' => $note]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function micropubClientApiRequestCreatesArticlesWhenItIncludesTheNameProperty(): void
|
public function micropubClientApiRequestCreatesArticlesWhenItIncludesTheNameProperty(): void
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
|
|
@ -10,6 +10,8 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -18,13 +20,11 @@ class MicropubMediaTest extends TestCase
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
use TestToken;
|
use TestToken;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function emptyResponseForLastUploadWhenNoneFound(): void
|
public function emptyResponseForLastUploadWhenNoneFound(): void
|
||||||
{
|
{
|
||||||
// Make sure there’s no media
|
// Make sure there’s no media
|
||||||
Media::all()->each(function ($media) {
|
$this->assertCount(0, Media::all());
|
||||||
$media->delete();
|
|
||||||
});
|
|
||||||
|
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
'/api/media?q=last',
|
'/api/media?q=last',
|
||||||
|
@ -34,7 +34,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJson(['url' => null]);
|
$response->assertJson(['url' => null]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function getRequestWithInvalidTokenReturnsErrorResponse(): void
|
public function getRequestWithInvalidTokenReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
|
@ -45,7 +45,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJsonFragment(['error_description' => 'The provided token did not pass validation']);
|
$response->assertJsonFragment(['error_description' => 'The provided token did not pass validation']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function getRequestWithTokenWithoutScopeReturnsErrorResponse(): void
|
public function getRequestWithTokenWithoutScopeReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
|
@ -56,7 +56,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJsonFragment(['error_description' => 'The provided token has no scopes']);
|
$response->assertJsonFragment(['error_description' => 'The provided token has no scopes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function getRequestWithTokenWithInsufficientScopeReturnsErrorResponse(): void
|
public function getRequestWithTokenWithInsufficientScopeReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
|
@ -67,7 +67,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJsonFragment(['error_description' => 'The token’s scope does not have the necessary requirements.']);
|
$response->assertJsonFragment(['error_description' => 'The token’s scope does not have the necessary requirements.']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function emptyGetRequestWithTokenReceivesOkResponse(): void
|
public function emptyGetRequestWithTokenReceivesOkResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
|
@ -78,14 +78,12 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJson(['status' => 'OK']);
|
$response->assertJson(['status' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function clientCanListLastUpload(): void
|
public function clientCanListLastUpload(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
$file = __DIR__ . '/../aaron.png';
|
$file = __DIR__ . '/../aaron.png';
|
||||||
$token = $this->getToken();
|
$token = $this->getToken();
|
||||||
config(['filesystems.disks.s3.url' => 'https://s3.example.com']);
|
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
'/api/media',
|
'/api/media',
|
||||||
|
@ -95,12 +93,8 @@ class MicropubMediaTest extends TestCase
|
||||||
['HTTP_Authorization' => 'Bearer ' . $token]
|
['HTTP_Authorization' => 'Bearer ' . $token]
|
||||||
);
|
);
|
||||||
|
|
||||||
$location = $response->headers->get('Location');
|
|
||||||
|
|
||||||
$this->assertStringStartsWith('https://s3.example.com/', $location);
|
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/media/');
|
||||||
|
|
||||||
$lastUploadResponse = $this->get(
|
$lastUploadResponse = $this->get(
|
||||||
'/api/media?q=last',
|
'/api/media?q=last',
|
||||||
|
@ -109,14 +103,14 @@ class MicropubMediaTest extends TestCase
|
||||||
$lastUploadResponse->assertJson(['url' => $response->headers->get('Location')]);
|
$lastUploadResponse->assertJson(['url' => $response->headers->get('Location')]);
|
||||||
|
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/media/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function clientCanSourceUploads(): void
|
public function clientCanSourceUploads(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
$file = __DIR__ . '/../aaron.png';
|
$file = __DIR__ . '/../aaron.png';
|
||||||
$token = $this->getToken();
|
$token = $this->getToken();
|
||||||
|
|
||||||
|
@ -129,7 +123,7 @@ class MicropubMediaTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/media/');
|
||||||
|
|
||||||
$sourceUploadResponse = $this->get(
|
$sourceUploadResponse = $this->get(
|
||||||
'/api/media?q=source',
|
'/api/media?q=source',
|
||||||
|
@ -141,14 +135,14 @@ class MicropubMediaTest extends TestCase
|
||||||
]]]);
|
]]]);
|
||||||
|
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/media/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function clientCanSourceUploadsWithLimit(): void
|
public function clientCanSourceUploadsWithLimit(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
$file = __DIR__ . '/../aaron.png';
|
$file = __DIR__ . '/../aaron.png';
|
||||||
$token = $this->getToken();
|
$token = $this->getToken();
|
||||||
|
|
||||||
|
@ -161,7 +155,7 @@ class MicropubMediaTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/media/');
|
||||||
|
|
||||||
$sourceUploadResponse = $this->get(
|
$sourceUploadResponse = $this->get(
|
||||||
'/api/media?q=source&limit=1',
|
'/api/media?q=source&limit=1',
|
||||||
|
@ -175,10 +169,11 @@ class MicropubMediaTest extends TestCase
|
||||||
$this->assertCount(1, json_decode($sourceUploadResponse->getContent(), true)['items']);
|
$this->assertCount(1, json_decode($sourceUploadResponse->getContent(), true)['items']);
|
||||||
|
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/media/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointUploadRequiresFile(): void
|
public function mediaEndpointUploadRequiresFile(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -194,7 +189,7 @@ class MicropubMediaTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function errorResponseForUnknownQValue(): void
|
public function errorResponseForUnknownQValue(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
|
@ -205,7 +200,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJson(['error' => 'invalid_request']);
|
$response->assertJson(['error' => 'invalid_request']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function optionsRequestReturnsCorsResponse(): void
|
public function optionsRequestReturnsCorsResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->options('/api/media');
|
$response = $this->options('/api/media');
|
||||||
|
@ -214,7 +209,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertHeader('access-control-allow-origin', '*');
|
$response->assertHeader('access-control-allow-origin', '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointRequestWithInvalidTokenReturns400Response(): void
|
public function mediaEndpointRequestWithInvalidTokenReturns400Response(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -226,7 +221,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJsonFragment(['error_description' => 'The provided token did not pass validation']);
|
$response->assertJsonFragment(['error_description' => 'The provided token did not pass validation']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointRequestWithTokenWithNoScopeReturns400Response(): void
|
public function mediaEndpointRequestWithTokenWithNoScopeReturns400Response(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -238,7 +233,7 @@ class MicropubMediaTest extends TestCase
|
||||||
$response->assertJsonFragment(['error_description' => 'The provided token has no scopes']);
|
$response->assertJsonFragment(['error_description' => 'The provided token has no scopes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointRequestWithInsufficientTokenScopesReturns401Response(): void
|
public function mediaEndpointRequestWithInsufficientTokenScopesReturns401Response(): void
|
||||||
{
|
{
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -252,11 +247,10 @@ class MicropubMediaTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointUploadFile(): void
|
public function mediaEndpointUploadFile(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
$file = __DIR__ . '/../aaron.png';
|
$file = __DIR__ . '/../aaron.png';
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -268,18 +262,18 @@ class MicropubMediaTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/');
|
||||||
Queue::assertPushed(ProcessMedia::class);
|
Queue::assertPushed(ProcessMedia::class);
|
||||||
Storage::disk('local')->assertExists($filename);
|
Storage::disk('local')->assertExists($filename);
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointUploadAudioFile(): void
|
public function mediaEndpointUploadAudioFile(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
$file = __DIR__ . '/../audio.mp3';
|
$file = __DIR__ . '/../audio.mp3';
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -291,18 +285,18 @@ class MicropubMediaTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/');
|
||||||
Queue::assertPushed(ProcessMedia::class);
|
Queue::assertPushed(ProcessMedia::class);
|
||||||
Storage::disk('local')->assertExists($filename);
|
Storage::disk('local')->assertExists($filename);
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointUploadVideoFile(): void
|
public function mediaEndpointUploadVideoFile(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
$file = __DIR__ . '/../video.ogv';
|
$file = __DIR__ . '/../video.ogv';
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
|
@ -314,18 +308,18 @@ class MicropubMediaTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/');
|
||||||
Queue::assertPushed(ProcessMedia::class);
|
Queue::assertPushed(ProcessMedia::class);
|
||||||
Storage::disk('local')->assertExists($filename);
|
Storage::disk('local')->assertExists($filename);
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointUploadDocumentFile(): void
|
public function mediaEndpointUploadDocumentFile(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
Storage::fake('s3');
|
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
'/api/media',
|
'/api/media',
|
||||||
|
@ -336,14 +330,15 @@ class MicropubMediaTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
$path = parse_url($response->headers->get('Location'), PHP_URL_PATH);
|
||||||
$filename = substr($path, 7);
|
$filename = Str::chopStart($path, '/storage/');
|
||||||
Queue::assertPushed(ProcessMedia::class);
|
Queue::assertPushed(ProcessMedia::class);
|
||||||
Storage::disk('local')->assertExists($filename);
|
Storage::disk('local')->assertExists($filename);
|
||||||
// now remove file
|
// now remove file
|
||||||
unlink(storage_path('app/') . $filename);
|
unlink(storage_path('app/private/') . $filename);
|
||||||
|
$this->removeDirIfEmpty(storage_path('app/private/media'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mediaEndpointUploadInvalidFileReturnsError(): void
|
public function mediaEndpointUploadInvalidFileReturnsError(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class NotesControllerTest extends TestCase
|
class NotesControllerTest extends TestCase
|
||||||
|
@ -15,9 +16,8 @@ class NotesControllerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Test the `/notes` page returns 200, this should
|
* Test the `/notes` page returns 200, this should
|
||||||
* mean the database is being hit.
|
* mean the database is being hit.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function notesPageLoads(): void
|
public function notesPageLoads(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/notes');
|
$response = $this->get('/notes');
|
||||||
|
@ -26,9 +26,8 @@ class NotesControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a specific note.
|
* Test a specific note.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function specificNotePageLoads(): void
|
public function specificNotePageLoads(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -46,9 +45,8 @@ class NotesControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that `/note/{decID}` redirects to `/notes/{nb60id}`.
|
* Test that `/note/{decID}` redirects to `/notes/{nb60id}`.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function oldNoteUrlsRedirect(): void
|
public function oldNoteUrlsRedirect(): void
|
||||||
{
|
{
|
||||||
$note = Note::factory()->create();
|
$note = Note::factory()->create();
|
||||||
|
@ -58,23 +56,22 @@ class NotesControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit the tagged page and check the tag view data.
|
* Visit the tagged page and check the tag view data.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function taggedNotesPageLoads(): void
|
public function taggedNotesPageLoads(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/notes/tagged/beer');
|
$response = $this->get('/notes/tagged/beer');
|
||||||
$response->assertViewHas('tag', 'beer');
|
$response->assertViewHas('tag', 'beer');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function unknownNoteGives404(): void
|
public function unknownNoteGives404(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/notes/112233');
|
$response = $this->get('/notes/112233');
|
||||||
$response->assertNotFound();
|
$response->assertNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function checkNoteIdNotOutOfRange(): void
|
public function checkNoteIdNotOutOfRange(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/notes/photou-photologo');
|
$response = $this->get('/notes/photou-photologo');
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ class OwnYourGramTest extends TestCase
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
use TestToken;
|
use TestToken;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function postingInstagramUrlSavesMediaPath(): void
|
public function postingInstagramUrlSavesMediaPath(): void
|
||||||
{
|
{
|
||||||
$response = $this->json(
|
$response = $this->json(
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\FileSystem\FileSystem;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ParseCachedWebMentionsTest extends TestCase
|
class ParseCachedWebMentionsTest extends TestCase
|
||||||
|
@ -25,7 +26,7 @@ class ParseCachedWebMentionsTest extends TestCase
|
||||||
copy(__DIR__ . '/../tantek.html', storage_path('HTML') . '/http/tantek.com/index.html');
|
copy(__DIR__ . '/../tantek.html', storage_path('HTML') . '/http/tantek.com/index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function parseWebmentionHtml(): void
|
public function parseWebmentionHtml(): void
|
||||||
{
|
{
|
||||||
$webmentionAaron = WebMention::factory()->create([
|
$webmentionAaron = WebMention::factory()->create([
|
||||||
|
@ -60,7 +61,7 @@ class ParseCachedWebMentionsTest extends TestCase
|
||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$fs = new FileSystem();
|
$fs = new FileSystem;
|
||||||
if ($fs->exists(storage_path() . '/HTML/https')) {
|
if ($fs->exists(storage_path() . '/HTML/https')) {
|
||||||
$fs->deleteDirectory(storage_path() . '/HTML/https');
|
$fs->deleteDirectory(storage_path() . '/HTML/https');
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Models\Place;
|
use App\Models\Place;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class PlacesTest extends TestCase
|
class PlacesTest extends TestCase
|
||||||
|
@ -14,9 +15,8 @@ class PlacesTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the `/places` page for OK response.
|
* Test the `/places` page for OK response.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function placesPageLoads(): void
|
public function placesPageLoads(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/places');
|
$response = $this->get('/places');
|
||||||
|
@ -25,9 +25,8 @@ class PlacesTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a specific place.
|
* Test a specific place.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function singlePlacePageLoads(): void
|
public function singlePlacePageLoads(): void
|
||||||
{
|
{
|
||||||
$place = Place::factory()->create();
|
$place = Place::factory()->create();
|
||||||
|
@ -35,7 +34,7 @@ class PlacesTest extends TestCase
|
||||||
$response->assertViewHas('place', $place);
|
$response->assertViewHas('place', $place);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function unknownPlaceGives404()
|
public function unknownPlaceGives404()
|
||||||
{
|
{
|
||||||
$response = $this->get('/places/unknown');
|
$response = $this->get('/places/unknown');
|
||||||
|
|
|
@ -9,13 +9,14 @@ use App\Models\WebMention;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ReDownloadWebMentionsTest extends TestCase
|
class ReDownloadWebMentionsTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function downloadJobGetsQueued(): void
|
public function downloadJobGetsQueued(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
|
|
@ -5,11 +5,12 @@ declare(strict_types=1);
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SearchTest extends TestCase
|
class SearchTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @test */
|
#[Test]
|
||||||
public function searchEndpointReturnsResults(): void
|
public function searchEndpointReturnsResults(): void
|
||||||
{
|
{
|
||||||
Note::factory(10)->create();
|
Note::factory(10)->create();
|
||||||
|
|
|
@ -4,32 +4,33 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ShortURLsControllerTest extends TestCase
|
class ShortURLsControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @test */
|
#[Test]
|
||||||
public function shortDomainRedirectsToLongDomain(): void
|
public function shortDomainRedirectsToLongDomain(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('https://' . config('url.shorturl'));
|
$response = $this->get('https://' . config('url.shorturl'));
|
||||||
$response->assertRedirect(config('app.url'));
|
$response->assertRedirect(config('app.url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function shortDomainSlashAtRedirectsToTwitter(): void
|
public function shortDomainSlashAtRedirectsToTwitter(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('https://' . config('url.shorturl') . '/@');
|
$response = $this->get('https://' . config('url.shorturl') . '/@');
|
||||||
$response->assertRedirect('https://twitter.com/jonnybarnes');
|
$response->assertRedirect('https://twitter.com/jonnybarnes');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function shortDomainSlashTRedirectsToLongDomainSlashNotes(): void
|
public function shortDomainSlashTRedirectsToLongDomainSlashNotes(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('https://' . config('url.shorturl') . '/t/E');
|
$response = $this->get('https://' . config('url.shorturl') . '/t/E');
|
||||||
$response->assertRedirect(config('app.url') . '/notes/E');
|
$response->assertRedirect(config('app.url') . '/notes/E');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function shortDomainSlashBRedirectsToLongDomainSlashBlog(): void
|
public function shortDomainSlashBRedirectsToLongDomainSlashBlog(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('https://' . config('url.shorturl') . '/b/1');
|
$response = $this->get('https://' . config('url.shorturl') . '/b/1');
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Jobs\SendWebMentions;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestToken;
|
use Tests\TestToken;
|
||||||
|
|
||||||
|
@ -18,9 +19,8 @@ class SwarmTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a check in to Foursquare, this is the content Ownyourswarm will post to us.
|
* Given a check in to Foursquare, this is the content Ownyourswarm will post to us.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function mockedOwnyourswarmRequestWithFoursquare(): void
|
public function mockedOwnyourswarmRequestWithFoursquare(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -66,9 +66,8 @@ class SwarmTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* This request would actually come from another client than OwnYourSwarm, but we’re testing
|
* This request would actually come from another client than OwnYourSwarm, but we’re testing
|
||||||
* OpenStreetMap data.
|
* OpenStreetMap data.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function mockedOwnyourswarmRequestWithOsm(): void
|
public function mockedOwnyourswarmRequestWithOsm(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -109,9 +108,8 @@ class SwarmTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This request would actually come from another client than OwnYourSwarm, as that would include a Foursquare URL
|
* This request would actually come from another client than OwnYourSwarm, as that would include a Foursquare URL
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function mockedOwnyourswarmRequestWithoutKnownExternalUrl(): void
|
public function mockedOwnyourswarmRequestWithoutKnownExternalUrl(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -150,7 +148,7 @@ class SwarmTest extends TestCase
|
||||||
Queue::assertPushed(SendWebMentions::class);
|
Queue::assertPushed(SendWebMentions::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mockedOwnyourswarmRequestWithNoTextContent(): void
|
public function mockedOwnyourswarmRequestWithNoTextContent(): void
|
||||||
{
|
{
|
||||||
$response = $this->json(
|
$response = $this->json(
|
||||||
|
@ -187,7 +185,7 @@ class SwarmTest extends TestCase
|
||||||
$this->get($response->__get('headers')->get('location'))->assertSee('📍');
|
$this->get($response->__get('headers')->get('location'))->assertSee('📍');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mockedOwnyourswarmRequestSavesJustThePostWhenAnErrorOccursInTheCheckinData(): void
|
public function mockedOwnyourswarmRequestSavesJustThePostWhenAnErrorOccursInTheCheckinData(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -225,7 +223,7 @@ class SwarmTest extends TestCase
|
||||||
Queue::assertPushed(SendWebMentions::class);
|
Queue::assertPushed(SendWebMentions::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function mockedOwnyourswarmRequestWithHAdrLocation(): void
|
public function mockedOwnyourswarmRequestWithHAdrLocation(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
@ -271,7 +269,7 @@ class SwarmTest extends TestCase
|
||||||
Queue::assertPushed(SendWebMentions::class);
|
Queue::assertPushed(SendWebMentions::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function ownyourswarmCheckinTestUsingRealData(): void
|
public function ownyourswarmCheckinTestUsingRealData(): void
|
||||||
{
|
{
|
||||||
$response = $this->json(
|
$response = $this->json(
|
||||||
|
|
|
@ -9,6 +9,7 @@ use DateTimeImmutable;
|
||||||
use Lcobucci\JWT\Configuration;
|
use Lcobucci\JWT\Configuration;
|
||||||
use Lcobucci\JWT\Signer\Key\InMemory;
|
use Lcobucci\JWT\Signer\Key\InMemory;
|
||||||
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class TokenServiceTest extends TestCase
|
class TokenServiceTest extends TestCase
|
||||||
|
@ -16,12 +17,11 @@ class TokenServiceTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Given the token is dependent on a random nonce, the time of creation and
|
* Given the token is dependent on a random nonce, the time of creation and
|
||||||
* the APP_KEY, to test, we shall create a token, and then verify it.
|
* the APP_KEY, to test, we shall create a token, and then verify it.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function tokenserviceCreatesAndValidatesTokens(): void
|
public function tokenserviceCreatesAndValidatesTokens(): void
|
||||||
{
|
{
|
||||||
$tokenService = new TokenService();
|
$tokenService = new TokenService;
|
||||||
$data = [
|
$data = [
|
||||||
'me' => 'https://example.org',
|
'me' => 'https://example.org',
|
||||||
'client_id' => 'https://quill.p3k.io',
|
'client_id' => 'https://quill.p3k.io',
|
||||||
|
@ -37,11 +37,7 @@ class TokenServiceTest extends TestCase
|
||||||
$this->assertSame($data, $validData);
|
$this->assertSame($data, $validData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function tokensWithDifferentSigningKeyThrowsException(): void
|
public function tokensWithDifferentSigningKeyThrowsException(): void
|
||||||
{
|
{
|
||||||
$this->expectException(RequiredConstraintsViolated::class);
|
$this->expectException(RequiredConstraintsViolated::class);
|
||||||
|
@ -55,7 +51,7 @@ class TokenServiceTest extends TestCase
|
||||||
$config = resolve(Configuration::class);
|
$config = resolve(Configuration::class);
|
||||||
|
|
||||||
$token = $config->builder()
|
$token = $config->builder()
|
||||||
->issuedAt(new DateTimeImmutable())
|
->issuedAt(new DateTimeImmutable)
|
||||||
->withClaim('client_id', $data['client_id'])
|
->withClaim('client_id', $data['client_id'])
|
||||||
->withClaim('me', $data['me'])
|
->withClaim('me', $data['me'])
|
||||||
->withClaim('scope', $data['scope'])
|
->withClaim('scope', $data['scope'])
|
||||||
|
@ -63,7 +59,7 @@ class TokenServiceTest extends TestCase
|
||||||
->getToken($config->signer(), InMemory::plainText(random_bytes(32)))
|
->getToken($config->signer(), InMemory::plainText(random_bytes(32)))
|
||||||
->toString();
|
->toString();
|
||||||
|
|
||||||
$service = new TokenService();
|
$service = new TokenService;
|
||||||
$service->validateToken($token);
|
$service->validateToken($token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@ use App\Jobs\ProcessWebMention;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class WebMentionsControllerTest extends TestCase
|
class WebMentionsControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function webmentionEndpointCanServeBrowserRequest(): void
|
public function webmentionEndpointCanServeBrowserRequest(): void
|
||||||
{
|
{
|
||||||
$response = $this->get('/webmention');
|
$response = $this->get('/webmention');
|
||||||
|
@ -23,9 +24,8 @@ class WebMentionsControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test webmentions without source and target are rejected.
|
* Test webmentions without source and target are rejected.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function webmentionsWithoutSourceAndTargetAreRejected(): void
|
public function webmentionsWithoutSourceAndTargetAreRejected(): void
|
||||||
{
|
{
|
||||||
$response = $this->call('POST', '/webmention', ['source' => 'https://example.org/post/123']);
|
$response = $this->call('POST', '/webmention', ['source' => 'https://example.org/post/123']);
|
||||||
|
@ -36,9 +36,8 @@ class WebMentionsControllerTest extends TestCase
|
||||||
* Test invalid target gives a 400 response.
|
* Test invalid target gives a 400 response.
|
||||||
*
|
*
|
||||||
* In this case an invalid target is a URL that doesn’t exist on our domain.
|
* In this case an invalid target is a URL that doesn’t exist on our domain.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function invalidTargetReturnsErrorResponse(): void
|
public function invalidTargetReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->call('POST', '/webmention', [
|
$response = $this->call('POST', '/webmention', [
|
||||||
|
@ -50,9 +49,8 @@ class WebMentionsControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test blog target gets a 501 response due to our not supporting it.
|
* Test blog target gets a 501 response due to our not supporting it.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function blogTargetReturns501Response(): void
|
public function blogTargetReturns501Response(): void
|
||||||
{
|
{
|
||||||
$response = $this->call('POST', '/webmention', [
|
$response = $this->call('POST', '/webmention', [
|
||||||
|
@ -64,9 +62,8 @@ class WebMentionsControllerTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that a non-existent note gives a 400 response.
|
* Test that a non-existent note gives a 400 response.
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
*/
|
||||||
|
#[Test]
|
||||||
public function nonexistentNoteReturnsErrorResponse(): void
|
public function nonexistentNoteReturnsErrorResponse(): void
|
||||||
{
|
{
|
||||||
$response = $this->call('POST', '/webmention', [
|
$response = $this->call('POST', '/webmention', [
|
||||||
|
@ -76,7 +73,7 @@ class WebMentionsControllerTest extends TestCase
|
||||||
$response->assertStatus(400);
|
$response->assertStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
#[Test]
|
||||||
public function legitimateWebmentionTriggersProcessWebmentionJob(): void
|
public function legitimateWebmentionTriggersProcessWebmentionJob(): void
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
|
|
@ -7,4 +7,13 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication;
|
use CreatesApplication;
|
||||||
|
|
||||||
|
public function removeDirIfEmpty(string $dir): void
|
||||||
|
{
|
||||||
|
// scandir() will always return `.` and `..` so even an “empty”
|
||||||
|
// directory will have a count of 2
|
||||||
|
if (is_dir($dir) && count(scandir($dir)) === 2) {
|
||||||
|
rmdir($dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ trait TestToken
|
||||||
$config = $this->app->make(Configuration::class);
|
$config = $this->app->make(Configuration::class);
|
||||||
|
|
||||||
return $config->builder()
|
return $config->builder()
|
||||||
->issuedAt(new DateTimeImmutable())
|
->issuedAt(new DateTimeImmutable)
|
||||||
->withClaim('client_id', 'https://quill.p3k.io')
|
->withClaim('client_id', 'https://quill.p3k.io')
|
||||||
->withClaim('me', 'http://jonnybarnes.localhost')
|
->withClaim('me', 'http://jonnybarnes.localhost')
|
||||||
->withClaim('scope', ['create', 'update'])
|
->withClaim('scope', ['create', 'update'])
|
||||||
|
@ -25,7 +25,7 @@ trait TestToken
|
||||||
$config = $this->app->make(Configuration::class);
|
$config = $this->app->make(Configuration::class);
|
||||||
|
|
||||||
return $config->builder()
|
return $config->builder()
|
||||||
->issuedAt(new DateTimeImmutable())
|
->issuedAt(new DateTimeImmutable)
|
||||||
->withClaim('client_id', 'https://quill.p3k.io')
|
->withClaim('client_id', 'https://quill.p3k.io')
|
||||||
->withClaim('me', 'https://jonnybarnes.localhost')
|
->withClaim('me', 'https://jonnybarnes.localhost')
|
||||||
->withClaim('scope', 'view')
|
->withClaim('scope', 'view')
|
||||||
|
@ -38,7 +38,7 @@ trait TestToken
|
||||||
$config = $this->app->make(Configuration::class);
|
$config = $this->app->make(Configuration::class);
|
||||||
|
|
||||||
return $config->builder()
|
return $config->builder()
|
||||||
->issuedAt(new DateTimeImmutable())
|
->issuedAt(new DateTimeImmutable)
|
||||||
->withClaim('client_id', 'https://quill.p3k.io')
|
->withClaim('client_id', 'https://quill.p3k.io')
|
||||||
->withClaim('me', 'https://jonnybarnes.localhost')
|
->withClaim('me', 'https://jonnybarnes.localhost')
|
||||||
->getToken($config->signer(), $config->signingKey())
|
->getToken($config->signer(), $config->signingKey())
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue