mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-22 00:03:09 +01:00
Update passport:install invocation to prevent unwanted confirmations
This commit is contained in:
parent
dd44b49c4e
commit
b8b4d22efb
2
app.json
2
app.json
@ -15,7 +15,7 @@
|
|||||||
"repository": "https://github.com/Bubka/2FAuth",
|
"repository": "https://github.com/Bubka/2FAuth",
|
||||||
"success_url": "/register",
|
"success_url": "/register",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postdeploy": "php artisan passport:install;php artisan storage:link"
|
"postdeploy": "php artisan passport:install --no-interaction;php artisan storage:link"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"APP_KEY": {
|
"APP_KEY": {
|
||||||
|
@ -142,7 +142,7 @@ public function handle()
|
|||||||
protected function installPassport() : void
|
protected function installPassport() : void
|
||||||
{
|
{
|
||||||
$this->components->task('Setting up Passport', function () : void {
|
$this->components->task('Setting up Passport', function () : void {
|
||||||
$this->callSilently('passport:install');
|
$this->callSilently('passport:install', ['--no-interaction' => true]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ protected function seedDB(string $seeder) : void
|
|||||||
{
|
{
|
||||||
$this->callSilent('db:seed', [
|
$this->callSilent('db:seed', [
|
||||||
'--class' => $seeder,
|
'--class' => $seeder,
|
||||||
|
'--no-interaction' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->line('Database seeded');
|
$this->line('Database seeded');
|
||||||
|
2
docker/entrypoint.sh
vendored
2
docker/entrypoint.sh
vendored
@ -55,7 +55,7 @@ if [ -f /2fauth/installed ]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
php artisan migrate:refresh --force
|
php artisan migrate:refresh --force
|
||||||
php artisan passport:install
|
php artisan passport:install --no-interaction
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${COMMIT}" > /2fauth/installed
|
echo "${COMMIT}" > /2fauth/installed
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
@ -325,6 +326,11 @@ public function test_store_returns_UserManagerResource_of_created_admin() : void
|
|||||||
*/
|
*/
|
||||||
public function test_revokePATs_flushes_pats()
|
public function test_revokePATs_flushes_pats()
|
||||||
{
|
{
|
||||||
|
Artisan::call('passport:install', [
|
||||||
|
'--verbose' => 2,
|
||||||
|
'--no-interaction' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
$tokenRepository = app(TokenRepository::class);
|
$tokenRepository = app(TokenRepository::class);
|
||||||
|
|
||||||
$this->actingAs($this->user, 'api-guard')
|
$this->actingAs($this->user, 'api-guard')
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Tests\Feature\Console;
|
namespace Tests\Feature\Console;
|
||||||
|
|
||||||
use App\Console\Commands\Install;
|
use App\Console\Commands\Install;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Jackiedo\DotenvEditor\DotenvEditor;
|
use Jackiedo\DotenvEditor\DotenvEditor;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
@ -16,10 +17,21 @@ class InstallTest extends FeatureTestCase
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
|
const PASSPORT_PENDING_MIGRATIONS_CONFIRMATION = 'Would you like to run all pending database migrations?';
|
||||||
|
|
||||||
|
const PASSPORT_CREATE_CLIENTS_CONFIRMATION = 'Would you like to create the "personal access" and "password grant" clients?';
|
||||||
|
|
||||||
|
const TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION = 'Existing .env file found. Do you wish to review its vars?';
|
||||||
|
|
||||||
public function test_install_completes()
|
public function test_install_completes()
|
||||||
{
|
{
|
||||||
$this->artisan('2fauth:install')
|
$this->artisan('2fauth:install')
|
||||||
->expectsConfirmation('Existing .env file found. Do you wish to review its vars?', 'no')
|
->expectsConfirmation(self::TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION, 'no')
|
||||||
|
// 2 following confirmations have been introduced with Passport v12 and its auto-publishing
|
||||||
|
// migrations feature. Even if the '2fauth:install' command runs 'passport:install'
|
||||||
|
// silently, the 2 confirmations are triggered and needs to be handled in tests.
|
||||||
|
->expectsConfirmation(self::PASSPORT_PENDING_MIGRATIONS_CONFIRMATION, 'yes')
|
||||||
|
->expectsConfirmation(self::PASSPORT_CREATE_CLIENTS_CONFIRMATION, 'yes')
|
||||||
->assertSuccessful();
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +42,9 @@ public function test_install_informs_about_no_interaction()
|
|||||||
{
|
{
|
||||||
$this->artisan('2fauth:install', ['--no-interaction' => true])
|
$this->artisan('2fauth:install', ['--no-interaction' => true])
|
||||||
->expectsOutput('(Running in no-interaction mode)')
|
->expectsOutput('(Running in no-interaction mode)')
|
||||||
->expectsConfirmation('Existing .env file found. Do you wish to review its vars?', 'no')
|
->expectsConfirmation(self::TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION, 'no')
|
||||||
|
->expectsConfirmation(self::PASSPORT_PENDING_MIGRATIONS_CONFIRMATION, 'yes')
|
||||||
|
->expectsConfirmation(self::PASSPORT_CREATE_CLIENTS_CONFIRMATION, 'yes')
|
||||||
->assertSuccessful();
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +58,9 @@ public function test_install_generates_an_app_key()
|
|||||||
$this->assertEquals('', config('app.key'));
|
$this->assertEquals('', config('app.key'));
|
||||||
|
|
||||||
$this->artisan('2fauth:install')
|
$this->artisan('2fauth:install')
|
||||||
->expectsConfirmation('Existing .env file found. Do you wish to review its vars?', 'no')
|
->expectsConfirmation(self::TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION, 'no')
|
||||||
|
->expectsConfirmation(self::PASSPORT_PENDING_MIGRATIONS_CONFIRMATION, 'yes')
|
||||||
|
->expectsConfirmation(self::PASSPORT_CREATE_CLIENTS_CONFIRMATION, 'yes')
|
||||||
->assertSuccessful();
|
->assertSuccessful();
|
||||||
|
|
||||||
$this->assertNotEquals('', config('app.key'));
|
$this->assertNotEquals('', config('app.key'));
|
||||||
@ -56,7 +72,9 @@ public function test_install_generates_an_app_key()
|
|||||||
public function test_install_gives_2fauth_address()
|
public function test_install_gives_2fauth_address()
|
||||||
{
|
{
|
||||||
$this->artisan('2fauth:install')
|
$this->artisan('2fauth:install')
|
||||||
->expectsConfirmation('Existing .env file found. Do you wish to review its vars?', 'no')
|
->expectsConfirmation(self::TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION, 'no')
|
||||||
|
->expectsConfirmation(self::PASSPORT_PENDING_MIGRATIONS_CONFIRMATION, 'yes')
|
||||||
|
->expectsConfirmation(self::PASSPORT_CREATE_CLIENTS_CONFIRMATION, 'yes')
|
||||||
->expectsOutputToContain(config('app.url'))
|
->expectsOutputToContain(config('app.url'))
|
||||||
->assertSuccessful();
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
@ -67,7 +85,9 @@ public function test_install_gives_2fauth_address()
|
|||||||
public function test_install_informs_about_sponsoring()
|
public function test_install_informs_about_sponsoring()
|
||||||
{
|
{
|
||||||
$this->artisan('2fauth:install')
|
$this->artisan('2fauth:install')
|
||||||
->expectsConfirmation('Existing .env file found. Do you wish to review its vars?', 'no')
|
->expectsConfirmation(self::TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION, 'no')
|
||||||
|
->expectsConfirmation(self::PASSPORT_PENDING_MIGRATIONS_CONFIRMATION, 'yes')
|
||||||
|
->expectsConfirmation(self::PASSPORT_CREATE_CLIENTS_CONFIRMATION, 'yes')
|
||||||
->expectsOutputToContain('https://ko-fi.com/bubka')
|
->expectsOutputToContain('https://ko-fi.com/bubka')
|
||||||
->expectsOutputToContain('https://github.com/sponsors/Bubka')
|
->expectsOutputToContain('https://github.com/sponsors/Bubka')
|
||||||
->assertSuccessful();
|
->assertSuccessful();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Console;
|
namespace Tests\Feature\Console;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
|
|
||||||
@ -22,6 +23,11 @@ public function test_reset_demo_without_demo_mode_succeeded()
|
|||||||
*/
|
*/
|
||||||
public function test_reset_demo_succeeded()
|
public function test_reset_demo_succeeded()
|
||||||
{
|
{
|
||||||
|
Artisan::call('passport:install', [
|
||||||
|
'--verbose' => 2,
|
||||||
|
'--no-interaction' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
Config::set('2fauth.config.isDemoApp', true);
|
Config::set('2fauth.config.isDemoApp', true);
|
||||||
|
|
||||||
$this->artisan('2fauth:reset-demo')
|
$this->artisan('2fauth:reset-demo')
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
use App\Models\TwoFAccount;
|
use App\Models\TwoFAccount;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Auth\Events\PasswordReset;
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\Facades\Password;
|
use Illuminate\Support\Facades\Password;
|
||||||
@ -116,6 +117,11 @@ public function test_resetPassword_dispatch_event()
|
|||||||
*/
|
*/
|
||||||
public function test_delete_removes_user_data()
|
public function test_delete_removes_user_data()
|
||||||
{
|
{
|
||||||
|
Artisan::call('passport:install', [
|
||||||
|
'--verbose' => 2,
|
||||||
|
'--no-interaction' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
TwoFAccount::factory()->for($user)->create();
|
TwoFAccount::factory()->for($user)->create();
|
||||||
AuthLog::factory()->for($user, 'authenticatable')->create();
|
AuthLog::factory()->for($user, 'authenticatable')->create();
|
||||||
|
@ -22,6 +22,6 @@ abstract class FeatureTestCase extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
protected function afterRefreshingDatabase()
|
protected function afterRefreshingDatabase()
|
||||||
{
|
{
|
||||||
Artisan::call('passport:install', ['--verbose' => 2]);
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user