forceCreate([ 'email' => new Email('verify-callback@example.com'), 'hashcode' => (string) Str::uuid(), ]); $notification = new VerifyEmail(); // WHEN $mail = $notification->toMail($customer); Assert::isInstanceOf($mail, MailMessage::class); /** @var string $actionUrl */ $actionUrl = $mail->actionUrl; $relativeUrl = (string) parse_url($actionUrl, \PHP_URL_PATH) . '?' . (string) parse_url($actionUrl, \PHP_URL_QUERY); $request = Request::create($relativeUrl, 'GET'); // THEN $expectedHash = hash_hmac('sha256', 'verify-callback@example.com', Config::string('app.key')); expect($actionUrl)->toContain('/auth/email/verify/' . $customer->id . '/' . $expectedHash) ->and(URL::hasValidSignature($request, absolute: false))->toBeTrue(); }); it('registers ResetPassword URL callback during boot without instantiating AuthController', function (): void { // GIVEN /** @var Customer $customer */ $customer = Customer::query()->forceCreate([ 'email' => new Email('reset-callback@example.com'), 'hashcode' => (string) Str::uuid(), ]); $notification = new ResetPassword('secret-reset-token'); // WHEN $mail = $notification->toMail($customer); Assert::isInstanceOf($mail, MailMessage::class); /** @var string $actionUrl */ $actionUrl = $mail->actionUrl; $relativeUrl = (string) parse_url($actionUrl, \PHP_URL_PATH) . '?' . (string) parse_url($actionUrl, \PHP_URL_QUERY); $request = Request::create($relativeUrl, 'GET'); // THEN expect($actionUrl)->toContain('/auth/reinitialiser-mdp/secret-reset-token') ->and($actionUrl)->toContain('email=reset-callback%40example.com') ->and(URL::hasValidSignature($request, absolute: false))->toBeTrue(); }); });