diff --git a/.github/workflows/app-tests.yml b/.github/workflows/app-tests.yml index c0fee81..87c884b 100644 --- a/.github/workflows/app-tests.yml +++ b/.github/workflows/app-tests.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: true matrix: - php: [ 8.1 ] - laravel: [ 9 ] + php: [ 8.1, 8.2 ] + laravel: [ 9, 10 ] stability: [ 'prefer-lowest', 'prefer-stable' ] variants: [ '', diff --git a/.github/workflows/package-tests.yml b/.github/workflows/package-tests.yml index 7f3f828..cc6fdff 100644 --- a/.github/workflows/package-tests.yml +++ b/.github/workflows/package-tests.yml @@ -11,8 +11,8 @@ jobs: fail-fast: true matrix: package: [ 'core', 'bladebones' ] - php: [ 8.1 ] - laravel: [ 9 ] + php: [ 8.1, 8.2 ] + laravel: [ 9, 10 ] stability: [ 'prefer-lowest', 'prefer-stable' ] name: ${{ matrix.package }} - PHP ${{ matrix.php }} L${{ matrix.laravel }} w/ ${{ matrix.stability }} diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8ccfe..b0f9f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/claudiodekker/laravel-auth/compare/v0.1.2...HEAD) +### Added + +- PHP 8.2 Support ([#23](https://github.com/claudiodekker/laravel-auth/pull/23)) +- Laravel 10 Support ([#23](https://github.com/claudiodekker/laravel-auth/pull/23)) + ### Changed - Moved `claudiodekker/laravel-auth` v0.1.0 into this monorepo - Moved `claudiodekker/laravel-auth-bladebones` v0.1.2 into this monorepo - Updated this `CHANGELOG.md` to reflect previous non-monorepo releases +- Bladebones: Improved generator styling, as per Laravel Pint standards ([#23](https://github.com/claudiodekker/laravel-auth/pull/23)) +- Core: Improved tests to use translations instead of string matches ([#23](https://github.com/claudiodekker/laravel-auth/pull/23)) + +### Fixed + +- Core: Fixed timing-related test regression ([#23](https://github.com/claudiodekker/laravel-auth/pull/23)) ## [v0.1.2](https://github.com/claudiodekker/laravel-auth-bladebones/compare/v0.1.2...v0.1.1) - 2022-11-30 diff --git a/composer.json b/composer.json index 9556dd6..fe27c9f 100644 --- a/composer.json +++ b/composer.json @@ -3,18 +3,16 @@ "authors": [ { "name": "Claudio Dekker", - "email": "claudio@ubient.net", - "homepage": "https://ubient.net", - "role": "Developer" + "email": "claudio@ubient.net" } ], "require": { + "ext-json": "*", + "php": "~8.1.0|~8.2.0", + "laravel/framework": "^9.33|^10.0", "bacon/bacon-qr-code": "^2.0", "claudiodekker/word-generator": "^1.0", - "ext-json": "*", - "laravel/framework": "^9.0", "nyholm/psr7": "^1.5", - "php": "~8.1.0", "pragmarx/google2fa": "^8.0", "symfony/psr-http-message-bridge": "^2.1", "web-auth/webauthn-lib": "^4.0" @@ -47,8 +45,8 @@ } }, "replace": { - "claudiodekker/laravel-auth-core": "self.version", - "claudiodekker/laravel-auth-bladebones": "self.version" + "claudiodekker/laravel-auth-bladebones": "self.version", + "claudiodekker/laravel-auth-core": "self.version" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/packages/bladebones/composer.json b/packages/bladebones/composer.json index 2d2123c..36b454b 100644 --- a/packages/bladebones/composer.json +++ b/packages/bladebones/composer.json @@ -23,9 +23,9 @@ } ], "require": { - "php": "~8.1.0", + "php": "~8.1.0|~8.2.0", "ext-json": "*", - "laravel/framework": "^9.0", + "laravel/framework": "^9.33|^10.0", "claudiodekker/laravel-auth-core": "^0.1.3" }, "require-dev": { diff --git a/packages/bladebones/templates/Controllers/AccountRecoveryRequestController.bladetmpl b/packages/bladebones/templates/Controllers/AccountRecoveryRequestController.bladetmpl index bc6cb61..f44b344 100644 --- a/packages/bladebones/templates/Controllers/AccountRecoveryRequestController.bladetmpl +++ b/packages/bladebones/templates/Controllers/AccountRecoveryRequestController.bladetmpl @@ -59,9 +59,6 @@ class AccountRecoveryRequestController extends BaseController @endif /** * Handle an incoming request to view the account recovery page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request): View { @@ -70,9 +67,6 @@ class AccountRecoveryRequestController extends BaseController /** * Handle an incoming request to receive an account recovery link. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function store(Request $request): RedirectResponse { @@ -87,9 +81,6 @@ class AccountRecoveryRequestController extends BaseController * * {!! '@' !!}see sendNoSuchUserResponse * {!! '@' !!}see sendRecoveryAlreadyRequestedResponse - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function sendRecoveryLinkSentResponse(Request $request): RedirectResponse { @@ -101,10 +92,6 @@ class AccountRecoveryRequestController extends BaseController * * NOTE: To prevent malicious visitors from probing the system for valid email addresses, this method should not * indicate that recovery has already been requested. Instead, it should always return the same response. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \Illuminate\Contracts\Auth\Authenticatable $user - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendRecoveryAlreadyRequestedResponse(Request $request, Authenticatable $user): RedirectResponse { @@ -116,9 +103,6 @@ class AccountRecoveryRequestController extends BaseController * * NOTE: To prevent malicious visitors from probing the system for valid email addresses, this method should not * indicate that the account was not found. Instead, it should always return the same response. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendNoSuchUserResponse(Request $request): RedirectResponse { @@ -129,10 +113,6 @@ class AccountRecoveryRequestController extends BaseController /** * Sends a response indicating that the user's requests have been rate limited. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param int $availableInSeconds - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendRateLimitedResponse(Request $request, int $availableInSeconds): void diff --git a/packages/bladebones/templates/Controllers/Challenges/AccountRecoveryChallengeController.bladetmpl b/packages/bladebones/templates/Controllers/Challenges/AccountRecoveryChallengeController.bladetmpl index cd169f2..37cfbce 100644 --- a/packages/bladebones/templates/Controllers/Challenges/AccountRecoveryChallengeController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Challenges/AccountRecoveryChallengeController.bladetmpl @@ -29,10 +29,6 @@ class AccountRecoveryChallengeController extends BaseController @endif /** * Handle an incoming request to view the account recovery challenge page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param string $token - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request, string $token): View { @@ -41,10 +37,6 @@ class AccountRecoveryChallengeController extends BaseController /** * Handle an incoming account recovery challenge response. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param string $token - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function store(Request $request, string $token): RedirectResponse { @@ -53,10 +45,6 @@ class AccountRecoveryChallengeController extends BaseController /** * Sends a response that displays the account recovery challenge page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param string $token - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendChallengePageResponse(Request $request, string $token): View { @@ -68,9 +56,6 @@ class AccountRecoveryChallengeController extends BaseController /** * Sends a response indicating that the given recovery link is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidRecoveryLinkResponse(Request $request): void @@ -81,9 +66,6 @@ class AccountRecoveryChallengeController extends BaseController /** * Sends a response indicating that the given recovery code is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendInvalidRecoveryCodeResponse(Request $request): void @@ -98,10 +80,6 @@ class AccountRecoveryChallengeController extends BaseController * * Typically, you'd want this response to redirect the user to their account's security settings page, * where they can adjust whatever is causing them to be unable to authenticate using normal means. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \Illuminate\Contracts\Auth\Authenticatable $user - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendAccountRecoveredResponse(Request $request, Authenticatable $user): RedirectResponse { @@ -112,10 +90,6 @@ class AccountRecoveryChallengeController extends BaseController /** * Sends a response indicating that the user's requests have been rate limited. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param int $availableInSeconds - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendRateLimitedResponse(Request $request, int $availableInSeconds): void diff --git a/packages/bladebones/templates/Controllers/Challenges/MultiFactorChallengeController.bladetmpl b/packages/bladebones/templates/Controllers/Challenges/MultiFactorChallengeController.bladetmpl index 8d82ec9..f5d433c 100644 --- a/packages/bladebones/templates/Controllers/Challenges/MultiFactorChallengeController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Challenges/MultiFactorChallengeController.bladetmpl @@ -43,9 +43,6 @@ class MultiFactorChallengeController extends BaseController @endif /** * Handle an incoming request to view the multi-factor challenge page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse */ public function create(Request $request): View|RedirectResponse { @@ -54,9 +51,6 @@ class MultiFactorChallengeController extends BaseController /** * Handle an incoming multi-factor challenge confirmation request. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ public function store(Request $request): JsonResponse { @@ -65,11 +59,6 @@ class MultiFactorChallengeController extends BaseController /** * Sends a response that displays the multi-factor challenge page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \ClaudioDekker\LaravelAuth\Specifications\WebAuthn\Dictionaries\PublicKeyCredentialRequestOptions|null $options - * {!! '@' !!}param \Illuminate\Support\Collection $availableCredentialTypes - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendChallengePageResponse(Request $request, PublicKeyCredentialRequestOptions|null $options, Collection $availableCredentialTypes): View { @@ -82,11 +71,6 @@ class MultiFactorChallengeController extends BaseController /** * Sends a response indicating that the user has been successfully authenticated. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \Illuminate\Contracts\Auth\Authenticatable $user - * {!! '@' !!}param string $intendedUrl - * {!! '@' !!}return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ protected function sendAuthenticatedResponse(Request $request, Authenticatable $user, string $intendedUrl): JsonResponse|RedirectResponse { @@ -104,9 +88,6 @@ class MultiFactorChallengeController extends BaseController /** * Sends a response indicating that the public key credential challenge state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidPublicKeyChallengeStateResponse(Request $request): void @@ -120,9 +101,6 @@ class MultiFactorChallengeController extends BaseController * This can be for a large number of reasons, including (but not limited to) a malformed request, * a non-existent credential, an invalid signature or confirmation code etc. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendChallengeFailedResponse(Request $request): void @@ -142,10 +120,6 @@ class MultiFactorChallengeController extends BaseController /** * Sends a response indicating that the user's requests have been rate limited. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param int $availableInSeconds - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendRateLimitedResponse(Request $request, int $availableInSeconds): void diff --git a/packages/bladebones/templates/Controllers/Challenges/SudoModeChallengeController.bladetmpl b/packages/bladebones/templates/Controllers/Challenges/SudoModeChallengeController.bladetmpl index ef06076..dc53635 100644 --- a/packages/bladebones/templates/Controllers/Challenges/SudoModeChallengeController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Challenges/SudoModeChallengeController.bladetmpl @@ -39,9 +39,6 @@ class SudoModeChallengeController extends BaseController @endif /** * Display the sudo-mode challenge view. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request): View { @@ -50,9 +47,6 @@ class SudoModeChallengeController extends BaseController /** * Verify the sudo-mode confirmation request. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ public function store(Request $request): JsonResponse { @@ -61,10 +55,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response that displays the sudo-mode challenge page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \ClaudioDekker\LaravelAuth\Specifications\WebAuthn\Dictionaries\PublicKeyCredentialRequestOptions|null $options - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendChallengePageResponse(Request $request, PublicKeyCredentialRequestOptions|null $options): View { @@ -76,9 +66,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response indicating that sudo-mode has been enabled. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ protected function sendSudoModeEnabledResponse(Request $request): JsonResponse { @@ -90,9 +77,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response indicating that sudo-mode is currently not required. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendConfirmationNotRequiredResponse(Request $request): void @@ -103,9 +87,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response indicating that the password challenge did not succeed. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendPasswordChallengeFailedResponse(Request $request): void @@ -118,9 +99,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response indicating that the public key challenge state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidPublicKeyChallengeStateResponse(Request $request): void @@ -131,9 +109,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response indicating that the public key challenge did not succeed. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendPublicKeyChallengeFailedResponse(Request $request): void @@ -147,10 +122,6 @@ class SudoModeChallengeController extends BaseController /** * Sends a response indicating that the user's requests have been rate limited. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param int $availableInSeconds - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendRateLimitedResponse(Request $request, int $availableInSeconds): void diff --git a/packages/bladebones/templates/Controllers/LoginController.bladetmpl b/packages/bladebones/templates/Controllers/LoginController.bladetmpl index 0c117bc..734c6e3 100644 --- a/packages/bladebones/templates/Controllers/LoginController.bladetmpl +++ b/packages/bladebones/templates/Controllers/LoginController.bladetmpl @@ -42,9 +42,6 @@ class LoginController extends BaseController @endif /** * Display the login view. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request): View { @@ -53,9 +50,6 @@ class LoginController extends BaseController /** * Handle an incoming authentication request. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ public function store(Request $request): JsonResponse { @@ -64,9 +58,6 @@ class LoginController extends BaseController /** * Sign the user out of the application. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function destroy(Request $request): RedirectResponse { @@ -75,10 +66,6 @@ class LoginController extends BaseController /** * Sends a response that displays the login page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \ClaudioDekker\LaravelAuth\Specifications\WebAuthn\Dictionaries\PublicKeyCredentialRequestOptions $options - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendLoginPageResponse(Request $request, PublicKeyCredentialRequestOptions $options): View { @@ -89,10 +76,6 @@ class LoginController extends BaseController /** * Sends a response indicating that the user has been authenticated successfully. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \Illuminate\Contracts\Auth\Authenticatable $user - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ protected function sendAuthenticatedResponse(Request $request, Authenticatable $user): JsonResponse { @@ -104,9 +87,6 @@ class LoginController extends BaseController /** * Sends a response indicating that authentication has failed. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendAuthenticationFailedResponse(Request $request): void @@ -118,10 +98,6 @@ class LoginController extends BaseController /** * Sends a response indicating that the user needs to confirm a 2FA challenge. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \ClaudioDekker\LaravelAuth\CredentialType $preferredMethod - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ protected function sendMultiFactorChallengeResponse(Request $request, CredentialType $preferredMethod): JsonResponse { @@ -133,9 +109,6 @@ class LoginController extends BaseController /** * Sends a response indicating that the passkey authentication state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidPasskeyAuthenticationStateResponse(Request $request): void @@ -145,9 +118,6 @@ class LoginController extends BaseController /** * Sends a response indicating that the user has been signed out. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendLoggedOutResponse(Request $request): RedirectResponse { @@ -158,10 +128,6 @@ class LoginController extends BaseController /** * Sends a response indicating that the user's requests have been rate limited. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param int $availableInSeconds - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendRateLimitedResponse(Request $request, int $availableInSeconds): void diff --git a/packages/bladebones/templates/Controllers/RegisterController.bladetmpl b/packages/bladebones/templates/Controllers/RegisterController.bladetmpl index 1ec02ad..a17afe8 100644 --- a/packages/bladebones/templates/Controllers/RegisterController.bladetmpl +++ b/packages/bladebones/templates/Controllers/RegisterController.bladetmpl @@ -50,9 +50,6 @@ class RegisterController extends BaseController @endif /** * Display the registration view. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request): View { @@ -61,9 +58,6 @@ class RegisterController extends BaseController /** * Handle an incoming registration request. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ public function store(Request $request): JsonResponse { @@ -72,10 +66,6 @@ class RegisterController extends BaseController /** * Sends a response indicating that the passkey-based registration process has been initialized. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \ClaudioDekker\LaravelAuth\Specifications\WebAuthn\Dictionaries\PublicKeyCredentialCreationOptions $options - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ protected function sendPasskeyBasedRegistrationInitializedResponse(Request $request, PublicKeyCredentialCreationOptions $options): JsonResponse { @@ -85,9 +75,6 @@ class RegisterController extends BaseController /** * Sends a response indicating that the passkey-based registration state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidPasskeyRegistrationStateResponse(Request $request): void @@ -98,9 +85,6 @@ class RegisterController extends BaseController /** * Sends a response indicating that the signed passkey is not valid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendInvalidPasskeyResponse(Request $request): void @@ -112,10 +96,6 @@ class RegisterController extends BaseController /** * Sends a response indicating that the user has successfully registered. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \Illuminate\Contracts\Auth\Authenticatable $user - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ protected function sendRegisteredResponse(Request $request, Authenticatable $user): JsonResponse { diff --git a/packages/bladebones/templates/Controllers/Settings/ChangePasswordController.bladetmpl b/packages/bladebones/templates/Controllers/Settings/ChangePasswordController.bladetmpl index bd04116..d82066a 100644 --- a/packages/bladebones/templates/Controllers/Settings/ChangePasswordController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Settings/ChangePasswordController.bladetmpl @@ -8,9 +8,6 @@ class ChangePasswordController extends BaseController { /** * Change the current user's password. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function update(Request $request): RedirectResponse { @@ -19,9 +16,6 @@ class ChangePasswordController extends BaseController /** * Send a response indicating that the user's password has been changed. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendPasswordChangedResponse(Request $request): RedirectResponse { diff --git a/packages/bladebones/templates/Controllers/Settings/CredentialsController.bladetmpl b/packages/bladebones/templates/Controllers/Settings/CredentialsController.bladetmpl index 12448f0..9596aea 100644 --- a/packages/bladebones/templates/Controllers/Settings/CredentialsController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Settings/CredentialsController.bladetmpl @@ -13,9 +13,6 @@ class CredentialsController extends BaseController { /** * Display an overview of all security-related settings. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function index(Request $request): View { @@ -25,9 +22,7 @@ class CredentialsController extends BaseController /** * Delete a multi-factor credential. * - * {!! '@' !!}param \Illuminate\Http\Request $request * {!! '@' !!}param string $id - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function destroy(Request $request, mixed $id): RedirectResponse { @@ -36,10 +31,6 @@ class CredentialsController extends BaseController /** * Sends a response that displays the credential overview page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \Illuminate\Support\Collection $mfaCredentials - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendOverviewPageResponse(Request $request, Collection $mfaCredentials): View { @@ -54,9 +45,7 @@ class CredentialsController extends BaseController /** * Sends a response indicating that the multi-factor credential could not be found. * - * {!! '@' !!}param \Illuminate\Http\Request $request * {!! '@' !!}param string $id - * {!! '@' !!}return void * * {!! '@' !!}throws \Illuminate\Database\Eloquent\ModelNotFoundException */ @@ -71,9 +60,7 @@ class CredentialsController extends BaseController /** * Sends a response indicating that the multi-factor credential was deleted. * - * {!! '@' !!}param \Illuminate\Http\Request $request * {!! '@' !!}param \ClaudioDekker\LaravelAuth\MultiFactorCredential $credential - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendCredentialDeletedResponse(Request $request, $credential): RedirectResponse { diff --git a/packages/bladebones/templates/Controllers/Settings/GenerateRecoveryCodesController.bladetmpl b/packages/bladebones/templates/Controllers/Settings/GenerateRecoveryCodesController.bladetmpl index 337363a..0cb68b4 100644 --- a/packages/bladebones/templates/Controllers/Settings/GenerateRecoveryCodesController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Settings/GenerateRecoveryCodesController.bladetmpl @@ -10,9 +10,6 @@ class GenerateRecoveryCodesController extends BaseController { /** * Prepare the configuration of fresh recovery codes. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request): View { @@ -21,9 +18,6 @@ class GenerateRecoveryCodesController extends BaseController /** * Display the view for confirming that the user has saved their recovery codes. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function confirm(Request $request): View { @@ -32,9 +26,6 @@ class GenerateRecoveryCodesController extends BaseController /** * Confirm and finalize the generation of the recovery codes. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function store(Request $request): RedirectResponse { @@ -44,9 +35,7 @@ class GenerateRecoveryCodesController extends BaseController /** * Sends a response indicating that new recovery codes have been prepared. * - * {!! '@' !!}param \Illuminate\Http\Request $request * {!! '@' !!}param \ClaudioDekker\LaravelAuth\RecoveryCodeManager $codes - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendRecoveryCodesPreparedResponse(Request $request, $codes): View { @@ -57,9 +46,6 @@ class GenerateRecoveryCodesController extends BaseController /** * Sends a response that displays the recovery code confirmation page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendConfirmationPageResponse(Request $request): View { @@ -68,9 +54,6 @@ class GenerateRecoveryCodesController extends BaseController /** * Sends a response indicating that the new recovery codes have been configured. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendRecoveryCodesConfiguredResponse(Request $request): RedirectResponse { @@ -80,9 +63,6 @@ class GenerateRecoveryCodesController extends BaseController /** * Sends a response indicating that the recovery codes configuration state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidConfigurationStateResponse(Request $request): void @@ -93,9 +73,6 @@ class GenerateRecoveryCodesController extends BaseController /** * Sends a response indicating that the provided confirmation code is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendInvalidRecoveryCodeResponse(Request $request): void diff --git a/packages/bladebones/templates/Controllers/Settings/RegisterPublicKeyCredentialController.bladetmpl b/packages/bladebones/templates/Controllers/Settings/RegisterPublicKeyCredentialController.bladetmpl index 11cf6ef..fbccb34 100644 --- a/packages/bladebones/templates/Controllers/Settings/RegisterPublicKeyCredentialController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Settings/RegisterPublicKeyCredentialController.bladetmpl @@ -33,9 +33,6 @@ class RegisterPublicKeyCredentialController extends BaseController @endif /** * Initialize and display the view for registering a new public key credential. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function create(Request $request): View { @@ -44,9 +41,6 @@ class RegisterPublicKeyCredentialController extends BaseController /** * Complete the registration of a new public key credential. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ public function store(Request $request): JsonResponse { @@ -55,10 +49,6 @@ class RegisterPublicKeyCredentialController extends BaseController /** * Sends a response that displays the public key registration page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param \ClaudioDekker\LaravelAuth\Specifications\WebAuthn\Dictionaries\PublicKeyCredentialCreationOptions $options - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendRegistrationPageResponse(Request $request, PublicKeyCredentialCreationOptions $options): View { @@ -71,9 +61,7 @@ class RegisterPublicKeyCredentialController extends BaseController /** * Sends a response indicating that the public key credential has been registered. * - * {!! '@' !!}param \Illuminate\Http\Request $request * {!! '@' !!}param \ClaudioDekker\LaravelAuth\MultiFactorCredential $credential - * {!! '@' !!}return \Illuminate\Http\JsonResponse */ protected function sendCredentialRegisteredResponse(Request $request, $credential): JsonResponse { @@ -85,9 +73,6 @@ class RegisterPublicKeyCredentialController extends BaseController /** * Sends a response indicating that the public key credential registration state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidPublicKeyRegistrationStateResponse(Request $request): void @@ -98,9 +83,6 @@ class RegisterPublicKeyCredentialController extends BaseController /** * Sends a response indicating that the provided public key credential is not valid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendInvalidPublicKeyCredentialResponse(Request $request): void diff --git a/packages/bladebones/templates/Controllers/Settings/RegisterTotpCredentialController.bladetmpl b/packages/bladebones/templates/Controllers/Settings/RegisterTotpCredentialController.bladetmpl index ca387fa..2b7ed55 100644 --- a/packages/bladebones/templates/Controllers/Settings/RegisterTotpCredentialController.bladetmpl +++ b/packages/bladebones/templates/Controllers/Settings/RegisterTotpCredentialController.bladetmpl @@ -33,9 +33,6 @@ class RegisterTotpCredentialController extends BaseController /** * Initialize the registration of a new time-based one-time-password credential. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse - * * {!! '@' !!}throws \ClaudioDekker\LaravelAuth\Methods\Totp\Exceptions\InvalidSecretException */ public function initialize(Request $request): RedirectResponse @@ -45,9 +42,6 @@ class RegisterTotpCredentialController extends BaseController /** * Display the view for confirming the time-based one-time-password credential registration. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Contracts\View\View */ public function confirm(Request $request): View { @@ -56,9 +50,6 @@ class RegisterTotpCredentialController extends BaseController /** * Confirm and finalize the registration of the time-based one-time-password credential. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function store(Request $request): RedirectResponse { @@ -67,9 +58,6 @@ class RegisterTotpCredentialController extends BaseController /** * Cancel the registration of the time-based one-time-password credential. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function cancel(Request $request): RedirectResponse { @@ -78,10 +66,6 @@ class RegisterTotpCredentialController extends BaseController /** * Sends a response indicating that the time-based one-time-password registration has been initialized. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param string $secret - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendRegistrationInitializedResponse(Request $request, string $secret): RedirectResponse { @@ -90,10 +74,6 @@ class RegisterTotpCredentialController extends BaseController /** * Sends a response that displays the time-based one-time-password confirmation page. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}param string $secret - * {!! '@' !!}return \Illuminate\Contracts\View\View */ protected function sendConfirmationPageResponse(Request $request, string $secret): View { @@ -107,9 +87,7 @@ class RegisterTotpCredentialController extends BaseController /** * Sends a response indicating that the time-based one-time-password credential has been registered. * - * {!! '@' !!}param \Illuminate\Http\Request $request * {!! '@' !!}param \ClaudioDekker\LaravelAuth\MultiFactorCredential $credential - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendCredentialRegisteredResponse(Request $request, $credential): RedirectResponse { @@ -118,9 +96,6 @@ class RegisterTotpCredentialController extends BaseController /** * Sends a response indicating that the time-based one-time-password credential registration has been cancelled. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendRegistrationCancelledResponse(Request $request): RedirectResponse { @@ -130,9 +105,6 @@ class RegisterTotpCredentialController extends BaseController /** * Sends a response indicating that the time-based one-time-password registration state is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function sendInvalidRegistrationStateResponse(Request $request): void @@ -143,9 +115,6 @@ class RegisterTotpCredentialController extends BaseController /** * Sends a response indicating that the provided confirmation code is invalid. * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return void - * * {!! '@' !!}throws \Illuminate\Validation\ValidationException */ protected function sendInvalidConfirmationCodeResponse(Request $request): void diff --git a/packages/bladebones/templates/Controllers/VerifyEmailController.bladetmpl b/packages/bladebones/templates/Controllers/VerifyEmailController.bladetmpl index 7461816..8554b00 100644 --- a/packages/bladebones/templates/Controllers/VerifyEmailController.bladetmpl +++ b/packages/bladebones/templates/Controllers/VerifyEmailController.bladetmpl @@ -14,9 +14,6 @@ class VerifyEmailController extends BaseController { /** * Sends a response indicating that the email verification link has been resent. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendEmailVerificationSentResponse(Request $request): RedirectResponse { @@ -26,9 +23,6 @@ class VerifyEmailController extends BaseController /** * Sends a response indicating that the email has already been verified. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendEmailAlreadyVerifiedResponse(Request $request): RedirectResponse { @@ -38,9 +32,6 @@ class VerifyEmailController extends BaseController /** * Sends a response indicating that the email has been successfully verified. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ protected function sendEmailSuccessfullyVerifiedResponse(Request $request): RedirectResponse { @@ -50,9 +41,6 @@ class VerifyEmailController extends BaseController /** * Handle an incoming request to (re)send the verification email. - * - * {!! '@' !!}param \Illuminate\Http\Request $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function store(Request $request): RedirectResponse { @@ -61,9 +49,6 @@ class VerifyEmailController extends BaseController /** * Handle an incoming request to confirm the email verification. - * - * {!! '@' !!}param \Illuminate\Foundation\Auth\EmailVerificationRequest $request - * {!! '@' !!}return \Illuminate\Http\RedirectResponse */ public function update(EmailVerificationRequest $request): RedirectResponse { diff --git a/packages/core/composer.json b/packages/core/composer.json index d2f4232..4919f52 100644 --- a/packages/core/composer.json +++ b/packages/core/composer.json @@ -14,11 +14,11 @@ } ], "require": { - "php": "~8.1.0", + "php": "~8.1.0|~8.2.0", "ext-json": "*", "bacon/bacon-qr-code": "^2.0", "claudiodekker/word-generator": "^1.0", - "laravel/framework": "^9.0", + "laravel/framework": "^9.33|^10.0", "nyholm/psr7": "^1.5", "pragmarx/google2fa": "^8.0", "symfony/psr-http-message-bridge": "^2.1", diff --git a/packages/core/src/Testing/Flavors/EmailBased.php b/packages/core/src/Testing/Flavors/EmailBased.php index 75c7955..310e845 100644 --- a/packages/core/src/Testing/Flavors/EmailBased.php +++ b/packages/core/src/Testing/Flavors/EmailBased.php @@ -43,24 +43,24 @@ protected function tooLongUsername(): string protected function assertUsernameRequiredValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The email field is required.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.required', ['attribute' => 'email'])]], $response->exception->errors()); } protected function assertUsernameMustBeValidValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The email must be a valid email address.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.email', ['attribute' => 'email'])]], $response->exception->errors()); } protected function assertUsernameTooLongValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The email must not be greater than 255 characters.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.max.string', ['attribute' => 'email', 'max' => 255])]], $response->exception->errors()); } protected function assertUsernameAlreadyExistsValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The email has already been taken.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.unique', ['attribute' => 'email'])]], $response->exception->errors()); } } diff --git a/packages/core/src/Testing/Flavors/UsernameBased.php b/packages/core/src/Testing/Flavors/UsernameBased.php index 32e089e..ad00a6f 100644 --- a/packages/core/src/Testing/Flavors/UsernameBased.php +++ b/packages/core/src/Testing/Flavors/UsernameBased.php @@ -43,7 +43,7 @@ protected function tooLongUsername(): string protected function assertUsernameRequiredValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The username field is required.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.required', ['attribute' => 'username'])]], $response->exception->errors()); } protected function assertUsernameMustBeValidValidationError(TestResponse $response): void @@ -55,12 +55,12 @@ protected function assertUsernameMustBeValidValidationError(TestResponse $respon protected function assertUsernameTooLongValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The username must not be greater than 255 characters.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.max.string', ['attribute' => 'username', 'max' => 255])]], $response->exception->errors()); } protected function assertUsernameAlreadyExistsValidationError(TestResponse $response): void { $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['The username has already been taken.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('validation.unique', ['attribute' => 'username'])]], $response->exception->errors()); } } diff --git a/packages/core/src/Testing/Partials/Challenges/MultiFactor/SubmitMultiFactorChallengeUsingTotpCodeTests.php b/packages/core/src/Testing/Partials/Challenges/MultiFactor/SubmitMultiFactorChallengeUsingTotpCodeTests.php index 7a444b5..48952b5 100644 --- a/packages/core/src/Testing/Partials/Challenges/MultiFactor/SubmitMultiFactorChallengeUsingTotpCodeTests.php +++ b/packages/core/src/Testing/Partials/Challenges/MultiFactor/SubmitMultiFactorChallengeUsingTotpCodeTests.php @@ -28,7 +28,7 @@ public function the_code_field_is_required_when_completing_the_multi_factor_chal $response = $this->postJson(route('login.challenge.multi_factor')); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code field is required.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.required', ['attribute' => 'code'])]], $response->exception->errors()); $this->assertPartlyAuthenticatedAs($response, $user); } @@ -43,7 +43,7 @@ public function the_code_field_must_be_a_string_when_completing_the_multi_factor $response = $this->postJson(route('login.challenge.multi_factor'), ['code' => true]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code must be a string.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.string', ['attribute' => 'code'])]], $response->exception->errors()); $this->assertPartlyAuthenticatedAs($response, $user); Event::assertNothingDispatched(); } diff --git a/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingCredentialTests.php b/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingCredentialTests.php index 12fa057..67e26b4 100644 --- a/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingCredentialTests.php +++ b/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingCredentialTests.php @@ -269,7 +269,7 @@ public function it_validates_that_the_credential_is_required_when_an_user_confir ->post(route('auth.sudo_mode'), []); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['credential' => ['The credential field is required.']], $response->exception->errors()); + $this->assertSame(['credential' => [__('validation.required', ['attribute' => 'credential'])]], $response->exception->errors()); $response->assertSessionHas(EnsureSudoMode::REQUIRED_AT_KEY, now()->unix()); $response->assertSessionMissing(EnsureSudoMode::CONFIRMED_AT_KEY); $response->assertSessionMissing('laravel-auth::sudo_mode.public_key_challenge_request_options'); diff --git a/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingPasswordTests.php b/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingPasswordTests.php index f95e830..558d875 100644 --- a/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingPasswordTests.php +++ b/packages/core/src/Testing/Partials/Challenges/SudoMode/ConfirmSudoModeUsingPasswordTests.php @@ -92,7 +92,7 @@ public function a_passwordless_user_cannot_confirm_sudo_mode_using_a_password(): ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['credential' => ['The credential field is required.']], $response->exception->errors()); + $this->assertSame(['credential' => [__('validation.required', ['attribute' => 'credential'])]], $response->exception->errors()); $response->assertSessionHas(EnsureSudoMode::REQUIRED_AT_KEY, now()->unix()); $response->assertSessionMissing(EnsureSudoMode::CONFIRMED_AT_KEY); Event::assertNothingDispatched(); diff --git a/packages/core/src/Testing/Partials/RateLimiting/AccountRecoveryChallengeRateLimitingTests.php b/packages/core/src/Testing/Partials/RateLimiting/AccountRecoveryChallengeRateLimitingTests.php index dfc31e9..b44a5d5 100644 --- a/packages/core/src/Testing/Partials/RateLimiting/AccountRecoveryChallengeRateLimitingTests.php +++ b/packages/core/src/Testing/Partials/RateLimiting/AccountRecoveryChallengeRateLimitingTests.php @@ -3,6 +3,7 @@ namespace ClaudioDekker\LaravelAuth\Testing\Partials\RateLimiting; use Illuminate\Auth\Events\Lockout; +use Illuminate\Support\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Password; @@ -15,6 +16,7 @@ trait AccountRecoveryChallengeRateLimitingTests /** @test */ public function account_recovery_challenge_requests_are_rate_limited_after_too_many_failed_requests(): void { + Carbon::setTestNow(now()); Event::fake([Lockout::class]); $user = $this->generateUser(['recovery_codes' => $codes = ['H4PFK-ENVZV', 'PIPIM-7LTUT']]); $token = Password::getRepository()->create($user); @@ -29,6 +31,7 @@ public function account_recovery_challenge_requests_are_rate_limited_after_too_m $this->assertSame(['code' => [__('laravel-auth::auth.challenge.throttle', ['seconds' => 60])]], $response->exception->errors()); $this->assertSame($codes, $user->fresh()->recovery_codes); Event::assertDispatched(Lockout::class, fn (Lockout $event) => $event->request === request()); + Carbon::setTestNow(); } /** @test */ diff --git a/packages/core/src/Testing/Partials/RateLimiting/LoginRateLimitingTests.php b/packages/core/src/Testing/Partials/RateLimiting/LoginRateLimitingTests.php index c02e24b..04ff596 100644 --- a/packages/core/src/Testing/Partials/RateLimiting/LoginRateLimitingTests.php +++ b/packages/core/src/Testing/Partials/RateLimiting/LoginRateLimitingTests.php @@ -27,7 +27,7 @@ public function password_based_authentication_requests_are_rate_limited_after_to $response = $this->submitPasswordBasedLoginAttempt(); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['Too many login attempts. Please try again in 75 seconds.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('auth.throttle', ['seconds' => 75])]], $response->exception->errors()); $this->assertGuest(); Event::assertDispatched(Lockout::class, fn (Lockout $event) => $event->request === request()); Event::assertNotDispatched(Authenticated::class); @@ -106,7 +106,7 @@ public function passkey_based_authentication_requests_are_rate_limited_after_too ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame([$this->usernameField() => ['Too many login attempts. Please try again in 75 seconds.']], $response->exception->errors()); + $this->assertSame([$this->usernameField() => [__('auth.throttle', ['seconds' => 75])]], $response->exception->errors()); $this->assertGuest(); Event::assertNotDispatched(Authenticated::class); Event::assertNotDispatched(AuthenticationFailed::class); diff --git a/packages/core/src/Testing/Partials/RateLimiting/MultiFactorChallengeRateLimitingTests.php b/packages/core/src/Testing/Partials/RateLimiting/MultiFactorChallengeRateLimitingTests.php index 68d0537..427a0fe 100644 --- a/packages/core/src/Testing/Partials/RateLimiting/MultiFactorChallengeRateLimitingTests.php +++ b/packages/core/src/Testing/Partials/RateLimiting/MultiFactorChallengeRateLimitingTests.php @@ -8,6 +8,7 @@ use ClaudioDekker\LaravelAuth\Methods\Totp\GoogleTwoFactorAuthenticator; use ClaudioDekker\LaravelAuth\MultiFactorCredential; use Illuminate\Auth\Events\Lockout; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\RateLimiter; @@ -18,6 +19,7 @@ trait MultiFactorChallengeRateLimitingTests /** @test */ public function the_public_key_multi_factor_challenge_is_rate_limited_after_too_many_failed_attempts(): void { + Carbon::setTestNow(now()); Event::fake([Lockout::class, Authenticated::class, MultiFactorChallengeFailed::class]); $user = $this->generateUser(['id' => 1]); $credential = MultiFactorCredential::factory()->publicKey()->forUser($user)->create([ @@ -50,11 +52,13 @@ public function the_public_key_multi_factor_challenge_is_rate_limited_after_too_ Event::assertDispatched(Lockout::class, fn (Lockout $event) => $event->request === request()); Event::assertNotDispatched(Authenticated::class); Event::assertNotDispatched(MultiFactorChallengeFailed::class); + Carbon::setTestNow(); } /** @test */ public function the_time_based_one_time_password_multi_factor_challenge_is_rate_limited_after_too_many_failed_attempts(): void { + Carbon::setTestNow(now()); Event::fake([Lockout::class, Authenticated::class, MultiFactorChallengeFailed::class]); $user = $this->generateUser(); LaravelAuth::multiFactorCredential()::factory()->totp()->forUser($user)->create(); @@ -71,6 +75,7 @@ public function the_time_based_one_time_password_multi_factor_challenge_is_rate_ Event::assertDispatched(Lockout::class, fn (Lockout $event) => $event->request === request()); Event::assertNotDispatched(Authenticated::class); Event::assertNotDispatched(MultiFactorChallengeFailed::class); + Carbon::setTestNow(); } /** @test */ diff --git a/packages/core/src/Testing/Partials/RateLimiting/SudoModeRateLimitingTests.php b/packages/core/src/Testing/Partials/RateLimiting/SudoModeRateLimitingTests.php index 419ba94..764130c 100644 --- a/packages/core/src/Testing/Partials/RateLimiting/SudoModeRateLimitingTests.php +++ b/packages/core/src/Testing/Partials/RateLimiting/SudoModeRateLimitingTests.php @@ -6,6 +6,7 @@ use ClaudioDekker\LaravelAuth\Http\Middleware\EnsureSudoMode; use ClaudioDekker\LaravelAuth\MultiFactorCredential; use Illuminate\Auth\Events\Lockout; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\RateLimiter; @@ -17,6 +18,7 @@ trait SudoModeRateLimitingTests /** @test */ public function password_based_sudo_mode_confirmation_requests_are_rate_limited_after_too_many_failed_attempts(): void { + Carbon::setTestNow(now()); Event::fake([Lockout::class, SudoModeEnabled::class]); Session::put(EnsureSudoMode::REQUIRED_AT_KEY, now()->unix()); $user = $this->generateUser(); @@ -32,6 +34,7 @@ public function password_based_sudo_mode_confirmation_requests_are_rate_limited_ $this->assertSame(['password' => [__('laravel-auth::auth.challenge.throttle', ['seconds' => 75])]], $response->exception->errors()); Event::assertNotDispatched(SudoModeEnabled::class); Event::assertDispatched(Lockout::class, fn (Lockout $event) => $event->request === request()); + Carbon::setTestNow(); } /** @test */ @@ -71,6 +74,7 @@ public function it_resets_the_rate_limiting_attempts_when_password_based_sudo_mo /** @test */ public function credential_based_sudo_mode_confirmation_requests_are_rate_limited_after_too_many_failed_attempts(): void { + Carbon::setTestNow(now()); Event::fake([Lockout::class, SudoModeEnabled::class]); Session::put(EnsureSudoMode::REQUIRED_AT_KEY, now()->unix()); $user = $this->generateUser(['id' => 1]); @@ -99,6 +103,7 @@ public function credential_based_sudo_mode_confirmation_requests_are_rate_limite $this->assertSame(['password' => [__('laravel-auth::auth.challenge.throttle', ['seconds' => 75])]], $response->exception->errors()); Event::assertNotDispatched(SudoModeEnabled::class); Event::assertDispatched(Lockout::class, fn (Lockout $event) => $event->request === request()); + Carbon::setTestNow(); } /** @test */ diff --git a/packages/core/src/Testing/Partials/Settings/Recovery/ConfirmRecoveryCodesGenerationTests.php b/packages/core/src/Testing/Partials/Settings/Recovery/ConfirmRecoveryCodesGenerationTests.php index 6d34ab5..1da3f15 100644 --- a/packages/core/src/Testing/Partials/Settings/Recovery/ConfirmRecoveryCodesGenerationTests.php +++ b/packages/core/src/Testing/Partials/Settings/Recovery/ConfirmRecoveryCodesGenerationTests.php @@ -41,7 +41,7 @@ public function a_confirmation_code_is_required_to_save_the_newly_generated_reco $response = $this->actingAs($user)->post(route('auth.settings.generate_recovery.store')); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code field is required.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.required', ['attribute' => 'code'])]], $response->exception->errors()); $this->assertNull($user->fresh()->recovery_codes); Event::assertNothingDispatched(); } @@ -60,7 +60,7 @@ public function the_confirmation_code_must_be_a_string_when_confirming_the_newly ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code must be a string.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.string', ['attribute' => 'code'])]], $response->exception->errors()); $this->assertNull($user->fresh()->recovery_codes); Event::assertNothingDispatched(); } diff --git a/packages/core/src/Testing/Partials/Settings/Totp/ConfirmTotpCredentialRegistrationTests.php b/packages/core/src/Testing/Partials/Settings/Totp/ConfirmTotpCredentialRegistrationTests.php index 076e35e..1bfd1c1 100644 --- a/packages/core/src/Testing/Partials/Settings/Totp/ConfirmTotpCredentialRegistrationTests.php +++ b/packages/core/src/Testing/Partials/Settings/Totp/ConfirmTotpCredentialRegistrationTests.php @@ -48,7 +48,7 @@ public function the_confirmation_code_is_required_when_registering_a_time_based_ ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code field is required.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.required', ['attribute' => 'code'])]], $response->exception->errors()); $this->assertCount(0, MultiFactorCredential::all()); } @@ -65,7 +65,7 @@ public function the_confirmation_code_must_be_a_string_when_registering_a_time_b ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code must be a string.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.string', ['attribute' => 'code'])]], $response->exception->errors()); $this->assertCount(0, MultiFactorCredential::all()); } @@ -82,7 +82,7 @@ public function the_confirmation_code_must_be_six_characters_when_registering_a_ ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['code' => ['The code must be 6 characters.']], $response->exception->errors()); + $this->assertSame(['code' => [__('validation.size.string', ['attribute' => 'code', 'size' => 6])]], $response->exception->errors()); $this->assertCount(0, MultiFactorCredential::all()); } diff --git a/packages/core/src/Testing/Partials/SubmitAccountRecoveryRequestTests.php b/packages/core/src/Testing/Partials/SubmitAccountRecoveryRequestTests.php index 521b8f4..68fa820 100644 --- a/packages/core/src/Testing/Partials/SubmitAccountRecoveryRequestTests.php +++ b/packages/core/src/Testing/Partials/SubmitAccountRecoveryRequestTests.php @@ -64,7 +64,7 @@ public function it_validates_that_the_email_is_required_when_requesting_an_accou ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email field is required.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.required', ['attribute' => 'email'])]], $response->exception->errors()); $response->assertSessionMissing('status'); Notification::assertNothingSent(); } diff --git a/packages/core/src/Testing/Partials/SubmitPasskeyBasedAuthenticationTests.php b/packages/core/src/Testing/Partials/SubmitPasskeyBasedAuthenticationTests.php index 82a5b6c..13475d4 100644 --- a/packages/core/src/Testing/Partials/SubmitPasskeyBasedAuthenticationTests.php +++ b/packages/core/src/Testing/Partials/SubmitPasskeyBasedAuthenticationTests.php @@ -79,7 +79,7 @@ public function it_validates_that_the_credential_is_required_during_passkey_base ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['credential' => ['The credential field is required.']], $response->exception->errors()); + $this->assertSame(['credential' => [__('validation.required', ['attribute' => 'credential'])]], $response->exception->errors()); $this->assertTrue(Session::has('auth.login.passkey_authentication_options')); $this->assertGuest(); Event::assertNothingDispatched(); diff --git a/packages/core/src/Testing/Partials/SubmitPasskeyBasedRegistrationTests.php b/packages/core/src/Testing/Partials/SubmitPasskeyBasedRegistrationTests.php index c30777e..6945d75 100644 --- a/packages/core/src/Testing/Partials/SubmitPasskeyBasedRegistrationTests.php +++ b/packages/core/src/Testing/Partials/SubmitPasskeyBasedRegistrationTests.php @@ -90,7 +90,7 @@ public function it_validates_that_the_name_is_required_when_initializing_passkey $response->assertSessionMissing('auth.register.passkey_creation_options'); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['name' => ['The name field is required.']], $response->exception->errors()); + $this->assertSame(['name' => [__('validation.required', ['attribute' => 'name'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -101,7 +101,7 @@ public function it_validates_that_the_name_is_a_string_when_initializing_passkey $response->assertSessionMissing('auth.register.passkey_creation_options'); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['name' => ['The name must be a string.']], $response->exception->errors()); + $this->assertSame(['name' => [__('validation.string', ['attribute' => 'name'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -112,7 +112,7 @@ public function it_validates_that_the_name_does_not_exceed_255_characters_when_i $response->assertSessionMissing('auth.register.passkey_creation_options'); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['name' => ['The name must not be greater than 255 characters.']], $response->exception->errors()); + $this->assertSame(['name' => [__('validation.max.string', ['attribute' => 'name', 'max' => 255])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -143,7 +143,7 @@ public function it_validates_that_the_email_is_required_when_initializing_passke $response->assertSessionMissing('auth.register.passkey_creation_options'); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email field is required.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.required', ['attribute' => 'email'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -154,7 +154,7 @@ public function it_validates_that_the_email_does_not_exceed_255_characters_when_ $response->assertSessionMissing('auth.register.passkey_creation_options'); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email must not be greater than 255 characters.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.max.string', ['attribute' => 'email', 'max' => 255])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -164,7 +164,7 @@ public function it_validates_that_the_email_is_valid_when_initializing_passkey_b $response = $this->initializePasskeyBasedRegisterAttempt(['email' => 'foo']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email must be a valid email address.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.email', ['attribute' => 'email'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } diff --git a/packages/core/src/Testing/Partials/SubmitPasswordBasedAuthenticationTests.php b/packages/core/src/Testing/Partials/SubmitPasswordBasedAuthenticationTests.php index 4b7cd1f..5e00845 100644 --- a/packages/core/src/Testing/Partials/SubmitPasswordBasedAuthenticationTests.php +++ b/packages/core/src/Testing/Partials/SubmitPasswordBasedAuthenticationTests.php @@ -68,7 +68,7 @@ public function it_validates_that_the_password_is_required_during_password_based $response = $this->submitPasswordBasedLoginAttempt(['password' => '']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['password' => ['The password field is required.']], $response->exception->errors()); + $this->assertSame(['password' => [__('validation.required', ['attribute' => 'password'])]], $response->exception->errors()); $this->assertGuest(); } @@ -78,7 +78,7 @@ public function it_validates_that_the_password_is_a_string_during_password_based $response = $this->submitPasswordBasedLoginAttempt(['password' => 123]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['password' => ['The password must be a string.']], $response->exception->errors()); + $this->assertSame(['password' => [__('validation.string', ['attribute' => 'password'])]], $response->exception->errors()); $this->assertGuest(); } diff --git a/packages/core/src/Testing/Partials/SubmitPasswordBasedRegistrationTests.php b/packages/core/src/Testing/Partials/SubmitPasswordBasedRegistrationTests.php index f3d89f0..117b4d1 100644 --- a/packages/core/src/Testing/Partials/SubmitPasswordBasedRegistrationTests.php +++ b/packages/core/src/Testing/Partials/SubmitPasswordBasedRegistrationTests.php @@ -50,7 +50,7 @@ public function it_validates_that_the_name_is_required_during_password_based_reg $response = $this->submitPasswordBasedRegisterAttempt(['name' => '']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['name' => ['The name field is required.']], $response->exception->errors()); + $this->assertSame(['name' => [__('validation.required', ['attribute' => 'name'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -60,7 +60,7 @@ public function it_validates_that_the_name_is_a_string_during_password_based_reg $response = $this->submitPasswordBasedRegisterAttempt(['name' => 123]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['name' => ['The name must be a string.']], $response->exception->errors()); + $this->assertSame(['name' => [__('validation.string', ['attribute' => 'name'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -70,7 +70,7 @@ public function it_validates_that_the_name_does_not_exceed_255_characters_during $response = $this->submitPasswordBasedRegisterAttempt(['name' => str_repeat('a', 256)]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['name' => ['The name must not be greater than 255 characters.']], $response->exception->errors()); + $this->assertSame(['name' => [__('validation.max.string', ['attribute' => 'name', 'max' => 255])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -98,7 +98,7 @@ public function it_validates_that_the_email_is_required_during_password_based_re $response = $this->submitPasswordBasedRegisterAttempt(['email' => '']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email field is required.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.required', ['attribute' => 'email'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -108,7 +108,7 @@ public function it_validates_that_the_email_does_not_exceed_255_characters_durin $response = $this->submitPasswordBasedRegisterAttempt(['email' => str_repeat('a', 256).'@example.com']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email must not be greater than 255 characters.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.max.string', ['attribute' => 'email', 'max' => 255])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -118,7 +118,7 @@ public function it_validates_that_the_email_is_valid_during_password_based_regis $response = $this->submitPasswordBasedRegisterAttempt(['email' => 'foo']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['email' => ['The email must be a valid email address.']], $response->exception->errors()); + $this->assertSame(['email' => [__('validation.email', ['attribute' => 'email'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -139,7 +139,7 @@ public function it_validates_that_the_password_is_required_during_password_based $response = $this->submitPasswordBasedRegisterAttempt(['password' => '']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['password' => ['The password field is required.']], $response->exception->errors()); + $this->assertSame(['password' => [__('validation.required', ['attribute' => 'password'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -149,7 +149,7 @@ public function it_validates_that_the_password_confirmation_is_required_during_p $response = $this->submitPasswordBasedRegisterAttempt(['password_confirmation' => '']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['password' => ['The password confirmation does not match.']], $response->exception->errors()); + $this->assertSame(['password' => [__('validation.confirmed', ['attribute' => 'password'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -159,7 +159,7 @@ public function it_validates_that_the_password_is_confirmed_during_password_base $response = $this->submitPasswordBasedRegisterAttempt(['password_confirmation' => 'invalid-password-confirmation']); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['password' => ['The password confirmation does not match.']], $response->exception->errors()); + $this->assertSame(['password' => [__('validation.confirmed', ['attribute' => 'password'])]], $response->exception->errors()); $this->assertCount(0, User::all()); } @@ -172,7 +172,7 @@ public function it_validates_that_the_password_default_rules_are_applied_during_ ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['password' => ['The password must be at least 8 characters.']], $response->exception->errors()); + $this->assertSame(['password' => [__('validation.min.string', ['attribute' => 'password', 'min' => 8])]], $response->exception->errors()); $this->assertCount(0, User::all()); } diff --git a/packages/core/src/Testing/SubmitChangePasswordTests.php b/packages/core/src/Testing/SubmitChangePasswordTests.php index ae2f277..2db0f0b 100644 --- a/packages/core/src/Testing/SubmitChangePasswordTests.php +++ b/packages/core/src/Testing/SubmitChangePasswordTests.php @@ -44,7 +44,7 @@ public function it_validates_that_the_current_password_is_required_when_changing ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['current_password' => ['The current password field is required.']], $response->exception->errors()); + $this->assertSame(['current_password' => [__('validation.required', ['attribute' => 'current password'])]], $response->exception->errors()); $this->assertTrue(password_verify('password', $user->fresh()->password)); Event::assertNothingDispatched(); } @@ -65,7 +65,7 @@ public function it_validates_that_the_current_password_is_valid_when_changing_th ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['current_password' => ['The password is incorrect.']], $response->exception->errors()); + $this->assertSame(['current_password' => [__('validation.current_password')]], $response->exception->errors()); $this->assertTrue(password_verify('password', $user->fresh()->password)); Event::assertNothingDispatched(); } @@ -85,7 +85,7 @@ public function it_validates_that_the_new_password_is_required_when_changing_the ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['new_password' => ['The new password field is required.']], $response->exception->errors()); + $this->assertSame(['new_password' => [__('validation.required', ['attribute' => 'new password'])]], $response->exception->errors()); $this->assertTrue(password_verify('password', $user->fresh()->password)); Event::assertNothingDispatched(); } @@ -105,7 +105,7 @@ public function it_validates_that_the_password_confirmation_is_required_when_cha ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['new_password' => ['The new password confirmation does not match.']], $response->exception->errors()); + $this->assertSame(['new_password' => [__('validation.confirmed', ['attribute' => 'new password'])]], $response->exception->errors()); $this->assertTrue(password_verify('password', $user->fresh()->password)); Event::assertNothingDispatched(); } @@ -126,7 +126,7 @@ public function it_validates_that_the_password_is_confirmed_when_changing_the_us ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['new_password' => ['The new password confirmation does not match.']], $response->exception->errors()); + $this->assertSame(['new_password' => [__('validation.confirmed', ['attribute' => 'new password'])]], $response->exception->errors()); $this->assertTrue(password_verify('password', $user->fresh()->password)); Event::assertNothingDispatched(); } @@ -147,7 +147,7 @@ public function it_validates_that_the_password_default_rules_are_applied_when_ch ]); $this->assertInstanceOf(ValidationException::class, $response->exception); - $this->assertSame(['new_password' => ['The new password must be at least 8 characters.']], $response->exception->errors()); + $this->assertSame(['new_password' => [__('validation.min.string', ['attribute' => 'new password', 'min' => 8])]], $response->exception->errors()); $this->assertTrue(password_verify('password', $user->fresh()->password)); Event::assertNothingDispatched(); }