Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/Commands/LoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LoginCommand extends Command
*
* @var string
*/
protected $signature = 'login';
protected $signature = 'login {--token= : Forge API token}';

/**
* The description of the command.
Expand All @@ -27,7 +27,11 @@ class LoginCommand extends Command
*/
public function handle()
{
$token = $this->askStep('Please enter your Forge API token');
$token = $this->option('token');

if ($token === null) {
$token = $this->askStep('Please enter your Forge API token');
}

$this->config->set('token', $token);

Expand Down
13 changes: 13 additions & 0 deletions tests/Feature/LoginCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
->expectsOutput('==> Authenticated Successfully As [nuno@laravel.com]');
});

it('authenticates users with token', function () {
$this->client->shouldReceive('user')->andReturn((object) [
'email' => 'nuno@laravel.com',
]);

$this->client->shouldReceive('servers')->andReturn([
(object) ['id' => 1],
]);

$this->artisan('login --token 123123123')
->expectsOutput('==> Authenticated Successfully As [nuno@laravel.com]');
});

it('sets current server', function () {
$this->client->shouldReceive('user')->andReturn((object) [
'email' => 'nuno@laravel.com',
Expand Down