mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-22 00:03:09 +01:00
Replace DocBlocks tests markup with phpunit v11 attributes
This commit is contained in:
parent
cced8dbaff
commit
1a752d1243
@ -6,6 +6,7 @@
|
||||
use App\Api\v1\Resources\UserResource;
|
||||
use App\Models\User;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -25,9 +26,6 @@ class UserControllerTest extends FeatureTestCase
|
||||
'value',
|
||||
];
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -35,9 +33,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_existing_user_when_authenticated_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -54,9 +50,7 @@ public function test_show_existing_user_when_authenticated_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_allPreferences_returns_consistent_json_structure()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -67,9 +61,7 @@ public function test_allPreferences_returns_consistent_json_structure()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_allPreferences_returns_preferences_with_default_values()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -84,9 +76,7 @@ public function test_allPreferences_returns_preferences_with_default_values()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_allPreferences_returns_preferences_with_user_values()
|
||||
{
|
||||
$userPrefs = [];
|
||||
@ -117,9 +107,7 @@ public function test_allPreferences_returns_preferences_with_user_values()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_showPreference_returns_preference_with_default_value()
|
||||
{
|
||||
/**
|
||||
@ -136,9 +124,7 @@ public function test_showPreference_returns_preference_with_default_value()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_showPreference_returns_preference_with_custom_value()
|
||||
{
|
||||
$showOtpAsDot = ! config('2fauth.preferences.showOtpAsDot');
|
||||
@ -153,9 +139,7 @@ public function test_showPreference_returns_preference_with_custom_value()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_showPreference_for_missing_preference_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -163,9 +147,7 @@ public function test_showPreference_for_missing_preference_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_setPreference_returns_updated_preference()
|
||||
{
|
||||
/**
|
||||
@ -187,9 +169,7 @@ public function test_setPreference_returns_updated_preference()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_setPreference_for_missing_preference_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -200,9 +180,7 @@ public function test_setPreference_for_missing_preference_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_setPreference_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
|
@ -10,6 +10,7 @@
|
||||
use App\Models\User;
|
||||
use App\Policies\GroupPolicy;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
#[CoversClass(GroupController::class)]
|
||||
@ -50,9 +51,6 @@ class GroupControllerTest extends FeatureTestCase
|
||||
|
||||
private const NEW_GROUP_NAME = 'MyNewGroup';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -80,9 +78,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_returns_user_groups_only_with_pseudo_group()
|
||||
{
|
||||
$this->actingAs($this->user, 'api-guard')
|
||||
@ -107,9 +103,7 @@ public function test_index_returns_user_groups_only_with_pseudo_group()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_returns_created_group_resource()
|
||||
{
|
||||
$this->actingAs($this->user, 'api-guard')
|
||||
@ -128,9 +122,7 @@ public function test_store_returns_created_group_resource()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_invalid_data_returns_validation_error()
|
||||
{
|
||||
$this->actingAs($this->user, 'api-guard')
|
||||
@ -140,9 +132,7 @@ public function test_store_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_returns_group_resource()
|
||||
{
|
||||
$group = Group::factory()->for($this->user)->create([
|
||||
@ -158,9 +148,7 @@ public function test_show_returns_group_resource()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_missing_group_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -171,9 +159,7 @@ public function test_show_missing_group_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_group_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
@ -184,9 +170,7 @@ public function test_show_group_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_returns_updated_group_resource()
|
||||
{
|
||||
$group = Group::factory()->for($this->user)->create();
|
||||
@ -202,9 +186,7 @@ public function test_update_returns_updated_group_resource()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_missing_group_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -217,9 +199,7 @@ public function test_update_missing_group_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$group = Group::factory()->for($this->user)->create();
|
||||
@ -231,9 +211,7 @@ public function test_update_with_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_group_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
@ -246,9 +224,7 @@ public function test_update_group_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_accounts_returns_updated_group_resource()
|
||||
{
|
||||
$group = Group::factory()->for($this->user)->create();
|
||||
@ -266,9 +242,7 @@ public function test_assign_accounts_returns_updated_group_resource()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_accounts_to_missing_group_returns_not_found()
|
||||
{
|
||||
$accounts = TwoFAccount::factory()->count(2)->for($this->user)->create();
|
||||
@ -283,9 +257,7 @@ public function test_assign_accounts_to_missing_group_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_invalid_accounts_returns_validation_error()
|
||||
{
|
||||
$group = Group::factory()->for($this->user)->create();
|
||||
@ -298,9 +270,7 @@ public function test_assign_invalid_accounts_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_to_group_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
@ -313,9 +283,7 @@ public function test_assign_to_group_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_accounts_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -328,9 +296,7 @@ public function test_assign_accounts_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_accounts_returns_twofaccounts_collection()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -358,9 +324,7 @@ public function test_accounts_returns_twofaccounts_collection()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_accounts_returns_twofaccounts_collection_with_secret()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -383,9 +347,7 @@ public function test_accounts_returns_twofaccounts_collection_with_secret()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_accounts_of_missing_group_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -396,9 +358,7 @@ public function test_accounts_of_missing_group_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_accounts_of_another_user_group_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
@ -411,9 +371,8 @@ public function test_accounts_of_another_user_group_is_forbidden()
|
||||
|
||||
/**
|
||||
* test Group deletion via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_group_returns_success()
|
||||
{
|
||||
$group = Group::factory()->for($this->user)->create();
|
||||
@ -425,9 +384,8 @@ public function test_destroy_group_returns_success()
|
||||
|
||||
/**
|
||||
* test Group deletion via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_missing_group_returns_not_found()
|
||||
{
|
||||
$this->actingAs($this->user, 'api-guard')
|
||||
@ -438,9 +396,7 @@ public function test_destroy_missing_group_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_group_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
@ -451,9 +407,7 @@ public function test_destroy_group_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_group_resets_user_preferences()
|
||||
{
|
||||
// Set the default group to a specific one
|
||||
@ -474,9 +428,7 @@ public function test_destroy_group_resets_user_preferences()
|
||||
$this->assertEquals(0, $this->user->preferences['activeGroup']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_twofaccount_is_released_on_group_destroy()
|
||||
{
|
||||
$this->actingAs($this->user, 'api-guard')
|
||||
|
@ -7,6 +7,7 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -27,9 +28,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_upload_icon_returns_filename()
|
||||
{
|
||||
$file = UploadedFile::fake()->image('testIcon.jpg');
|
||||
@ -44,9 +43,7 @@ public function test_upload_icon_returns_filename()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_upload_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -56,9 +53,7 @@ public function test_upload_with_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fetch_logo_returns_filename()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -71,9 +66,7 @@ public function test_fetch_logo_returns_filename()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fetch_unknown_logo_returns_nothing()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -83,9 +76,7 @@ public function test_fetch_unknown_logo_returns_nothing()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_icon_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -93,9 +84,7 @@ public function test_delete_icon_returns_success()
|
||||
->assertNoContent(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_invalid_icon_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -103,9 +92,7 @@ public function test_delete_invalid_icon_returns_success()
|
||||
->assertNoContent(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_icon_of_another_user_is_forbidden()
|
||||
{
|
||||
$anotherUser = User::factory()->create();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Models\TwoFAccount;
|
||||
use App\Models\User;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Classes\LocalFile;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
@ -27,9 +28,6 @@ class QrCodeControllerTest extends FeatureTestCase
|
||||
*/
|
||||
protected $twofaccount;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -49,9 +47,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_qrcode_returns_base64_image()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -64,9 +60,7 @@ public function test_show_qrcode_returns_base64_image()
|
||||
$this->assertStringStartsWith('data:image/svg+xml;base64', $response->getData()->qrcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_missing_qrcode_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -77,9 +71,7 @@ public function test_show_missing_qrcode_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_qrcode_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
@ -90,9 +82,7 @@ public function test_show_qrcode_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_decode_qrcode_return_success()
|
||||
{
|
||||
$file = LocalFile::fake()->validQrcode();
|
||||
@ -109,9 +99,7 @@ public function test_decode_qrcode_return_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_decode_missing_qrcode_return_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -121,9 +109,7 @@ public function test_decode_missing_qrcode_return_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_decode_invalid_qrcode_return_bad_request()
|
||||
{
|
||||
$file = LocalFile::fake()->invalidQrcode();
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -41,9 +42,6 @@ class SettingControllerTest extends FeatureTestCase
|
||||
|
||||
private const USER_DEFINED_SETTING_CHANGED_VALUE = 'mySetting';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -52,9 +50,7 @@ public function setUp() : void
|
||||
$this->admin = User::factory()->administrator()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_all_controller_routes_are_protected_by_admin_middleware()
|
||||
{
|
||||
$routes = Route::getRoutes()->getRoutes();
|
||||
@ -70,9 +66,7 @@ public function test_all_controller_routes_are_protected_by_admin_middleware()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_returns_setting_collection()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -83,9 +77,7 @@ public function test_index_returns_setting_collection()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_is_forbidden_to_users()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -96,9 +88,7 @@ public function test_index_is_forbidden_to_users()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_native_unchanged_setting_returns_consistent_value()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -110,9 +100,7 @@ public function test_show_native_unchanged_setting_returns_consistent_value()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_native_changed_setting_returns_consistent_value()
|
||||
{
|
||||
Settings::set(self::TWOFAUTH_NATIVE_SETTING, self::TWOFAUTH_NATIVE_SETTING_CHANGED_VALUE);
|
||||
@ -126,9 +114,7 @@ public function test_show_native_changed_setting_returns_consistent_value()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_custom_user_setting_returns_consistent_value()
|
||||
{
|
||||
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
|
||||
@ -142,9 +128,7 @@ public function test_show_custom_user_setting_returns_consistent_value()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_missing_setting_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -152,9 +136,7 @@ public function test_show_missing_setting_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_setting_is_forbidden_to_users()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -165,9 +147,7 @@ public function test_show_setting_is_forbidden_to_users()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_custom_user_setting_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -182,9 +162,7 @@ public function test_store_custom_user_setting_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_invalid_custom_user_setting_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -195,9 +173,7 @@ public function test_store_invalid_custom_user_setting_returns_validation_error(
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_existing_custom_user_setting_returns_validation_error()
|
||||
{
|
||||
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
|
||||
@ -210,9 +186,7 @@ public function test_store_existing_custom_user_setting_returns_validation_error
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_unchanged_native_setting_returns_updated_setting()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -226,9 +200,7 @@ public function test_update_unchanged_native_setting_returns_updated_setting()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_custom_user_setting_returns_updated_setting()
|
||||
{
|
||||
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
|
||||
@ -244,9 +216,7 @@ public function test_update_custom_user_setting_returns_updated_setting()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_missing_user_setting_returns_created_setting()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -260,9 +230,7 @@ public function test_update_missing_user_setting_returns_created_setting()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_user_setting_returns_success()
|
||||
{
|
||||
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
|
||||
@ -272,9 +240,7 @@ public function test_destroy_user_setting_returns_success()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_native_setting_returns_bad_request()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -286,9 +252,7 @@ public function test_destroy_native_setting_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_missing_user_setting_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -296,9 +260,7 @@ public function test_destroy_missing_user_setting_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_is_forbidden_to_users()
|
||||
{
|
||||
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
|
||||
|
@ -19,6 +19,7 @@
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Classes\LocalFile;
|
||||
use Tests\Data\MigrationTestData;
|
||||
use Tests\Data\OtpTestData;
|
||||
@ -178,9 +179,6 @@ class TwoFAccountControllerTest extends FeatureTestCase
|
||||
'secret' => OtpTestData::SECRET,
|
||||
];
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -208,9 +206,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('indexUrlParameterProvider')]
|
||||
public function test_index_returns_user_twofaccounts_only($urlParameter, $expected)
|
||||
{
|
||||
@ -252,9 +248,7 @@ public static function indexUrlParameterProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_returns_twofaccount_resource_with_secret()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -263,9 +257,7 @@ public function test_show_returns_twofaccount_resource_with_secret()
|
||||
->assertJsonStructure(self::VALID_RESOURCE_STRUCTURE_WITH_SECRET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_returns_twofaccount_resource_without_secret()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -274,9 +266,7 @@ public function test_show_returns_twofaccount_resource_without_secret()
|
||||
->assertJsonStructure(self::VALID_RESOURCE_STRUCTURE_WITHOUT_SECRET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
//#[Test]
|
||||
// public function test_show_twofaccount_with_indeciphered_data_returns_replaced_data()
|
||||
// {
|
||||
// $dbEncryptionService = resolve('App\Services\DbEncryptionService');
|
||||
@ -299,9 +289,7 @@ public function test_show_returns_twofaccount_resource_without_secret()
|
||||
// ]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_missing_twofaccount_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -312,9 +300,7 @@ public function test_show_missing_twofaccount_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_twofaccount_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -325,9 +311,7 @@ public function test_show_twofaccount_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('accountCreationProvider')]
|
||||
public function test_store_without_encryption_returns_success_with_consistent_resource_structure($payload, $expected)
|
||||
{
|
||||
@ -341,9 +325,7 @@ public function test_store_without_encryption_returns_success_with_consistent_re
|
||||
->assertJsonFragment($expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('accountCreationProvider')]
|
||||
public function test_store_with_encryption_returns_success_with_consistent_resource_structure($payload, $expected)
|
||||
{
|
||||
@ -406,9 +388,7 @@ public static function accountCreationProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_with_invalid_uri_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -418,9 +398,7 @@ public function test_store_with_invalid_uri_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_assigns_created_account_when_default_group_is_a_specific_one()
|
||||
{
|
||||
// Set the default group to a specific one
|
||||
@ -436,9 +414,7 @@ public function test_store_assigns_created_account_when_default_group_is_a_speci
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_assigns_created_account_when_default_group_is_the_active_one()
|
||||
{
|
||||
// Set the default group to be the active one
|
||||
@ -456,9 +432,7 @@ public function test_store_assigns_created_account_when_default_group_is_the_act
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_assigns_created_account_when_default_group_is_no_group()
|
||||
{
|
||||
// Set the default group to No group
|
||||
@ -474,9 +448,7 @@ public function test_store_assigns_created_account_when_default_group_is_no_grou
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_assigns_created_account_when_default_group_does_not_exist()
|
||||
{
|
||||
// Set the default group to a non-existing one
|
||||
@ -492,9 +464,7 @@ public function test_store_assigns_created_account_when_default_group_does_not_e
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_totp_returns_success_with_updated_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -503,9 +473,7 @@ public function test_update_totp_returns_success_with_updated_resource()
|
||||
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_hotp_returns_success_with_updated_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -514,9 +482,7 @@ public function test_update_hotp_returns_success_with_updated_resource()
|
||||
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_HOTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_missing_twofaccount_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -524,9 +490,7 @@ public function test_update_missing_twofaccount_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_twofaccount_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$twofaccount = TwoFAccount::factory()->create();
|
||||
@ -536,9 +500,7 @@ public function test_update_twofaccount_with_invalid_data_returns_validation_err
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_twofaccount_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -549,9 +511,7 @@ public function test_update_twofaccount_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_valid_gauth_payload_returns_success_with_consistent_resources()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -585,9 +545,7 @@ public function test_migrate_valid_gauth_payload_returns_success_with_consistent
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_with_invalid_gauth_payload_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -597,9 +555,7 @@ public function test_migrate_with_invalid_gauth_payload_returns_validation_error
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_payload_with_duplicates_returns_negative_ids()
|
||||
{
|
||||
$twofaccount = TwoFAccount::factory()->for($this->user)->create([
|
||||
@ -643,9 +599,7 @@ public function test_migrate_payload_with_duplicates_returns_negative_ids()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_identify_duplicates_in_authenticated_user_twofaccounts_only()
|
||||
{
|
||||
$twofaccount = TwoFAccount::factory()->for($this->anotherUser)->create([
|
||||
@ -689,9 +643,7 @@ public function test_migrate_identify_duplicates_in_authenticated_user_twofaccou
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_invalid_gauth_payload_returns_bad_request()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -704,9 +656,7 @@ public function test_migrate_invalid_gauth_payload_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_valid_aegis_json_file_returns_success()
|
||||
{
|
||||
$file = LocalFile::fake()->validAegisJsonFile();
|
||||
@ -754,9 +704,7 @@ public function test_migrate_valid_aegis_json_file_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidAegisJsonFileProvider')]
|
||||
public function test_migrate_invalid_aegis_json_file_returns_bad_request($file)
|
||||
{
|
||||
@ -783,9 +731,7 @@ public static function invalidAegisJsonFileProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('validPlainTextFileProvider')]
|
||||
public function test_migrate_valid_plain_text_file_returns_success($file)
|
||||
{
|
||||
@ -847,9 +793,7 @@ public static function validPlainTextFileProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidPlainTextFileProvider')]
|
||||
public function test_migrate_invalid_plain_text_file_returns_bad_request($file)
|
||||
{
|
||||
@ -882,9 +826,7 @@ public static function invalidPlainTextFileProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reorder_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -897,9 +839,7 @@ public function test_reorder_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reorder_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -909,9 +849,7 @@ public function test_reorder_with_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reorder_twofaccounts_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -924,9 +862,7 @@ public function test_reorder_twofaccounts_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_preview_returns_success_with_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -937,9 +873,7 @@ public function test_preview_returns_success_with_resource()
|
||||
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_preview_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -949,9 +883,7 @@ public function test_preview_with_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_preview_with_unreachable_image_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -964,9 +896,7 @@ public function test_preview_with_unreachable_image_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_returns_json_migration_resource()
|
||||
{
|
||||
$this->twofaccountA = TwoFAccount::factory()->for($this->user)->create(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP);
|
||||
@ -980,9 +910,7 @@ public function test_export_returns_json_migration_resource()
|
||||
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_DEFAULT_HOTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_too_many_ids_returns_bad_request()
|
||||
{
|
||||
TwoFAccount::factory()->count(102)->for($this->user)->create();
|
||||
@ -998,9 +926,7 @@ public function test_export_too_many_ids_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_missing_twofaccount_returns_existing_ones_only()
|
||||
{
|
||||
$this->twofaccountA = TwoFAccount::factory()->for($this->user)->create(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP);
|
||||
@ -1010,9 +936,7 @@ public function test_export_missing_twofaccount_returns_existing_ones_only()
|
||||
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_twofaccount_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1023,9 +947,7 @@ public function test_export_twofaccount_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resource()
|
||||
{
|
||||
$twofaccount = TwoFAccount::factory()->for($this->user)->create([
|
||||
@ -1050,9 +972,7 @@ public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resour
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_totp_uri_returns_consistent_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1067,9 +987,7 @@ public function test_get_otp_by_posting_totp_uri_returns_consistent_resource()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_totp_parameters_returns_consistent_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1082,9 +1000,7 @@ public function test_get_otp_by_posting_totp_parameters_returns_consistent_resou
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resource()
|
||||
{
|
||||
$twofaccount = TwoFAccount::factory()->for($this->user)->create([
|
||||
@ -1109,9 +1025,7 @@ public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resour
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_hotp_uri_returns_consistent_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1126,9 +1040,7 @@ public function test_get_otp_by_posting_hotp_uri_returns_consistent_resource()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_hotp_parameters_returns_consistent_resource()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1141,9 +1053,7 @@ public function test_get_otp_by_posting_hotp_parameters_returns_consistent_resou
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_multiple_inputs_returns_bad_request()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1158,9 +1068,7 @@ public function test_get_otp_by_posting_multiple_inputs_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_request()
|
||||
{
|
||||
Settings::set('useEncryption', true);
|
||||
@ -1181,9 +1089,7 @@ public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_req
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_using_missing_twofaccount_id_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1191,9 +1097,7 @@ public function test_get_otp_using_missing_twofaccount_id_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_invalid_uri_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1203,9 +1107,7 @@ public function test_get_otp_by_posting_invalid_uri_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_by_posting_invalid_parameters_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1213,9 +1115,7 @@ public function test_get_otp_by_posting_invalid_parameters_returns_validation_er
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_otp_of_another_user_twofaccount_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1226,9 +1126,7 @@ public function test_get_otp_of_another_user_twofaccount_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_count_returns_right_number_of_twofaccounts()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1239,9 +1137,7 @@ public function test_count_returns_right_number_of_twofaccounts()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_withdraw_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1252,9 +1148,7 @@ public function test_withdraw_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_withdraw_too_many_ids_returns_bad_request()
|
||||
{
|
||||
TwoFAccount::factory()->count(102)->for($this->user)->create();
|
||||
@ -1270,9 +1164,7 @@ public function test_withdraw_too_many_ids_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_twofaccount_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1280,9 +1172,7 @@ public function test_destroy_twofaccount_returns_success()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_missing_twofaccount_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1290,9 +1180,7 @@ public function test_destroy_missing_twofaccount_returns_not_found()
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_twofaccount_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -1303,9 +1191,7 @@ public function test_destroy_twofaccount_of_another_user_is_forbidden()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_batch_destroy_twofaccount_returns_success()
|
||||
{
|
||||
TwoFAccount::factory()->count(3)->for($this->user)->create();
|
||||
@ -1315,9 +1201,7 @@ public function test_batch_destroy_twofaccount_returns_success()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_batch_destroy_too_many_twofaccounts_returns_bad_request()
|
||||
{
|
||||
TwoFAccount::factory()->count(102)->for($this->user)->create();
|
||||
@ -1333,9 +1217,7 @@ public function test_batch_destroy_too_many_twofaccounts_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_batch_destroy_twofaccount_of_another_user_is_forbidden()
|
||||
{
|
||||
TwoFAccount::factory()->count(2)->for($this->anotherUser)->create();
|
||||
|
@ -24,6 +24,7 @@
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
#[CoversClass(UserManagerController::class)]
|
||||
@ -52,9 +53,6 @@ class UserManagerControllerTest extends FeatureTestCase
|
||||
|
||||
private const PASSWORD = 'password';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -69,9 +67,7 @@ public function setUp() : void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_all_controller_routes_are_protected_by_admin_middleware()
|
||||
{
|
||||
$routes = Route::getRoutes()->getRoutes();
|
||||
@ -87,9 +83,7 @@ public function test_all_controller_routes_are_protected_by_admin_middleware()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_returns_all_users_with_expected_UserManagerResources() : void
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -130,9 +124,7 @@ public function test_index_returns_all_users_with_expected_UserManagerResources(
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_returns_the_expected_UserManagerResource() : void
|
||||
{
|
||||
$this->actingAs($this->admin, 'api-guard')
|
||||
@ -155,9 +147,7 @@ public function test_show_returns_the_expected_UserManagerResource() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_resetPassword_resets_password_and_sends_password_reset_to_user()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -181,9 +171,7 @@ public function test_resetPassword_resets_password_and_sends_password_reset_to_u
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_resetPassword_returns_UserManagerResource()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -199,9 +187,7 @@ public function test_resetPassword_returns_UserManagerResource()
|
||||
$response->assertExactJson($resources->response($request)->getData(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_resetPassword_does_not_notify_when_reset_failed_and_returns_error()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -228,9 +214,7 @@ public function test_resetPassword_does_not_notify_when_reset_failed_and_returns
|
||||
Notification::assertNothingSent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_resetPassword_returns_error_when_notify_send_failed()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -259,9 +243,7 @@ public function test_resetPassword_returns_error_when_notify_send_failed()
|
||||
Notification::assertNothingSent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_creates_the_user_and_returns_success()
|
||||
{
|
||||
$this->actingAs($this->admin, 'api-guard')
|
||||
@ -280,9 +262,7 @@ public function test_store_creates_the_user_and_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_returns_UserManagerResource_of_created_user() : void
|
||||
{
|
||||
$path = '/api/v1/users';
|
||||
@ -300,9 +280,7 @@ public function test_store_returns_UserManagerResource_of_created_user() : void
|
||||
$response->assertExactJson($resource->response($request)->getData(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_returns_UserManagerResource_of_created_admin() : void
|
||||
{
|
||||
$path = '/api/v1/users';
|
||||
@ -321,9 +299,7 @@ public function test_store_returns_UserManagerResource_of_created_admin() : void
|
||||
$response->assertExactJson($resource->response($request)->getData(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokePATs_flushes_pats()
|
||||
{
|
||||
Artisan::call('passport:install', [
|
||||
@ -350,9 +326,7 @@ public function test_revokePATs_flushes_pats()
|
||||
$this->assertCount(0, $tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokePATs_returns_no_content()
|
||||
{
|
||||
$this->actingAs($this->admin, 'api-guard')
|
||||
@ -360,9 +334,7 @@ public function test_revokePATs_returns_no_content()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokePATs_always_returns_no_content()
|
||||
{
|
||||
// a fresh user has no token
|
||||
@ -373,9 +345,7 @@ public function test_revokePATs_always_returns_no_content()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokeWebauthnCredentials_flushes_credentials()
|
||||
{
|
||||
DB::table('webauthn_credentials')->insert([
|
||||
@ -401,9 +371,7 @@ public function test_revokeWebauthnCredentials_flushes_credentials()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokeWebauthnCredentials_returns_no_content()
|
||||
{
|
||||
DB::table('webauthn_credentials')->insert([
|
||||
@ -426,9 +394,7 @@ public function test_revokeWebauthnCredentials_returns_no_content()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokeWebauthnCredentials_always_returns_no_content()
|
||||
{
|
||||
DB::table('webauthn_credentials')->delete();
|
||||
@ -438,9 +404,7 @@ public function test_revokeWebauthnCredentials_always_returns_no_content()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revokeWebauthnCredentials_resets_useWebauthnOnly_user_preference()
|
||||
{
|
||||
$this->user['preferences->useWebauthnOnly'] = true;
|
||||
@ -455,9 +419,7 @@ public function test_revokeWebauthnCredentials_resets_useWebauthnOnly_user_prefe
|
||||
$this->assertFalse($this->user->preferences['useWebauthnOnly']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_returns_no_content()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
@ -467,9 +429,7 @@ public function test_destroy_returns_no_content()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_the_only_admin_returns_forbidden()
|
||||
{
|
||||
$this->actingAs($this->admin, 'api-guard')
|
||||
@ -477,9 +437,7 @@ public function test_destroy_the_only_admin_returns_forbidden()
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_promote_changes_admin_status() : void
|
||||
{
|
||||
$this->actingAs($this->admin, 'api-guard')
|
||||
@ -493,9 +451,7 @@ public function test_promote_changes_admin_status() : void
|
||||
$this->assertTrue($this->user->isAdministrator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_promote_returns_UserManagerResource() : void
|
||||
{
|
||||
$path = '/api/v1/users/' . $this->user->id . '/promote';
|
||||
@ -512,9 +468,7 @@ public function test_promote_returns_UserManagerResource() : void
|
||||
$response->assertExactJson($resources->response($request)->getData(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_demote_returns_UserManagerResource() : void
|
||||
{
|
||||
$anotherAdmin = User::factory()->administrator()->create();
|
||||
@ -533,9 +487,7 @@ public function test_demote_returns_UserManagerResource() : void
|
||||
$response->assertExactJson($resources->response($request)->getData(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_demote_the_only_admin_returns_forbidden() : void
|
||||
{
|
||||
$this->assertTrue(User::admins()->count() == 1);
|
||||
@ -547,9 +499,7 @@ public function test_demote_the_only_admin_returns_forbidden() : void
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_all_preserved_entries() : void
|
||||
{
|
||||
AuthLog::factory()->for($this->user, 'authenticatable')->duringLastYear()->create();
|
||||
@ -566,9 +516,7 @@ public function test_authentications_returns_all_preserved_entries() : void
|
||||
->assertJsonCount(7);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_does_not_return_old_entries() : void
|
||||
{
|
||||
AuthLog::factory()->for($this->user, 'authenticatable')->beforeLastYear()->create();
|
||||
@ -579,9 +527,7 @@ public function test_authentications_does_not_return_old_entries() : void
|
||||
->assertJsonCount(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_user_entries_only() : void
|
||||
{
|
||||
AuthLog::factory()->for($this->admin, 'authenticatable')->create();
|
||||
@ -594,9 +540,7 @@ public function test_authentications_returns_user_entries_only() : void
|
||||
$this->assertEquals($response->getData()[0]->id, $this->user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_expected_resource() : void
|
||||
{
|
||||
AuthLog::factory()->for($this->user, 'authenticatable')->create();
|
||||
@ -620,9 +564,7 @@ public function test_authentications_returns_expected_resource() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_resource_with_timezoned_dates() : void
|
||||
{
|
||||
$timezone = 'Europe/Paris';
|
||||
@ -649,9 +591,7 @@ public function test_authentications_returns_resource_with_timezoned_dates() : v
|
||||
$this->assertTrue($logout_at->isSameMinute($timezonedNow));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_loginless_entries() : void
|
||||
{
|
||||
$this->logUserOut();
|
||||
@ -664,9 +604,7 @@ public function test_authentications_returns_loginless_entries() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_logoutless_entries() : void
|
||||
{
|
||||
$this->logUserIn();
|
||||
@ -679,9 +617,7 @@ public function test_authentications_returns_logoutless_entries() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_failed_entry() : void
|
||||
{
|
||||
$this->json('POST', '/user/login', [
|
||||
@ -697,9 +633,7 @@ public function test_authentications_returns_failed_entry() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_last_month_entries() : void
|
||||
{
|
||||
$this->travel(-2)->months();
|
||||
@ -714,9 +648,7 @@ public function test_authentications_returns_last_month_entries() : void
|
||||
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_last_three_months_entries() : void
|
||||
{
|
||||
$this->travel(-100)->days();
|
||||
@ -733,9 +665,7 @@ public function test_authentications_returns_last_three_months_entries() : void
|
||||
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subDays(80)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_last_six_months_entries() : void
|
||||
{
|
||||
$this->travel(-7)->months();
|
||||
@ -752,9 +682,7 @@ public function test_authentications_returns_last_six_months_entries() : void
|
||||
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subMonths(5)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_last_year_entries() : void
|
||||
{
|
||||
$this->travel(-13)->months();
|
||||
@ -771,9 +699,7 @@ public function test_authentications_returns_last_year_entries() : void
|
||||
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subMonths(11)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('LimitProvider')]
|
||||
public function test_authentications_returns_limited_entries($limit) : void
|
||||
{
|
||||
@ -801,9 +727,7 @@ public static function LimitProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authentications_returns_expected_ip_and_useragent_chunks() : void
|
||||
{
|
||||
AuthLog::factory()->for($this->user, 'authenticatable')->create([
|
||||
@ -821,9 +745,7 @@ public function test_authentications_returns_expected_ip_and_useragent_chunks()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidQueryParameterProvider')]
|
||||
public function test_authentications_with_invalid_limit_returns_validation_error($limit) : void
|
||||
{
|
||||
@ -832,9 +754,7 @@ public function test_authentications_with_invalid_limit_returns_validation_error
|
||||
->assertInvalid(['limit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidQueryParameterProvider')]
|
||||
public function test_authentications_with_invalid_period_returns_validation_error($period) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class GroupAssignRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -58,9 +55,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -28,9 +29,6 @@ class GroupStoreRequestTest extends FeatureTestCase
|
||||
|
||||
const UNIQUE_GROUP_NAME = 'MyGroup';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -38,9 +36,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -52,9 +48,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -79,9 +73,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Classes\LocalFile;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -19,9 +20,7 @@ class QrCodeDecodeRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -33,9 +32,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -59,9 +56,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -21,9 +22,7 @@ class SettingStoreRequestTest extends FeatureTestCase
|
||||
|
||||
const UNIQUE_KEY = 'UniqueKey';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -35,9 +34,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -68,9 +65,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -19,9 +20,7 @@ class SettingUpdateRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -33,9 +32,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -63,9 +60,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class TwoFAccountBatchRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -59,9 +56,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class TwoFAccountDynamicRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input()
|
||||
{
|
||||
$twofaccountUriRequest = new TwoFAccountUriRequest();
|
||||
@ -44,9 +41,7 @@ public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input()
|
||||
$this->assertEquals($twofaccountUriRequest->rules(), $request->rules());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_returns_TwoFAccountStoreRequest_rules_otherwise()
|
||||
{
|
||||
$twofaccountStoreRequest = new TwoFAccountStoreRequest();
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class TwoFAccountImportRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -56,9 +53,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class TwoFAccountReorderRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -59,9 +56,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -20,9 +21,7 @@ class TwoFAccountStoreRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -34,9 +33,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -110,9 +107,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -20,9 +21,7 @@ class TwoFAccountUpdateRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -34,9 +33,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -86,9 +83,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class TwoFAccountUriRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -63,9 +60,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(RouteServiceProvider::class)]
|
||||
class ThrottlingTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_api_calls_are_throttled_using_config()
|
||||
{
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Console\Commands\CheckDbConnection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -13,18 +14,14 @@
|
||||
#[CoversClass(CheckDbConnection::class)]
|
||||
class CheckDbConnectionTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_CheckDbConnection_ends_successfully()
|
||||
{
|
||||
$this->artisan('2fauth:check-db-connection')
|
||||
->assertExitCode(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
// #[Test]
|
||||
// public function test_CheckDbConnection_without_db_returns_false()
|
||||
// {
|
||||
// DB::shouldReceive('connection', 'getPDO')
|
||||
|
@ -6,6 +6,7 @@
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Jackiedo\DotenvEditor\DotenvEditor;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -14,15 +15,13 @@
|
||||
#[CoversClass(Install::class)]
|
||||
class InstallTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
const PASSPORT_PENDING_MIGRATIONS_CONFIRMATION = 'Would you like to run all pending database migrations?';
|
||||
|
||||
const PASSPORT_CREATE_CLIENTS_CONFIRMATION = 'Would you like to create the "personal access" and "password grant" clients?';
|
||||
|
||||
const TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION = 'Existing .env file found. Do you wish to review its vars?';
|
||||
|
||||
#[Test]
|
||||
public function test_install_completes()
|
||||
{
|
||||
$this->artisan('2fauth:install')
|
||||
@ -35,9 +34,7 @@ public function test_install_completes()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_install_informs_about_no_interaction()
|
||||
{
|
||||
$this->artisan('2fauth:install', ['--no-interaction' => true])
|
||||
@ -48,9 +45,7 @@ public function test_install_informs_about_no_interaction()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_install_generates_an_app_key()
|
||||
{
|
||||
config(['app.key' => '']);
|
||||
@ -66,9 +61,7 @@ public function test_install_generates_an_app_key()
|
||||
$this->assertNotEquals('', config('app.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_install_gives_2fauth_address()
|
||||
{
|
||||
$this->artisan('2fauth:install')
|
||||
@ -79,9 +72,7 @@ public function test_install_gives_2fauth_address()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_install_informs_about_sponsoring()
|
||||
{
|
||||
$this->artisan('2fauth:install')
|
||||
@ -93,9 +84,7 @@ public function test_install_informs_about_sponsoring()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_install_fails_with_exception_message()
|
||||
{
|
||||
$mock = $this->mock(DotenvEditor::class);
|
||||
@ -107,9 +96,7 @@ public function test_install_fails_with_exception_message()
|
||||
->assertFailed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_install_fails_with_link_to_online_help()
|
||||
{
|
||||
$mock = $this->mock(DotenvEditor::class);
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
class PurgeLogTest extends FeatureTestCase
|
||||
@ -15,9 +16,6 @@ class PurgeLogTest extends FeatureTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -25,18 +23,14 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_purgeLog_completes()
|
||||
{
|
||||
$this->artisan('2fauth:purge-log')
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_purgeLog_defaults_to_one_year()
|
||||
{
|
||||
$oneYearOldLog = AuthLog::factory()->daysAgo(366)->for($this->user, 'authenticatable')->create();
|
||||
@ -52,9 +46,7 @@ public function test_purgeLog_defaults_to_one_year()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_purgeLog_deletes_records_older_than_retention_time()
|
||||
{
|
||||
$retention = 180;
|
||||
@ -68,9 +60,7 @@ public function test_purgeLog_deletes_records_older_than_retention_time()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_purgeLog_deletes_logout_only_records_older_than_retention_time()
|
||||
{
|
||||
$retention = 180;
|
||||
@ -85,9 +75,7 @@ public function test_purgeLog_deletes_logout_only_records_older_than_retention_t
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_purgeLog_does_not_delete_records_younger_than_retention_time()
|
||||
{
|
||||
$retention = 180;
|
||||
@ -101,9 +89,7 @@ public function test_purgeLog_does_not_delete_records_younger_than_retention_tim
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidConfig')]
|
||||
public function test_purgeLog_with_invalid_config_defaults_to_one_year($config)
|
||||
{
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
class ResetDemoTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_demo_without_demo_mode_succeeded()
|
||||
{
|
||||
$this->artisan('2fauth:reset-demo')
|
||||
@ -18,9 +17,7 @@ public function test_reset_demo_without_demo_mode_succeeded()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_demo_succeeded()
|
||||
{
|
||||
Artisan::call('passport:install', [
|
||||
@ -138,9 +135,7 @@ public function test_reset_demo_succeeded()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_demo_with_invalid_confirmation_succeeded()
|
||||
{
|
||||
Config::set('2fauth.config.isDemoApp', true);
|
||||
@ -151,9 +146,7 @@ public function test_reset_demo_with_invalid_confirmation_succeeded()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_demo_with_no_confirm_option_succeeded()
|
||||
{
|
||||
Config::set('2fauth.config.isDemoApp', true);
|
||||
|
@ -3,13 +3,12 @@
|
||||
namespace Tests\Feature\Console;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
class ResetTestingTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_testing_without_testing_mode_succeeded()
|
||||
{
|
||||
$this->artisan('2fauth:reset-testing')
|
||||
@ -17,9 +16,7 @@ public function test_reset_testing_without_testing_mode_succeeded()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_testing_succeeded()
|
||||
{
|
||||
Config::set('2fauth.config.isTestingApp', true);
|
||||
@ -132,9 +129,7 @@ public function test_reset_testing_succeeded()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_testing_with_invalid_confirmation_succeeded()
|
||||
{
|
||||
Config::set('2fauth.config.isTestingApp', true);
|
||||
@ -145,9 +140,7 @@ public function test_reset_testing_with_invalid_confirmation_succeeded()
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_reset_testing_with_no_confirm_option_succeeded()
|
||||
{
|
||||
Config::set('2fauth.config.isTestingApp', true);
|
||||
|
@ -7,6 +7,7 @@
|
||||
use App\Services\Auth\ReverseProxyGuard;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -37,9 +38,7 @@ public function test_user_is_retreived_from_db()
|
||||
$this->assertEquals($dbUser->id, $user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_set_from_proxy_headers()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -61,9 +60,7 @@ public function test_user_is_set_from_proxy_headers()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_set_from_proxy_headers_with_an_email()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -87,9 +84,7 @@ public function test_user_is_set_from_proxy_headers_with_an_email()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_set_from_proxy_headers_even_if_name_is_long()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -116,9 +111,7 @@ public function test_user_is_set_from_proxy_headers_even_if_name_is_long()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_not_set_from_proxy_headers_when_name_is_missing()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -137,9 +130,7 @@ public function test_user_is_not_set_from_proxy_headers_when_name_is_missing()
|
||||
$this->assertDatabaseCount('users', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_email_is_synced_with_email_from_proxy_headers()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -164,9 +155,7 @@ public function test_user_email_is_synced_with_email_from_proxy_headers()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_missing()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -191,9 +180,7 @@ public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_m
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_invalid()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -218,9 +205,7 @@ public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_i
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_email_is_not_sync_when_email_from_proxy_headers_is_already_in_use()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
|
@ -11,6 +11,7 @@
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -27,9 +28,7 @@ class ForgotPasswordControllerTest extends FeatureTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_email_password_request_without_email_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/password/lost', [
|
||||
@ -40,9 +39,7 @@ public function test_submit_email_password_request_without_email_returns_validat
|
||||
->assertJsonValidationErrors(['email']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_email_password_request_with_invalid_email_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/password/lost', [
|
||||
@ -53,9 +50,7 @@ public function test_submit_email_password_request_with_invalid_email_returns_va
|
||||
->assertJsonValidationErrors(['email']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_email_password_request_with_unknown_email_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/password/lost', [
|
||||
@ -66,9 +61,7 @@ public function test_submit_email_password_request_with_unknown_email_returns_va
|
||||
->assertJsonValidationErrors(['email']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_email_password_request_returns_success()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -89,9 +82,7 @@ public function test_submit_email_password_request_returns_success()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_email_password_request_in_demo_mode_returns_unauthorized()
|
||||
{
|
||||
Config::set('2fauth.config.isDemoApp', true);
|
||||
@ -103,9 +94,7 @@ public function test_submit_email_password_request_in_demo_mode_returns_unauthor
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_email_password_request_when_authenticated_returns_bad_request()
|
||||
{
|
||||
/**
|
||||
|
@ -2,7 +2,10 @@
|
||||
|
||||
namespace Tests\Feature\Http\Auth;
|
||||
|
||||
use App\Exceptions\Handler;
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Middleware\KickOutInactiveUser;
|
||||
use App\Http\Middleware\LogUserLastSeen;
|
||||
use App\Http\Middleware\RejectIfAuthenticated;
|
||||
use App\Http\Middleware\RejectIfDemoMode;
|
||||
use App\Http\Middleware\RejectIfReverseProxy;
|
||||
@ -12,10 +15,13 @@
|
||||
use App\Models\User;
|
||||
use App\Notifications\FailedLogin;
|
||||
use App\Notifications\SignedInWithNewDevice;
|
||||
use App\Rules\CaseInsensitiveEmailExists;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\CoversMethod;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -25,9 +31,13 @@
|
||||
#[CoversClass(RejectIfAuthenticated::class)]
|
||||
#[CoversClass(RejectIfReverseProxy::class)]
|
||||
#[CoversClass(RejectIfDemoMode::class)]
|
||||
#[CoversClass(SkipIfAuthenticated::class)]
|
||||
#[CoversClass(LoginListener::class)]
|
||||
#[CoversClass(FailedLoginListener::class)]
|
||||
#[CoversMethod(CaseInsensitiveEmailExists::class, 'handle')]
|
||||
#[CoversMethod(SkipIfAuthenticated::class, 'handle')]
|
||||
#[CoversMethod(Handler::class, 'register')]
|
||||
#[CoversMethod(KickOutInactiveUser::class, 'handle')]
|
||||
#[CoversMethod(LogUserLastSeen::class, 'handle')]
|
||||
class LoginTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
@ -44,9 +54,6 @@ class LoginTest extends FeatureTestCase
|
||||
|
||||
private const WRONG_PASSWORD = 'wrong_password';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -55,9 +62,7 @@ public function setUp() : void
|
||||
$this->admin = User::factory()->administrator()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_login_returns_success()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -77,9 +82,7 @@ public function test_user_login_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_login_send_new_device_notification()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -107,9 +110,7 @@ public function test_login_send_new_device_notification()
|
||||
Notification::assertSentTo($this->user, SignedInWithNewDevice::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_login_does_not_send_new_device_notification()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -137,9 +138,7 @@ public function test_login_does_not_send_new_device_notification()
|
||||
Notification::assertNothingSentTo($this->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_admin_login_returns_admin_role()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -152,11 +151,7 @@ public function test_admin_login_returns_admin_role()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @covers \App\Rules\CaseInsensitiveEmailExists
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_login_with_uppercased_email_returns_success()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -175,11 +170,7 @@ public function test_user_login_with_uppercased_email_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @covers \App\Http\Middleware\SkipIfAuthenticated
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_login_already_authenticated_is_rejected()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -198,9 +189,7 @@ public function test_user_login_already_authenticated_is_rejected()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_login_with_missing_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -214,11 +203,7 @@ public function test_user_login_with_missing_data_returns_validation_error()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @covers \App\Exceptions\Handler
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_login_with_invalid_credentials_returns_unauthorized()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -231,9 +216,7 @@ public function test_user_login_with_invalid_credentials_returns_unauthorized()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_login_with_invalid_credentials_send_failed_login_notification()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -249,9 +232,7 @@ public function test_login_with_invalid_credentials_send_failed_login_notificati
|
||||
Notification::assertSentTo($this->user, FailedLogin::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_login_with_invalid_credentials_does_not_send_new_device_notification()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -267,9 +248,7 @@ public function test_login_with_invalid_credentials_does_not_send_new_device_not
|
||||
Notification::assertNothingSentTo($this->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_too_many_login_attempts_with_invalid_credentials_returns_too_many_request_error()
|
||||
{
|
||||
$throttle = 8;
|
||||
@ -291,9 +270,7 @@ public function test_too_many_login_attempts_with_invalid_credentials_returns_to
|
||||
->assertStatus(429);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_logout_returns_validation_success()
|
||||
{
|
||||
$response = $this->json('POST', '/user/login', [
|
||||
@ -309,12 +286,7 @@ public function test_user_logout_returns_validation_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @covers \App\Http\Middleware\KickOutInactiveUser
|
||||
* @covers \App\Http\Middleware\LogUserLastSeen
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_logout_after_inactivity_returns_teapot()
|
||||
{
|
||||
// Set the autolock period to 1 minute
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Http\Controllers\Auth\PasswordController;
|
||||
use App\Models\User;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -22,9 +23,6 @@ class PasswordControllerTest extends FeatureTestCase
|
||||
|
||||
private const NEW_PASSWORD = 'newPassword';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -32,9 +30,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_return_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -49,9 +45,7 @@ public function test_update_return_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_passing_bad_current_pwd_return_bad_request()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -66,9 +60,7 @@ public function test_update_passing_bad_current_pwd_return_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_passing_invalid_data_return_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
|
@ -9,6 +9,7 @@
|
||||
use App\Rules\ComplyWithEmailRestrictionPolicy;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -33,17 +34,12 @@ class RegisterControllerTest extends FeatureTestCase
|
||||
|
||||
private const EMAIL_FILTERING_RULE = '^[A-Za-z0-9._%+-]+@example\.org';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_returns_success()
|
||||
{
|
||||
DB::table('users')->delete();
|
||||
@ -69,9 +65,7 @@ public function test_register_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_with_uppercased_email_returns_success()
|
||||
{
|
||||
DB::table('users')->delete();
|
||||
@ -97,9 +91,7 @@ public function test_register_with_uppercased_email_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user', [
|
||||
@ -111,9 +103,7 @@ public function test_register_with_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_first_user_only_as_admin()
|
||||
{
|
||||
$this->assertDatabaseCount('users', 0);
|
||||
@ -142,9 +132,7 @@ public function test_register_first_user_only_as_admin()
|
||||
$this->assertEquals(1, User::admins()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_is_forbidden_when_registration_is_disabled()
|
||||
{
|
||||
Settings::set('disableRegistration', true);
|
||||
@ -158,9 +146,7 @@ public function test_register_is_forbidden_when_registration_is_disabled()
|
||||
->assertStatus(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_succeeds_when_email_is_in_restricted_list()
|
||||
{
|
||||
Settings::set('restrictRegistration', true);
|
||||
@ -176,9 +162,7 @@ public function test_register_succeeds_when_email_is_in_restricted_list()
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_fails_when_email_is_not_in_restricted_list()
|
||||
{
|
||||
Settings::set('restrictRegistration', true);
|
||||
@ -194,9 +178,7 @@ public function test_register_fails_when_email_is_not_in_restricted_list()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_succeeds_when_email_matchs_filtering_rule()
|
||||
{
|
||||
Settings::set('restrictRegistration', true);
|
||||
@ -212,9 +194,7 @@ public function test_register_succeeds_when_email_matchs_filtering_rule()
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_fails_when_email_does_not_match_filtering_rule()
|
||||
{
|
||||
Settings::set('restrictRegistration', true);
|
||||
@ -230,9 +210,7 @@ public function test_register_fails_when_email_does_not_match_filtering_rule()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_succeeds_when_email_is_allowed_by_list_over_regex()
|
||||
{
|
||||
Settings::set('restrictRegistration', true);
|
||||
@ -248,9 +226,7 @@ public function test_register_succeeds_when_email_is_allowed_by_list_over_regex(
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_succeeds_when_email_is_allowed_by_regex_over_list()
|
||||
{
|
||||
Settings::set('restrictRegistration', true);
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -22,9 +23,7 @@ class ResetPasswordControllerTest extends FeatureTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_reset_password_without_input_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/password/reset', [
|
||||
@ -38,9 +37,7 @@ public function test_submit_reset_password_without_input_returns_validation_erro
|
||||
->assertJsonValidationErrors(['email', 'password', 'token']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_reset_password_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/password/reset', [
|
||||
@ -54,9 +51,7 @@ public function test_submit_reset_password_with_invalid_data_returns_validation_
|
||||
->assertJsonValidationErrors(['email', 'password']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_reset_password_with_too_short_pwd_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/user/password/reset', [
|
||||
@ -70,9 +65,7 @@ public function test_submit_reset_password_with_too_short_pwd_returns_validation
|
||||
->assertJsonValidationErrors(['password']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_submit_reset_password_returns_success()
|
||||
{
|
||||
Notification::fake();
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -36,9 +37,6 @@ class SocialiteControllerTest extends FeatureTestCase
|
||||
|
||||
private const USER_EMAIL = 'john@provider.com';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -60,9 +58,7 @@ public function setUp() : void
|
||||
$this->socialiteUser->nickname = self::USER_NICKNAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_redirect_redirects_to_provider_url()
|
||||
{
|
||||
Settings::set('enableSso', true);
|
||||
@ -72,9 +68,7 @@ public function test_redirect_redirects_to_provider_url()
|
||||
$response->assertRedirectContains('https://github.com/login/oauth/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_redirect_returns_error_when_registrations_are_disabled()
|
||||
{
|
||||
Settings::set('enableSso', false);
|
||||
@ -84,9 +78,7 @@ public function test_redirect_returns_error_when_registrations_are_disabled()
|
||||
$response->assertRedirect('/error?err=sso_disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_authenticates_the_user()
|
||||
{
|
||||
Socialite::shouldReceive('driver->user')
|
||||
@ -97,9 +89,7 @@ public function test_callback_authenticates_the_user()
|
||||
$this->assertAuthenticatedAs($this->user, 'web-guard');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_redirects_authenticated_user_to_accounts()
|
||||
{
|
||||
Socialite::shouldReceive('driver->user')
|
||||
@ -110,9 +100,7 @@ public function test_callback_redirects_authenticated_user_to_accounts()
|
||||
$response->assertRedirect('/accounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_updates_user_informations()
|
||||
{
|
||||
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
|
||||
@ -132,9 +120,7 @@ public function test_callback_updates_user_informations()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_updates_username_with_fallback_value()
|
||||
{
|
||||
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
|
||||
@ -154,9 +140,7 @@ public function test_callback_updates_username_with_fallback_value()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_registers_new_user()
|
||||
{
|
||||
$newSocialiteUser = new \Laravel\Socialite\Two\User;
|
||||
@ -177,9 +161,7 @@ public function test_callback_registers_new_user()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_registers_new_user_with_existing_name()
|
||||
{
|
||||
$socialiteUserWithSameName = new \Laravel\Socialite\Two\User;
|
||||
@ -200,9 +182,7 @@ public function test_callback_registers_new_user_with_existing_name()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_always_registers_first_user_as_admin()
|
||||
{
|
||||
DB::table('users')->delete();
|
||||
@ -221,9 +201,7 @@ public function test_callback_always_registers_first_user_as_admin()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_returns_error_when_email_is_already_used()
|
||||
{
|
||||
$userWithSameEmail = User::factory()->create([
|
||||
@ -250,9 +228,7 @@ public function test_callback_returns_error_when_email_is_already_used()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_redirects_to_error_when_registrations_are_closed()
|
||||
{
|
||||
Settings::set('disableRegistration', true);
|
||||
@ -271,9 +247,7 @@ public function test_callback_redirects_to_error_when_registrations_are_closed()
|
||||
$response->assertRedirect('/error?err=sso_no_register');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_skips_registration_when_all_registrations_are_closed()
|
||||
{
|
||||
Settings::set('disableRegistration', true);
|
||||
@ -295,9 +269,7 @@ public function test_callback_skips_registration_when_all_registrations_are_clos
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_callback_registers_new_user_when_sso_registrations_are_enabled()
|
||||
{
|
||||
Settings::set('disableRegistration', true);
|
||||
|
@ -10,6 +10,7 @@
|
||||
use App\Policies\UserPolicy;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -33,9 +34,6 @@ class UserControllerTest extends FeatureTestCase
|
||||
|
||||
private const PASSWORD = 'password';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -43,9 +41,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -73,9 +69,7 @@ public function test_update_user_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_without_changing_email_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -100,9 +94,7 @@ public function test_update_user_without_changing_email_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_without_changing_name_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -127,9 +119,7 @@ public function test_update_user_without_changing_name_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_with_uppercased_email_returns_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -154,9 +144,7 @@ public function test_update_user_with_uppercased_email_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_in_demo_mode_returns_unchanged_user()
|
||||
{
|
||||
Config::set('2fauth.config.isDemoApp', true);
|
||||
@ -185,9 +173,7 @@ public function test_update_user_in_demo_mode_returns_unchanged_user()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_passing_wrong_password_returns_bad_request()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -199,9 +185,7 @@ public function test_update_user_passing_wrong_password_returns_bad_request()
|
||||
->assertStatus(400);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_user_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -213,9 +197,7 @@ public function test_update_user_with_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_user_returns_success()
|
||||
{
|
||||
$this->actingAs($this->user, 'web-guard')
|
||||
@ -225,9 +207,7 @@ public function test_delete_user_returns_success()
|
||||
->assertNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_user_in_demo_mode_returns_unauthorized()
|
||||
{
|
||||
Config::set('2fauth.config.isDemoApp', true);
|
||||
@ -246,9 +226,7 @@ public function test_delete_user_in_demo_mode_returns_unauthorized()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_user_passing_wrong_password_returns_bad_request()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -262,9 +240,7 @@ public function test_delete_user_passing_wrong_password_returns_bad_request()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_the_only_admin_returns_bad_request()
|
||||
{
|
||||
/**
|
||||
|
@ -8,9 +8,12 @@
|
||||
use App\Models\User;
|
||||
use App\Notifications\WebauthnRecoveryNotification;
|
||||
use App\Providers\AuthServiceProvider;
|
||||
use App\Rules\CaseInsensitiveEmailExists;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\CoversMethod;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -21,6 +24,7 @@
|
||||
#[CoversClass(WebauthnCredentialBroker::class)]
|
||||
#[CoversClass(WebauthnDeviceLostRequest::class)]
|
||||
#[CoversClass(AuthServiceProvider::class)]
|
||||
#[CoversMethod(CaseInsensitiveEmailExists::class, 'validate')]
|
||||
class WebAuthnDeviceLostControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
@ -28,9 +32,6 @@ class WebAuthnDeviceLostControllerTest extends FeatureTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -38,11 +39,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @covers \App\Models\Traits\WebAuthnManageCredentials
|
||||
*/
|
||||
#[Test]
|
||||
public function test_sendRecoveryEmail_sends_notification_on_success()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -63,9 +60,7 @@ public function test_sendRecoveryEmail_sends_notification_on_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_WebauthnRecoveryNotification_renders_to_email()
|
||||
{
|
||||
$mail = (new WebauthnRecoveryNotification('test_token'))->toMail($this->user)->render();
|
||||
@ -101,9 +96,7 @@ public function test_WebauthnRecoveryNotification_renders_to_email()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_sendRecoveryEmail_does_not_send_anything_to_unknown_email()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -124,9 +117,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_unknown_email()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_sendRecoveryEmail_does_not_send_anything_to_invalid_email()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -147,9 +138,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_invalid_email()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_sendRecoveryEmail_does_not_send_anything_to_not_WebAuthnAuthenticatable()
|
||||
{
|
||||
$mock = $this->mock(\App\Extensions\WebauthnCredentialBroker::class)->makePartial();
|
||||
@ -170,9 +159,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_not_WebAuthnAut
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_sendRecoveryEmail_is_throttled()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -202,9 +189,7 @@ public function test_sendRecoveryEmail_is_throttled()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_error_if_no_broker_is_set()
|
||||
{
|
||||
$this->app['config']->set('auth.passwords.webauthn', null);
|
||||
|
@ -4,12 +4,15 @@
|
||||
|
||||
use App\Extensions\WebauthnTwoFAuthUserProvider;
|
||||
use App\Http\Controllers\Auth\WebAuthnLoginController;
|
||||
use App\Http\Middleware\SkipIfAuthenticated;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Laragear\WebAuthn\Assertion\Validator\AssertionValidator;
|
||||
use Laragear\WebAuthn\Enums\UserVerification;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\CoversMethod;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -18,6 +21,7 @@
|
||||
#[CoversClass(WebAuthnLoginController::class)]
|
||||
#[CoversClass(User::class)]
|
||||
#[CoversClass(WebauthnTwoFAuthUserProvider::class)]
|
||||
#[CoversMethod(SkipIfAuthenticated::class, 'handle')]
|
||||
class WebAuthnLoginControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
@ -85,9 +89,6 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
|
||||
|
||||
const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA==';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -95,9 +96,7 @@ public function setUp() : void
|
||||
DB::table('users')->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_webauthn_login_returns_success()
|
||||
{
|
||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||
@ -141,9 +140,7 @@ public function test_webauthn_login_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_webauthn_admin_login_returns_admin_role()
|
||||
{
|
||||
$this->admin = User::factory()->administrator()->create(['email' => self::EMAIL]);
|
||||
@ -180,9 +177,7 @@ public function test_webauthn_admin_login_returns_admin_role()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_webauthn_login_merge_handle_if_missing()
|
||||
{
|
||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||
@ -225,9 +220,7 @@ public function test_webauthn_login_merge_handle_if_missing()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_legacy_login_is_rejected_when_webauthn_only_is_enable()
|
||||
{
|
||||
$this->user = User::factory()->create([
|
||||
@ -245,11 +238,7 @@ public function test_legacy_login_is_rejected_when_webauthn_only_is_enable()
|
||||
->assertUnauthorized();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @covers \App\Http\Middleware\SkipIfAuthenticated
|
||||
*/
|
||||
#[Test]
|
||||
public function test_webauthn_login_already_authenticated_is_rejected()
|
||||
{
|
||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||
@ -289,9 +278,7 @@ public function test_webauthn_login_already_authenticated_is_rejected()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_webauthn_login_with_missing_data_returns_validation_error()
|
||||
{
|
||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||
@ -320,9 +307,7 @@ public function test_webauthn_login_with_missing_data_returns_validation_error()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_webauthn_invalid_login_returns_unauthorized()
|
||||
{
|
||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||
@ -337,9 +322,7 @@ public function test_webauthn_invalid_login_returns_unauthorized()
|
||||
->assertUnauthorized();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_too_many_invalid_login_attempts_returns_too_many_request_error()
|
||||
{
|
||||
$throttle = 8;
|
||||
@ -364,9 +347,7 @@ public function test_too_many_invalid_login_attempts_returns_too_many_request_er
|
||||
->assertStatus(429);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_returns_success()
|
||||
{
|
||||
Config::set('webauthn.user_verification', UserVerification::PREFERRED);
|
||||
@ -404,9 +385,7 @@ public function test_get_options_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_for_securelogin_returns_required_userVerification()
|
||||
{
|
||||
Config::set('webauthn.user_verification', UserVerification::REQUIRED);
|
||||
@ -446,9 +425,7 @@ public function test_get_options_for_securelogin_returns_required_userVerificati
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_for_fastlogin_returns_discouraged_userVerification()
|
||||
{
|
||||
Config::set('webauthn.user_verification', UserVerification::DISCOURAGED);
|
||||
@ -488,9 +465,7 @@ public function test_get_options_for_fastlogin_returns_discouraged_userVerificat
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_with_capitalized_email_returns_success()
|
||||
{
|
||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||
@ -501,9 +476,7 @@ public function test_get_options_with_capitalized_email_returns_success()
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_with_missing_email_returns_validation_errors()
|
||||
{
|
||||
$this->json('POST', '/webauthn/login/options', [
|
||||
@ -515,9 +488,7 @@ public function test_get_options_with_missing_email_returns_validation_errors()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_with_invalid_email_returns_validation_errors()
|
||||
{
|
||||
$this->json('POST', '/webauthn/login/options', [
|
||||
@ -529,9 +500,7 @@ public function test_get_options_with_invalid_email_returns_validation_errors()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_options_with_unknown_email_returns_validation_errors()
|
||||
{
|
||||
$this->json('POST', '/webauthn/login/options', [
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -30,9 +31,6 @@ class WebAuthnManageControllerTest extends FeatureTestCase
|
||||
|
||||
public const CREDENTIAL_ID_RAW = '+VOLFKPY+/FuMI/sJ7gMllK76L3VoRUINj6lL/Z3qDg=';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -40,9 +38,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_returns_success_with_credentials()
|
||||
{
|
||||
DB::table('webauthn_credentials')->insert([
|
||||
@ -71,9 +67,7 @@ public function test_index_returns_success_with_credentials()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_rename_returns_success_with_new_name()
|
||||
{
|
||||
DB::table('webauthn_credentials')->insert([
|
||||
@ -102,9 +96,7 @@ public function test_rename_returns_success_with_new_name()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_rename_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -114,9 +106,7 @@ public function test_rename_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_rename_missing_credential_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
@ -129,9 +119,7 @@ public function test_rename_missing_credential_returns_not_found()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_as_reverse_proxy_returns_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'reverse-proxy-guard')
|
||||
@ -139,9 +127,7 @@ public function test_index_as_reverse_proxy_returns_error()
|
||||
->assertStatus(405);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_rename_as_reverse_proxy_returns_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'reverse-proxy-guard')
|
||||
@ -149,9 +135,7 @@ public function test_rename_as_reverse_proxy_returns_error()
|
||||
->assertStatus(405);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_as_reverse_proxy_returns_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'reverse-proxy-guard')
|
||||
@ -159,9 +143,7 @@ public function test_delete_as_reverse_proxy_returns_error()
|
||||
->assertStatus(405);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_returns_no_content()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'web-guard')
|
||||
|
@ -11,6 +11,7 @@
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -35,9 +36,6 @@ class WebAuthnRecoveryControllerTest extends FeatureTestCase
|
||||
|
||||
const CREDENTIAL_ID = '-VOLFKPY-_FuMI_sJ7gMllK76L3VoRUINj6lL_Z3qDg';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -53,9 +51,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_fails_if_no_recovery_is_set()
|
||||
{
|
||||
DB::table(config('auth.passwords.webauthn.table'))->delete();
|
||||
@ -69,9 +65,7 @@ public function test_recover_fails_if_no_recovery_is_set()
|
||||
->assertJsonValidationErrors('token');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_with_wrong_token_returns_validation_error()
|
||||
{
|
||||
$response = $this->json('POST', '/webauthn/recover', [
|
||||
@ -84,9 +78,7 @@ public function test_recover_with_wrong_token_returns_validation_error()
|
||||
->assertJsonValidationErrors('token');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_with_expired_token_returns_validation_error()
|
||||
{
|
||||
Date::setTestNow($now = Date::create(2020, 01, 01, 16, 30));
|
||||
@ -107,9 +99,7 @@ public function test_recover_with_expired_token_returns_validation_error()
|
||||
->assertJsonValidationErrors('token');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_with_invalid_password_returns_authentication_error()
|
||||
{
|
||||
$this->json('POST', '/webauthn/recover', [
|
||||
@ -120,9 +110,7 @@ public function test_recover_with_invalid_password_returns_authentication_error(
|
||||
->assertStatus(401);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_returns_validation_error_when_no_user_exists()
|
||||
{
|
||||
$this->json('POST', '/webauthn/recover', [
|
||||
@ -136,9 +124,7 @@ public function test_recover_returns_validation_error_when_no_user_exists()
|
||||
->assertJsonValidationErrors('email');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_returns_success()
|
||||
{
|
||||
$response = $this->json('POST', '/webauthn/recover', [
|
||||
@ -153,9 +139,7 @@ public function test_recover_returns_success()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_recover_resets_useWebauthnOnly_user_preference()
|
||||
{
|
||||
$this->user['preferences->useWebauthnOnly'] = true;
|
||||
@ -173,9 +157,7 @@ public function test_recover_resets_useWebauthnOnly_user_preference()
|
||||
$this->assertFalse($this->user->preferences['useWebauthnOnly']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_revoke_all_credentials_clear_registered_credentials()
|
||||
{
|
||||
DB::table('webauthn_credentials')->insert([
|
||||
|
@ -10,6 +10,7 @@
|
||||
use Laragear\WebAuthn\Http\Requests\AttestedRequest;
|
||||
use Laragear\WebAuthn\JsonTransport;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -23,9 +24,6 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -33,9 +31,7 @@ public function setUp() : void
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_uses_attestation_with_fastRegistration_request() : void
|
||||
{
|
||||
Config::set('webauthn.user_verification', UserVerification::DISCOURAGED);
|
||||
@ -50,9 +46,7 @@ public function test_uses_attestation_with_fastRegistration_request() : void
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_uses_attestation_with_secureRegistration_request() : void
|
||||
{
|
||||
Config::set('webauthn.user_verification', UserVerification::REQUIRED);
|
||||
@ -67,9 +61,7 @@ public function test_uses_attestation_with_secureRegistration_request() : void
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_register_uses_attested_request() : void
|
||||
{
|
||||
$request = $this->mock(AttestedRequest::class);
|
||||
|
@ -6,13 +6,12 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\Request;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
class AdminOnlyMiddlewareTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_users_are_rejected()
|
||||
{
|
||||
$this->expectException(AuthorizationException::class);
|
||||
@ -31,9 +30,7 @@ public function test_users_are_rejected()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_admins_pass()
|
||||
{
|
||||
/**
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\Http\Middlewares;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
class AuthenticateMiddlewareTest extends FeatureTestCase
|
||||
@ -11,9 +12,7 @@ class AuthenticateMiddlewareTest extends FeatureTestCase
|
||||
|
||||
private const USER_EMAIL = 'john@example.com';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_it_always_authenticates_with_reverse_proxy_guard()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -24,9 +23,7 @@ public function test_it_always_authenticates_with_reverse_proxy_guard()
|
||||
$this->assertAuthenticated('reverse-proxy-guard');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_it_does_not_authenticate_with_empty_header()
|
||||
{
|
||||
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
|
||||
@ -40,9 +37,7 @@ public function test_it_does_not_authenticate_with_empty_header()
|
||||
])->assertStatus(407);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_it_does_not_authenticate_with_missing_header()
|
||||
{
|
||||
$this->app['auth']->shouldUse('reverse-proxy-guard');
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class LoginRequestTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
$request = new LoginRequest();
|
||||
@ -28,9 +27,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -61,9 +58,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class UserDeleteRequestTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -56,9 +53,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class UserPatchPwdRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -58,9 +55,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class UserStoreRequestTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
$request = new UserStoreRequest();
|
||||
@ -28,9 +27,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -66,9 +63,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -20,9 +21,7 @@ class UserUpdateRequestTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -34,9 +33,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -81,9 +78,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -17,9 +18,7 @@ class WebauthnAssertedRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -50,9 +49,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@ class WebauthnRenameRequestTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_is_authorized()
|
||||
{
|
||||
Auth::shouldReceive('check')
|
||||
@ -32,9 +31,7 @@ public function test_user_is_authorized()
|
||||
$this->assertTrue($request->authorize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -56,9 +53,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -26,9 +27,6 @@ class SystemControllerTest extends FeatureTestCase
|
||||
|
||||
protected $admin;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -37,18 +35,14 @@ public function setUp() : void
|
||||
$this->admin = User::factory()->administrator()->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_infos_returns_unauthorized()
|
||||
{
|
||||
$response = $this->json('GET', '/system/infos')
|
||||
->assertUnauthorized();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_infos_returns_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -56,9 +50,7 @@ public function test_infos_returns_forbidden()
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_infos_returns_only_base_collection()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'api-guard')
|
||||
@ -87,9 +79,7 @@ public function test_infos_returns_only_base_collection()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy()
|
||||
{
|
||||
$response = $this->actingAs($this->admin, 'reverse-proxy-guard')
|
||||
@ -104,9 +94,7 @@ public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy(
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_latestrelease_runs_manual_scan()
|
||||
{
|
||||
$releaseRadarService = $this->mock(ReleaseRadarService::class)->makePartial();
|
||||
@ -121,9 +109,7 @@ public function test_latestrelease_runs_manual_scan()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_testEmail_sends_a_notification()
|
||||
{
|
||||
Notification::fake();
|
||||
@ -136,9 +122,7 @@ public function test_testEmail_sends_a_notification()
|
||||
Notification::assertSentTo($this->admin, TestEmailSettingNotification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_testEmail_renders_to_email()
|
||||
{
|
||||
$mail = (new TestEmailSettingNotification('test_token'))->toMail($this->user)->render();
|
||||
@ -149,18 +133,14 @@ public function test_testEmail_renders_to_email()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_testEmail_returns_unauthorized()
|
||||
{
|
||||
$response = $this->json('GET', '/system/infos')
|
||||
->assertUnauthorized();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_testEmail_returns_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
@ -168,9 +148,7 @@ public function test_testEmail_returns_forbidden()
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_clearCache_returns_success()
|
||||
{
|
||||
$response = $this->json('GET', '/system/clear-cache');
|
||||
@ -178,9 +156,7 @@ public function test_clearCache_returns_success()
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_optimize_returns_success()
|
||||
{
|
||||
$response = $this->json('GET', '/system/optimize');
|
||||
|
@ -11,6 +11,7 @@
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Data\HttpRequestTestData;
|
||||
use Tests\Data\OtpTestData;
|
||||
use Tests\FeatureTestCase;
|
||||
@ -42,9 +43,6 @@ class TwoFAccountModelTest extends FeatureTestCase
|
||||
*/
|
||||
protected $helpers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -92,9 +90,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_custom_totp_uri_returns_correct_value()
|
||||
{
|
||||
$file = (new FileFactory)->image('file.png', 10, 10);
|
||||
@ -125,9 +121,7 @@ public function test_fill_with_custom_totp_uri_returns_correct_value()
|
||||
Storage::disk('imagesLink')->assertMissing($twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_basic_totp_uri_returns_default_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -145,9 +139,7 @@ public function test_fill_with_basic_totp_uri_returns_default_value()
|
||||
$this->assertEquals(null, $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_ms_corporate_totp_uri_returns_correct_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -164,9 +156,7 @@ public function test_fill_with_ms_corporate_totp_uri_returns_correct_value()
|
||||
$this->assertEquals(OtpTestData::ALGORITHM_DEFAULT, $twofaccount->algorithm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_custom_hotp_uri_returns_correct_value()
|
||||
{
|
||||
$file = (new FileFactory)->image('file.png', 10, 10);
|
||||
@ -197,9 +187,7 @@ public function test_fill_with_custom_hotp_uri_returns_correct_value()
|
||||
Storage::disk('imagesLink')->assertMissing($twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_basic_hotp_uri_returns_default_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -217,9 +205,7 @@ public function test_fill_with_basic_hotp_uri_returns_default_value()
|
||||
$this->assertEquals(null, $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_filled_with_uri_persists_correct_values_to_db()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -240,9 +226,7 @@ public function test_filled_with_uri_persists_correct_values_to_db()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_invalid_uri_returns_ValidationException()
|
||||
{
|
||||
$this->expectException(\Illuminate\Validation\ValidationException::class);
|
||||
@ -250,9 +234,7 @@ public function test_fill_with_invalid_uri_returns_ValidationException()
|
||||
$twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_invalid_uri_with_mismatching_issuer_returns_ValidationException()
|
||||
{
|
||||
$this->expectException(\Illuminate\Validation\ValidationException::class);
|
||||
@ -260,9 +242,7 @@ public function test_fill_with_invalid_uri_with_mismatching_issuer_returns_Valid
|
||||
$twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI_MISMATCHING_ISSUER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_uri_without_label_returns_ValidationException()
|
||||
{
|
||||
$this->expectException(\Illuminate\Validation\ValidationException::class);
|
||||
@ -270,9 +250,7 @@ public function test_fill_with_uri_without_label_returns_ValidationException()
|
||||
$twofaccount->fillWithURI('otpauth://totp/?secret=' . OtpTestData::SECRET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_getOfficialIcons_On_triggers_icon_fetching()
|
||||
{
|
||||
// Set the getOfficialIcons preference On
|
||||
@ -291,9 +269,7 @@ public function test_fill_with_getOfficialIcons_On_triggers_icon_fetching()
|
||||
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP_NO_ICON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_with_getOfficialIcons_Off_skips_icon_fetching()
|
||||
{
|
||||
// Set the getOfficialIcons preference Off
|
||||
@ -311,9 +287,7 @@ public function test_fill_with_getOfficialIcons_Off_skips_icon_fetching()
|
||||
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_custom_totp_from_parameters_returns_correct_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -330,9 +304,7 @@ public function test_create_custom_totp_from_parameters_returns_correct_value()
|
||||
$this->assertStringEndsWith('.png', $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_basic_totp_from_parameters_returns_correct_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -349,9 +321,7 @@ public function test_create_basic_totp_from_parameters_returns_correct_value()
|
||||
$this->assertEquals(null, $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_custom_hotp_from_parameters_returns_correct_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -368,9 +338,7 @@ public function test_create_custom_hotp_from_parameters_returns_correct_value()
|
||||
$this->assertStringEndsWith('.png', $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_basic_hotp_from_parameters_returns_correct_value()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -387,9 +355,7 @@ public function test_create_basic_hotp_from_parameters_returns_correct_value()
|
||||
$this->assertEquals(null, $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_from_parameters_persists_correct_values_to_db()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -410,9 +376,7 @@ public function test_create_from_parameters_persists_correct_values_to_db()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_from_unsupported_parameters_returns_unsupportedOtpTypeException()
|
||||
{
|
||||
$this->expectException(\App\Exceptions\UnsupportedOtpTypeException::class);
|
||||
@ -420,9 +384,7 @@ public function test_create_from_unsupported_parameters_returns_unsupportedOtpTy
|
||||
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_PARAMETERS_FOR_UNSUPPORTED_OTP_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_from_invalid_parameters_type_returns_InvalidOtpParameterException()
|
||||
{
|
||||
$this->expectException(\App\Exceptions\InvalidOtpParameterException::class);
|
||||
@ -434,9 +396,7 @@ public function test_create_from_invalid_parameters_type_returns_InvalidOtpParam
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_create_from_invalid_parameters_returns_InvalidOtpParameterException()
|
||||
{
|
||||
$this->expectException(\App\Exceptions\InvalidOtpParameterException::class);
|
||||
@ -448,9 +408,7 @@ public function test_create_from_invalid_parameters_returns_InvalidOtpParameterE
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_totp_returns_updated_model()
|
||||
{
|
||||
$twofaccount = $this->customTotpTwofaccount;
|
||||
@ -468,9 +426,7 @@ public function test_update_totp_returns_updated_model()
|
||||
$this->assertEquals(null, $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_hotp_returns_updated_model()
|
||||
{
|
||||
$twofaccount = $this->customTotpTwofaccount;
|
||||
@ -488,9 +444,7 @@ public function test_update_hotp_returns_updated_model()
|
||||
$this->assertEquals(null, $twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_totp_persists_updated_model()
|
||||
{
|
||||
$twofaccount = $this->customTotpTwofaccount;
|
||||
@ -510,9 +464,7 @@ public function test_update_totp_persists_updated_model()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getOTP_for_totp_returns_the_same_password()
|
||||
{
|
||||
Http::preventStrayRequests();
|
||||
@ -540,9 +492,7 @@ public function test_getOTP_for_totp_returns_the_same_password()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getOTP_for_hotp_returns_the_same_password()
|
||||
{
|
||||
Http::preventStrayRequests();
|
||||
@ -565,9 +515,7 @@ public function test_getOTP_for_hotp_returns_the_same_password()
|
||||
$this->assertEquals($otp_from_model, $otp_from_parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getOTP_for_steamtotp_returns_the_same_password()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -587,9 +535,7 @@ public function test_getOTP_for_steamtotp_returns_the_same_password()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getOTP_for_totp_with_invalid_secret_returns_InvalidSecretException()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -598,9 +544,7 @@ public function test_getOTP_for_totp_with_invalid_secret_returns_InvalidSecretEx
|
||||
$otp_from_uri = $twofaccount->fillWithURI('otpauth://totp/' . OtpTestData::ACCOUNT . '?secret=1.0')->getOTP();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getOTP_for_totp_with_undecipherable_secret_returns_UndecipherableException()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -613,9 +557,7 @@ public function test_getOTP_for_totp_with_undecipherable_secret_returns_Undeciph
|
||||
])->getOTP();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getURI_for_custom_totp_model_returns_uri()
|
||||
{
|
||||
$uri = $this->customTotpTwofaccount->getURI();
|
||||
@ -629,9 +571,7 @@ public function test_getURI_for_custom_totp_model_returns_uri()
|
||||
$this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getURI_for_custom_hotp_model_returns_uri()
|
||||
{
|
||||
$uri = $this->customHotpTwofaccount->getURI();
|
||||
@ -645,9 +585,7 @@ public function test_getURI_for_custom_hotp_model_returns_uri()
|
||||
$this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_fill_succeed_when_image_fetching_fails()
|
||||
{
|
||||
Http::preventStrayRequests();
|
||||
@ -662,9 +600,7 @@ public function test_fill_succeed_when_image_fetching_fails()
|
||||
Storage::disk('imagesLink')->assertDirectoryEmpty('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_saving_totp_without_period_set_default_one()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -680,9 +616,7 @@ public function test_saving_totp_without_period_set_default_one()
|
||||
$this->assertEquals(TwoFAccount::DEFAULT_PERIOD, $account->period);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_saving_hotp_without_counter_set_default_one()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -698,9 +632,7 @@ public function test_saving_hotp_without_counter_set_default_one()
|
||||
$this->assertEquals(TwoFAccount::DEFAULT_COUNTER, $account->counter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_equals_returns_true()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -719,9 +651,7 @@ public function test_equals_returns_true()
|
||||
$this->assertTrue($twofaccount->equals($this->customTotpTwofaccount));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_equals_returns_false()
|
||||
{
|
||||
$twofaccount = new TwoFAccount;
|
||||
@ -740,9 +670,7 @@ public function test_equals_returns_false()
|
||||
$this->assertFalse($twofaccount->equals($this->customHotpTwofaccount));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('iconResourceProvider')]
|
||||
public function test_set_icon_stores_and_set_the_icon($res, $ext)
|
||||
{
|
||||
@ -787,9 +715,7 @@ public static function iconResourceProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidIconResourceProvider')]
|
||||
public function test_set_invalid_icon_ends_without_error($res, $ext)
|
||||
{
|
||||
|
@ -13,6 +13,7 @@
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Data\OtpTestData;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
@ -22,9 +23,7 @@
|
||||
#[CoversClass(User::class)]
|
||||
class UserModelTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_admin_scope_returns_only_admin()
|
||||
{
|
||||
User::factory()->count(4)->create();
|
||||
@ -45,9 +44,7 @@ public function test_admin_scope_returns_only_admin()
|
||||
$this->assertEquals($admins[1]->name, $secondAdmin->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_isAdministrator_returns_correct_state()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
@ -57,9 +54,7 @@ public function test_isAdministrator_returns_correct_state()
|
||||
$this->assertEquals($admin->isAdministrator(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_promoteToAdministrator_sets_administrator_status()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
@ -69,9 +64,7 @@ public function test_promoteToAdministrator_sets_administrator_status()
|
||||
$this->assertEquals($user->isAdministrator(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_promoteToAdministrator_demote_administrator_status()
|
||||
{
|
||||
$admin = User::factory()->administrator()->create();
|
||||
@ -85,9 +78,7 @@ public function test_promoteToAdministrator_demote_administrator_status()
|
||||
$this->assertFalse($admin->isAdministrator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_resetPassword_resets_password_with_success()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
@ -98,9 +89,7 @@ public function test_resetPassword_resets_password_with_success()
|
||||
$this->assertNotEquals($user->password, $oldPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_resetPassword_dispatch_event()
|
||||
{
|
||||
Event::fake();
|
||||
@ -112,9 +101,7 @@ public function test_resetPassword_dispatch_event()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_removes_user_data()
|
||||
{
|
||||
Artisan::call('passport:install', [
|
||||
@ -171,9 +158,7 @@ public function test_delete_removes_user_data()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_flushes_icons_of_user_twofaccounts()
|
||||
{
|
||||
Storage::fake('icons');
|
||||
@ -190,9 +175,7 @@ public function test_delete_flushes_icons_of_user_twofaccounts()
|
||||
Storage::disk('icons')->assertMissing($twofaccount->icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_does_not_delete_the_only_admin()
|
||||
{
|
||||
$admin = User::factory()->administrator()->create();
|
||||
|
@ -2,15 +2,12 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
class RouteTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* test return main web view
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_landing_view_is_returned()
|
||||
{
|
||||
$response = $this->get(route('landing', ['any' => '/']));
|
||||
@ -19,11 +16,7 @@ public function test_landing_view_is_returned()
|
||||
->assertViewIs('landing');
|
||||
}
|
||||
|
||||
/**
|
||||
* test return main web view
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_exception_handler_with_web_route()
|
||||
{
|
||||
$response = $this->post('/');
|
||||
|
@ -9,6 +9,7 @@
|
||||
use App\Services\GroupService;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -48,9 +49,6 @@ class GroupServiceTest extends FeatureTestCase
|
||||
|
||||
private const NEW_GROUP_NAME = 'MyNewGroup';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -76,9 +74,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_a_twofaccount_to_a_group_persists_the_relation()
|
||||
{
|
||||
Groups::assign($this->twofaccountOne->id, $this->user, $this->groupTwo);
|
||||
@ -89,9 +85,7 @@ public function test_assign_a_twofaccount_to_a_group_persists_the_relation()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_multiple_twofaccounts_to_group_persists_the_relation()
|
||||
{
|
||||
Groups::assign([$this->twofaccountOne->id, $this->twofaccountTwo->id], $this->user, $this->groupTwo);
|
||||
@ -106,9 +100,7 @@ public function test_assign_multiple_twofaccounts_to_group_persists_the_relation
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_a_twofaccount_to_no_group_assigns_to_user_default_group()
|
||||
{
|
||||
$this->user['preferences->defaultGroup'] = $this->groupTwo->id;
|
||||
@ -122,9 +114,7 @@ public function test_assign_a_twofaccount_to_no_group_assigns_to_user_default_gr
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_a_twofaccount_to_no_group_assigns_to_user_active_group()
|
||||
{
|
||||
$this->user['preferences->defaultGroup'] = -1;
|
||||
@ -139,9 +129,7 @@ public function test_assign_a_twofaccount_to_no_group_assigns_to_user_active_gro
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assign_a_twofaccount_to_missing_active_group_returns_not_found()
|
||||
{
|
||||
$orginalGroup = $this->twofaccountOne->group_id;
|
||||
@ -158,9 +146,7 @@ public function test_assign_a_twofaccount_to_missing_active_group_returns_not_fo
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_can_assign_an_account()
|
||||
{
|
||||
$this->expectException(AuthorizationException::class);
|
||||
@ -168,9 +154,7 @@ public function test_user_can_assign_an_account()
|
||||
Groups::assign($this->twofaccountThree->id, $this->user, $this->user->groups()->first());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_can_assign_multiple_accounts()
|
||||
{
|
||||
$this->expectException(AuthorizationException::class);
|
||||
@ -178,9 +162,7 @@ public function test_user_can_assign_multiple_accounts()
|
||||
Groups::assign([$this->twofaccountOne->id, $this->twofaccountThree->id], $this->user, $this->user->groups()->first());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_prependTheAllGroup_add_the_group_on_top_of_groups()
|
||||
{
|
||||
$groups = Groups::prependTheAllGroup($this->user->groups, $this->user);
|
||||
|
@ -7,6 +7,7 @@
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Data\HttpRequestTestData;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -18,17 +19,12 @@ class LogoServiceTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getIcon_returns_stored_icon_file_when_logo_exists()
|
||||
{
|
||||
$svgLogo = HttpRequestTestData::SVG_LOGO_BODY;
|
||||
@ -50,9 +46,7 @@ public function test_getIcon_returns_stored_icon_file_when_logo_exists()
|
||||
Storage::disk('icons')->assertExists($icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getIcon_returns_null_when_github_request_fails()
|
||||
{
|
||||
Http::preventStrayRequests();
|
||||
@ -69,9 +63,7 @@ public function test_getIcon_returns_null_when_github_request_fails()
|
||||
$this->assertEquals(null, $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getIcon_returns_null_when_logo_fetching_fails()
|
||||
{
|
||||
$tfaJsonBody = HttpRequestTestData::TFA_JSON_BODY;
|
||||
@ -90,9 +82,7 @@ public function test_getIcon_returns_null_when_logo_fetching_fails()
|
||||
$this->assertEquals(null, $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_getIcon_returns_null_when_no_logo_exists()
|
||||
{
|
||||
$logoService = new LogoService();
|
||||
@ -102,9 +92,7 @@ public function test_getIcon_returns_null_when_no_logo_exists()
|
||||
$this->assertEquals(null, $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_logoService_loads_empty_collection_when_tfajson_fetching_fails()
|
||||
{
|
||||
$svgLogo = HttpRequestTestData::SVG_LOGO_BODY;
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Facades\QrCode;
|
||||
use App\Services\QrCodeService;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Classes\LocalFile;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
@ -21,25 +22,18 @@ class QrCodeServiceTest extends FeatureTestCase
|
||||
|
||||
private const DECODED_IMAGE = 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_encode_returns_correct_value()
|
||||
{
|
||||
$this->assertEquals(self::STRING_ENCODED, QrCode::encode(self::STRING_TO_ENCODE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_decode_valid_image_returns_correct_value()
|
||||
{
|
||||
$file = LocalFile::fake()->validQrcode();
|
||||
@ -47,9 +41,7 @@ public function test_decode_valid_image_returns_correct_value()
|
||||
$this->assertEquals(self::DECODED_IMAGE, QrCode::decode($file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_decode_invalid_image_returns_correct_value()
|
||||
{
|
||||
$this->expectException(\App\Exceptions\InvalidQrCodeException::class);
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Data\HttpRequestTestData;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
@ -19,9 +20,7 @@ class ReleaseRadarServiceTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_manualScan_returns_no_new_release()
|
||||
{
|
||||
$url = config('2fauth.latestReleaseUrl');
|
||||
@ -41,9 +40,7 @@ public function test_manualScan_returns_no_new_release()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_manualScan_returns_new_release()
|
||||
{
|
||||
$url = config('2fauth.latestReleaseUrl');
|
||||
@ -63,9 +60,7 @@ public function test_manualScan_returns_new_release()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_manualScan_complete_when_http_call_fails()
|
||||
{
|
||||
// We do not fake the http request so an exception will be thrown
|
||||
@ -74,9 +69,7 @@ public function test_manualScan_complete_when_http_call_fails()
|
||||
$this->assertNull(ReleaseRadarService::manualScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_manualScan_succeed_when_github_is_unreachable()
|
||||
{
|
||||
$url = config('2fauth.latestReleaseUrl');
|
||||
@ -89,9 +82,7 @@ public function test_manualScan_succeed_when_github_is_unreachable()
|
||||
$this->assertNull(ReleaseRadarService::manualScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_scheduleScan_runs_after_one_week()
|
||||
{
|
||||
$url = config('2fauth.latestReleaseUrl');
|
||||
@ -119,9 +110,7 @@ public function test_scheduleScan_runs_after_one_week()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_scheduleScan_does_not_run_before_one_week()
|
||||
{
|
||||
$url = config('2fauth.latestReleaseUrl');
|
||||
@ -149,9 +138,7 @@ public function test_scheduleScan_does_not_run_before_one_week()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_scheduleScan_complete_when_http_call_fails()
|
||||
{
|
||||
// We do not fake the http request so an exception will be thrown
|
||||
|
@ -10,6 +10,7 @@
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
@ -62,9 +63,6 @@ class SettingServiceTest extends FeatureTestCase
|
||||
|
||||
private const TOTP_FULL_CUSTOM_URI = 'otpauth://totp/' . self::SERVICE . ':' . self::ACCOUNT . '?secret=' . self::SECRET . '&issuer=' . self::SERVICE . '&digits=' . self::DIGITS_CUSTOM . '&period=' . self::PERIOD_CUSTOM . '&algorithm=' . self::ALGORITHM_CUSTOM . '&image=' . self::IMAGE;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -96,9 +94,7 @@ public function setUp() : void
|
||||
$this->twofaccountTwo->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_string_setting_returns_correct_value()
|
||||
{
|
||||
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_STRING);
|
||||
@ -106,9 +102,7 @@ public function test_get_string_setting_returns_correct_value()
|
||||
$this->assertEquals(self::SETTING_VALUE_STRING, Settings::get(self::SETTING_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_boolean_setting_returns_true()
|
||||
{
|
||||
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_TRUE_TRANSFORMED);
|
||||
@ -116,9 +110,7 @@ public function test_get_boolean_setting_returns_true()
|
||||
$this->assertEquals(true, Settings::get(self::SETTING_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_boolean_setting_returns_false()
|
||||
{
|
||||
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FALSE_TRANSFORMED);
|
||||
@ -126,9 +118,7 @@ public function test_get_boolean_setting_returns_false()
|
||||
$this->assertEquals(false, Settings::get(self::SETTING_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_int_setting_returns_int()
|
||||
{
|
||||
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_INT);
|
||||
@ -139,9 +129,7 @@ public function test_get_int_setting_returns_int()
|
||||
$this->assertIsInt($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_get_float_setting_returns_float()
|
||||
{
|
||||
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FLOAT);
|
||||
@ -152,9 +140,7 @@ public function test_get_float_setting_returns_float()
|
||||
$this->assertIsFloat($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_all_returns_default_and_overloaded_settings()
|
||||
{
|
||||
$default_options = config('2fauth.settings');
|
||||
@ -172,9 +158,7 @@ public function test_all_returns_default_and_overloaded_settings()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_setting_persist_correct_value_in_db_and_cache()
|
||||
{
|
||||
$value = Settings::set(self::SETTING_NAME, self::SETTING_VALUE_STRING);
|
||||
@ -188,9 +172,7 @@ public function test_set_setting_persist_correct_value_in_db_and_cache()
|
||||
$this->assertEquals($cached->get(self::SETTING_NAME), self::SETTING_VALUE_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_useEncryption_on_encrypts_all_accounts()
|
||||
{
|
||||
Settings::set('useEncryption', true);
|
||||
@ -204,9 +186,7 @@ public function test_set_useEncryption_on_encrypts_all_accounts()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_useEncryption_on_twice_prevents_successive_encryption()
|
||||
{
|
||||
Settings::set('useEncryption', true);
|
||||
@ -221,9 +201,7 @@ public function test_set_useEncryption_on_twice_prevents_successive_encryption()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_useEncryption_off_decrypts_all_accounts()
|
||||
{
|
||||
Settings::set('useEncryption', true);
|
||||
@ -238,9 +216,7 @@ public function test_set_useEncryption_off_decrypts_all_accounts()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideUndecipherableData')]
|
||||
public function test_set_useEncryption_off_returns_exception_when_data_are_undecipherable(array $data)
|
||||
{
|
||||
@ -275,9 +251,7 @@ public static function provideUndecipherableData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_array_of_settings_persist_correct_values()
|
||||
{
|
||||
$value = Settings::set([
|
||||
@ -300,9 +274,7 @@ public function test_set_array_of_settings_persist_correct_values()
|
||||
$this->assertEquals($cached->get(self::SETTING_NAME_ALT), self::SETTING_VALUE_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_true_setting_persist_transformed_boolean()
|
||||
{
|
||||
$value = Settings::set(self::SETTING_NAME, true);
|
||||
@ -313,9 +285,7 @@ public function test_set_true_setting_persist_transformed_boolean()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_set_false_setting_persist_transformed_boolean()
|
||||
{
|
||||
$value = Settings::set(self::SETTING_NAME, false);
|
||||
@ -326,9 +296,7 @@ public function test_set_false_setting_persist_transformed_boolean()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_del_remove_setting_from_db_and_cache()
|
||||
{
|
||||
DB::table('options')->insert(
|
||||
@ -345,9 +313,7 @@ public function test_del_remove_setting_from_db_and_cache()
|
||||
$this->assertFalse($cached->has(self::SETTING_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_isEdited_returns_true()
|
||||
{
|
||||
DB::table('options')->insert(
|
||||
@ -357,9 +323,7 @@ public function test_isEdited_returns_true()
|
||||
$this->assertTrue(Settings::isEdited('showOtpAsDot'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_isEdited_returns_false()
|
||||
{
|
||||
DB::table('options')->where(self::KEY, 'showOtpAsDot')->delete();
|
||||
@ -367,9 +331,7 @@ public function test_isEdited_returns_false()
|
||||
$this->assertFalse(Settings::isEdited('showOtpAsDot'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_cache_is_requested_at_instanciation()
|
||||
{
|
||||
Cache::shouldReceive('remember')
|
||||
@ -380,9 +342,7 @@ public function test_cache_is_requested_at_instanciation()
|
||||
Cache::shouldHaveReceived('remember');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_cache_is_updated_when_setting_is_set()
|
||||
{
|
||||
Cache::shouldReceive('remember', 'put')
|
||||
@ -394,9 +354,7 @@ public function test_cache_is_updated_when_setting_is_set()
|
||||
Cache::shouldHaveReceived('put');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_cache_is_updated_when_setting_is_deleted()
|
||||
{
|
||||
Cache::shouldReceive('remember', 'put')
|
||||
|
@ -8,6 +8,7 @@
|
||||
use App\Models\User;
|
||||
use App\Services\TwoFAccountService;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Data\MigrationTestData;
|
||||
use Tests\Data\OtpTestData;
|
||||
use Tests\FeatureTestCase;
|
||||
@ -38,9 +39,6 @@ class TwoFAccountServiceTest extends FeatureTestCase
|
||||
|
||||
protected $userGroupB;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -76,9 +74,7 @@ public function setUp() : void
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_withdraw_comma_separated_ids_deletes_relation()
|
||||
{
|
||||
$twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]);
|
||||
@ -107,9 +103,7 @@ public function test_withdraw_comma_separated_ids_deletes_relation()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_withdraw_array_of_ids_deletes_relation()
|
||||
{
|
||||
$twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]);
|
||||
@ -137,9 +131,7 @@ public function test_withdraw_array_of_ids_deletes_relation()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_withdraw_single_id_deletes_relation()
|
||||
{
|
||||
$twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]);
|
||||
@ -158,17 +150,13 @@ public function test_withdraw_single_id_deletes_relation()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_withdraw_missing_ids_returns_void()
|
||||
{
|
||||
$this->assertNull(TwoFAccounts::withdraw(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_from_gauth_returns_correct_accounts()
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -196,9 +184,7 @@ public function test_migrate_from_gauth_returns_correct_accounts()
|
||||
$this->assertEquals(OtpTestData::ALGORITHM_DEFAULT, $twofaccounts->last()->algorithm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_from_gauth_returns_flagged_duplicates()
|
||||
{
|
||||
$this->actingAs($this->user, 'api-guard');
|
||||
@ -227,18 +213,14 @@ public function test_migrate_from_gauth_returns_flagged_duplicates()
|
||||
$this->assertEquals(-1, $twofaccounts->last()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_invalid_migration_from_gauth_returns_InvalidMigrationData_exception()
|
||||
{
|
||||
$this->expectException(\App\Exceptions\InvalidMigrationDataException::class);
|
||||
$twofaccounts = TwoFAccounts::migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_single_id_returns_collection()
|
||||
{
|
||||
$twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id);
|
||||
@ -247,9 +229,7 @@ public function test_export_single_id_returns_collection()
|
||||
$this->assertObjectEquals($this->customTotpTwofaccount, $twofaccounts->first());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_comma_separated_ids_returns_collection()
|
||||
{
|
||||
$twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id . ',' . $this->customHotpTwofaccount->id);
|
||||
@ -259,9 +239,7 @@ public function test_export_comma_separated_ids_returns_collection()
|
||||
$this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_export_array_of_ids_returns_collection()
|
||||
{
|
||||
$twofaccounts = TwoFAccounts::export([$this->customTotpTwofaccount->id, $this->customHotpTwofaccount->id]);
|
||||
@ -271,9 +249,7 @@ public function test_export_array_of_ids_returns_collection()
|
||||
$this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_comma_separated_ids()
|
||||
{
|
||||
$twofaccounts = TwoFAccount::factory()->count(2)->for($this->user)->create();
|
||||
@ -295,9 +271,7 @@ public function test_delete_comma_separated_ids()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_array_of_ids()
|
||||
{
|
||||
$twofaccounts = TwoFAccount::factory()->count(2)->for($this->user)->create();
|
||||
@ -319,9 +293,7 @@ public function test_delete_array_of_ids()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_delete_single_id()
|
||||
{
|
||||
$twofaccount = TwoFAccount::factory()->for($this->user)->create();
|
||||
|
@ -14,6 +14,7 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -41,9 +42,7 @@ public function setUp() : void
|
||||
$this->app['auth']->shouldUse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_index_returns_api_resources()
|
||||
{
|
||||
$user = Mockery::mock(User::class);
|
||||
@ -67,9 +66,7 @@ public function test_index_returns_api_resources()
|
||||
$this->assertContainsOnlyInstancesOf(GroupResource::class, $response->collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_store_uses_validated_data_and_returns_api_resource()
|
||||
{
|
||||
$request = Mockery::mock(GroupStoreRequest::class);
|
||||
@ -88,9 +85,7 @@ public function test_store_uses_validated_data_and_returns_api_resource()
|
||||
// $this->assertInstanceOf(GroupResource::class, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_show_returns_api_resource()
|
||||
{
|
||||
$controller = Mockery::mock(GroupController::class)->makePartial();
|
||||
@ -101,9 +96,7 @@ public function test_show_returns_api_resource()
|
||||
$this->assertInstanceOf(GroupResource::class, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_update_validates_data_and_returns_api_resource()
|
||||
{
|
||||
$request = Mockery::mock(GroupStoreRequest::class);
|
||||
@ -120,9 +113,7 @@ public function test_update_validates_data_and_returns_api_resource()
|
||||
$this->assertInstanceOf(GroupResource::class, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_assignAccounts_returns_api_resource_assigned_using_groupService()
|
||||
{
|
||||
$request = Mockery::mock(GroupAssignRequest::class);
|
||||
@ -144,9 +135,7 @@ public function test_assignAccounts_returns_api_resource_assigned_using_groupSer
|
||||
$this->assertInstanceOf(GroupResource::class, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_accounts_returns_api_resources()
|
||||
{
|
||||
$controller = Mockery::mock(GroupController::class)->makePartial();
|
||||
@ -157,9 +146,7 @@ public function test_accounts_returns_api_resources()
|
||||
$this->assertContainsOnlyInstancesOf(TwoFAccountReadResource::class, $response->collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_destroy_uses_group_service()
|
||||
{
|
||||
$controller = Mockery::mock(GroupController::class)->makePartial();
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Events\GroupDeleted;
|
||||
use App\Models\Group;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -13,9 +14,7 @@
|
||||
#[CoversClass(GroupDeleted::class)]
|
||||
class GroupDeletedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_event_constructor()
|
||||
{
|
||||
$group = Group::factory()->make();
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Events\GroupDeleting;
|
||||
use App\Models\Group;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -13,9 +14,7 @@
|
||||
#[CoversClass(GroupDeleting::class)]
|
||||
class GroupDeletingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_event_constructor()
|
||||
{
|
||||
$group = Group::factory()->make();
|
||||
|
@ -7,6 +7,7 @@
|
||||
use App\Services\SettingService;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -15,9 +16,7 @@
|
||||
#[CoversClass(TwoFAccountDeleted::class)]
|
||||
class TwoFAccountDeletedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_event_constructor()
|
||||
{
|
||||
$settingService = $this->mock(SettingService::class, function (MockInterface $settingService) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
use Illuminate\Http\Request;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -25,9 +26,7 @@
|
||||
#[CoversClass(Handler::class)]
|
||||
class HandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideExceptionsforBadRequest')]
|
||||
public function test_exceptions_returns_badRequest_json_response($exception)
|
||||
{
|
||||
@ -85,9 +84,7 @@ public static function provideExceptionsforBadRequest() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideExceptionsforNotFound')]
|
||||
public function test_exceptions_returns_notFound_json_response($exception)
|
||||
{
|
||||
@ -124,9 +121,7 @@ public static function provideExceptionsforNotFound() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authenticationException_returns_unauthorized_json_response()
|
||||
{
|
||||
$request = $this->createMock(Request::class);
|
||||
@ -150,9 +145,7 @@ public function test_authenticationException_returns_unauthorized_json_response(
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_authenticationException_returns_proxyAuthRequired_json_response_with_proxy_guard()
|
||||
{
|
||||
$request = $this->createMock(Request::class);
|
||||
@ -176,9 +169,7 @@ public function test_authenticationException_returns_proxyAuthRequired_json_resp
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_AccessDeniedException_returns_forbidden_json_response()
|
||||
{
|
||||
$request = $this->createMock(Request::class);
|
||||
|
@ -8,6 +8,7 @@
|
||||
use App\Models\TwoFAccount;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\ModelTestCase;
|
||||
|
||||
/**
|
||||
@ -16,9 +17,7 @@
|
||||
#[CoversClass(Group::class)]
|
||||
class GroupModelTest extends ModelTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_model_configuration()
|
||||
{
|
||||
$this->runConfigurationAssertions(
|
||||
@ -39,9 +38,7 @@ public function test_model_configuration()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_twofaccounts_relation()
|
||||
{
|
||||
$group = new Group();
|
||||
@ -49,9 +46,7 @@ public function test_twofaccounts_relation()
|
||||
$this->assertHasManyRelation($accounts, $group, new TwoFAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_relation()
|
||||
{
|
||||
$model = new Group;
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Helpers\Helpers;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -13,9 +14,7 @@
|
||||
#[CoversClass(Helpers::class)]
|
||||
class HelpersTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('versionNumberProvider')]
|
||||
public function test_cleanVersionNumber_returns_cleaned_version($dirtyVersion, $expected)
|
||||
{
|
||||
@ -49,9 +48,7 @@ public static function versionNumberProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidVersionNumberProvider')]
|
||||
public function test_cleanVersionNumber_returns_false_with_invalid_semver($dirtyVersion)
|
||||
{
|
||||
@ -84,9 +81,7 @@ public static function invalidVersionNumberProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('toBase32PaddedStringProvider')]
|
||||
public function test_toBase32Format_returns_base32_formated_string($str, $expected)
|
||||
{
|
||||
@ -136,9 +131,7 @@ public static function toBase32PaddedStringProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('commaSeparatedToArrayProvider')]
|
||||
public function test_commaSeparatedToArray_returns_ids_in_array($str, $expected)
|
||||
{
|
||||
@ -164,9 +157,7 @@ public static function commaSeparatedToArrayProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidCommaSeparatedToArrayProvider')]
|
||||
public function test_commaSeparatedToArray_returns_unchanged_ids($str, $expected)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
use Illuminate\Auth\Events\Failed;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(FailedLoginListener::class)]
|
||||
class FailedLoginListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_FailedLoginListener_listen_to_Failed_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(LoginListener::class)]
|
||||
class LoginListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_LoginListener_listen_to_Login_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use Illuminate\Auth\Events\Logout;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(LogoutListener::class)]
|
||||
class LogoutListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_LogoutListener_listen_to_Logout_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Listeners\Authentication\VisitedByProxyUserListener;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(VisitedByProxyUserListener::class)]
|
||||
class VisitedByProxyUserListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_VisitedByProxyUserListener_listen_to_VisitedByProxyUser_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -10,6 +10,7 @@
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -18,9 +19,7 @@
|
||||
#[CoversClass(CleanIconStorage::class)]
|
||||
class CleanIconStorageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_it_deletes_icon_file_using_storage_facade()
|
||||
{
|
||||
$settingService = $this->mock(SettingService::class, function (MockInterface $settingService) {
|
||||
@ -39,9 +38,7 @@ public function test_it_deletes_icon_file_using_storage_facade()
|
||||
$this->assertNull($listener->handle($event));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_CleanIconStorage_listen_to_TwoFAccountDeleted_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Listeners\DissociateTwofaccountFromGroup;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(DissociateTwofaccountFromGroup::class)]
|
||||
class DissociateTwofaccountFromGroupTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_DissociateTwofaccountFromGroup_listen_to_groupDeleting_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use Illuminate\Notifications\Events\NotificationSent;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(LogNotification::class)]
|
||||
class LogNotificationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_LogNotificationTest_listen_to_NotificationSent_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Laravel\Socialite\Contracts\Factory as SocialiteFactory;
|
||||
use Laravel\Socialite\SocialiteManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use SocialiteProviders\Manager\SocialiteWasCalled;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -17,9 +18,7 @@
|
||||
#[CoversClass(RegisterOpenId::class)]
|
||||
class RegisterOpenIdTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_it_registers_openId_driver()
|
||||
{
|
||||
/** @var SocialiteManager $socialite */
|
||||
@ -30,9 +29,7 @@ public function test_it_registers_openId_driver()
|
||||
$this->assertInstanceOf(OpenId::class, $driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_RegisterOpenId_listen_to_SocialiteWasCalled_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -8,6 +8,7 @@
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -16,9 +17,7 @@
|
||||
#[CoversClass(ReleaseRadar::class)]
|
||||
class ReleaseRadarTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_it_starts_release_scan()
|
||||
{
|
||||
$this->mock(ReleaseRadarService::class, function (MockInterface $releaseRadarService) {
|
||||
@ -31,9 +30,7 @@ public function test_it_starts_release_scan()
|
||||
$this->assertNull($listener->handle($event));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_ReleaseRadar_listen_to_ScanForNewReleaseCalled_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Listeners\ResetUsersPreference;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(ResetUsersPreference::class)]
|
||||
class ResetUsersPreferenceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_ResetUsersPreference_listen_to_GroupDeleted_event()
|
||||
{
|
||||
Event::fake();
|
||||
|
@ -20,6 +20,7 @@
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Data\MigrationTestData;
|
||||
use Tests\Data\OtpTestData;
|
||||
use Tests\TestCase;
|
||||
@ -150,9 +151,7 @@ protected function tearDown() : void
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('validMigrationsProvider')]
|
||||
public function test_migrate_returns_consistent_accounts(Migrator $migrator, mixed $payload, string $expected, bool $hasSteam)
|
||||
{
|
||||
@ -226,9 +225,7 @@ public static function validMigrationsProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('invalidMigrationsProvider')]
|
||||
public function test_migrate_with_invalid_payload_returns_InvalidMigrationDataException(Migrator $migrator, mixed $payload)
|
||||
{
|
||||
@ -295,9 +292,7 @@ public static function invalidMigrationsProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('migrationWithInvalidAccountsProvider')]
|
||||
public function test_migrate_returns_fake_accounts(Migrator $migrator, mixed $payload)
|
||||
{
|
||||
@ -337,9 +332,7 @@ public static function migrationWithInvalidAccountsProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_gauth_returns_fake_accounts()
|
||||
{
|
||||
$migrator = $this->partialMock(GoogleAuthMigrator::class, function (MockInterface $migrator) {
|
||||
@ -361,9 +354,7 @@ public function test_migrate_gauth_returns_fake_accounts()
|
||||
$this->forgetMock(GoogleAuthMigrator::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('AegisWithIconMigrationProvider')]
|
||||
public function test_migrate_aegis_payload_with_icon_sets_and_stores_the_icon($migration)
|
||||
{
|
||||
@ -396,9 +387,7 @@ public static function AegisWithIconMigrationProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_aegis_payload_with_unsupported_icon_does_not_fail()
|
||||
{
|
||||
Storage::fake('icons');
|
||||
@ -413,9 +402,7 @@ public function test_migrate_aegis_payload_with_unsupported_icon_does_not_fail()
|
||||
Storage::disk('icons')->assertDirectoryEmpty('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('TwoFAuthWithIconMigrationProvider')]
|
||||
public function test_migrate_2fauth_payload_with_icon_sets_and_stores_the_icon($migration)
|
||||
{
|
||||
@ -454,9 +441,7 @@ public static function TwoFAuthWithIconMigrationProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_migrate_2fauth_payload_with_unsupported_icon_does_not_fail()
|
||||
{
|
||||
Storage::fake('icons');
|
||||
@ -471,9 +456,7 @@ public function test_migrate_2fauth_payload_with_unsupported_icon_does_not_fail(
|
||||
Storage::disk('icons')->assertDirectoryEmpty('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('factoryProvider')]
|
||||
public function test_factory_returns_relevant_migrator($payload, $migratorClass)
|
||||
{
|
||||
@ -517,9 +500,7 @@ public static function factoryProvider()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_factory_throw_UnsupportedMigrationException()
|
||||
{
|
||||
$this->expectException(UnsupportedMigrationException::class);
|
||||
@ -528,9 +509,7 @@ public function test_factory_throw_UnsupportedMigrationException()
|
||||
$migrator = $factory->create('not_a_valid_payload');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('encryptedMigrationDataProvider')]
|
||||
public function test_factory_throw_EncryptedMigrationException($payload)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -17,9 +18,7 @@ class IsValidEmailListTest extends TestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideValidData')]
|
||||
public function test_valid_data(array $data) : void
|
||||
{
|
||||
@ -49,9 +48,7 @@ public static function provideValidData() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideInvalidData')]
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\ModelTestCase;
|
||||
|
||||
/**
|
||||
@ -19,9 +20,7 @@
|
||||
#[CoversClass(TwoFAccount::class)]
|
||||
class TwoFAccountModelTest extends ModelTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_model_configuration()
|
||||
{
|
||||
$this->runConfigurationAssertions(
|
||||
@ -43,9 +42,7 @@ public function test_model_configuration()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideSensitiveAttributes')]
|
||||
public function test_sensitive_attributes_are_stored_encrypted(string $attribute)
|
||||
{
|
||||
@ -81,9 +78,7 @@ public static function provideSensitiveAttributes() : array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideSensitiveAttributes')]
|
||||
public function test_sensitive_attributes_are_returned_clear(string $attribute)
|
||||
{
|
||||
@ -99,9 +94,7 @@ public function test_sensitive_attributes_are_returned_clear(string $attribute)
|
||||
$this->forgetMock(SettingService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideSensitiveAttributes')]
|
||||
public function test_indecipherable_attributes_returns_masked_value(string $attribute)
|
||||
{
|
||||
@ -120,9 +113,7 @@ public function test_indecipherable_attributes_returns_masked_value(string $attr
|
||||
$this->forgetMock(SettingService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_secret_is_uppercased_and_padded_at_setup()
|
||||
{
|
||||
$settingService = $this->mock(SettingService::class, function (MockInterface $settingService) {
|
||||
@ -144,9 +135,7 @@ public function test_secret_is_uppercased_and_padded_at_setup()
|
||||
$this->forgetMock(SettingService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_user_relation()
|
||||
{
|
||||
$model = new TwoFAccount();
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Models\TwoFAccount;
|
||||
use App\Models\User;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\ModelTestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +15,7 @@
|
||||
#[CoversClass(User::class)]
|
||||
class UserModelTest extends ModelTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_model_configuration()
|
||||
{
|
||||
$this->runConfigurationAssertions(new User(),
|
||||
@ -35,9 +34,7 @@ public function test_model_configuration()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_email_is_set_lowercased()
|
||||
{
|
||||
$user = User::factory()->make([
|
||||
@ -47,9 +44,7 @@ public function test_email_is_set_lowercased()
|
||||
$this->assertEquals(strtolower('UPPERCASE@example.COM'), $user->email);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_twofaccounts_relation()
|
||||
{
|
||||
$user = new User();
|
||||
@ -57,9 +52,7 @@ public function test_twofaccounts_relation()
|
||||
$this->assertHasManyRelation($accounts, $user, new TwoFAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function test_groups_relation()
|
||||
{
|
||||
$user = new User();
|
||||
|
Loading…
Reference in New Issue
Block a user