mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-05-29 06:27:33 +02:00
Update php tests
This commit is contained in:
parent
4685e23fdb
commit
eaaefc1f1b
@ -43,11 +43,14 @@ class UserControllerTest extends FeatureTestCase
|
|||||||
$response = $this->actingAs($this->user, 'api-guard')
|
$response = $this->actingAs($this->user, 'api-guard')
|
||||||
->json('GET', '/api/v1/user')
|
->json('GET', '/api/v1/user')
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertExactJson([
|
->assertJsonFragment([
|
||||||
'name' => $this->user->name,
|
'name' => $this->user->name,
|
||||||
'id' => $this->user->id,
|
'id' => $this->user->id,
|
||||||
'email' => $this->user->email,
|
'email' => $this->user->email,
|
||||||
'is_admin' => $this->user->is_admin,
|
'is_admin' => $this->user->is_admin,
|
||||||
|
])
|
||||||
|
->assertJsonStructure([
|
||||||
|
'preferences',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class IconControllerTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$response = $this->actingAs($this->user, 'api-guard')
|
$response = $this->actingAs($this->user, 'api-guard')
|
||||||
->json('POST', '/api/v1/icons/default', [
|
->json('POST', '/api/v1/icons/default', [
|
||||||
'service' => 'abode',
|
'service' => 'dropbox',
|
||||||
])
|
])
|
||||||
->assertStatus(201)
|
->assertStatus(201)
|
||||||
->assertJsonStructure([
|
->assertJsonStructure([
|
||||||
|
@ -91,7 +91,7 @@ class LoginTest extends FeatureTestCase
|
|||||||
*
|
*
|
||||||
* @covers \App\Http\Middleware\SkipIfAuthenticated
|
* @covers \App\Http\Middleware\SkipIfAuthenticated
|
||||||
*/
|
*/
|
||||||
public function test_user_login_already_authenticated_returns_success()
|
public function test_user_login_already_authenticated_is_rejected()
|
||||||
{
|
{
|
||||||
$response = $this->json('POST', '/user/login', [
|
$response = $this->json('POST', '/user/login', [
|
||||||
'email' => $this->user->email,
|
'email' => $this->user->email,
|
||||||
@ -103,10 +103,9 @@ class LoginTest extends FeatureTestCase
|
|||||||
'email' => $this->user->email,
|
'email' => $this->user->email,
|
||||||
'password' => self::PASSWORD,
|
'password' => self::PASSWORD,
|
||||||
])
|
])
|
||||||
->assertStatus(200)
|
->assertStatus(400)
|
||||||
->assertJson([
|
->assertJsonStructure([
|
||||||
'message' => 'authenticated',
|
'message',
|
||||||
'name' => $this->user->name,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +53,14 @@ class UserControllerTest extends FeatureTestCase
|
|||||||
'password' => self::PASSWORD,
|
'password' => self::PASSWORD,
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertExactJson([
|
->assertJsonFragment([
|
||||||
'name' => self::NEW_USERNAME,
|
'name' => self::NEW_USERNAME,
|
||||||
'id' => $this->user->id,
|
'id' => $this->user->id,
|
||||||
'email' => self::NEW_EMAIL,
|
'email' => self::NEW_EMAIL,
|
||||||
'is_admin' => false,
|
'is_admin' => false,
|
||||||
|
])
|
||||||
|
->assertJsonStructure([
|
||||||
|
'preferences',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertDatabaseHas('users', [
|
$this->assertDatabaseHas('users', [
|
||||||
@ -80,7 +83,7 @@ class UserControllerTest extends FeatureTestCase
|
|||||||
'password' => self::PASSWORD,
|
'password' => self::PASSWORD,
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertExactJson([
|
->assertJsonFragment([
|
||||||
'name' => self::NEW_USERNAME,
|
'name' => self::NEW_USERNAME,
|
||||||
'id' => $this->user->id,
|
'id' => $this->user->id,
|
||||||
'email' => $this->user->email,
|
'email' => $this->user->email,
|
||||||
@ -107,7 +110,7 @@ class UserControllerTest extends FeatureTestCase
|
|||||||
'password' => self::PASSWORD,
|
'password' => self::PASSWORD,
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertExactJson([
|
->assertJsonFragment([
|
||||||
'name' => $this->user->name,
|
'name' => $this->user->name,
|
||||||
'id' => $this->user->id,
|
'id' => $this->user->id,
|
||||||
'email' => self::NEW_EMAIL,
|
'email' => self::NEW_EMAIL,
|
||||||
@ -134,7 +137,7 @@ class UserControllerTest extends FeatureTestCase
|
|||||||
'password' => self::PASSWORD,
|
'password' => self::PASSWORD,
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertExactJson([
|
->assertJsonFragment([
|
||||||
'name' => self::NEW_USERNAME,
|
'name' => self::NEW_USERNAME,
|
||||||
'id' => $this->user->id,
|
'id' => $this->user->id,
|
||||||
'email' => self::NEW_EMAIL,
|
'email' => self::NEW_EMAIL,
|
||||||
@ -166,7 +169,7 @@ class UserControllerTest extends FeatureTestCase
|
|||||||
'password' => self::PASSWORD,
|
'password' => self::PASSWORD,
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertExactJson([
|
->assertJsonFragment([
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'id' => $this->user->id,
|
'id' => $this->user->id,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
|
@ -205,7 +205,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
|
|||||||
*
|
*
|
||||||
* @covers \App\Http\Middleware\SkipIfAuthenticated
|
* @covers \App\Http\Middleware\SkipIfAuthenticated
|
||||||
*/
|
*/
|
||||||
public function test_webauthn_login_already_authenticated_returns_success()
|
public function test_webauthn_login_already_authenticated_is_rejected()
|
||||||
{
|
{
|
||||||
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
$this->user = User::factory()->create(['email' => self::EMAIL]);
|
||||||
|
|
||||||
@ -238,15 +238,9 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
|
|||||||
->assertOk();
|
->assertOk();
|
||||||
|
|
||||||
$this->json('POST', '/webauthn/login', self::ASSERTION_RESPONSE)
|
$this->json('POST', '/webauthn/login', self::ASSERTION_RESPONSE)
|
||||||
->assertOk()
|
->assertStatus(400)
|
||||||
->assertJsonFragment([
|
|
||||||
'message' => 'authenticated',
|
|
||||||
'name' => $this->user->name,
|
|
||||||
])
|
|
||||||
->assertJsonStructure([
|
->assertJsonStructure([
|
||||||
'message',
|
'message',
|
||||||
'name',
|
|
||||||
'preferences',
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user