Merge branch 'feature/api-integration-testing' into develop

This commit is contained in:
Dane Everitt 2018-03-26 19:55:28 -05:00
commit 68f0811273
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
30 changed files with 1374 additions and 80 deletions

View file

@ -1,6 +1,8 @@
<?php
use Cake\Chronos\Chronos;
use Faker\Generator as Faker;
use Pterodactyl\Models\ApiKey;
/*
|--------------------------------------------------------------------------
@ -34,6 +36,8 @@ $factory->define(Pterodactyl\Models\Server::class, function (Faker $faker) {
'egg_id' => $faker->randomNumber(),
'pack_id' => null,
'installed' => 1,
'database_limit' => null,
'allocation_limit' => null,
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now(),
];
@ -44,7 +48,7 @@ $factory->define(Pterodactyl\Models\User::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'external_id' => null,
'external_id' => $faker->unique()->isbn10,
'uuid' => $faker->uuid,
'username' => $faker->userName,
'email' => $faker->safeEmail,
@ -54,6 +58,8 @@ $factory->define(Pterodactyl\Models\User::class, function (Faker $faker) {
'language' => 'en',
'root_admin' => false,
'use_totp' => false,
'created_at' => Chronos::now(),
'updated_at' => Chronos::now(),
];
});
@ -66,7 +72,7 @@ $factory->state(Pterodactyl\Models\User::class, 'admin', function () {
$factory->define(Pterodactyl\Models\Location::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'short' => $faker->domainWord,
'short' => $faker->unique()->domainWord,
'long' => $faker->catchPhrase,
];
});
@ -74,7 +80,6 @@ $factory->define(Pterodactyl\Models\Location::class, function (Faker $faker) {
$factory->define(Pterodactyl\Models\Node::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid,
'public' => true,
'name' => $faker->firstName,
'fqdn' => $faker->ipv4,
@ -224,21 +229,17 @@ $factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker $faker) {
});
$factory->define(Pterodactyl\Models\ApiKey::class, function (Faker $faker) {
static $token;
return [
'id' => $faker->unique()->randomNumber(),
'user_id' => $faker->randomNumber(),
'key_type' => ApiKey::TYPE_APPLICATION,
'identifier' => str_random(Pterodactyl\Models\ApiKey::IDENTIFIER_LENGTH),
'token' => 'encrypted_string',
'token' => $token ?: $token = encrypt(str_random(Pterodactyl\Models\ApiKey::KEY_LENGTH)),
'allowed_ips' => null,
'memo' => 'Test Function Key',
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
];
});
$factory->define(Pterodactyl\Models\APIPermission::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'key_id' => $faker->randomNumber(),
'permission' => mb_strtolower($faker->word),
];
});

View file

@ -36,8 +36,8 @@ class UpgradeTaskSystem extends Migration
public function down()
{
Schema::table('tasks', function (Blueprint $table) {
$table->dropForeign(['server_id']);
$table->dropForeign(['user_id']);
// $table->dropForeign(['server_id']);
// $table->dropForeign(['user_id']);
$table->renameColumn('server_id', 'server');
$table->dropColumn('user_id');

View file

@ -23,10 +23,6 @@ class DeleteTaskWhenParentServerIsDeleted extends Migration
*/
public function down()
{
Schema::table('tasks', function (Blueprint $table) {
$table->dropForeign(['server_id']);
$table->foreign('server_id')->references('id')->on('servers');
});
//
}
}

View file

@ -41,7 +41,7 @@ class AddApiKeyPermissionColumns extends Migration
$table->unsignedInteger('key_id');
$table->string('permission');
$table->foreign('key_id')->references('id')->on('keys')->onDelete('cascade');
$table->foreign('key_id')->references('id')->on('api_keys')->onDelete('cascade');
});
Schema::table('api_keys', function (Blueprint $table) {

View file

@ -26,7 +26,10 @@ class EnsureUniqueAllocationIdOnServersTable extends Migration
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropForeign(['allocation_id']);
$table->dropUnique(['allocation_id']);
$table->foreign('allocation_id')->references('id')->on('allocations');
});
}
}