diff --git a/app/TwoFAccount.php b/app/TwoFAccount.php index 67043098..559738ba 100644 --- a/app/TwoFAccount.php +++ b/app/TwoFAccount.php @@ -99,23 +99,6 @@ protected static function boot() } - /** - * Scope a query to only include TwoFAccounts of a given group. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param mixed $groupId - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeOfGroup($query, $groupId) - { - if( $groupId ) { - return $query->where('group_id', $groupId); - } - - return $query; - } - - /** * Sortable settings * diff --git a/tests/Feature/AccountsGroupTest.php b/tests/Feature/AccountsGroupTest.php index d3ef27fc..2d29d7ad 100644 --- a/tests/Feature/AccountsGroupTest.php +++ b/tests/Feature/AccountsGroupTest.php @@ -176,64 +176,31 @@ public function testMoveAccountsToGroup() $response = $this->actingAs($this->user, 'api') ->json('GET', '/api/twofaccounts/1') ->assertJsonFragment([ - 'group_id' => (string) $this->group->id + 'group_id' => $this->group->id ]); $response = $this->actingAs($this->user, 'api') ->json('GET', '/api/twofaccounts/2') ->assertJsonFragment([ - 'group_id' => (string) $this->group->id + 'group_id' => $this->group->id ]); $response = $this->actingAs($this->user, 'api') ->json('GET', '/api/twofaccounts/3') ->assertJsonFragment([ - 'group_id' => (string) $this->group->id + 'group_id' => $this->group->id ]); // test the accounts count of the user group $response = $this->actingAs($this->user, 'api') ->json('GET', '/api/groups') ->assertJsonFragment([ - 'twofaccounts_count' => '3' + 'twofaccounts_count' => 3 ] ); } - /** - * test 2FAccounts are scoped when an active group is set via API - * - * @test - */ - public function testScopedAccounts() - { - // Set the default group to the existing one - $response = $this->actingAs($this->user, 'api') - ->json('POST', '/api/settings/options', [ - 'activeGroup' => $this->group->id, - ]) - ->assertStatus(200); - - // We associate 2 accounts to the group - $response = $this->actingAs($this->user, 'api') - ->json('PATCH', '/api/group/accounts/', [ - 'groupId' => $this->group->id, - 'accountsIds' => [1,2] - ]) - ->assertStatus(200); - - // Test accounts index is scoped with active group - $response = $this->actingAs($this->user, 'api') - ->json('GET', '/api/twofaccounts') - ->assertJsonCount(2) - ->assertJsonFragment([ - 'id' => 1, - 'id' => 2 - ]); - } - - /** * test 2FAccounts association with a missing group via API * @@ -284,8 +251,8 @@ public function testMoveAccountsToPseudoGroup() $response = $this->actingAs($this->user, 'api') ->json('GET', '/api/groups') ->assertJsonFragment([ - 'twofaccounts_count' => '3', // the 3 accounts for 'all' - 'twofaccounts_count' => '2' // the 2 accounts that remain in the user group + 'twofaccounts_count' => 3, // the 3 accounts for 'all' + 'twofaccounts_count' => 2 // the 2 accounts that remain in the user group ] ); diff --git a/tests/Feature/Auth/RegisterTest.php b/tests/Feature/Auth/RegisterTest.php index c904f819..bb9172d1 100644 --- a/tests/Feature/Auth/RegisterTest.php +++ b/tests/Feature/Auth/RegisterTest.php @@ -32,7 +32,7 @@ public function testExistingUserCount() $response = $this->json('POST', '/api/checkuser') ->assertStatus(200) ->assertJson([ - 'userCount' => '1', + 'username' => $this->user->name, ]); } @@ -51,7 +51,7 @@ public function testUserCreationWithAnExistingUser() 'password_confirmation' => 'test', ]); - $response->assertStatus(400); + $response->assertStatus(422); }