Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/AuthTest.php
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | public function testLogin(): string | ||||
$response = $this->post("api/auth/login", $post); | $response = $this->post("api/auth/login", $post); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertTrue(!empty($json['access_token'])); | $this->assertTrue(!empty($json['access_token'])); | ||||
$this->assertEquals(\config('jwt.ttl') * 60, $json['expires_in']); | $this->assertEquals(\config('jwt.ttl') * 60, $json['expires_in']); | ||||
$this->assertEquals('bearer', $json['token_type']); | $this->assertEquals('bearer', $json['token_type']); | ||||
// Valid user+password (upper-case) | |||||
$post = ['email' => 'John@Kolab.org', 'password' => 'simple123']; | |||||
$response = $this->post("api/auth/login", $post); | |||||
$json = $response->json(); | |||||
$response->assertStatus(200); | |||||
$this->assertTrue(!empty($json['access_token'])); | |||||
$this->assertEquals(\config('jwt.ttl') * 60, $json['expires_in']); | |||||
$this->assertEquals('bearer', $json['token_type']); | |||||
// TODO: We have browser tests for 2FA but we should probably also test it here | // TODO: We have browser tests for 2FA but we should probably also test it here | ||||
return $json['access_token']; | return $json['access_token']; | ||||
} | } | ||||
/** | /** | ||||
* Test /api/auth/logout | * Test /api/auth/logout | ||||
* | * | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |