|
@@ -15,12 +15,12 @@ use Tests\FeatureTestCase;
|
|
#[CoversClass(SystemController::class)]
|
|
#[CoversClass(SystemController::class)]
|
|
class SystemControllerTest extends FeatureTestCase
|
|
class SystemControllerTest extends FeatureTestCase
|
|
{
|
|
{
|
|
- use WithoutMiddleware;
|
|
|
|
|
|
+ //use WithoutMiddleware;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
|
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
|
*/
|
|
*/
|
|
- protected $user;
|
|
|
|
|
|
+ protected $user, $admin;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @test
|
|
* @test
|
|
@@ -30,85 +30,55 @@ class SystemControllerTest extends FeatureTestCase
|
|
parent::setUp();
|
|
parent::setUp();
|
|
|
|
|
|
$this->user = User::factory()->create();
|
|
$this->user = User::factory()->create();
|
|
|
|
+ $this->admin = User::factory()->administrator()->create();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* @test
|
|
* @test
|
|
*/
|
|
*/
|
|
- public function test_infos_returns_only_base_collection()
|
|
|
|
|
|
+ public function test_infos_returns_unauthorized()
|
|
{
|
|
{
|
|
$response = $this->json('GET', '/infos')
|
|
$response = $this->json('GET', '/infos')
|
|
- ->assertOk()
|
|
|
|
- ->assertJsonStructure([
|
|
|
|
- 'common' => [
|
|
|
|
- 'Date',
|
|
|
|
- 'userAgent',
|
|
|
|
- 'Version',
|
|
|
|
- 'Environment',
|
|
|
|
- 'Install path',
|
|
|
|
- 'Debug',
|
|
|
|
- 'Cache driver',
|
|
|
|
- 'Log channel',
|
|
|
|
- 'Log level',
|
|
|
|
- 'DB driver',
|
|
|
|
- 'PHP version',
|
|
|
|
- 'Operating system',
|
|
|
|
- 'interface',
|
|
|
|
- ],
|
|
|
|
- ])
|
|
|
|
- ->assertJsonMissing([
|
|
|
|
- 'user_preferences',
|
|
|
|
- 'admin_settings',
|
|
|
|
- ]);
|
|
|
|
|
|
+ ->assertUnauthorized();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* @test
|
|
* @test
|
|
*/
|
|
*/
|
|
- public function test_infos_returns_user_preferences_when_signed_in()
|
|
|
|
|
|
+ public function test_infos_returns_forbidden()
|
|
{
|
|
{
|
|
$response = $this->actingAs($this->user, 'api-guard')
|
|
$response = $this->actingAs($this->user, 'api-guard')
|
|
->json('GET', '/infos')
|
|
->json('GET', '/infos')
|
|
- ->assertOk()
|
|
|
|
- ->assertJsonStructure([
|
|
|
|
- 'user_preferences' => [
|
|
|
|
- 'showOtpAsDot',
|
|
|
|
- 'closeOtpOnCopy',
|
|
|
|
- 'copyOtpOnDisplay',
|
|
|
|
- 'useBasicQrcodeReader',
|
|
|
|
- 'displayMode',
|
|
|
|
- 'showAccountsIcons',
|
|
|
|
- 'kickUserAfter',
|
|
|
|
- 'activeGroup',
|
|
|
|
- 'rememberActiveGroup',
|
|
|
|
- 'defaultGroup',
|
|
|
|
- 'defaultCaptureMode',
|
|
|
|
- 'useDirectCapture',
|
|
|
|
- 'useWebauthnOnly',
|
|
|
|
- 'getOfficialIcons',
|
|
|
|
- 'lang',
|
|
|
|
- ],
|
|
|
|
- ]);
|
|
|
|
|
|
+ ->assertForbidden();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* @test
|
|
* @test
|
|
*/
|
|
*/
|
|
- public function test_infos_returns_admin_settings_when_signed_in_as_admin()
|
|
|
|
|
|
+ public function test_infos_returns_only_base_collection()
|
|
{
|
|
{
|
|
- /**
|
|
|
|
- * @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
|
|
|
- */
|
|
|
|
- $admin = User::factory()->administrator()->create();
|
|
|
|
-
|
|
|
|
- $response = $this->actingAs($admin, 'api-guard')
|
|
|
|
|
|
+ $response = $this->actingAs($this->admin, 'api-guard')
|
|
->json('GET', '/infos')
|
|
->json('GET', '/infos')
|
|
->assertOk()
|
|
->assertOk()
|
|
->assertJsonStructure([
|
|
->assertJsonStructure([
|
|
- 'admin_settings' => [
|
|
|
|
- 'useEncryption',
|
|
|
|
- 'lastRadarScan',
|
|
|
|
- 'checkForUpdate',
|
|
|
|
|
|
+ 'common' => [
|
|
|
|
+ 'Date',
|
|
|
|
+ 'userAgent',
|
|
|
|
+ 'Version',
|
|
|
|
+ 'Environment',
|
|
|
|
+ 'Install path',
|
|
|
|
+ 'Debug',
|
|
|
|
+ 'Cache driver',
|
|
|
|
+ 'Log channel',
|
|
|
|
+ 'Log level',
|
|
|
|
+ 'DB driver',
|
|
|
|
+ 'PHP version',
|
|
|
|
+ 'Operating system',
|
|
|
|
+ 'interface',
|
|
|
|
+ '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()
|
|
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')
|
|
->json('GET', '/infos')
|
|
->assertOk()
|
|
->assertOk()
|
|
->assertJsonStructure([
|
|
->assertJsonStructure([
|
|
'common' => [
|
|
'common' => [
|
|
|
|
+ 'Auth proxy logout url',
|
|
'Auth proxy header for user',
|
|
'Auth proxy header for user',
|
|
'Auth proxy header for email',
|
|
'Auth proxy header for email',
|
|
],
|
|
],
|