mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-25 00:19:47 +01:00
Update php tests
This commit is contained in:
parent
4685e23fdb
commit
eaaefc1f1b
@ -43,11 +43,14 @@ public function test_show_existing_user_when_authenticated_returns_success()
|
|||||||
$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 @@ public function test_fetch_logo_returns_filename()
|
|||||||
{
|
{
|
||||||
$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 @@ public function test_user_login_with_uppercased_email_returns_success()
|
|||||||
*
|
*
|
||||||
* @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 @@ public function test_user_login_already_authenticated_returns_success()
|
|||||||
'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 @@ public function test_update_user_returns_success()
|
|||||||
'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 @@ public function test_update_user_without_changing_email_returns_success()
|
|||||||
'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 @@ public function test_update_user_without_changing_name_returns_success()
|
|||||||
'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 @@ public function test_update_user_with_uppercased_email_returns_success()
|
|||||||
'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 @@ public function test_update_user_in_demo_mode_returns_unchanged_user()
|
|||||||
'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 @@ public function test_legacy_login_is_rejected_when_webauthn_only_is_enable()
|
|||||||
*
|
*
|
||||||
* @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 @@ public function test_webauthn_login_already_authenticated_returns_success()
|
|||||||
->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…
Reference in New Issue
Block a user