Skip to content

Commit

Permalink
Merge branch 'tests-fix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Dec 5, 2021
1 parent 7b32a12 commit 6f72213
Show file tree
Hide file tree
Showing 26 changed files with 717 additions and 604 deletions.
15 changes: 12 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
- touch composer_installed

- name: npm
image: node
image: node:16
commands:
- node --version
- npm install
Expand Down Expand Up @@ -55,15 +55,20 @@ steps:
DB_USERNAME: homestead
DB_PASSWORD: secret
APP_URL: http://webserver
DAEMON_SETUP_TOKEN: test_auto_setup_token
CACHE_DRIVER: null
commands:
- ./artisan migrate:fresh --seed
- ./artisan dusk --debug
- ./artisan dusk --debug --exclude-group daemon,userServers
- ./artisan migrate:fresh --seed
- ./artisan dusk --debug --group daemon
- rm -rf storage/app/certs
- rm -rf storage/framework/cache/data/*
- rm -rf storage/framework/sessions/*
- rm -rf storage/framework/views/*
- rm -rf storage/debugbar/*
- rm -rf storage/logs/*
shm_size: 2000000000
volumes:
- name: daemon_logs
path: /var/log/gameap-daemon
Expand Down Expand Up @@ -196,14 +201,18 @@ services:
DB_DATABASE: homestead
DB_USERNAME: homestead
DB_PASSWORD: secret
CACHE_DRIVER: null
commands:
- while [[ ! -f composer_installed ]]; do sleep 2; echo "Waiting composer..."; done;
- ./artisan serve --host=webserver --port=80

- name: selenium
image: selenium/standalone-chrome:3.141.59-zirconium
image: selenium/standalone-chrome:4.1.0
shm_size: 2000000000
environment:
HUB_PORT: 4444
SCREEN_WIDTH: 1280
SCREEN_HEIGHT: 800

volumes:
- name: daemon_logs
Expand Down
29 changes: 14 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
.env
/.idea
/.phpstorm.meta.php
/.phpunit.result.cache
/.vagrant
/_ide_helper.php
/config/ide-helper.php
/modules/*
/node_modules
/public/hot
/public/storage
/public/js/app.js
/public/css/app.css
/public/fonts
/public/hot
/public/js/*
/public/mix-manifest.json
/public/storage
/storage/*.key
/tests/_output/
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
modules_statuses.json
npm-debug.log
yarn-error.log
.env
/modules/*
/_ide_helper.php
/config/ide-helper.php
/public/js/chunks/
/.phpstorm.meta.php
/public/mix-manifest.json
/tests/_output/
/.phpunit.result.cache
modules_statuses.json
1 change: 0 additions & 1 deletion app/Http/Requests/Admin/DedicatedServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function rules()
'gdaemon_login' => 'max:128',
'gdaemon_password' => 'max:128',
'gdaemon_api_key' => '',
'gdaemon_server_cert' => 'sometimes',
'client_certificate_id' => 'numeric|exists:client_certificates,id',
];
}
Expand Down
33 changes: 16 additions & 17 deletions app/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@

namespace Gameap\Repositories;

use Bouncer;
use DB;
use Gameap\Helpers\ServerPermissionHelper;
use Gameap\Models\Server;
use Gameap\Models\User;
use Illuminate\Support\Facades\DB;
use Silber\Bouncer\Bouncer;

class UserRepository extends Repository
class UserRepository
{
/**
* UserRepository constructor.
* @param User $model
*/
public function __construct(User $model)
/** @var Bouncer */
private $bouncer;

public function __construct(Bouncer $bouncer)
{
$this->model = $model;
$this->bouncer = $bouncer;
}

/**
* @param int $perPage
* @return mixed
*/
public function getAll($perPage = 20)
public function getAll(int $perPage = 20)
{
return User::orderBy('id')->paginate($perPage);
}
Expand All @@ -37,11 +36,11 @@ public function store(array $attributes): void

if (isset($attributes['roles'])) {
foreach ($attributes['roles'] as &$role) {
if (Bouncer::role()->where(['name' => $role])->exists()) {
if ($this->bouncer->role()->where(['name' => $role])->exists()) {
$user->assign($role);
}
}
Bouncer::refresh();
$this->bouncer->refresh();
}
}

Expand Down Expand Up @@ -79,13 +78,13 @@ public function update(User $user, array $fields)
->delete();
}

$user->retract(Bouncer::role()->all());
$user->retract($this->bouncer->role()->all());

if (isset($fields['roles'])) {
$user->assign($fields['roles']);
}

Bouncer::refresh();
$this->bouncer->refresh();

return true;
}
Expand All @@ -94,16 +93,16 @@ public function updateServerPermission(User $user, Server $server, ?array $disab
{
foreach (ServerPermissionHelper::getAllPermissions() as $pname) {
if (isset($disabledPermissions[$pname]) && $disabledPermissions[$pname]) {
Bouncer::forbid($user)->to($pname, $server);
$this->bouncer->forbid($user)->to($pname, $server);
$user->disallow($pname, $server);
} else {
Bouncer::unforbid($user)->to($pname, $server);
$this->bouncer->unforbid($user)->to($pname, $server);
$user->allow($pname, $server);
}
}

$user->servers()->syncWithoutDetaching([$server->id]);

Bouncer::refresh();
$this->bouncer->refreshFor($user);
}
}
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"moontoast/math": "^1.1",
"nwidart/laravel-modules": "^6.0",
"phpseclib/phpseclib": "^2.0.33",
"silber/bouncer": "v1.0.0-rc.10",
"silber/bouncer": "v1.0.0-rc.11",
"spatie/laravel-query-builder": "^3.6.0",
"splitbrain/php-archive": "^1.2"
},
Expand Down Expand Up @@ -78,12 +78,6 @@
"module-dir": "modules"
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
Expand Down
Loading

0 comments on commit 6f72213

Please sign in to comment.