mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-28 09:34:36 +08:00
Open root registration for ten minutes after startup, then require a Coolify restart to reopen it. Update installer credential handling and explain the setup window in the registration UI.
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Actions\Fortify\CreateNewUser;
|
|
use App\Models\InstanceSettings;
|
|
use App\Models\OauthSetting;
|
|
use App\Support\RootSetupWindow;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Once;
|
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
RootSetupWindow::openIfNoUserExists();
|
|
|
|
InstanceSettings::forceCreate([
|
|
'id' => 0,
|
|
'is_registration_enabled' => true,
|
|
'disable_registration_when_oauth_enabled' => true,
|
|
]);
|
|
Once::flush();
|
|
});
|
|
|
|
it('blocks password registration when oauth registration policy disables it', function () {
|
|
OauthSetting::create([
|
|
'provider' => 'oidc',
|
|
'enabled' => true,
|
|
'client_id' => 'client-id',
|
|
'client_secret' => 'secret',
|
|
'base_url' => 'https://idp.example.com',
|
|
]);
|
|
|
|
app(CreateNewUser::class)->create([
|
|
'name' => 'Password User',
|
|
'email' => 'password@example.com',
|
|
'password' => 'password',
|
|
'password_confirmation' => 'password',
|
|
]);
|
|
})->throws(HttpException::class);
|
|
|
|
it('allows password registration when no oauth provider is enabled', function () {
|
|
OauthSetting::create([
|
|
'provider' => 'oidc',
|
|
'enabled' => false,
|
|
]);
|
|
|
|
$user = app(CreateNewUser::class)->create([
|
|
'name' => 'Password User',
|
|
'email' => 'password@example.com',
|
|
'password' => 'password',
|
|
'password_confirmation' => 'password',
|
|
]);
|
|
|
|
expect($user->email)->toBe('password@example.com')
|
|
->and($user->email_verified_at)->toBeNull();
|
|
});
|