mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
update tests to use new factories
This commit is contained in:
@@ -92,7 +92,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
|
||||
*/
|
||||
protected function createApiUser(): User
|
||||
{
|
||||
return factory(User::class)->create([
|
||||
return User::factory()->create([
|
||||
'root_admin' => true,
|
||||
]);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
|
||||
*/
|
||||
protected function createApiKey(User $user, array $permissions = []): ApiKey
|
||||
{
|
||||
return factory(ApiKey::class)->create(array_merge([
|
||||
return ApiKey::factory()->create(array_merge([
|
||||
'user_id' => $user->id,
|
||||
'key_type' => ApiKey::TYPE_APPLICATION,
|
||||
'r_servers' => AdminAcl::READ | AdminAcl::WRITE,
|
||||
|
||||
@@ -16,7 +16,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testGetLocations()
|
||||
{
|
||||
$locations = factory(Location::class)->times(2)->create();
|
||||
$locations = Location::factory()->times(2)->create();
|
||||
|
||||
$response = $this->getJson('/api/application/locations');
|
||||
$response->assertStatus(Response::HTTP_OK);
|
||||
@@ -70,7 +70,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testGetSingleLocation()
|
||||
{
|
||||
$location = factory(Location::class)->create();
|
||||
$location = Location::factory()->create();
|
||||
|
||||
$response = $this->getJson('/api/application/locations/' . $location->id);
|
||||
$response->assertStatus(Response::HTTP_OK);
|
||||
@@ -93,7 +93,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testRelationshipsCanBeLoaded()
|
||||
{
|
||||
$location = factory(Location::class)->create();
|
||||
$location = Location::factory()->create();
|
||||
$server = $this->createServerModel(['user_id' => $this->getApiUser()->id, 'location_id' => $location->id]);
|
||||
|
||||
$response = $this->getJson('/api/application/locations/' . $location->id . '?include=servers,nodes');
|
||||
@@ -143,8 +143,8 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||
{
|
||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]);
|
||||
|
||||
$location = factory(Location::class)->create();
|
||||
factory(Node::class)->create(['location_id' => $location->id]);
|
||||
$location = Location::factory()->create();
|
||||
Node::factory()->create(['location_id' => $location->id]);
|
||||
|
||||
$response = $this->getJson('/api/application/locations/' . $location->id . '?include=nodes');
|
||||
$response->assertStatus(Response::HTTP_OK);
|
||||
@@ -187,7 +187,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testErrorReturnedIfNoPermission()
|
||||
{
|
||||
$location = factory(Location::class)->create();
|
||||
$location = Location::factory()->create();
|
||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_locations' => 0]);
|
||||
|
||||
$response = $this->getJson('/api/application/locations/' . $location->id);
|
||||
|
||||
@@ -13,7 +13,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testGetRemoteUser()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->getJson('/api/application/users/external/' . $user->external_id);
|
||||
$response->assertStatus(Response::HTTP_OK);
|
||||
@@ -60,7 +60,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testErrorReturnedIfNoPermission()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
|
||||
|
||||
$response = $this->getJson('/api/application/users/external/' . $user->external_id);
|
||||
|
||||
@@ -16,7 +16,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testGetUsers()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->getJson('/api/application/users');
|
||||
$response->assertStatus(Response::HTTP_OK);
|
||||
@@ -85,7 +85,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testGetSingleUser()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->getJson('/api/application/users/' . $user->id);
|
||||
$response->assertStatus(Response::HTTP_OK);
|
||||
@@ -119,7 +119,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testRelationshipsCanBeLoaded()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$server = $this->createServerModel(['user_id' => $user->id]);
|
||||
|
||||
$response = $this->getJson('/api/application/users/' . $user->id . '?include=servers');
|
||||
@@ -152,7 +152,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
{
|
||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_servers' => 0]);
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$this->createServerModel(['user_id' => $user->id]);
|
||||
|
||||
$response = $this->getJson('/api/application/users/' . $user->id . '?include=servers');
|
||||
@@ -194,7 +194,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testErrorReturnedIfNoPermission()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
|
||||
|
||||
$response = $this->getJson('/api/application/users/' . $user->id);
|
||||
@@ -250,7 +250,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testUpdateUser()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->patchJson('/api/application/users/' . $user->id, [
|
||||
'username' => 'new.test.name',
|
||||
@@ -279,7 +279,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
*/
|
||||
public function testDeleteUser()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$this->assertDatabaseHas('users', ['id' => $user->id]);
|
||||
|
||||
$response = $this->delete('/api/application/users/' . $user->id);
|
||||
@@ -302,7 +302,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]);
|
||||
|
||||
if (str_contains($url, '{id}')) {
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$url = str_replace('{id}', $user->id, $url);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testAccountDetailsAreReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('/api/client/account');
|
||||
|
||||
@@ -39,7 +39,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testEmailIsUpdated()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
|
||||
'email' => 'hodor@example.com',
|
||||
@@ -58,7 +58,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testEmailIsNotUpdatedWhenPasswordIsInvalid()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
|
||||
'email' => 'hodor@example.com',
|
||||
@@ -77,7 +77,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testEmailIsNotUpdatedWhenNotValid()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
|
||||
'email' => '',
|
||||
@@ -104,7 +104,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testPasswordIsUpdated()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$mock = Mockery::mock(AuthManager::class);
|
||||
$mock->expects('logoutOtherDevices')->with('New_Password1');
|
||||
@@ -127,7 +127,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testPasswordIsNotUpdatedIfCurrentPasswordIsInvalid()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/api/client/account/password', [
|
||||
'current_password' => 'invalid',
|
||||
@@ -146,7 +146,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
*/
|
||||
public function testErrorIsReturnedForInvalidRequestData()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)->putJson('/api/client/account/password', [
|
||||
'current_password' => 'password',
|
||||
@@ -170,7 +170,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testErrorIsReturnedIfPasswordIsNotConfirmed()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/api/client/account/password', [
|
||||
'current_password' => 'password',
|
||||
|
||||
@@ -24,9 +24,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testApiKeysAreReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
/** @var \Pterodactyl\Models\ApiKey $key */
|
||||
$key = factory(ApiKey::class)->create([
|
||||
$key = ApiKey::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'key_type' => ApiKey::TYPE_ACCOUNT,
|
||||
]);
|
||||
@@ -59,13 +59,13 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testApiKeyCanBeCreatedForAccount()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
// Small sub-test to ensure we're always comparing the number of keys to the
|
||||
// specific logged in account, and not just the total number of keys stored in
|
||||
// the database.
|
||||
factory(ApiKey::class)->times(10)->create([
|
||||
'user_id' => factory(User::class)->create()->id,
|
||||
ApiKey::factory()->times(10)->create([
|
||||
'user_id' => User::factory()->create()->id,
|
||||
'key_type' => ApiKey::TYPE_ACCOUNT,
|
||||
]);
|
||||
|
||||
@@ -103,8 +103,8 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testNoMoreThanFiveApiKeysCanBeCreatedForAnAccount()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
factory(ApiKey::class)->times(5)->create([
|
||||
$user = User::factory()->create();
|
||||
ApiKey::factory()->times(5)->create([
|
||||
'user_id' => $user->id,
|
||||
'key_type' => ApiKey::TYPE_ACCOUNT,
|
||||
]);
|
||||
@@ -127,7 +127,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testValidationErrorIsReturnedForBadRequests()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson('/api/client/account/api-keys', [
|
||||
'description' => '',
|
||||
@@ -154,9 +154,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testApiKeyCanBeDeleted()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
/** @var \Pterodactyl\Models\ApiKey $key */
|
||||
$key = factory(ApiKey::class)->create([
|
||||
$key = ApiKey::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'key_type' => ApiKey::TYPE_ACCOUNT,
|
||||
]);
|
||||
@@ -173,9 +173,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testNonExistentApiKeyDeletionReturns404Error()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
/** @var \Pterodactyl\Models\ApiKey $key */
|
||||
$key = factory(ApiKey::class)->create([
|
||||
$key = ApiKey::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'key_type' => ApiKey::TYPE_ACCOUNT,
|
||||
]);
|
||||
@@ -193,11 +193,11 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testApiKeyBelongingToAnotherUserCannotBeDeleted()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
/** @var \Pterodactyl\Models\User $user2 */
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
/** @var \Pterodactyl\Models\ApiKey $key */
|
||||
$key = factory(ApiKey::class)->create([
|
||||
$key = ApiKey::factory()->create([
|
||||
'user_id' => $user2->id,
|
||||
'key_type' => ApiKey::TYPE_ACCOUNT,
|
||||
]);
|
||||
@@ -215,9 +215,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testApplicationApiKeyCannotBeDeleted()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
/** @var \Pterodactyl\Models\ApiKey $key */
|
||||
$key = factory(ApiKey::class)->create([
|
||||
$key = ApiKey::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'key_type' => ApiKey::TYPE_APPLICATION,
|
||||
]);
|
||||
|
||||
@@ -84,7 +84,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
|
||||
protected function generateTestAccount(array $permissions = []): array
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
if (empty($permissions)) {
|
||||
return [$user, $this->createServerModel(['user_id' => $user->id])];
|
||||
|
||||
@@ -19,7 +19,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testOnlyLoggedInUsersServersAreReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(3)->create();
|
||||
$users = User::factory()->times(3)->create();
|
||||
|
||||
/** @var \Pterodactyl\Models\Server[] $servers */
|
||||
$servers = [
|
||||
@@ -46,7 +46,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testServersAreFilteredUsingNameAndUuidInformation()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(2)->create();
|
||||
$users = User::factory()->times(2)->create();
|
||||
$users[0]->update(['root_admin' => true]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Server[] $servers */
|
||||
@@ -106,8 +106,8 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
$server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]);
|
||||
|
||||
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]);
|
||||
$allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]);
|
||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]);
|
||||
$allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]);
|
||||
|
||||
$server->update(['allocation_id' => $allocation->id]);
|
||||
$server2->update(['allocation_id' => $allocation2->id]);
|
||||
@@ -144,7 +144,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testServersUserIsASubuserOfAreReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(3)->create();
|
||||
$users = User::factory()->times(3)->create();
|
||||
$servers = [
|
||||
$this->createServerModel(['user_id' => $users[0]->id]),
|
||||
$this->createServerModel(['user_id' => $users[1]->id]),
|
||||
@@ -175,7 +175,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testFilterOnlyOwnerServers()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(3)->create();
|
||||
$users = User::factory()->times(3)->create();
|
||||
$servers = [
|
||||
$this->createServerModel(['user_id' => $users[0]->id]),
|
||||
$this->createServerModel(['user_id' => $users[1]->id]),
|
||||
@@ -204,7 +204,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testPermissionsAreReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->getJson('/api/client/permissions')
|
||||
@@ -224,7 +224,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testOnlyAdminLevelServersAreReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(4)->create();
|
||||
$users = User::factory()->times(4)->create();
|
||||
$users[0]->update(['root_admin' => true]);
|
||||
|
||||
$servers = [
|
||||
@@ -259,7 +259,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testAllServersAreReturnedToAdmin()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(4)->create();
|
||||
$users = User::factory()->times(4)->create();
|
||||
$users[0]->update(['root_admin' => true]);
|
||||
|
||||
$servers = [
|
||||
@@ -292,7 +292,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser($type)
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User[] $users */
|
||||
$users = factory(User::class)->times(3)->create();
|
||||
$users = User::factory()->times(3)->create();
|
||||
|
||||
$this->createServerModel(['user_id' => $users[0]->id]);
|
||||
$this->createServerModel(['user_id' => $users[1]->id]);
|
||||
@@ -315,7 +315,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
|
||||
$server->allocation->notes = 'Test notes';
|
||||
$server->allocation->save();
|
||||
|
||||
factory(Allocation::class)->times(2)->create([
|
||||
Allocation::factory()->times(2)->create([
|
||||
'node_id' => $server->node_id,
|
||||
'server_id' => $server->id,
|
||||
]);
|
||||
|
||||
@@ -22,7 +22,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount($permission);
|
||||
|
||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||
$allocation = factory(Allocation::class)->create([
|
||||
$allocation = Allocation::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'node_id' => $server->node_id,
|
||||
'notes' => 'hodor',
|
||||
@@ -42,7 +42,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||
$allocation = factory(Allocation::class)->create([
|
||||
$allocation = Allocation::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'node_id' => $server->node_id,
|
||||
'notes' => 'hodor',
|
||||
|
||||
@@ -32,7 +32,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testServerAllocationsAreNotReturnedWithoutPermission()
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
|
||||
$server->owner_id = $user2->id;
|
||||
$server->save();
|
||||
@@ -85,7 +85,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testAllocationNotesCannotBeUpdatedByInvalidUsers()
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
|
||||
$server->owner_id = $user2->id;
|
||||
$server->save();
|
||||
@@ -105,7 +105,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
$allocation = $server->allocation;
|
||||
$allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||
$allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||
|
||||
$server->allocation_id = $allocation->id;
|
||||
$server->save();
|
||||
@@ -121,7 +121,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testPrimaryAllocationCannotBeModifiedByInvalidUser()
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
|
||||
$server->owner_id = $user2->id;
|
||||
$server->save();
|
||||
|
||||
@@ -20,8 +20,8 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
@@ -52,7 +52,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
@@ -69,7 +69,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
|
||||
@@ -25,7 +25,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
|
||||
Bus::fake();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create([
|
||||
$schedule = Schedule::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
]);
|
||||
|
||||
@@ -35,7 +35,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
|
||||
$response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.');
|
||||
|
||||
/** @var \Pterodactyl\Models\Task $task */
|
||||
$task = factory(Task::class)->create([
|
||||
$task = Task::factory()->create([
|
||||
'schedule_id' => $schedule->id,
|
||||
'sequence_id' => 1,
|
||||
'time_offset' => 2,
|
||||
@@ -60,7 +60,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create([
|
||||
$schedule = Schedule::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'is_active' => false,
|
||||
]);
|
||||
@@ -80,7 +80,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden();
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
/** @var \Pterodactyl\Models\Task $task */
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]);
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->getJson(
|
||||
@@ -66,7 +66,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
@@ -84,7 +84,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
||||
->getJson("/api/client/servers/{$server->uuid}/schedules")
|
||||
->assertForbidden();
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
|
||||
@@ -34,7 +34,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*');
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
@@ -59,7 +59,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
@@ -74,7 +74,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
@@ -92,7 +92,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create([
|
||||
$schedule = Schedule::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'is_active' => true,
|
||||
'is_processing' => true,
|
||||
|
||||
@@ -21,7 +21,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$this->assertEmpty($schedule->tasks);
|
||||
|
||||
$response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
|
||||
@@ -51,7 +51,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
|
||||
@@ -96,7 +96,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
|
||||
'action' => 'backup',
|
||||
@@ -121,8 +121,8 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
factory(Task::class)->times(2)->create(['schedule_id' => $schedule->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
Task::factory()->times(2)->create(['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
|
||||
'action' => 'command',
|
||||
@@ -144,7 +144,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks")
|
||||
@@ -160,7 +160,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->postJson($this->link($schedule, '/tasks'))
|
||||
|
||||
@@ -19,8 +19,8 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
$server2 = $this->createServerModel();
|
||||
[$user] = $this->generateTestAccount();
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]);
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->actingAs($user)->deleteJson($this->link($task))->assertNotFound();
|
||||
}
|
||||
@@ -33,9 +33,9 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule2 = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$schedule2 = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule2->id}/tasks/{$task->id}")->assertNotFound();
|
||||
}
|
||||
@@ -47,12 +47,12 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->actingAs($user)->deleteJson($this->link($task))->assertForbidden();
|
||||
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
|
||||
$this->actingAs($user2)->deleteJson($this->link($task))->assertNotFound();
|
||||
}
|
||||
@@ -65,12 +65,12 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
$tasks = [
|
||||
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]),
|
||||
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]),
|
||||
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]),
|
||||
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]),
|
||||
Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]),
|
||||
Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]),
|
||||
Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]),
|
||||
Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]),
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->deleteJson($this->link($tasks[1]));
|
||||
|
||||
@@ -55,7 +55,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
|
||||
$this->actingAs($user)->getJson($this->link($server) . "/startup")->assertForbidden();
|
||||
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
$this->actingAs($user2)->getJson($this->link($server) . "/startup")->assertNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
|
||||
$this->actingAs($user)->putJson($this->link($server) . "/startup/variable")->assertForbidden();
|
||||
|
||||
$user2 = factory(User::class)->create();
|
||||
$user2 = User::factory()->create();
|
||||
$this->actingAs($user2)->putJson($this->link($server) . "/startup/variable")->assertNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\User $existing */
|
||||
$existing = factory(User::class)->create(['email' => $this->faker->email]);
|
||||
$existing = User::factory()->create(['email' => $this->faker->email]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson($this->link($server) . "/users", [
|
||||
'email' => $existing->email,
|
||||
|
||||
@@ -30,13 +30,13 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\User $differentUser */
|
||||
$differentUser = factory(User::class)->create();
|
||||
$differentUser = User::factory()->create();
|
||||
|
||||
// Generate a UUID that lines up with a user in the database if it were to be cast to an int.
|
||||
$uuid = $differentUser->id . str_repeat('a', strlen((string)$differentUser->id)) . substr(Uuid::uuid4()->toString(), 8);
|
||||
|
||||
/** @var \Pterodactyl\Models\User $subuser */
|
||||
$subuser = factory(User::class)->create(['uuid' => $uuid]);
|
||||
$subuser = User::factory()->create(['uuid' => $uuid]);
|
||||
|
||||
Subuser::query()->forceCreate([
|
||||
'user_id' => $subuser->id,
|
||||
@@ -52,7 +52,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
||||
// anything in the database.
|
||||
$uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8);
|
||||
/** @var \Pterodactyl\Models\User $subuser */
|
||||
$subuser = factory(User::class)->create(['uuid' => $uuid]);
|
||||
$subuser = User::factory()->create(['uuid' => $uuid]);
|
||||
|
||||
Subuser::query()->forceCreate([
|
||||
'user_id' => $subuser->id,
|
||||
|
||||
@@ -18,7 +18,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testTwoFactorImageDataIsReturned()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create(['use_totp' => false]);
|
||||
$user = User::factory()->create(['use_totp' => false]);
|
||||
|
||||
$this->assertFalse($user->use_totp);
|
||||
$this->assertEmpty($user->totp_secret);
|
||||
@@ -42,7 +42,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create(['use_totp' => true]);
|
||||
$user = User::factory()->create(['use_totp' => true]);
|
||||
|
||||
$response = $this->actingAs($user)->getJson('/api/client/account/two-factor');
|
||||
|
||||
@@ -57,7 +57,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create(['use_totp' => false]);
|
||||
$user = User::factory()->create(['use_totp' => false]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson('/api/client/account/two-factor', [
|
||||
'code' => '',
|
||||
@@ -74,7 +74,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
|
||||
public function testTwoFactorCanBeEnabledOnAccount()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create(['use_totp' => false]);
|
||||
$user = User::factory()->create(['use_totp' => false]);
|
||||
|
||||
// Make the initial call to get the account setup for 2FA.
|
||||
$this->actingAs($user)->getJson('/api/client/account/two-factor')->assertOk();
|
||||
@@ -126,7 +126,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
|
||||
Carbon::setTestNow(Carbon::now());
|
||||
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create(['use_totp' => true]);
|
||||
$user = User::factory()->create(['use_totp' => true]);
|
||||
|
||||
$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
|
||||
'password' => 'invalid',
|
||||
@@ -157,7 +157,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
|
||||
Carbon::setTestNow(Carbon::now());
|
||||
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create(['use_totp' => false]);
|
||||
$user = User::factory()->create(['use_totp' => false]);
|
||||
|
||||
$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
|
||||
'password' => 'password',
|
||||
|
||||
@@ -23,8 +23,8 @@ class UserControllerTest extends IntegrationTestCase
|
||||
{
|
||||
$unique = Str::random(16);
|
||||
$users = [
|
||||
factory(User::class)->create(['username' => $unique . '_1']),
|
||||
factory(User::class)->create(['username' => $unique . '_2']),
|
||||
User::factory()->create(['username' => $unique . '_1']),
|
||||
User::factory()->create(['username' => $unique . '_2']),
|
||||
];
|
||||
|
||||
$servers = [
|
||||
|
||||
@@ -32,7 +32,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
|
||||
$created = factory(Allocation::class)->create([
|
||||
$created = Allocation::factory()->create([
|
||||
'node_id' => $server->node_id,
|
||||
'ip' => $server->allocation->ip,
|
||||
]);
|
||||
@@ -74,7 +74,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
|
||||
config()->set('pterodactyl.client_features.allocations.range_start', 5000);
|
||||
config()->set('pterodactyl.client_features.allocations.range_end', 5001);
|
||||
|
||||
factory(Allocation::class)->create([
|
||||
Allocation::factory()->create([
|
||||
'server_id' => $server2->id,
|
||||
'node_id' => $server->node_id,
|
||||
'ip' => $server->allocation->ip,
|
||||
@@ -93,7 +93,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
|
||||
config()->set('pterodactyl.client_features.allocations.range_end', 5005);
|
||||
|
||||
for ($i = 5000; $i <= 5005; $i++) {
|
||||
factory(Allocation::class)->create([
|
||||
Allocation::factory()->create([
|
||||
'ip' => $server->allocation->ip,
|
||||
'port' => $i,
|
||||
'node_id' => $server->node_id,
|
||||
@@ -115,7 +115,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
|
||||
factory(Allocation::class)->times(5)->create(['node_id' => $server->node_id]);
|
||||
Allocation::factory()->times(5)->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->expectException(NoAutoAllocationSpaceAvailableException::class);
|
||||
$this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.');
|
||||
|
||||
@@ -63,9 +63,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
|
||||
public function testDatabaseCannotBeCreatedIfServerHasReachedLimit()
|
||||
{
|
||||
$server = $this->createServerModel(['database_limit' => 2]);
|
||||
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]);
|
||||
$host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
factory(Database::class)->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]);
|
||||
Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]);
|
||||
|
||||
$this->expectException(TooManyDatabasesException::class);
|
||||
|
||||
@@ -96,9 +96,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
|
||||
$server = $this->createServerModel();
|
||||
$name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id);
|
||||
|
||||
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]);
|
||||
$host2 = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]);
|
||||
factory(Database::class)->create([
|
||||
$host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
|
||||
$host2 = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
|
||||
Database::factory()->create([
|
||||
'database' => $name,
|
||||
'database_host_id' => $host->id,
|
||||
'server_id' => $server->id,
|
||||
@@ -125,7 +125,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
|
||||
$server = $this->createServerModel();
|
||||
$name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id);
|
||||
|
||||
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]);
|
||||
$host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->repository->expects('createDatabase')->with($name);
|
||||
|
||||
@@ -183,7 +183,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
|
||||
$server = $this->createServerModel();
|
||||
$name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id);
|
||||
|
||||
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]);
|
||||
$host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->repository->expects('createDatabase')->with($name)->andThrows(new BadMethodCallException);
|
||||
$this->repository->expects('dropDatabase')->with($name);
|
||||
|
||||
@@ -65,8 +65,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
|
||||
$node = factory(Node::class)->create(['location_id' => $server->location->id]);
|
||||
factory(DatabaseHost::class)->create(['node_id' => $node->id]);
|
||||
$node = Node::factory()->create(['location_id' => $server->location->id]);
|
||||
DatabaseHost::factory()->create(['node_id' => $node->id]);
|
||||
|
||||
config()->set('pterodactyl.client_features.databases.allow_random', false);
|
||||
|
||||
@@ -100,9 +100,9 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
|
||||
$node = factory(Node::class)->create(['location_id' => $server->location->id]);
|
||||
factory(DatabaseHost::class)->create(['node_id' => $node->id]);
|
||||
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]);
|
||||
$node = Node::factory()->create(['location_id' => $server->location->id]);
|
||||
DatabaseHost::factory()->create(['node_id' => $node->id]);
|
||||
$host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->managementService->expects('create')->with($server, [
|
||||
'database_host_id' => $host->id,
|
||||
@@ -127,8 +127,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
|
||||
$node = factory(Node::class)->create(['location_id' => $server->location->id]);
|
||||
$host = factory(DatabaseHost::class)->create(['node_id' => $node->id]);
|
||||
$node = Node::factory()->create(['location_id' => $server->location->id]);
|
||||
$host = DatabaseHost::factory()->create(['node_id' => $node->id]);
|
||||
|
||||
$this->managementService->expects('create')->with($server, [
|
||||
'database_host_id' => $host->id,
|
||||
|
||||
@@ -71,24 +71,24 @@ class FindViableNodesServiceTest extends IntegrationTestCase
|
||||
public function testExpectedNodeIsReturnedForLocation()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Location[] $locations */
|
||||
$locations = factory(Location::class)->times(2)->create();
|
||||
$locations = Location::factory()->times(2)->create();
|
||||
|
||||
/** @var \Pterodactyl\Models\Node[] $nodes */
|
||||
$nodes = [
|
||||
// This node should never be returned once we've completed the initial test which
|
||||
// runs without a location filter.
|
||||
factory(Node::class)->create([
|
||||
Node::factory()->create([
|
||||
'location_id' => $locations[0]->id,
|
||||
'memory' => 2048,
|
||||
'disk' => 1024 * 100,
|
||||
]),
|
||||
factory(Node::class)->create([
|
||||
Node::factory()->create([
|
||||
'location_id' => $locations[1]->id,
|
||||
'memory' => 1024,
|
||||
'disk' => 10240,
|
||||
'disk_overallocate' => 10,
|
||||
]),
|
||||
factory(Node::class)->create([
|
||||
Node::factory()->create([
|
||||
'location_id' => $locations[1]->id,
|
||||
'memory' => 1024 * 4,
|
||||
'memory_overallocate' => 50,
|
||||
|
||||
@@ -23,7 +23,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
|
||||
public function testScheduleWithNoTasksReturnsException()
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->expectException(DisplayException::class);
|
||||
$this->expectExceptionMessage('Cannot process schedule for task execution: no tasks are registered.');
|
||||
@@ -39,13 +39,13 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
|
||||
$server = $this->createServerModel();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create([
|
||||
$schedule = Schedule::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'cron_minute' => 'hodor', // this will break the getNextRunDate() function.
|
||||
]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Task $task */
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
@@ -68,10 +68,10 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
|
||||
$server = $this->createServerModel();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Task $task */
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]);
|
||||
|
||||
$this->getService()->handle($schedule, $now);
|
||||
|
||||
@@ -100,12 +100,12 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
|
||||
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Task $task */
|
||||
$task2 = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]);
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]);
|
||||
$task3 = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]);
|
||||
$task2 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]);
|
||||
$task3 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]);
|
||||
|
||||
$this->getService()->handle($schedule);
|
||||
|
||||
@@ -131,9 +131,9 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
|
||||
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create(['server_id' => $server->id, 'last_run_at' => null]);
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id, 'last_run_at' => null]);
|
||||
/** @var \Pterodactyl\Models\Task $task */
|
||||
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
|
||||
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
|
||||
|
||||
$dispatcher->expects('dispatchNow')->andThrows(new Exception('Test thrown exception'));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
$server2 = $this->createServerModel();
|
||||
|
||||
/** @var \Pterodactyl\Models\Allocation[] $allocations */
|
||||
$allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']);
|
||||
$allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']);
|
||||
|
||||
$initialAllocationId = $server->allocation_id;
|
||||
$allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']);
|
||||
@@ -83,7 +83,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Allocation[] $allocations */
|
||||
$allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id]);
|
||||
$allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id]);
|
||||
|
||||
$allocations[0]->update(['server_id' => $server->id]);
|
||||
|
||||
@@ -156,7 +156,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Allocation[] $allocations */
|
||||
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||
|
||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
||||
|
||||
@@ -179,7 +179,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Allocation[] $allocations */
|
||||
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id]);
|
||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
||||
|
||||
@@ -198,8 +198,8 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Allocation[] $allocations */
|
||||
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||
$allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id]);
|
||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||
$allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
||||
|
||||
@@ -220,7 +220,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
/** @var \Pterodactyl\Models\Allocation[] $allocations */
|
||||
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id]);
|
||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
|
||||
|
||||
$this->daemonServerRepository->expects('setServer->update')->andThrows(new DisplayException('Test'));
|
||||
|
||||
|
||||
@@ -48,15 +48,15 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||
public function testServerIsCreatedWithDeploymentObject()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
/** @var \Pterodactyl\Models\Node $node */
|
||||
$node = factory(Node::class)->create([
|
||||
'location_id' => factory(Location::class)->create()->id,
|
||||
$node = Node::factory()->create([
|
||||
'location_id' => Location::factory()->create()->id,
|
||||
]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */
|
||||
$allocations = factory(Allocation::class)->times(5)->create([
|
||||
$allocations = Allocation::factory()->times(5)->create([
|
||||
'node_id' => $node->id,
|
||||
]);
|
||||
|
||||
@@ -156,15 +156,15 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||
public function testErrorEncounteredByWingsCausesServerToBeDeleted()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
/** @var \Pterodactyl\Models\Node $node */
|
||||
$node = factory(Node::class)->create([
|
||||
'location_id' => factory(Location::class)->create()->id,
|
||||
$node = Node::factory()->create([
|
||||
'location_id' => Location::factory()->create()->id,
|
||||
]);
|
||||
|
||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||
$allocation = factory(Allocation::class)->create([
|
||||
$allocation = Allocation::factory()->create([
|
||||
'node_id' => $node->id,
|
||||
]);
|
||||
|
||||
|
||||
@@ -113,10 +113,10 @@ class ServerDeletionServiceTest extends IntegrationTestCase
|
||||
public function testExceptionWhileDeletingStopsProcess()
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
$host = factory(DatabaseHost::class)->create();
|
||||
$host = DatabaseHost::factory()->create();
|
||||
|
||||
/** @var \Pterodactyl\Models\Database $db */
|
||||
$db = factory(Database::class)->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
|
||||
$db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
|
||||
|
||||
$server->refresh();
|
||||
|
||||
@@ -138,10 +138,10 @@ class ServerDeletionServiceTest extends IntegrationTestCase
|
||||
public function testExceptionWhileDeletingDatabasesDoesNotAbortIfForceDeleted()
|
||||
{
|
||||
$server = $this->createServerModel();
|
||||
$host = factory(DatabaseHost::class)->create();
|
||||
$host = DatabaseHost::factory()->create();
|
||||
|
||||
/** @var \Pterodactyl\Models\Database $db */
|
||||
$db = factory(Database::class)->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
|
||||
$db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
|
||||
|
||||
$server->refresh();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user