mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Add ability to specify auth tokens when creating new users
This commit is contained in:
@@ -37,7 +37,7 @@ class StoreUsersController extends AdminController
|
||||
|
||||
$insertData = [
|
||||
'name' => $request->get('name'),
|
||||
'auth_token' => (string) Str::uuid(),
|
||||
'auth_token' => $request->get('token', (string) Str::uuid()),
|
||||
'can_specify_subdomains' => (int) $request->get('can_specify_subdomains'),
|
||||
'can_specify_domains' => (int) $request->get('can_specify_domains'),
|
||||
'can_share_tcp_ports' => (int) $request->get('can_share_tcp_ports'),
|
||||
|
||||
@@ -65,6 +65,34 @@ class ApiTest extends TestCase
|
||||
$this->assertSame([], $users[0]->sites);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_specify_tokens_when_creating_a_user()
|
||||
{
|
||||
/** @var Response $response */
|
||||
$this->await($this->browser->post('http://127.0.0.1:8080/api/users', [
|
||||
'Host' => 'expose.localhost',
|
||||
'Authorization' => base64_encode('username:secret'),
|
||||
'Content-Type' => 'application/json',
|
||||
], json_encode([
|
||||
'name' => 'Marcel',
|
||||
'token' => 'this-is-my-token'
|
||||
])));
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $this->await($this->browser->get('http://127.0.0.1:8080/api/users', [
|
||||
'Host' => 'expose.localhost',
|
||||
'Authorization' => base64_encode('username:secret'),
|
||||
'Content-Type' => 'application/json',
|
||||
]));
|
||||
|
||||
$body = json_decode($response->getBody()->getContents());
|
||||
$users = $body->paginated->users;
|
||||
|
||||
$this->assertCount(1, $users);
|
||||
$this->assertSame('Marcel', $users[0]->name);
|
||||
$this->assertSame('this-is-my-token', $users[0]->auth_token);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_allow_domain_reservation_for_users_without_the_right_flag()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user