Skip to content

Commit

Permalink
fix server settings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Nov 28, 2023
1 parent 9d179b5 commit 7852d40
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Models\Backup;
use Convoy\Enums\Server\BackupMode;
use Convoy\Models\Server;
use Illuminate\Validation\Rules\Enum;
use Illuminate\Foundation\Http\FormRequest;
use Convoy\Enums\Server\BackupCompressionType;
Expand All @@ -13,7 +14,7 @@ class StoreBackupRequest extends BaseApiRequest
{
public function authorize(): bool
{
return $this->user()->can('create', $this->parameter('server', Backup::class));
return $this->user()->can('create', [Backup::class, $this->parameter('server', Server::class)]);
}

public function rules(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Convoy\Http\Requests\Client\Servers\Settings;

use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Models\Server;
use Exception;
use Convoy\Rules\Password;
use Faker\Provider\Base;
use Grpc\Server;
use Illuminate\Validation\Validator;
use Illuminate\Validation\Rules\Enum;
use phpseclib3\Crypt\PublicKeyLoader;
Expand Down
4 changes: 2 additions & 2 deletions app/Policies/ServerPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class ServerPolicy
{
public function before(User $user, string $ability): ?bool
public function before(User $user, string $ability, Server $server): ?bool
{
if ($user->root_admin) {
if ($user->root_admin || $user->id === $server->user_id) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

[$user, $_, $_, $server] = createServerModel();

$response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/settings/security");
$response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/settings/auth");

$response->assertOk();
});
Expand All @@ -61,7 +61,7 @@

[$user, $_, $_, $server] = createServerModel();

$response = $this->actingAs($user)->putJson("/api/client/servers/{$server->uuid}/settings/security", [
$response = $this->actingAs($user)->putJson("/api/client/servers/{$server->uuid}/settings/auth", [
'type' => 'password',
'password' => 'Advinservers is king!123',
]);
Expand Down

0 comments on commit 7852d40

Please sign in to comment.