fix: keep Google OAuth routes always registered and add tests
Routes must always exist so Wayfinder can generate TypeScript helpers. The toggle now only controls frontend visibility via Inertia prop.
This commit is contained in:
parent
d94374c31a
commit
557507672e
2 changed files with 73 additions and 4 deletions
|
|
@ -29,10 +29,8 @@
|
|||
Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])->name('password.reset');
|
||||
Route::post('/reset-password', [NewPasswordController::class, 'store'])->name('password.store');
|
||||
|
||||
if (config('trypost.google_auth_enabled')) {
|
||||
Route::get('/auth/google/redirect', [SocialLoginController::class, 'redirect'])->name('auth.google.redirect');
|
||||
Route::get('/auth/google/callback', [SocialLoginController::class, 'callback'])->name('auth.google.callback');
|
||||
}
|
||||
Route::get('/auth/google/redirect', [SocialLoginController::class, 'redirect'])->name('auth.google.redirect');
|
||||
Route::get('/auth/google/callback', [SocialLoginController::class, 'callback'])->name('auth.google.callback');
|
||||
});
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
|
|
|
|||
71
tests/Feature/GoogleAuthToggleTest.php
Normal file
71
tests/Feature/GoogleAuthToggleTest.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('login page loads when google auth is disabled', function () {
|
||||
config(['trypost.google_auth_enabled' => false]);
|
||||
|
||||
$response = $this->get(route('login'));
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('login page loads when google auth is enabled', function () {
|
||||
config(['trypost.google_auth_enabled' => true]);
|
||||
|
||||
$response = $this->get(route('login'));
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('register page loads when google auth is disabled', function () {
|
||||
config(['trypost.google_auth_enabled' => false]);
|
||||
|
||||
$response = $this->get(route('register'));
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('register page loads when google auth is enabled', function () {
|
||||
config(['trypost.google_auth_enabled' => true]);
|
||||
|
||||
$response = $this->get(route('register'));
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('login page shares google auth enabled prop as false when disabled', function () {
|
||||
config(['trypost.google_auth_enabled' => false]);
|
||||
|
||||
$response = $this->get(route('login'));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$page = $response->original->getData()['page'];
|
||||
expect($page['props']['googleAuthEnabled'])->toBeFalse();
|
||||
});
|
||||
|
||||
test('login page shares google auth enabled prop as true when enabled', function () {
|
||||
config(['trypost.google_auth_enabled' => true]);
|
||||
|
||||
$response = $this->get(route('login'));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$page = $response->original->getData()['page'];
|
||||
expect($page['props']['googleAuthEnabled'])->toBeTrue();
|
||||
});
|
||||
|
||||
test('google auth redirect route exists', function () {
|
||||
$response = $this->get(route('auth.google.redirect'));
|
||||
|
||||
// Should redirect to Google OAuth, not 404
|
||||
$response->assertRedirect();
|
||||
});
|
||||
|
||||
test('google auth callback route exists', function () {
|
||||
$response = $this->get(route('auth.google.callback'));
|
||||
|
||||
// Should redirect to login on failure (no OAuth code), not 404
|
||||
$response->assertRedirect(route('login'));
|
||||
});
|
||||
Loading…
Reference in a new issue