-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1176 from kenjis/add-group-validation-to-user-com…
…mand fix: add missing validation for group name to `shield:user addgroup`/`removegroup`
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -595,6 +595,24 @@ public function testAddgroup(): void | |
$this->assertTrue($user->inGroup('admin')); | ||
} | ||
|
||
public function testAddgroupWithInvalidGroup(): void | ||
{ | ||
$this->createUser([ | ||
'username' => 'user10', | ||
'email' => '[email protected]', | ||
'password' => 'secret123', | ||
]); | ||
|
||
$this->setMockIo(['y']); | ||
|
||
command('shield:user addgroup -n user10 -g invalid'); | ||
|
||
$this->assertStringContainsString( | ||
'Invalid group: "invalid"', | ||
$this->io->getLastOutput() | ||
); | ||
} | ||
|
||
public function testAddgroupCancel(): void | ||
{ | ||
$this->createUser([ | ||
|
@@ -643,6 +661,32 @@ public function testRemovegroup(): void | |
$this->assertFalse($user->inGroup('admin')); | ||
} | ||
|
||
public function testRemovegroupWithInvalidGroup(): void | ||
{ | ||
$this->createUser([ | ||
'username' => 'user11', | ||
'email' => '[email protected]', | ||
'password' => 'secret123', | ||
]); | ||
$users = model(UserModel::class); | ||
$user = $users->findByCredentials(['email' => '[email protected]']); | ||
$user->addGroup('admin'); | ||
$this->assertTrue($user->inGroup('admin')); | ||
|
||
$this->setMockIo(['y']); | ||
|
||
command('shield:user removegroup -n user11 -g invalid'); | ||
|
||
$this->assertStringContainsString( | ||
'Invalid group: "invalid"', | ||
$this->io->getLastOutput() | ||
); | ||
|
||
$users = model(UserModel::class); | ||
$user = $users->findByCredentials(['email' => '[email protected]']); | ||
$this->assertTrue($user->inGroup('admin')); | ||
} | ||
|
||
public function testRemovegroupCancel(): void | ||
{ | ||
$this->createUser([ | ||
|