Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/AuthTest.php
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertEquals($user->id, $json['id']); | $this->assertEquals($user->id, $json['id']); | ||||
$this->assertEquals($user->email, $json['email']); | $this->assertEquals($user->email, $json['email']); | ||||
$this->assertEquals(User::STATUS_NEW | User::STATUS_ACTIVE, $json['status']); | $this->assertEquals(User::STATUS_NEW | User::STATUS_ACTIVE, $json['status']); | ||||
$this->assertTrue(is_array($json['statusInfo'])); | $this->assertTrue(is_array($json['statusInfo'])); | ||||
$this->assertTrue(is_array($json['settings'])); | $this->assertTrue(is_array($json['settings'])); | ||||
$this->assertTrue(is_array($json['aliases'])); | $this->assertTrue(is_array($json['aliases'])); | ||||
$this->assertTrue(!isset($json['access_token'])); | |||||
// Note: Details of the content are tested in testUserResponse() | // Note: Details of the content are tested in testUserResponse() | ||||
// Test token refresh via the info request | |||||
// First we log in as we need the token (actingAs() will not work) | |||||
$post = ['email' => 'john@kolab.org', 'password' => 'simple123']; | |||||
$response = $this->post("api/auth/login", $post); | |||||
$json = $response->json(); | |||||
$response = $this->withHeaders(['Authorization' => 'Bearer ' . $json['access_token']]) | |||||
->get("api/auth/info?refresh_token=1"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertEquals('john@kolab.org', $json['email']); | |||||
$this->assertTrue(is_array($json['statusInfo'])); | |||||
$this->assertTrue(is_array($json['settings'])); | |||||
$this->assertTrue(is_array($json['aliases'])); | |||||
$this->assertTrue(!empty($json['access_token'])); | |||||
$this->assertTrue(!empty($json['expires_in'])); | |||||
} | } | ||||
/** | /** | ||||
* Test /api/auth/login | * Test /api/auth/login | ||||
*/ | */ | ||||
public function testLogin(): string | public function testLogin(): string | ||||
{ | { | ||||
// Request with no data | // Request with no data | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |