Skip to content

Firefly III: a personal finances manager

Drop Sandstorm related code.

James Coleb83d06294d6a
diff --git a/.env.example b/.env.example
index 67e9c9f33d..7888a92370 100644
--- a/.env.example
+++ b/.env.example
@@ -304,7 +304,6 @@ PUSHER_ID=
DEMO_USERNAME=
DEMO_PASSWORD=
USE_ENCRYPTION=false
-IS_SANDSTORM=false
IS_HEROKU=false
FIREFLY_III_LAYOUT=v1
diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php
index 6a026d938d..c965bd3a0a 100644
--- a/app/Http/Controllers/Admin/ConfigurationController.php
+++ b/app/Http/Controllers/Admin/ConfigurationController.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
-use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\ConfigurationRequest;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
@@ -55,7 +54,6 @@ class ConfigurationController extends Controller
}
);
$this->middleware(IsDemoUser::class)->except(['index']);
- $this->middleware(IsSandStormUser::class);
}
/**
diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php
index 5c3366037f..e31e211102 100644
--- a/app/Http/Controllers/Admin/HomeController.php
+++ b/app/Http/Controllers/Admin/HomeController.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
-use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\User;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
@@ -48,7 +47,6 @@ class HomeController extends Controller
{
parent::__construct();
$this->middleware(IsDemoUser::class)->except(['index']);
- $this->middleware(IsSandStormUser::class)->except(['index']);
}
/**
@@ -61,9 +59,8 @@ class HomeController extends Controller
Log::channel('audit')->info('User visits admin index.');
$title = (string) trans('firefly.administration');
$mainTitleIcon = 'fa-hand-spock-o';
- $sandstorm = 1 === (int) getenv('SANDSTORM');
- return view('admin.index', compact('title', 'mainTitleIcon', 'sandstorm'));
+ return view('admin.index', compact('title', 'mainTitleIcon'));
}
/**
diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php
index f21d016fda..f9c0b1d1e6 100644
--- a/app/Http/Controllers/Admin/UpdateController.php
+++ b/app/Http/Controllers/Admin/UpdateController.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
-use FireflyIII\Http\Middleware\IsSandStormUser;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@@ -57,7 +56,6 @@ class UpdateController extends Controller
}
);
$this->middleware(IsDemoUser::class)->except(['index']);
- $this->middleware(IsSandStormUser::class)->except(['index']);
}
/**
diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php
index 1f07ded42b..941b94ecdc 100644
--- a/app/Http/Controllers/Admin/UserController.php
+++ b/app/Http/Controllers/Admin/UserController.php
@@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
-use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\UserFormRequest;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
@@ -57,7 +56,6 @@ class UserController extends Controller
}
);
$this->middleware(IsDemoUser::class)->except(['index', 'show']);
- $this->middleware(IsSandStormUser::class);
}
/**
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 6cd342aaba..164b7fc344 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -28,7 +28,6 @@ use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Exceptions\ValidationException;
use FireflyIII\Http\Middleware\IsDemoUser;
-use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
use FireflyIII\Http\Requests\EmailFormRequest;
use FireflyIII\Http\Requests\ProfileFormRequest;
@@ -85,7 +84,6 @@ class ProfileController extends Controller
$this->externalIdentity = 'eloquent' === $loginProvider || 'remote_user_guard' === $authGuard;
$this->middleware(IsDemoUser::class)->except(['index']);
- $this->middleware(IsSandStormUser::class)->except('index');
}
/**
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 2c538f94d0..d84cf3d709 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -31,7 +31,6 @@ use FireflyIII\Http\Middleware\InterestingMessage;
use FireflyIII\Http\Middleware\IsAdmin;
use FireflyIII\Http\Middleware\Range;
use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
-use FireflyIII\Http\Middleware\Sandstorm;
use FireflyIII\Http\Middleware\SecureHeaders;
use FireflyIII\Http\Middleware\StartFireflySession;
use FireflyIII\Http\Middleware\TrimStrings;
@@ -85,7 +84,6 @@ class Kernel extends HttpKernel
// does not check 2fa
// does not check activation
'web' => [
- Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartFireflySession::class,
@@ -105,7 +103,6 @@ class Kernel extends HttpKernel
// MUST NOT be logged in. Does not care about 2FA or confirmation.
'user-not-logged-in' => [
Installer::class,
- Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartFireflySession::class,
@@ -119,7 +116,6 @@ class Kernel extends HttpKernel
// don't care about confirmation:
'user-logged-in-no-2fa' => [
Installer::class,
- Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartFireflySession::class,
@@ -134,7 +130,6 @@ class Kernel extends HttpKernel
// don't care about 2fa
// don't care about confirmation.
'user-simple-auth' => [
- Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartFireflySession::class,
@@ -149,7 +144,6 @@ class Kernel extends HttpKernel
// MUST be confirmed.
// (this group includes the other Firefly middleware)
'user-full-auth' => [
- Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartFireflySession::class,
@@ -168,7 +162,6 @@ class Kernel extends HttpKernel
// MUST have owner role
// (this group includes the other Firefly middleware)
'admin' => [
- Sandstorm::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartFireflySession::class,
diff --git a/app/Http/Middleware/IsSandStormUser.php b/app/Http/Middleware/IsSandStormUser.php
deleted file mode 100644
index dc5065d8e8..0000000000
--- a/app/Http/Middleware/IsSandStormUser.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * IsSandStormUser.php
- * Copyright (c) 2019 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Http\Middleware;
-
-use Closure;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
-
-
-/**
- * Class IsSandStormUser.
- */
-class IsSandStormUser
-{
- /**
- * Handle an incoming request. May not be a limited user (ie. Sandstorm env. or demo user).
- *
- * @param Request $request
- * @param Closure $next
- * @param string|null $guard
- *
- * @return mixed
- */
- public function handle(Request $request, Closure $next, $guard = null)
- {
- if (Auth::guard($guard)->guest()) {
- // don't care when not logged in, usual stuff applies:
- return $next($request);
- }
-
- if (1 === (int) getenv('SANDSTORM')) {
- app('session')->flash('warning', (string) trans('firefly.sandstorm_not_available'));
-
- return response()->redirectTo(route('index'));
- }
-
- return $next($request);
- }
-}
diff --git a/app/Http/Middleware/Sandstorm.php b/app/Http/Middleware/Sandstorm.php
deleted file mode 100644
index 3a2dae74f8..0000000000
--- a/app/Http/Middleware/Sandstorm.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * Sandstorm.php
- * Copyright (c) 2019 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-/** @noinspection PhpDynamicAsStaticMethodCallInspection */
-declare(strict_types=1);
-
-namespace FireflyIII\Http\Middleware;
-
-use Auth;
-use Closure;
-use FireflyIII\Repositories\User\UserRepositoryInterface;
-use FireflyIII\User;
-use Illuminate\Http\Request;
-use Log;
-
-/**
- * Class Sandstorm.
- */
-class Sandstorm
-{
- /**
- * Detects if is using Sandstorm, and responds by logging the user
- * in and/or creating an account.
- *
- * @param Request $request
- * @param Closure $next
- * @param string|null $guard
- *
- * @return mixed
- */
- public function handle(Request $request, Closure $next, $guard = null)
- {
- // is in Sandstorm environment?
- $sandstorm = 1 === (int) getenv('SANDSTORM');
- app('view')->share('SANDSTORM', $sandstorm);
- if (!$sandstorm) {
- return $next($request);
- }
-
- // we're in sandstorm! is user a guest?
- if (Auth::guard($guard)->guest()) {
- /** @var UserRepositoryInterface $repository */
- $repository = app(UserRepositoryInterface::class);
- $userId = (string) $request->header('X-Sandstorm-User-Id');
-
- // catch anonymous:
- $userId = '' === $userId ? 'anonymous' : $userId;
- $email = $userId . '@firefly';
-
- // always grab the first user in the Sandstorm DB:
- $user = $repository->findByEmail($email) ?? $repository->first();
- // or create somebody if necessary.
- $user = $user ?? $this->createUser($email);
-
- // then log this user in:
- Log::info(sprintf('Sandstorm user ID is "%s"', $userId));
- Log::info(sprintf('Access to database under "%s"', $email));
- Auth::guard($guard)->login($user);
- $repository->attachRole($user, 'owner');
- app('view')->share('SANDSTORM_ANON', false);
- }
-
- return $next($request);
- }
-
-
- /**
- * Create a user.
- *
- * @param string $email
- *
- * @return User
- * @codeCoverageIgnore
- */
- private function createUser(string $email): User
- {
- $repository = app(UserRepositoryInterface::class);
-
- return $repository->store(
- [
- 'blocked' => false,
- 'blocked_code' => null,
- 'email' => $email,
- ]
- );
-
- }
-}
-
-
diff --git a/config/firefly.php b/config/firefly.php
index 5fe3c1b17a..06885c4115 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -143,7 +143,7 @@ return [
],
//'encryption' => null === env('USE_ENCRYPTION') || true === env('USE_ENCRYPTION'),
- 'version' => '5.3.0-alpha.1',
+ 'version' => '5.3.0-beta.1',
'api_version' => '1.2.0',
'db_version' => 14,
'maxUploadSize' => 15242880,
@@ -152,7 +152,6 @@ return [
'send_registration_mail' => env('SEND_REGISTRATION_MAIL', true),
'demo_username' => env('DEMO_USERNAME', ''),
'demo_password' => env('DEMO_PASSWORD', ''),
- 'is_sandstorm' => env('IS_SANDSTORM', 'unknown'),
'fixer_api_key' => env('FIXER_API_KEY', ''),
'mapbox_api_key' => env('MAPBOX_API_KEY', ''),
'trusted_proxies' => env('TRUSTED_PROXIES', ''),
@@ -185,6 +184,7 @@ return [
Tag::class,
Transaction::class,
TransactionJournal::class,
+ Recurrence::class,
],
'allowedMimes' => [
/* plain files */
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index d939a20c8a..cc89626612 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -1511,9 +1511,6 @@ return [
'reset_after' => 'Reset form after submission',
'errors_submission' => 'There was something wrong with your submission. Please check out the errors below.',
- // sandstorm.io errors and messages:
- 'sandstorm_not_available' => 'This function is not available when you are using Firefly III within a Sandstorm.io environment.',
-
// object groups
'default_group_title_name' => '(ungrouped)',
diff --git a/resources/views/v1/admin/index.twig b/resources/views/v1/admin/index.twig
index 065f2c1af2..dd2f1e0883 100644
--- a/resources/views/v1/admin/index.twig
+++ b/resources/views/v1/admin/index.twig
@@ -17,9 +17,7 @@
{% if config('firefly.feature_flags.telemetry') %}
<li><a href="{{ route('admin.telemetry.index') }}">{{ 'telemetry_admin_index'|_ }}</a></li>
{% endif %}
- {% if not sandstorm %}
- <li><a href="{{ route('admin.update-check') }}">{{ 'update_check_title'|_ }}</a></li>
- {% endif %}
+ <li><a href="{{ route('admin.update-check') }}">{{ 'update_check_title'|_ }}</a></li>
</ul>
</div>
</div>
diff --git a/resources/views/v1/layout/default.twig b/resources/views/v1/layout/default.twig
index deeb9d0cb6..3e9466e425 100644
--- a/resources/views/v1/layout/default.twig
+++ b/resources/views/v1/layout/default.twig
@@ -84,13 +84,11 @@
</span>
</li>
- {% if not SANDSTORM %}
- <li class="dropdown user user-menu">
- <span style="cursor:default;color:#fff;padding: 15px;display: block;line-height: 20px;">
- <span class="hidden-xs">{{ Auth.user.email }}</span>
- </span>
- </li>
- {% endif %}
+ <li class="dropdown user user-menu">
+ <span style="cursor:default;color:#fff;padding: 15px;display: block;line-height: 20px;">
+ <span class="hidden-xs">{{ Auth.user.email }}</span>
+ </span>
+ </li>
<li id="sidebar-toggle">
<a href="#" data-toggle="control-sidebar"><i class="fa fa-plus-circle"></i></a>
</li>
diff --git a/resources/views/v1/partials/menu-sidebar.twig b/resources/views/v1/partials/menu-sidebar.twig
index c133b18ad6..e0f141298f 100644
--- a/resources/views/v1/partials/menu-sidebar.twig
+++ b/resources/views/v1/partials/menu-sidebar.twig
@@ -213,12 +213,10 @@
</ul>
</li>
- {% if not SANDSTORM %}
<li>
<a href="{{ route('logout') }}">
<i class="fa fa-sign-out fa-fw"></i>
<span>{{ 'logout'|_ }}</span>
</a>
</li>
- {% endif %}
</ul>
diff --git a/resources/views/v1/profile/index.twig b/resources/views/v1/profile/index.twig
index c33460bfbd..ba6768dcd5 100644
--- a/resources/views/v1/profile/index.twig
+++ b/resources/views/v1/profile/index.twig
@@ -17,7 +17,6 @@
<p>
{{ trans('firefly.user_id_is',{user: userId})|raw }}
</p>
- {% if not SANDSTORM %}
<div class="row">
<div class="col-lg-6">
<ul>
@@ -37,34 +36,11 @@
</ul>
</div>
</div>
-
- {% endif %}
</div>
</div>
</div>
</div>
- {% if SANDSTORM %}
- <div class="row">
- <div class="col-lg-8 col-lg-offset-2 col-md-12 col-sm-12">
- <div class="box box-primary">
- <div class="box-header with-border">
- <h3 class="box-title">Offer template</h3>
- </div>
- <div class="box-body">
- <p>
- Block for sandstorm thing
- </p>
- <div>
- <iframe style="width: 100%; height: 55px; margin: 0; border: 0;" id="offer-iframe">
- </iframe>
- </div>
- </div>
- </div>
- </div>
- </div>
- {% endif %}
- {% if not SANDSTORM %}
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-12 col-sm-12">
<div class="box box-primary">
@@ -89,9 +65,7 @@
</div>
</div>
</div>
- {% endif %}
- {% if not SANDSTORM %}
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-12 col-sm-12">
<div class="box box-primary">
@@ -128,7 +102,6 @@
</div>
</div>
</div>
- {% endif %}
<div id="passport_clients"></div>
{% endblock %}
{% block scripts %}
diff --git a/resources/views/v1/test/test.twig b/resources/views/v1/test/test.twig
index 05aea8e64e..6befc1f428 100644
--- a/resources/views/v1/test/test.twig
+++ b/resources/views/v1/test/test.twig
@@ -1,3 +1,2 @@
list-length: {{ listLength }}
-sandstorm-anon: {% if SANDSTORM_ANON %}true{% else %}false{% endif %}
user-email: {{ Auth.user.email }}
diff --git a/tests/Unit/Middleware/IsSandstormUserTest.php b/tests/Unit/Middleware/IsSandstormUserTest.php
deleted file mode 100644
index 4360447591..0000000000
--- a/tests/Unit/Middleware/IsSandstormUserTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-/**
- * IsSandstormUserTest.php
- * Copyright (c) 2019 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Tests\Unit\Middleware;
-
-use FireflyIII\Http\Middleware\IsSandStormUser;
-use Log;
-use Route;
-use Symfony\Component\HttpFoundation\Response;
-use Tests\TestCase;
-
-/**
- * Class IsSandstormUserTest
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- * @SuppressWarnings(PHPMD.TooManyPublicMethods)
- */
-class IsSandstormUserTest extends TestCase
-{
- /**
- * Set up test
- */
- public function setUp(): void
- {
- parent::setUp();
- Log::info(sprintf('Now in %s.', get_class($this)));
- Route::middleware(IsSandStormUser::class)->any(
- '/_test/is-sandstorm',static function () {
- return 'OK';
- }
- );
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\IsSandStormUser
- */
- public function testMiddlewareNotAuthenticated(): void
- {
- $this->withoutExceptionHandling();
- $response = $this->get('/_test/is-sandstorm');
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\IsSandStormUser
- */
- public function testMiddlewareNotSandStorm(): void
- {
- $this->withoutExceptionHandling();
- $this->be($this->user());
- $response = $this->get('/_test/is-sandstorm');
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\IsSandStormUser
- */
- public function testMiddlewareSandstorm(): void
- {
- putenv('SANDSTORM=1');
- $this->withoutExceptionHandling();
- $this->be($this->user());
- $response = $this->get('/_test/is-sandstorm');
-
- $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
- $response->assertSessionHas('warning', (string)trans('firefly.sandstorm_not_available'));
- $response->assertRedirect(route('index'));
- putenv('SANDSTORM=0');
- }
-}
diff --git a/tests/Unit/Middleware/SandstormTest.php b/tests/Unit/Middleware/SandstormTest.php
deleted file mode 100644
index 9e4459a753..0000000000
--- a/tests/Unit/Middleware/SandstormTest.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-/**
- * SandstormTest.php
- * Copyright (c) 2019 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Tests\Unit\Middleware;
-
-use FireflyIII\Http\Middleware\Sandstorm;
-use FireflyIII\Repositories\User\UserRepositoryInterface;
-use Log;
-use Mockery;
-use Route;
-use Symfony\Component\HttpFoundation\Response;
-use Tests\TestCase;
-
-/**
- * Class RangeTest
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- * @SuppressWarnings(PHPMD.TooManyPublicMethods)
- */
-class SandstormTest extends TestCase
-{
- /**
- * Set up test
- */
- public function setUp(): void
- {
- parent::setUp();
- Log::info(sprintf('Now in %s.', get_class($this)));
- Route::middleware(Sandstorm::class)->any(
- '/_test/sandstorm', function () {
- return view('test.test');
- }
- );
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\Sandstorm
- */
- public function testMiddlewareBasic(): void
- {
- putenv('SANDSTORM=1');
-
- $repository = $this->mock(UserRepositoryInterface::class);
- $repository->shouldReceive('findByEmail')->withArgs(['anonymous@firefly'])->once()->andReturn($this->user());
- // single user, checks if user is admin
- $repository->shouldReceive('count')->andReturn(1);
- $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->once();
- $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->once();
- $repository->shouldReceive('attachRole')->withArgs([Mockery::any(), 'owner'])->once();
-
- $response = $this->get('/_test/sandstorm');
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
- $response->assertSee('sandstorm-anon: false');
-
- putenv('SANDSTORM=0');
- }
-
-
-
- /**
- * @covers \FireflyIII\Http\Middleware\Sandstorm
- */
- public function testMiddlewareNotSandstorm(): void
- {
- putenv('SANDSTORM=0');
-
- $response = $this->get('/_test/sandstorm');
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
- $response->assertSee('sandstorm-anon: false');
- }
-}