mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-16 16:41:03 +02:00
Move debug information to the admin section - Closes #303
This commit is contained in:
@ -15,12 +15,12 @@ use Tests\FeatureTestCase;
|
||||
#[CoversClass(SystemController::class)]
|
||||
class SystemControllerTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
//use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user;
|
||||
protected $user, $admin;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -30,6 +30,26 @@ class SystemControllerTest extends FeatureTestCase
|
||||
parent::setUp();
|
||||
|
||||
$this->user = User::factory()->create();
|
||||
$this->admin = User::factory()->administrator()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_infos_returns_unauthorized()
|
||||
{
|
||||
$response = $this->json('GET', '/infos')
|
||||
->assertUnauthorized();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_infos_returns_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('GET', '/infos')
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +57,8 @@ class SystemControllerTest extends FeatureTestCase
|
||||
*/
|
||||
public function test_infos_returns_only_base_collection()
|
||||
{
|
||||
$response = $this->json('GET', '/infos')
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
->json('GET', '/infos')
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'common' => [
|
||||
@ -54,61 +75,10 @@ class SystemControllerTest extends FeatureTestCase
|
||||
'PHP version',
|
||||
'Operating system',
|
||||
'interface',
|
||||
],
|
||||
])
|
||||
->assertJsonMissing([
|
||||
'user_preferences',
|
||||
'admin_settings',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_infos_returns_user_preferences_when_signed_in()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('GET', '/infos')
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'user_preferences' => [
|
||||
'showOtpAsDot',
|
||||
'closeOtpOnCopy',
|
||||
'copyOtpOnDisplay',
|
||||
'useBasicQrcodeReader',
|
||||
'displayMode',
|
||||
'showAccountsIcons',
|
||||
'kickUserAfter',
|
||||
'activeGroup',
|
||||
'rememberActiveGroup',
|
||||
'defaultGroup',
|
||||
'defaultCaptureMode',
|
||||
'useDirectCapture',
|
||||
'useWebauthnOnly',
|
||||
'getOfficialIcons',
|
||||
'lang',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_infos_returns_admin_settings_when_signed_in_as_admin()
|
||||
{
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
$admin = User::factory()->administrator()->create();
|
||||
|
||||
$response = $this->actingAs($admin, 'api-guard')
|
||||
->json('GET', '/infos')
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'admin_settings' => [
|
||||
'useEncryption',
|
||||
'lastRadarScan',
|
||||
'checkForUpdate',
|
||||
'Auth guard',
|
||||
'webauthn user verification',
|
||||
'Trusted proxies',
|
||||
'lastRadarScan'
|
||||
],
|
||||
]);
|
||||
}
|
||||
@ -118,11 +88,12 @@ class SystemControllerTest extends FeatureTestCase
|
||||
*/
|
||||
public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'reverse-proxy-guard')
|
||||
$response = $this->actingAs($this->admin, 'reverse-proxy-guard')
|
||||
->json('GET', '/infos')
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'common' => [
|
||||
'Auth proxy logout url',
|
||||
'Auth proxy header for user',
|
||||
'Auth proxy header for email',
|
||||
],
|
||||
|
Reference in New Issue
Block a user