mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
wip
This commit is contained in:
@@ -186,9 +186,9 @@ class Client
|
||||
$host = $this->configuration->host();
|
||||
|
||||
$this->logger->info($data->message);
|
||||
$this->logger->info("Local-Port:\t\t{$port}");
|
||||
$this->logger->info("Shared-Port:\t\t{$data->shared_port}");
|
||||
$this->logger->info("Expose-URL:\t\ttcp://{$host}:{$data->shared_port}.");
|
||||
$this->logger->info("Local-Port:\t\t<options=bold>{$port}</>");
|
||||
$this->logger->info("Shared-Port:\t\t<options=bold>{$data->shared_port}</>");
|
||||
$this->logger->info("Expose-URL:\t\t<options=bold>tcp://{$host}:{$data->shared_port}</>");
|
||||
$this->logger->line('');
|
||||
|
||||
$deferred->resolve($data);
|
||||
|
||||
@@ -145,19 +145,25 @@ class Factory
|
||||
$this->router->get('/api/statistics', GetStatisticsController::class, $adminCondition);
|
||||
$this->router->get('/api/settings', GetSettingsController::class, $adminCondition);
|
||||
$this->router->post('/api/settings', StoreSettingsController::class, $adminCondition);
|
||||
|
||||
$this->router->get('/api/users', GetUsersController::class, $adminCondition);
|
||||
$this->router->post('/api/users', StoreUsersController::class, $adminCondition);
|
||||
$this->router->get('/api/users/{id}', GetUserDetailsController::class, $adminCondition);
|
||||
$this->router->delete('/api/users/{id}', DeleteUsersController::class, $adminCondition);
|
||||
|
||||
$this->router->get('/api/logs', GetLogsController::class, $adminCondition);
|
||||
$this->router->get('/api/logs/{subdomain}', GetLogsForSubdomainController::class, $adminCondition);
|
||||
|
||||
$this->router->post('/api/domains', StoreDomainController::class, $adminCondition);
|
||||
$this->router->delete('/api/domains/{domain}', DeleteSubdomainController::class, $adminCondition);
|
||||
|
||||
$this->router->post('/api/subdomains', StoreSubdomainController::class, $adminCondition);
|
||||
$this->router->delete('/api/subdomains/{subdomain}', DeleteSubdomainController::class, $adminCondition);
|
||||
$this->router->delete('/api/users/{id}', DeleteUsersController::class, $adminCondition);
|
||||
|
||||
$this->router->get('/api/sites', GetSitesController::class, $adminCondition);
|
||||
$this->router->get('/api/sites/{site}', GetSiteDetailsController::class, $adminCondition);
|
||||
$this->router->delete('/api/sites/{id}', DisconnectSiteController::class, $adminCondition);
|
||||
|
||||
$this->router->get('/api/tcp', GetTcpConnectionsController::class, $adminCondition);
|
||||
$this->router->delete('/api/tcp/{id}', DisconnectTcpConnectionController::class, $adminCondition);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,54 @@ class ApiTest extends TestCase
|
||||
$this->assertSame([], $users[0]->sites);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_update_registered_users()
|
||||
{
|
||||
/** @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',
|
||||
'can_specify_subdomains' => true,
|
||||
])));
|
||||
|
||||
/** @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',
|
||||
]));
|
||||
$user = json_decode($response->getBody()->getContents())->paginated->users[0];
|
||||
|
||||
$this->assertSame('Marcel', $user->name);
|
||||
$this->assertSame(1, $user->can_specify_subdomains);
|
||||
|
||||
|
||||
$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([
|
||||
'token' => $user->auth_token,
|
||||
'name' => 'Julia',
|
||||
'can_specify_subdomains' => false,
|
||||
])));
|
||||
|
||||
$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',
|
||||
]));
|
||||
$users = json_decode($response->getBody()->getContents())->paginated;
|
||||
$user = $users->users[0];
|
||||
|
||||
$this->assertCount(1, $users->users);
|
||||
$this->assertSame('Julia', $user->name);
|
||||
$this->assertSame(0, $user->can_specify_subdomains);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_specify_a_token_when_creating_a_user()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user