Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

fix: keep Google OAuth routes always registered and add tests

Paulo Castellano557507672e26
diff --git a/routes/auth.php b/routes/auth.php
index cd3deaaba..798ec5e85 100644
--- a/routes/auth.php
+++ b/routes/auth.php
@@ -29,10 +29,8 @@ Route::middleware(['guest'])->group(function () {
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 () {
diff --git a/tests/Feature/GoogleAuthToggleTest.php b/tests/Feature/GoogleAuthToggleTest.php
new file mode 100644
index 000000000..bb01975e7
--- /dev/null
+++ b/tests/Feature/GoogleAuthToggleTest.php
@@ -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'));
+});