Update egg import/update logic to all use the same pathwaus

This commit is contained in:
DaneEveritt 2022-05-15 14:40:19 -04:00
parent 6554164252
commit cca0010a00
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
12 changed files with 271 additions and 334 deletions

View file

@ -11,13 +11,25 @@ use Pterodactyl\Services\Servers\VariableValidatorService;
class VariableValidatorServiceTest extends IntegrationTestCase
{
protected Egg $egg;
public function setUp(): void
{
parent::setUp();
/* @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->egg = Egg::query()
->where('author', 'support@pterodactyl.io')
->where('name', 'Bungeecord')
->firstOrFail();
}
/**
* Test that enviornment variables for a server are validated as expected.
*/
public function testEnvironmentVariablesCanBeValidated()
{
/** @noinspection PhpParamsInspection */
$egg = $this->cloneEggAndVariables(Egg::query()->findOrFail(1));
$egg = $this->cloneEggAndVariables($this->egg);
try {
$this->getService()->handle($egg->id, [
@ -54,8 +66,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
*/
public function testNormalUserCannotValidateNonUserEditableVariables()
{
/** @noinspection PhpParamsInspection */
$egg = $this->cloneEggAndVariables(Egg::query()->findOrFail(1));
$egg = $this->cloneEggAndVariables($this->egg);
$egg->variables()->first()->update([
'user_editable' => false,
]);
@ -74,8 +85,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
public function testEnvironmentVariablesCanBeUpdatedAsAdmin()
{
/** @noinspection PhpParamsInspection */
$egg = $this->cloneEggAndVariables(Egg::query()->findOrFail(1));
$egg = $this->cloneEggAndVariables($this->egg);
$egg->variables()->first()->update([
'user_editable' => false,
]);
@ -107,8 +117,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
public function testNullableEnvironmentVariablesCanBeUsedCorrectly()
{
/** @noinspection PhpParamsInspection */
$egg = $this->cloneEggAndVariables(Egg::query()->findOrFail(1));
$egg = $this->cloneEggAndVariables($this->egg);
$egg->variables()->where('env_variable', '!=', 'BUNGEE_VERSION')->delete();
$egg->variables()->update(['rules' => 'nullable|string']);