mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -41,16 +41,6 @@ class INGDebitCreditTest extends TestCase
|
||||
$this->assertEquals(-1, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Converter\INGDebitCredit::convert()
|
||||
*/
|
||||
public function testConvertBij()
|
||||
{
|
||||
$converter = new INGDebitCredit;
|
||||
$result = $converter->convert('Bij');
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Converter\INGDebitCredit::convert()
|
||||
*/
|
||||
@@ -60,4 +50,14 @@ class INGDebitCreditTest extends TestCase
|
||||
$result = $converter->convert('9083jkdkj');
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Converter\INGDebitCredit::convert()
|
||||
*/
|
||||
public function testConvertBij()
|
||||
{
|
||||
$converter = new INGDebitCredit;
|
||||
$result = $converter->convert('Bij');
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
}
|
@@ -103,6 +103,39 @@ class AuthenticateTwoFactorTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* tests for user with 2FA and secret and cookie. Continue to page.
|
||||
*
|
||||
* 2FA enabled: true
|
||||
* 2FA secret : 'abcde'
|
||||
* cookie : false
|
||||
*
|
||||
*
|
||||
* @covers \FireflyIII\Http\Middleware\AuthenticateTwoFactor::handle
|
||||
*/
|
||||
public function testMiddlewareTwoFAAuthed()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$user = $this->user();
|
||||
$user->blocked = 0;
|
||||
$this->be($user);
|
||||
|
||||
// pref for has 2fa is true
|
||||
$preference = new Preference;
|
||||
$preference->data = true;
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->once()->andReturn($preference);
|
||||
|
||||
// pref for twoFactorAuthSecret
|
||||
$secret = new Preference;
|
||||
$secret->data = 'SomeSecret';
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->once()->andReturn($secret);
|
||||
|
||||
// no cookie
|
||||
$cookie = ['twoFactorAuthenticated' => 'true'];
|
||||
$response = $this->call('GET', '/_test/authenticate', [], $cookie);
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* tests for user with 2FA but no secret. 2FA is not fired.
|
||||
*
|
||||
@@ -168,40 +201,6 @@ class AuthenticateTwoFactorTest extends TestCase
|
||||
$response->assertRedirect(route('two-factor.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* tests for user with 2FA and secret and cookie. Continue to page.
|
||||
*
|
||||
* 2FA enabled: true
|
||||
* 2FA secret : 'abcde'
|
||||
* cookie : false
|
||||
*
|
||||
*
|
||||
* @covers \FireflyIII\Http\Middleware\AuthenticateTwoFactor::handle
|
||||
*/
|
||||
public function testMiddlewareTwoFAAuthed()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$user = $this->user();
|
||||
$user->blocked = 0;
|
||||
$this->be($user);
|
||||
|
||||
// pref for has 2fa is true
|
||||
$preference = new Preference;
|
||||
$preference->data = true;
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->once()->andReturn($preference);
|
||||
|
||||
// pref for twoFactorAuthSecret
|
||||
$secret = new Preference;
|
||||
$secret->data = 'SomeSecret';
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->once()->andReturn($secret);
|
||||
|
||||
// no cookie
|
||||
$cookie = ['twoFactorAuthenticated' => 'true'];
|
||||
$response = $this->call('GET', '/_test/authenticate', [], $cookie);
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
|
@@ -55,17 +55,6 @@ class IsAdminTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsAdmin::handle
|
||||
*/
|
||||
public function testMiddlewareOwner()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$this->withoutExceptionHandling();
|
||||
$response = $this->get('/_test/is-admin');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsAdmin::handle
|
||||
*/
|
||||
@@ -78,6 +67,17 @@ class IsAdminTest extends TestCase
|
||||
$response->assertRedirect(route('home'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsAdmin::handle
|
||||
*/
|
||||
public function testMiddlewareOwner()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$this->withoutExceptionHandling();
|
||||
$response = $this->get('/_test/is-admin');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
|
@@ -33,16 +33,6 @@ use Tests\TestCase;
|
||||
*/
|
||||
class IsDemoUserTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser::handle
|
||||
*/
|
||||
public function testMiddlewareNotAuthenticated()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$response = $this->get('/_test/is-demo');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser::handle
|
||||
*/
|
||||
@@ -68,6 +58,16 @@ class IsDemoUserTest extends TestCase
|
||||
$response->assertRedirect(route('index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser::handle
|
||||
*/
|
||||
public function testMiddlewareNotAuthenticated()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$response = $this->get('/_test/is-demo');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Helpers;
|
||||
|
||||
use FireflyIII\Http\Middleware\IsDemoUser;
|
||||
use FireflyIII\Http\Middleware\IsSandStormUser;
|
||||
use Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@@ -51,6 +51,21 @@ class SandstormTest extends TestCase
|
||||
putenv('SANDSTORM=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Sandstorm::handle
|
||||
*/
|
||||
public function testMiddlewareAnonLoggedIn()
|
||||
{
|
||||
putenv('SANDSTORM=1');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/sandstorm');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
$response->assertSee('sandstorm-anon: true');
|
||||
|
||||
putenv('SANDSTORM=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Sandstorm::handle
|
||||
*/
|
||||
@@ -83,21 +98,6 @@ class SandstormTest extends TestCase
|
||||
putenv('SANDSTORM=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Sandstorm::handle
|
||||
*/
|
||||
public function testMiddlewareAnonLoggedIn()
|
||||
{
|
||||
putenv('SANDSTORM=1');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/sandstorm');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
$response->assertSee('sandstorm-anon: true');
|
||||
|
||||
putenv('SANDSTORM=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Sandstorm::handle
|
||||
*/
|
||||
|
Reference in New Issue
Block a user