Merge pull request #114 from jonnybarnes/develop

MTM: recent work on Horizon
This commit is contained in:
Jonny Barnes 2019-03-23 16:10:06 +00:00 committed by GitHub
commit c40548be73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1315 additions and 301 deletions

View file

@ -4,8 +4,7 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\RedirectResponse;
class AuthController extends Controller
@ -13,30 +12,58 @@ class AuthController extends Controller
/**
* Show the login form.
*
* @return \Illuminate\View\View
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
*/
public function showLogin(): View
public function showLogin()
{
if (Auth::check()) {
return redirect('/');
}
return view('login');
}
/**
* Log in a user, set a sesion variable, check credentials against
* Log in a user, set a session variable, check credentials against
* the .env file.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function login(): RedirectResponse
{
if (request()->input('username') === config('admin.user')
&&
request()->input('password') === config('admin.pass')
) {
session(['loggedin' => true]);
$credentials = request()->only('name', 'password');
return redirect()->intended('admin');
if (Auth::attempt($credentials, true)) {
return redirect()->intended('/');
}
return redirect()->route('login');
}
/**
* Show the form to logout a user.
*
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
*/
public function showLogout()
{
if (Auth::check() === false) {
// The user is not logged in, just redirect them home
return redirect('/');
}
return view('logout');
}
/**
* Log the user out from their current session.
*
* @return \Illuminate\Http\RedirectResponse;
*/
public function logout(): RedirectResponse
{
Auth::logout();
return redirect('/');
}
}

View file

@ -6,6 +6,7 @@ namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class MyAuthMiddleware
{
@ -18,7 +19,7 @@ class MyAuthMiddleware
*/
public function handle(Request $request, Closure $next)
{
if ($request->session()->has('loggedin') !== true) {
if (Auth::check($request->user()) == false) {
//theyre not logged in, so send them to login form
return redirect()->route('login');
}

View file

@ -19,8 +19,8 @@ use App\Exceptions\TwitterContentException;
use Illuminate\Database\Eloquent\SoftDeletes;
use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\Block\Element\IndentedCode;
use Jonnybarnes\CommonmarkLinkify\LinkifyExtension;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer;
use League\CommonMark\Ext\Autolink\AutolinkExtension;
use Spatie\CommonMarkHighlighter\IndentedCodeRenderer;
class Note extends Model
@ -514,7 +514,7 @@ class Note extends Model
private function convertMarkdown(string $note): string
{
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new LinkifyExtension());
$environment->addExtension(new AutolinkExtension());
$environment->addBlockRenderer(FencedCode::class, new FencedCodeRenderer());
$environment->addBlockRenderer(IndentedCode::class, new IndentedCodeRenderer());
$converter = new CommonMarkConverter([], $environment);

View file

@ -17,7 +17,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'name', 'password',
];
/**

View file

@ -2,34 +2,41 @@
namespace App\Providers;
use Illuminate\Http\Request;
use Laravel\Horizon\Horizon;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\HorizonApplicationServiceProvider;
/**
* @codeCoverageIgnore
*/
class HorizonServiceProvider extends ServiceProvider
class HorizonServiceProvider extends HorizonApplicationServiceProvider
{
/**
* Bootstrap the application services.
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Horizon::auth(function (Request $request) {
// return true/false
if (app()->environment('production') !== true) {
// we arent live so just let us into Horizon
return true;
}
if ($request->session()->has('loggedin')) {
// are we logged in as an authed user
return $request->session()->get('loggedin');
}
parent::boot();
return false;
// Horizon::routeSmsNotificationsTo('15556667777');
// Horizon::routeMailNotificationsTo('example@example.com');
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
Horizon::night();
}
/**
* Register the Horizon gate.
*
* This gate determines who can access Horizon in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewHorizon', function ($user) {
return in_array($user->name, [
'jonny',
]);
});
}
}

View file

@ -15,16 +15,16 @@
"guzzlehttp/guzzle": "~6.0",
"indieauth/client": "~0.1",
"intervention/image": "^2.4",
"jonnybarnes/commonmark-linkify": "^0.5",
"jonnybarnes/emoji-a11y": "^0.3",
"jonnybarnes/indieweb": "dev-master",
"jonnybarnes/webmentions-parser": "0.4.*",
"laravel/framework": "5.8.*",
"laravel/horizon": "^1.0",
"laravel/horizon": "^3.0",
"laravel/scout": "^7.0",
"laravel/tinker": "^1.0",
"lcobucci/jwt": "^3.1",
"league/commonmark": "^0.18.0",
"league/commonmark-ext-autolink": "^0.2.0",
"league/flysystem-aws-s3-v3": "^1.0",
"mf2/mf2": "~0.3",
"phaza/laravel-postgis": "~3.1",

264
composer.lock generated
View file

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2337f94b0e6c7d9f3589283c1204c053",
"content-hash": "a1bedd7340f6f8a2fdcc375d3bc5672c",
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.90.3",
"version": "3.90.7",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "12ba8071bcc3d79cbfbf8cca77f59f146816b17a"
"reference": "5b188c9f5f21e87b4994bc1b477951eff4608547"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/12ba8071bcc3d79cbfbf8cca77f59f146816b17a",
"reference": "12ba8071bcc3d79cbfbf8cca77f59f146816b17a",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5b188c9f5f21e87b4994bc1b477951eff4608547",
"reference": "5b188c9f5f21e87b4994bc1b477951eff4608547",
"shasum": ""
},
"require": {
@ -86,7 +86,7 @@
"s3",
"sdk"
],
"time": "2019-03-14T18:32:41+00:00"
"time": "2019-03-21T18:10:13+00:00"
},
{
"name": "bosnadev/database",
@ -877,16 +877,16 @@
},
{
"name": "erusev/parsedown",
"version": "1.7.1",
"version": "v1.7.2",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "92e9c27ba0e74b8b028b111d1b6f956a15c01fc1"
"reference": "d60bcdc46978357759ecb13cb4b078da783f8faf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/92e9c27ba0e74b8b028b111d1b6f956a15c01fc1",
"reference": "92e9c27ba0e74b8b028b111d1b6f956a15c01fc1",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/d60bcdc46978357759ecb13cb4b078da783f8faf",
"reference": "d60bcdc46978357759ecb13cb4b078da783f8faf",
"shasum": ""
},
"require": {
@ -919,7 +919,7 @@
"markdown",
"parser"
],
"time": "2018-03-08T01:11:30+00:00"
"time": "2019-03-17T17:19:46+00:00"
},
{
"name": "fideloper/proxy",
@ -1595,52 +1595,6 @@
],
"time": "2015-09-27T15:35:21+00:00"
},
{
"name": "jonnybarnes/commonmark-linkify",
"version": "v0.5.1",
"source": {
"type": "git",
"url": "https://github.com/jonnybarnes/commonmark-linkify.git",
"reference": "e27103f5e0e9e84eb17344a361845241e27512e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jonnybarnes/commonmark-linkify/zipball/e27103f5e0e9e84eb17344a361845241e27512e0",
"reference": "e27103f5e0e9e84eb17344a361845241e27512e0",
"shasum": ""
},
"require": {
"league/commonmark": "^0.18.0",
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "~7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Jonnybarnes\\CommonmarkLinkify\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"CC0-1.0"
],
"authors": [
{
"name": "Jonny Barnes",
"email": "jonny@jonnybarnes.uk"
}
],
"description": "Turn plaintext URLs into click-able links",
"homepage": "https://github.com/jonnybarnes/commonmark-linkify",
"keywords": [
"commonmark",
"extension",
"markdown"
],
"time": "2019-02-17T10:48:03+00:00"
},
{
"name": "jonnybarnes/emoji-a11y",
"version": "v0.3",
@ -1778,16 +1732,16 @@
},
{
"name": "laravel/framework",
"version": "v5.8.4",
"version": "v5.8.7",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "d651f8bd25c6baf7ae4913bc51f02849fad4e925"
"reference": "f12c7baf9ceee80b131e06a01d3221d9a2488670"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/d651f8bd25c6baf7ae4913bc51f02849fad4e925",
"reference": "d651f8bd25c6baf7ae4913bc51f02849fad4e925",
"url": "https://api.github.com/repos/laravel/framework/zipball/f12c7baf9ceee80b131e06a01d3221d9a2488670",
"reference": "f12c7baf9ceee80b131e06a01d3221d9a2488670",
"shasum": ""
},
"require": {
@ -1921,44 +1875,45 @@
"framework",
"laravel"
],
"time": "2019-03-12T13:33:14+00:00"
"time": "2019-03-21T16:54:38+00:00"
},
{
"name": "laravel/horizon",
"version": "v1.4.3",
"version": "v3.0.6",
"source": {
"type": "git",
"url": "https://github.com/laravel/horizon.git",
"reference": "b00da78d10158036cab2f45115ecc360f2014ed4"
"reference": "2bcb51fcec9a50c08c86eb85663041657e6cf55d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/b00da78d10158036cab2f45115ecc360f2014ed4",
"reference": "b00da78d10158036cab2f45115ecc360f2014ed4",
"url": "https://api.github.com/repos/laravel/horizon/zipball/2bcb51fcec9a50c08c86eb85663041657e6cf55d",
"reference": "2bcb51fcec9a50c08c86eb85663041657e6cf55d",
"shasum": ""
},
"require": {
"cakephp/chronos": "^1.0",
"ext-json": "*",
"ext-pcntl": "*",
"ext-posix": "*",
"illuminate/contracts": "~5.5",
"illuminate/queue": "~5.5",
"illuminate/support": "~5.5",
"illuminate/contracts": "~5.7.0|~5.8.0",
"illuminate/queue": "~5.7.0|~5.8.0",
"illuminate/support": "~5.7.0|~5.8.0",
"php": ">=7.1.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.5",
"symfony/debug": "~3.3|~4.0"
"symfony/debug": "^4.2",
"symfony/process": "^4.2"
},
"require-dev": {
"mockery/mockery": "~1.0",
"orchestra/database": "~3.5",
"orchestra/testbench": "~3.5",
"phpunit/phpunit": "~6.0"
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.7",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "3.0-dev"
},
"laravel": {
"providers": [
@ -1989,7 +1944,7 @@
"laravel",
"queue"
],
"time": "2018-11-01T14:03:51+00:00"
"time": "2019-03-19T16:32:54+00:00"
},
{
"name": "laravel/scout",
@ -2179,16 +2134,16 @@
},
{
"name": "league/commonmark",
"version": "0.18.2",
"version": "0.18.3",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "ad51c7cafb90e0bbd9f34b71d18d05994547e352"
"reference": "b1ec41ce15c3bd6f7cbe86a645b3efc78d927446"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/ad51c7cafb90e0bbd9f34b71d18d05994547e352",
"reference": "ad51c7cafb90e0bbd9f34b71d18d05994547e352",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/b1ec41ce15c3bd6f7cbe86a645b3efc78d927446",
"reference": "b1ec41ce15c3bd6f7cbe86a645b3efc78d927446",
"shasum": ""
},
"require": {
@ -2204,7 +2159,7 @@
"erusev/parsedown": "~1.0",
"michelf/php-markdown": "~1.4",
"mikehaertl/php-shellcommand": "^1.2",
"phpunit/phpunit": "^5.7|^6.5",
"phpunit/phpunit": "^5.7.27|^6.5.14",
"scrutinizer/ocular": "^1.1",
"symfony/finder": "^3.0|^4.0"
},
@ -2244,7 +2199,64 @@
"markdown",
"parser"
],
"time": "2019-03-17T01:41:59+00:00"
"time": "2019-03-21T22:47:25+00:00"
},
{
"name": "league/commonmark-ext-autolink",
"version": "v0.2.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark-ext-autolink.git",
"reference": "585875f1531bbe6efd77ab480ee61ef2957137b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark-ext-autolink/zipball/585875f1531bbe6efd77ab480ee61ef2957137b3",
"reference": "585875f1531bbe6efd77ab480ee61ef2957137b3",
"shasum": ""
},
"require": {
"league/commonmark": "^0.18.2",
"php": "^5.6||^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.27"
},
"type": "commonmark-extension",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"autoload": {
"psr-4": {
"League\\CommonMark\\Ext\\Autolink\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "Extension for league/commonmark which autolinks URLs, emails, and @-mentions",
"homepage": "https://github.com/thephpleague/commonmark-ext-autolink",
"keywords": [
"autolink",
"commonmark",
"extension",
"gfm",
"github",
"markdown",
"twitter"
],
"time": "2019-03-17T03:06:54+00:00"
},
{
"name": "league/flysystem",
@ -3835,16 +3847,16 @@
},
{
"name": "spatie/image",
"version": "1.6.0",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/image.git",
"reference": "e2abb144195aab37f023efbe69a0491f0524a7af"
"reference": "19399b544ce1d78a3c675404791ab57a87eb8f55"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image/zipball/e2abb144195aab37f023efbe69a0491f0524a7af",
"reference": "e2abb144195aab37f023efbe69a0491f0524a7af",
"url": "https://api.github.com/repos/spatie/image/zipball/19399b544ce1d78a3c675404791ab57a87eb8f55",
"reference": "19399b544ce1d78a3c675404791ab57a87eb8f55",
"shasum": ""
},
"require": {
@ -3884,7 +3896,7 @@
"image",
"spatie"
],
"time": "2019-01-26T09:48:17+00:00"
"time": "2019-02-22T10:24:29+00:00"
},
{
"name": "spatie/image-optimizer",
@ -4551,16 +4563,16 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19"
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
@ -4572,7 +4584,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
@ -4605,20 +4617,20 @@
"polyfill",
"portable"
],
"time": "2018-08-06T14:22:27+00:00"
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-iconv",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-iconv.git",
"reference": "97001cfc283484c9691769f51cdf25259037eba2"
"reference": "f037ea22acfaee983e271dd9c3b8bb4150bd8ad7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/97001cfc283484c9691769f51cdf25259037eba2",
"reference": "97001cfc283484c9691769f51cdf25259037eba2",
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/f037ea22acfaee983e271dd9c3b8bb4150bd8ad7",
"reference": "f037ea22acfaee983e271dd9c3b8bb4150bd8ad7",
"shasum": ""
},
"require": {
@ -4630,7 +4642,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
@ -4664,20 +4676,20 @@
"portable",
"shim"
],
"time": "2018-09-21T06:26:08+00:00"
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "89de1d44f2c059b266f22c9cc9124ddc4cd0987a"
"reference": "c766e95bec706cdd89903b1eda8afab7d7a6b7af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/89de1d44f2c059b266f22c9cc9124ddc4cd0987a",
"reference": "89de1d44f2c059b266f22c9cc9124ddc4cd0987a",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/c766e95bec706cdd89903b1eda8afab7d7a6b7af",
"reference": "c766e95bec706cdd89903b1eda8afab7d7a6b7af",
"shasum": ""
},
"require": {
@ -4726,20 +4738,20 @@
"portable",
"shim"
],
"time": "2018-09-30T16:36:12+00:00"
"time": "2019-03-04T13:44:35+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494"
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609",
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609",
"shasum": ""
},
"require": {
@ -4751,7 +4763,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
@ -4785,20 +4797,20 @@
"portable",
"shim"
],
"time": "2018-09-21T13:07:52+00:00"
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-php72",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
"reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631"
"reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9050816e2ca34a8e916c3a0ae8b9c2fccf68b631",
"reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/ab50dcf166d5f577978419edd37aa2bb8eabce0c",
"reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c",
"shasum": ""
},
"require": {
@ -4807,7 +4819,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
@ -4840,7 +4852,7 @@
"portable",
"shim"
],
"time": "2018-09-21T13:07:52+00:00"
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/process",
@ -5621,27 +5633,29 @@
},
{
"name": "doctrine/instantiator",
"version": "1.1.0",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda"
"reference": "a2c590166b2133a4633738648b6b064edae0814a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
"reference": "a2c590166b2133a4633738648b6b064edae0814a",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"doctrine/coding-standard": "^6.0",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "^6.2.3",
"squizlabs/php_codesniffer": "^3.0.2"
"phpbench/phpbench": "^0.13",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
@ -5666,12 +5680,12 @@
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"time": "2017-07-22T11:58:36+00:00"
"time": "2019-03-17T17:37:11+00:00"
},
{
"name": "facebook/webdriver",

View file

@ -67,7 +67,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'model' => App\Models\User::class,
],
// 'users' => [

View file

@ -15,6 +15,19 @@ return [
'use' => 'default',
/*
|--------------------------------------------------------------------------
| Horizon Redis Prefix
|--------------------------------------------------------------------------
|
| This prefix will be used when storing all Horizon data in Redis. You
| may modify the prefix when you are running multiple installations
| of Horizon on the same server so that they don't have problems.
|
*/
'prefix' => env('HORIZON_PREFIX', 'horizon:'),
/*
|--------------------------------------------------------------------------
| Queue Wait Time Thresholds
@ -30,6 +43,37 @@ return [
'redis:default' => 60,
],
/*
|--------------------------------------------------------------------------
| Job Trimming Times
|--------------------------------------------------------------------------
|
| Here you can configure for how long (in minutes) you desire Horizon to
| persist the recent and failed jobs. Typically, recent jobs are kept
| for one hour while all failed jobs are stored for an entire week.
|
*/
'trim' => [
'recent' => 60,
'failed' => 10080,
],
/*
|--------------------------------------------------------------------------
| Fast Termination
|--------------------------------------------------------------------------
|
| When this option is enabled, Horizon's "terminate" command will not
| wait on all of the workers to terminate unless the --wait option
| is provided. Fast termination can shorten deployment delay by
| allowing a new instance of Horizon to start while the last
| instance will continue to terminate each of its workers.
|
*/
'fast_termination' => false,
/*
|--------------------------------------------------------------------------
| Queue Worker Configuration
@ -62,5 +106,4 @@ return [
],
],
],
];

View file

@ -1,5 +1,6 @@
<?php
use Illuminate\Support\Str;
use Faker\Generator as Faker;
/*
@ -12,12 +13,12 @@ use Faker\Generator as Faker;
| model instances for testing / seeding your application's database.
|
*/
$factory->define(App\User::class, function (Faker $faker) {
$factory->define(App\Models\User::class, function (Faker $faker) {
static $password;
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'name' => mb_strtolower($faker->firstName),
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'remember_token' => Str::random(10),
];
});

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View file

@ -19,5 +19,6 @@ class DatabaseSeeder extends Seeder
$this->call(WebMentionsTableSeeder::class);
$this->call(LikesTableSeeder::class);
$this->call(BookmarksTableSeeder::class);
$this->call(UsersTableSeeder::class);
}
}

View file

@ -0,0 +1,20 @@
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert([
'name' => 'jonny',
'password' => bcrypt('password'),
]);
}
}

8
public/vendor/horizon/app-dark.css vendored Normal file

File diff suppressed because one or more lines are too long

8
public/vendor/horizon/app.css vendored Normal file

File diff suppressed because one or more lines are too long

1
public/vendor/horizon/app.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"file":"/css/app.css","sources":[],"mappings":"","sourceRoot":""}
{"version":3,"file":"/css/app.css","sources":[],"mappings":";;;;;A","sourceRoot":""}

BIN
public/vendor/horizon/img/favicon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

View file

@ -1,13 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="226px" height="30px" viewBox="0 0 226 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 42 (36781) - http://www.bohemiancoding.com/sketch -->
<title>horizon</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="horizon" fill="#405263">
<path d="M54.132,25 L53.488,20.856 L47.552,20.856 L47.552,5.68 L42.764,5.68 L42.764,25 L54.132,25 Z M67.432,25 L63.68,25 L63.4,23.292 C62.28,24.468 60.964,25.28 59.088,25.28 C56.904,25.28 55.364,23.964 55.364,21.472 C55.364,18.252 57.828,16.74 63.204,16.264 L63.204,16.012 C63.204,14.808 62.532,14.276 61.132,14.276 C59.592,14.276 58.164,14.668 56.708,15.312 L56.204,12.12 C57.772,11.476 59.536,11.056 61.776,11.056 C65.556,11.056 67.432,12.316 67.432,15.816 L67.432,25 Z M63.204,21.22 L63.204,18.308 C60.32,18.756 59.536,19.708 59.536,20.912 C59.536,21.78 60.068,22.256 60.852,22.256 C61.664,22.256 62.448,21.892 63.204,21.22 Z M79.08,15.312 L78.38,11 C76.364,11.14 75.216,12.428 74.376,13.996 L73.928,11.28 L70.232,11.28 L70.232,25 L74.46,25 L74.46,17.384 C75.496,16.264 77.036,15.452 79.08,15.312 Z M92.184,25 L88.432,25 L88.152,23.292 C87.032,24.468 85.716,25.28 83.84,25.28 C81.656,25.28 80.116,23.964 80.116,21.472 C80.116,18.252 82.58,16.74 87.956,16.264 L87.956,16.012 C87.956,14.808 87.284,14.276 85.884,14.276 C84.344,14.276 82.916,14.668 81.46,15.312 L80.956,12.12 C82.524,11.476 84.288,11.056 86.528,11.056 C90.308,11.056 92.184,12.316 92.184,15.816 L92.184,25 Z M87.956,21.22 L87.956,18.308 C85.072,18.756 84.288,19.708 84.288,20.912 C84.288,21.78 84.82,22.256 85.604,22.256 C86.416,22.256 87.2,21.892 87.956,21.22 Z M107.5,11.28 L103.384,11.28 L100.892,19.764 L98.344,11.084 L93.808,11.616 L98.484,25.056 L102.712,25.056 L107.5,11.28 Z M121.052,18.112 C121.052,18.532 121.024,18.98 120.968,19.204 L112.736,19.204 C112.96,21.36 114.248,22.2 116.096,22.2 C117.608,22.2 119.092,21.64 120.604,20.772 L121.024,23.74 C119.54,24.692 117.72,25.28 115.564,25.28 C111.448,25.28 108.508,23.096 108.508,18.196 C108.508,13.716 111.252,11 114.976,11 C119.176,11 121.052,14.136 121.052,18.112 Z M117.02,16.88 C116.88,14.808 116.152,13.744 114.864,13.744 C113.688,13.744 112.848,14.78 112.708,16.88 L117.02,16.88 Z M127.66,25 L127.66,4.784 L123.404,5.456 L123.404,25 L127.66,25 Z M152.692,25 L152.692,5.68 L150.76,5.68 L150.76,14.024 L140.036,14.024 L140.036,5.68 L138.104,5.68 L138.104,25 L140.036,25 L140.036,15.76 L150.76,15.76 L150.76,25 L152.692,25 Z M168.568,18.392 C168.568,22.76 165.936,25.28 162.548,25.28 C159.16,25.28 156.612,22.76 156.612,18.392 C156.612,13.996 159.216,11.476 162.548,11.476 C165.992,11.476 168.568,13.996 168.568,18.392 Z M166.664,18.392 C166.664,15.34 165.208,13.044 162.548,13.044 C159.916,13.044 158.488,15.256 158.488,18.392 C158.488,21.444 159.944,23.712 162.548,23.712 C165.236,23.712 166.664,21.528 166.664,18.392 Z M178.872,13.212 L178.564,11.476 C176.38,11.532 174.84,12.988 173.86,14.472 L173.44,11.756 L172.068,11.756 L172.068,25 L173.916,25 L173.916,16.684 C174.812,14.92 176.688,13.352 178.872,13.212 Z M184.136,7.248 C184.136,6.52 183.548,5.904 182.82,5.904 C182.092,5.904 181.476,6.52 181.476,7.248 C181.476,7.976 182.092,8.592 182.82,8.592 C183.548,8.592 184.136,7.976 184.136,7.248 Z M183.716,25 L183.716,11.756 L181.896,11.756 L181.896,25 L183.716,25 Z M197.464,25 L197.212,23.46 L189.344,23.46 L197.24,13.184 L197.24,11.756 L187.636,11.756 L187.888,13.296 L195.112,13.296 L187.216,23.572 L187.216,25 L197.464,25 Z M211.94,18.392 C211.94,22.76 209.308,25.28 205.92,25.28 C202.532,25.28 199.984,22.76 199.984,18.392 C199.984,13.996 202.588,11.476 205.92,11.476 C209.364,11.476 211.94,13.996 211.94,18.392 Z M210.036,18.392 C210.036,15.34 208.58,13.044 205.92,13.044 C203.288,13.044 201.86,15.256 201.86,18.392 C201.86,21.444 203.316,23.712 205.92,23.712 C208.608,23.712 210.036,21.528 210.036,18.392 Z M225.884,25 L225.884,15.536 C225.884,12.988 224.568,11.476 221.936,11.476 C220.144,11.476 218.632,12.428 217.176,13.716 L216.868,11.756 L215.44,11.756 L215.44,25 L217.288,25 L217.288,15.424 C218.744,13.996 220.172,13.128 221.572,13.128 C223.252,13.128 224.036,14.164 224.036,15.872 L224.036,25 L225.884,25 Z" id="Laravel-Horizon"></path>
<path d="M5.26176342,26.4094389 C2.04147988,23.6582233 0,19.5675182 0,15 C0,10.8578644 1.67893219,7.10786438 4.39339828,4.39339828 C7.10786438,1.67893219 10.8578644,0 15,0 C23.2842712,3.55271368e-15 30,6.71572875 30,15 C30,23.2842712 23.2842712,30 15,30 C11.283247,30 7.88222338,28.6482016 5.26176342,26.4094389 L5.26176342,26.4094389 Z M4.03811305,15.9222506 C5.70084247,14.4569342 6.87195416,12.5 10,12.5 C15,12.5 15,17.5 20,17.5 C23.1280454,17.5 24.2991572,15.5430664 25.961887,14.0777498 C25.4934253,8.43417206 20.7645408,4 15,4 C8.92486775,4 4,8.92486775 4,15 C4,15.3105915 4.01287248,15.6181765 4.03811305,15.9222506 L4.03811305,15.9222506 Z" id="Combined-Shape" fill-rule="nonzero"></path>
</g>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="226" height="30" viewBox="0 0 226 30">
<path fill="#405263" d="M54.132 25l-.644-4.144h-5.936V5.68h-4.788V25h11.368zm13.3 0H63.68l-.28-1.708c-1.12 1.176-2.436 1.988-4.312 1.988-2.184 0-3.724-1.316-3.724-3.808 0-3.22 2.464-4.732 7.84-5.208v-.252c0-1.204-.672-1.736-2.072-1.736-1.54 0-2.968.392-4.424 1.036l-.504-3.192c1.568-.644 3.332-1.064 5.572-1.064 3.78 0 5.656 1.26 5.656 4.76V25zm-4.228-3.78v-2.912c-2.884.448-3.668 1.4-3.668 2.604 0 .868.532 1.344 1.316 1.344.812 0 1.596-.364 2.352-1.036zm15.876-5.908L78.38 11c-2.016.14-3.164 1.428-4.004 2.996l-.448-2.716h-3.696V25h4.228v-7.616c1.036-1.12 2.576-1.932 4.62-2.072zM92.184 25h-3.752l-.28-1.708c-1.12 1.176-2.436 1.988-4.312 1.988-2.184 0-3.724-1.316-3.724-3.808 0-3.22 2.464-4.732 7.84-5.208v-.252c0-1.204-.672-1.736-2.072-1.736-1.54 0-2.968.392-4.424 1.036l-.504-3.192c1.568-.644 3.332-1.064 5.572-1.064 3.78 0 5.656 1.26 5.656 4.76V25zm-4.228-3.78v-2.912c-2.884.448-3.668 1.4-3.668 2.604 0 .868.532 1.344 1.316 1.344.812 0 1.596-.364 2.352-1.036zm19.544-9.94h-4.116l-2.492 8.484-2.548-8.68-4.536.532 4.676 13.44h4.228L107.5 11.28zm13.552 6.832c0 .42-.028.868-.084 1.092h-8.232c.224 2.156 1.512 2.996 3.36 2.996 1.512 0 2.996-.56 4.508-1.428l.42 2.968c-1.484.952-3.304 1.54-5.46 1.54-4.116 0-7.056-2.184-7.056-7.084 0-4.48 2.744-7.196 6.468-7.196 4.2 0 6.076 3.136 6.076 7.112zm-4.032-1.232c-.14-2.072-.868-3.136-2.156-3.136-1.176 0-2.016 1.036-2.156 3.136h4.312zM127.66 25V4.784l-4.256.672V25h4.256zm25.032 0V5.68h-1.932v8.344h-10.724V5.68h-1.932V25h1.932v-9.24h10.724V25h1.932zm15.876-6.608c0 4.368-2.632 6.888-6.02 6.888-3.388 0-5.936-2.52-5.936-6.888 0-4.396 2.604-6.916 5.936-6.916 3.444 0 6.02 2.52 6.02 6.916zm-1.904 0c0-3.052-1.456-5.348-4.116-5.348-2.632 0-4.06 2.212-4.06 5.348 0 3.052 1.456 5.32 4.06 5.32 2.688 0 4.116-2.184 4.116-5.32zm12.208-5.18l-.308-1.736c-2.184.056-3.724 1.512-4.704 2.996l-.42-2.716h-1.372V25h1.848v-8.316c.896-1.764 2.772-3.332 4.956-3.472zm5.264-5.964c0-.728-.588-1.344-1.316-1.344-.728 0-1.344.616-1.344 1.344 0 .728.616 1.344 1.344 1.344.728 0 1.316-.616 1.316-1.344zM183.716 25V11.756h-1.82V25h1.82zm13.748 0l-.252-1.54h-7.868l7.896-10.276v-1.428h-9.604l.252 1.54h7.224l-7.896 10.276V25h10.248zm14.476-6.608c0 4.368-2.632 6.888-6.02 6.888-3.388 0-5.936-2.52-5.936-6.888 0-4.396 2.604-6.916 5.936-6.916 3.444 0 6.02 2.52 6.02 6.916zm-1.904 0c0-3.052-1.456-5.348-4.116-5.348-2.632 0-4.06 2.212-4.06 5.348 0 3.052 1.456 5.32 4.06 5.32 2.688 0 4.116-2.184 4.116-5.32zM225.884 25v-9.464c0-2.548-1.316-4.06-3.948-4.06-1.792 0-3.304.952-4.76 2.24l-.308-1.96h-1.428V25h1.848v-9.576c1.456-1.428 2.884-2.296 4.284-2.296 1.68 0 2.464 1.036 2.464 2.744V25h1.848z"/>
<path fill="#405263" d="M5.26176342 26.4094389C2.04147988 23.6582233 0 19.5675182 0 15c0-4.1421356 1.67893219-7.89213562 4.39339828-10.60660172C7.10786438 1.67893219 10.8578644 0 15 0c8.2842712 0 15 6.71572875 15 15 0 8.2842712-6.7157288 15-15 15-3.716753 0-7.11777662-1.3517984-9.73823658-3.5905611zM4.03811305 15.9222506C5.70084247 14.4569342 6.87195416 12.5 10 12.5c5 0 5 5 10 5 3.1280454 0 4.2991572-1.9569336 5.961887-3.4222502C25.4934253 8.43417206 20.7645408 4 15 4 8.92486775 4 4 8.92486775 4 15c0 .3105915.01287248.6181765.03811305.9222506z"/>
</svg>

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 60 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,5 @@
{
"/js/app.js": "/js/app.js?id=9bd1f62368806951d0da",
"/css/app.css": "/css/app.css?id=1f235151e78555d1e034",
"/js/app.js.map": "/js/app.js.map?id=f979e94a4ab33a650101",
"/css/app.css.map": "/css/app.css.map?id=e763cea28ae63fce4ad5"
}
"/app.js": "/app.js?id=3fc0c0b5d14850a52685",
"/app.css": "/app.css?id=cefed9132a927b70fdd6",
"/app-dark.css": "/app-dark.css?id=596688837e7ffbb58e37"
}

View file

@ -5,7 +5,7 @@
<h2>Login</h2>
<form action="login" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="text" name="username" placeholder="username">
<input type="text" name="name" placeholder="username">
<input type="password" name="password" placeholder="password">
<input type="submit" name="submit" value="Login">
</form>

View file

@ -0,0 +1,10 @@
@extends('master')
@section('title')Logout @stop
@section('content')
<h2>Logout</h2>
<form action="logout" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="submit" name="submit" value="Logout">
</form>
@stop

View file

@ -14,17 +14,21 @@
Route::group(['domain' => config('url.longurl')], function () {
Route::get('/', 'NotesController@index');
//Static project page
// Static project page
Route::view('projects', 'projects');
//Static colophon page
// Static colophon page
Route::view('colophon', 'colophon');
//The login routes to get authe'd for admin
// The login routes to get auth'd for admin
Route::get('login', 'AuthController@showLogin')->name('login');
Route::post('login', 'AuthController@login');
//Admin pages grouped for filter
// And the logout routes
Route::get('logout', 'AuthController@showLogout')->name('logout');
Route::post('logout', 'AuthController@logout');
// Admin pages grouped for filter
Route::group([
'middleware' => 'myauth',
'namespace' => 'Admin',
@ -42,7 +46,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::delete('/{id}', 'ArticlesController@destroy');
});
//Notes
// Notes
Route::group(['prefix' => 'notes'], function () {
Route::get('/', 'NotesController@index');
Route::get('/create', 'NotesController@create');
@ -52,7 +56,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::delete('/{id}', 'NotesController@destroy');
});
//Micropub Clients
// Micropub Clients
Route::group(['prefix' => 'clients'], function () {
Route::get('/', 'ClientsController@index');
Route::get('/create', 'ClientsController@create');
@ -62,7 +66,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::delete('/{id}', 'ClientsController@destroy');
});
//Contacts
// Contacts
Route::group(['prefix' => 'contacts'], function () {
Route::get('/', 'ContactsController@index');
Route::get('/create', 'ContactsController@create');
@ -73,7 +77,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::get('/{id}/getavatar', 'ContactsController@getAvatar');
});
//Places
// Places
Route::group(['prefix' => 'places'], function () {
Route::get('/', 'PlacesController@index');
Route::get('/create', 'PlacesController@create');
@ -86,7 +90,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::delete('/{id}', 'PlacesController@destroy');
});
//Likes
// Likes
Route::group(['prefix' => 'likes'], function () {
Route::get('/', 'LikesController@index');
Route::get('/create', 'LikesController@create');
@ -97,7 +101,7 @@ Route::group(['domain' => config('url.longurl')], function () {
});
});
//Blog pages using ArticlesController
// Blog pages using ArticlesController
Route::group(['prefix' => 'blog'], function () {
Route::get('/feed.rss', 'FeedsController@blogRss');
Route::get('/feed.atom', 'FeedsController@blogAtom');
@ -107,7 +111,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::get('/{year}/{month}/{slug}', 'ArticlesController@show');
});
//Notes pages using NotesController
// Notes pages using NotesController
Route::group(['prefix' => 'notes'], function () {
Route::get('/', 'NotesController@index');
Route::get('/feed.rss', 'FeedsController@notesRss');
@ -139,15 +143,15 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::post('api/media', 'MicropubController@media')->middleware('micropub.token', 'cors')->name('media-endpoint');
Route::options('/api/media', 'MicropubController@mediaOptionsResponse')->middleware('cors');
//webmention
// Webmention
Route::get('webmention', 'WebMentionsController@get');
Route::post('webmention', 'WebMentionsController@receive');
//Contacts
// Contacts
Route::get('contacts', 'ContactsController@index');
Route::get('contacts/{nick}', 'ContactsController@show');
//Places
// Places
Route::get('places', 'PlacesController@index');
Route::get('places/{slug}', 'PlacesController@show');
@ -156,7 +160,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::post('update-colour-scheme', 'SessionStoreController@saveColour');
});
//Short URL
// Short URL
Route::group(['domain' => config('url.shorturl')], function () {
Route::get('/', 'ShortURLsController@baseURL');
Route::get('@', 'ShortURLsController@twitter');

View file

@ -3,13 +3,20 @@
namespace Tests\Feature\Admin;
use Tests\TestCase;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class AdminHomeControllerTest extends TestCase
{
use DatabaseTransactions;
public function test_admin_homepage()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin');
$response->assertViewIs('admin.welcome');
}
}

View file

@ -18,15 +18,6 @@ class AdminTest extends TestCase
$response->assertViewIs('login');
}
public function test_attempt_login_with_good_credentials()
{
$response = $this->post('/login', [
'username' => config('admin.user'),
'password' => config('admin.pass'),
]);
$response->assertRedirect('/admin');
}
public function test_attempt_login_with_bad_credentials()
{
$response = $this->post('/login', [

View file

@ -3,6 +3,7 @@
namespace Tests\Feature\Admin;
use Tests\TestCase;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -12,21 +13,27 @@ class ArticlesTest extends TestCase
public function test_index_page()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/blog');
$response->assertSeeText('Select article to edit:');
}
public function test_create_page()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/blog/create');
$response->assertSeeText('Title (URL)');
}
public function test_create_new_article()
{
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/blog', [
'title' => 'Test Title',
'main' => 'Article content'
@ -36,6 +43,7 @@ class ArticlesTest extends TestCase
public function test_create_new_article_with_upload()
{
$user = factory(User::class)->create();
$faker = \Faker\Factory::create();
$text = $faker->text;
if ($fh = fopen(sys_get_temp_dir() . '/article.md', 'w')) {
@ -45,7 +53,7 @@ class ArticlesTest extends TestCase
$path = sys_get_temp_dir() . '/article.md';
$file = new UploadedFile($path, 'article.md', 'text/plain', filesize($path), null, true);
$this->withSession(['loggedin' => true])
$this->actingAs($user)
->post('/admin/blog', [
'title' => 'Uploaded Article',
'article' => $file,
@ -59,14 +67,18 @@ class ArticlesTest extends TestCase
public function test_see_edit_form()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/blog/1/edit');
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
}
public function test_edit_article()
{
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/blog/1', [
'_method' => 'PUT',
'title' => 'My New Blog',
@ -80,7 +92,9 @@ class ArticlesTest extends TestCase
public function test_delete_article()
{
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/blog/1', [
'_method' => 'DELETE',
]);

View file

@ -3,6 +3,7 @@
namespace Tests\Feature\Admin;
use Tests\TestCase;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ClientsTest extends TestCase
@ -11,21 +12,27 @@ class ClientsTest extends TestCase
public function test_index_page()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/clients');
$response->assertSeeText('Clients');
}
public function test_create_page()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/clients/create');
$response->assertSeeText('New Client');
}
public function test_create_new_client()
{
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/clients', [
'client_name' => 'Micropublish',
'client_url' => 'https://micropublish.net'
@ -38,14 +45,18 @@ class ClientsTest extends TestCase
public function test_see_edit_form()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/clients/1/edit');
$response->assertSee('https://jbl5.dev/notes/new');
}
public function test_edit_client()
{
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/clients/1', [
'_method' => 'PUT',
'client_url' => 'https://jbl5.dev/notes/new',
@ -59,7 +70,9 @@ class ClientsTest extends TestCase
public function test_delete_client()
{
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/clients/1', [
'_method' => 'DELETE',
]);

View file

@ -3,6 +3,7 @@
namespace Tests\Feature\Admin;
use Tests\TestCase;
use App\Models\User;
use GuzzleHttp\Client;
use App\Models\Contact;
use GuzzleHttp\HandlerStack;
@ -26,25 +27,25 @@ class ContactsTest extends TestCase
public function test_index_page()
{
$response = $this->withSession([
'loggedin' => true
])->get('/admin/contacts');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/contacts');
$response->assertViewIs('admin.contacts.index');
}
public function test_create_page()
{
$response = $this->withSession([
'loggedin' => true
])->get('/admin/contacts/create');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/contacts/create');
$response->assertViewIs('admin.contacts.create');
}
public function test_create_new_contact()
{
$this->withSession([
'loggedin' => true
])->post('/admin/contacts', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/contacts', [
'name' => 'Fred Bloggs',
'nick' => 'fred',
'homepage' => 'https://fred.blog/gs',
@ -58,17 +59,17 @@ class ContactsTest extends TestCase
public function test_see_edit_form()
{
$response = $this->withSession([
'loggedin' => true
])->get('/admin/contacts/1/edit');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/contacts/1/edit');
$response->assertViewIs('admin.contacts.edit');
}
public function test_update_contact_no_uploaded_avatar()
{
$this->withSession([
'loggedin' => true
])->post('/admin/contacts/1', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/contacts/1', [
'_method' => 'PUT',
'name' => 'Tantek Celik',
'nick' => 'tantek',
@ -86,9 +87,9 @@ class ContactsTest extends TestCase
copy(__DIR__ . '/../../aaron.png', sys_get_temp_dir() . '/tantek.png');
$path = sys_get_temp_dir() . '/tantek.png';
$file = new UploadedFile($path, 'tantek.png', 'image/png', filesize($path), null, true);
$this->withSession([
'loggedin' => true
])->post('/admin/contacts/1', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/contacts/1', [
'_method' => 'PUT',
'name' => 'Tantek Celik',
'nick' => 'tantek',
@ -104,9 +105,9 @@ class ContactsTest extends TestCase
public function test_delete_contact()
{
$this->withSession([
'loggedin' => true
])->post('/admin/contacts/1', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/contacts/1', [
'_method' => 'DELETE',
]);
$this->assertDatabaseMissing('contacts', [
@ -129,10 +130,9 @@ HTML;
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$this->app->instance(Client::class, $client);
$user = factory(User::class)->create();
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/contacts/1/getavatar');
$this->actingAs($user)->get('/admin/contacts/1/getavatar');
$this->assertFileEquals(
__DIR__ . '/../../aaron.png',
@ -148,10 +148,9 @@ HTML;
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$this->app->instance(Client::class, $client);
$user = factory(User::class)->create();
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/contacts/1/getavatar');
$response = $this->actingAs($user)->get('/admin/contacts/1/getavatar');
$response->assertRedirect('/admin/contacts/1/edit');
}
@ -170,10 +169,9 @@ HTML;
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$this->app->instance(Client::class, $client);
$user = factory(User::class)->create();
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/contacts/1/getavatar');
$response = $this->actingAs($user)->get('/admin/contacts/1/getavatar');
$response->assertRedirect('/admin/contacts/1/edit');
}
@ -184,10 +182,9 @@ HTML;
'nick' => 'fred',
'name' => 'Fred Bloggs',
]);
$user = factory(User::class)->create();
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/contacts/' . $contact->id . '/getavatar');
$response = $this->actingAs($user)->get('/admin/contacts/' . $contact->id . '/getavatar');
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
}

View file

@ -2,11 +2,11 @@
namespace Tests\Feature\Admin;
use App\Models\User;
use Tests\TestCase;
use App\Models\Like;
use App\Jobs\ProcessLike;
use Illuminate\Support\Facades\Queue;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class LikesTest extends TestCase
@ -15,14 +15,18 @@ class LikesTest extends TestCase
public function test_index_page()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/likes');
$response->assertSeeText('Likes');
}
public function test_create_page()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/likes/create');
$response->assertSeeText('New Like');
}
@ -30,7 +34,9 @@ class LikesTest extends TestCase
public function test_create_new_like()
{
Queue::fake();
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/likes', [
'like_url' => 'https://example.com'
]);
@ -42,7 +48,9 @@ class LikesTest extends TestCase
public function test_see_edit_form()
{
$response = $this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/admin/likes/1/edit');
$response->assertSee('Edit Like');
}
@ -50,7 +58,9 @@ class LikesTest extends TestCase
public function test_edit_like()
{
Queue::fake();
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/likes/1', [
'_method' => 'PUT',
'like_url' => 'https://example.com',
@ -65,7 +75,9 @@ class LikesTest extends TestCase
{
$like = Like::find(1);
$url = $like->url;
$this->withSession(['loggedin' => true])
$user = factory(User::class)->create();
$this->actingAs($user)
->post('/admin/likes/1', [
'_method' => 'DELETE',
]);

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Admin;
use App\Models\User;
use Tests\TestCase;
use App\Jobs\SendWebMentions;
use Illuminate\Support\Facades\Queue;
@ -13,25 +14,25 @@ class NotesTest extends TestCase
public function test_index_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/notes');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/notes');
$response->assertViewIs('admin.notes.index');
}
public function test_create_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/notes/create');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/notes/create');
$response->assertViewIs('admin.notes.create');
}
public function test_create_a_new_note()
{
$this->withSession([
'loggedin' => true,
])->post('/admin/notes', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/notes', [
'content' => 'A new test note',
]);
$this->assertDatabaseHas('notes', [
@ -41,19 +42,18 @@ class NotesTest extends TestCase
public function test_edit_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/notes/1/edit');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/notes/1/edit');
$response->assertViewIs('admin.notes.edit');
}
public function test_edit_a_note()
{
Queue::fake();
$user = factory(User::class)->create();
$this->withSession([
'loggedin' => true,
])->post('/admin/notes/1', [
$this->actingAs($user)->post('/admin/notes/1', [
'_method' => 'PUT',
'content' => 'An edited note',
'webmentions' => true,
@ -67,9 +67,9 @@ class NotesTest extends TestCase
public function test_delete_note()
{
$this->withSession([
'loggedin' => true,
])->post('/admin/notes/1', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/notes/1', [
'_method' => 'DELETE',
]);
$this->assertSoftDeleted('notes', [

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Admin;
use App\Models\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -11,25 +12,25 @@ class PlacesTest extends TestCase
public function test_index_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/places');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/places');
$response->assertViewIs('admin.places.index');
}
public function test_create_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/places/create');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/places/create');
$response->assertViewIs('admin.places.create');
}
public function test_create_new_place()
{
$this->withSession([
'loggedin' => true,
])->post('/admin/places', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/places', [
'name' => 'Test Place',
'description' => 'A dummy place for feature tests',
'latitude' => '1.23',
@ -43,17 +44,17 @@ class PlacesTest extends TestCase
public function test_edit_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/places/1/edit');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/places/1/edit');
$response->assertViewIs('admin.places.edit');
}
public function test_updating_a_place()
{
$this->withSession([
'loggedin' => true,
])->post('/admin/places/1', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/places/1', [
'_method' => 'PUT',
'name' => 'The Bridgewater',
'description' => 'Who uses “Pub” anyway',