From c3df886ffa1d1edfd2df5dfbb363de980b995c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Wed, 31 Mar 2021 16:09:49 +0200 Subject: [PATCH] Add a Command to create an Admin test account --- flexiapi/app/Account.php | 1 - .../Commands/CreateAdminAccountTest.php | 87 ++++++++++ flexiapi/composer.lock | 162 +++++++++--------- flexisip-account-manager.spec | 2 +- 4 files changed, 169 insertions(+), 83 deletions(-) create mode 100644 flexiapi/app/Console/Commands/CreateAdminAccountTest.php diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php index 8486397..8e69808 100644 --- a/flexiapi/app/Account.php +++ b/flexiapi/app/Account.php @@ -21,7 +21,6 @@ namespace App; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Mail; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Support\Str; diff --git a/flexiapi/app/Console/Commands/CreateAdminAccountTest.php b/flexiapi/app/Console/Commands/CreateAdminAccountTest.php new file mode 100644 index 0000000..0ff53e6 --- /dev/null +++ b/flexiapi/app/Console/Commands/CreateAdminAccountTest.php @@ -0,0 +1,87 @@ +delete(); + + // Delete the account if it already exists + $account = Account::withoutGlobalScopes() + ->where('username', $username) + ->where('domain', $domain) + ->first(); + + if ($account) { + // We don't have foreign keys yet… + $account->admin()->delete(); + $account->delete(); + } + + $account = new Account; + $account->username = $username; + $account->domain = $domain; + $account->email = 'admin_test@sip.example.org'; + $account->activated = true; + $account->user_agent = 'Test'; + $account->ip_address = '0.0.0.0'; + $account->creation_time = Carbon::now(); + $account->save(); + + $admin = new Admin; + $admin->account_id = $account->id; + $admin->save(); + + $apiKey = new ApiKey; + $apiKey->account_id = $account->id; + $apiKey->key = $secret; + $apiKey->save(); + + $this->info('Admin test account created: "sip:' . $username . '@' . $domain . '" | API Key: "' . $secret . '"'); + + return 0; + } +} diff --git a/flexiapi/composer.lock b/flexiapi/composer.lock index 3d25fcc..83878b2 100644 --- a/flexiapi/composer.lock +++ b/flexiapi/composer.lock @@ -970,16 +970,16 @@ }, { "name": "laravel/framework", - "version": "v8.33.1", + "version": "v8.35.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "354c57b8cb457549114074c500944455a288d6cc" + "reference": "d118c0df39e7524131176aaf76493eae63a8a602" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/354c57b8cb457549114074c500944455a288d6cc", - "reference": "354c57b8cb457549114074c500944455a288d6cc", + "url": "https://api.github.com/repos/laravel/framework/zipball/d118c0df39e7524131176aaf76493eae63a8a602", + "reference": "d118c0df39e7524131176aaf76493eae63a8a602", "shasum": "" }, "require": { @@ -1134,7 +1134,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-03-16T19:42:32+00:00" + "time": "2021-03-30T21:34:17+00:00" }, { "name": "laravel/tinker", @@ -1278,16 +1278,16 @@ }, { "name": "league/commonmark", - "version": "1.5.7", + "version": "1.5.8", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "11df9b36fd4f1d2b727a73bf14931d81373b9a54" + "reference": "08fa59b8e4e34ea8a773d55139ae9ac0e0aecbaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/11df9b36fd4f1d2b727a73bf14931d81373b9a54", - "reference": "11df9b36fd4f1d2b727a73bf14931d81373b9a54", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/08fa59b8e4e34ea8a773d55139ae9ac0e0aecbaf", + "reference": "08fa59b8e4e34ea8a773d55139ae9ac0e0aecbaf", "shasum": "" }, "require": { @@ -1375,7 +1375,7 @@ "type": "tidelift" } ], - "time": "2020-10-31T13:49:32+00:00" + "time": "2021-03-28T18:51:39+00:00" }, { "name": "league/flysystem", @@ -2749,16 +2749,16 @@ }, { "name": "symfony/console", - "version": "v5.2.5", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "938ebbadae1b0a9c9d1ec313f87f9708609f1b79" + "reference": "35f039df40a3b335ebf310f244cb242b3a83ac8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/938ebbadae1b0a9c9d1ec313f87f9708609f1b79", - "reference": "938ebbadae1b0a9c9d1ec313f87f9708609f1b79", + "url": "https://api.github.com/repos/symfony/console/zipball/35f039df40a3b335ebf310f244cb242b3a83ac8d", + "reference": "35f039df40a3b335ebf310f244cb242b3a83ac8d", "shasum": "" }, "require": { @@ -2826,7 +2826,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.5" + "source": "https://github.com/symfony/console/tree/v5.2.6" }, "funding": [ { @@ -2842,7 +2842,7 @@ "type": "tidelift" } ], - "time": "2021-03-06T13:42:15+00:00" + "time": "2021-03-28T09:42:18+00:00" }, { "name": "symfony/css-selector", @@ -2978,16 +2978,16 @@ }, { "name": "symfony/error-handler", - "version": "v5.2.4", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "b547d3babcab5c31e01de59ee33e9d9c1421d7d0" + "reference": "bdb7fb4188da7f4211e4b88350ba0dfdad002b03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/b547d3babcab5c31e01de59ee33e9d9c1421d7d0", - "reference": "b547d3babcab5c31e01de59ee33e9d9c1421d7d0", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/bdb7fb4188da7f4211e4b88350ba0dfdad002b03", + "reference": "bdb7fb4188da7f4211e4b88350ba0dfdad002b03", "shasum": "" }, "require": { @@ -3027,7 +3027,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v5.2.4" + "source": "https://github.com/symfony/error-handler/tree/v5.2.6" }, "funding": [ { @@ -3043,7 +3043,7 @@ "type": "tidelift" } ], - "time": "2021-02-11T08:21:20+00:00" + "time": "2021-03-16T09:07:47+00:00" }, { "name": "symfony/event-dispatcher", @@ -3424,16 +3424,16 @@ }, { "name": "symfony/http-kernel", - "version": "v5.2.5", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "b8c63ef63c2364e174c3b3e0ba0bf83455f97f73" + "reference": "f34de4c61ca46df73857f7f36b9a3805bdd7e3b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/b8c63ef63c2364e174c3b3e0ba0bf83455f97f73", - "reference": "b8c63ef63c2364e174c3b3e0ba0bf83455f97f73", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f34de4c61ca46df73857f7f36b9a3805bdd7e3b2", + "reference": "f34de4c61ca46df73857f7f36b9a3805bdd7e3b2", "shasum": "" }, "require": { @@ -3516,7 +3516,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v5.2.5" + "source": "https://github.com/symfony/http-kernel/tree/v5.2.6" }, "funding": [ { @@ -3532,20 +3532,20 @@ "type": "tidelift" } ], - "time": "2021-03-10T17:07:35+00:00" + "time": "2021-03-29T05:16:58+00:00" }, { "name": "symfony/mime", - "version": "v5.2.5", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "554ba128f1955038b45db5e1fa7e93bfc683b139" + "reference": "1b2092244374cbe48ae733673f2ca0818b37197b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/554ba128f1955038b45db5e1fa7e93bfc683b139", - "reference": "554ba128f1955038b45db5e1fa7e93bfc683b139", + "url": "https://api.github.com/repos/symfony/mime/zipball/1b2092244374cbe48ae733673f2ca0818b37197b", + "reference": "1b2092244374cbe48ae733673f2ca0818b37197b", "shasum": "" }, "require": { @@ -3599,7 +3599,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.2.5" + "source": "https://github.com/symfony/mime/tree/v5.2.6" }, "funding": [ { @@ -3615,7 +3615,7 @@ "type": "tidelift" } ], - "time": "2021-03-07T16:08:20+00:00" + "time": "2021-03-12T13:18:39+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4410,16 +4410,16 @@ }, { "name": "symfony/routing", - "version": "v5.2.4", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "cafa138128dfd6ab6be1abf6279169957b34f662" + "reference": "31fba555f178afd04d54fd26953501b2c3f0c6e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/cafa138128dfd6ab6be1abf6279169957b34f662", - "reference": "cafa138128dfd6ab6be1abf6279169957b34f662", + "url": "https://api.github.com/repos/symfony/routing/zipball/31fba555f178afd04d54fd26953501b2c3f0c6e6", + "reference": "31fba555f178afd04d54fd26953501b2c3f0c6e6", "shasum": "" }, "require": { @@ -4480,7 +4480,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v5.2.4" + "source": "https://github.com/symfony/routing/tree/v5.2.6" }, "funding": [ { @@ -4496,7 +4496,7 @@ "type": "tidelift" } ], - "time": "2021-02-22T15:48:39+00:00" + "time": "2021-03-14T13:53:33+00:00" }, { "name": "symfony/service-contracts", @@ -4579,16 +4579,16 @@ }, { "name": "symfony/string", - "version": "v5.2.4", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "4e78d7d47061fa183639927ec40d607973699609" + "reference": "ad0bd91bce2054103f5eaa18ebeba8d3bc2a0572" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609", - "reference": "4e78d7d47061fa183639927ec40d607973699609", + "url": "https://api.github.com/repos/symfony/string/zipball/ad0bd91bce2054103f5eaa18ebeba8d3bc2a0572", + "reference": "ad0bd91bce2054103f5eaa18ebeba8d3bc2a0572", "shasum": "" }, "require": { @@ -4642,7 +4642,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.4" + "source": "https://github.com/symfony/string/tree/v5.2.6" }, "funding": [ { @@ -4658,20 +4658,20 @@ "type": "tidelift" } ], - "time": "2021-02-16T10:20:28+00:00" + "time": "2021-03-17T17:12:15+00:00" }, { "name": "symfony/translation", - "version": "v5.2.5", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "0947ab1e3aabd22a6bef393874b2555d2bb976da" + "reference": "2cc7f45d96db9adfcf89adf4401d9dfed509f4e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/0947ab1e3aabd22a6bef393874b2555d2bb976da", - "reference": "0947ab1e3aabd22a6bef393874b2555d2bb976da", + "url": "https://api.github.com/repos/symfony/translation/zipball/2cc7f45d96db9adfcf89adf4401d9dfed509f4e1", + "reference": "2cc7f45d96db9adfcf89adf4401d9dfed509f4e1", "shasum": "" }, "require": { @@ -4735,7 +4735,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.2.5" + "source": "https://github.com/symfony/translation/tree/v5.2.6" }, "funding": [ { @@ -4751,7 +4751,7 @@ "type": "tidelift" } ], - "time": "2021-03-06T07:59:01+00:00" + "time": "2021-03-23T19:33:48+00:00" }, { "name": "symfony/translation-contracts", @@ -4833,16 +4833,16 @@ }, { "name": "symfony/var-dumper", - "version": "v5.2.5", + "version": "v5.2.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "002ab5a36702adf0c9a11e6d8836623253e9045e" + "reference": "89412a68ea2e675b4e44f260a5666729f77f668e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/002ab5a36702adf0c9a11e6d8836623253e9045e", - "reference": "002ab5a36702adf0c9a11e6d8836623253e9045e", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/89412a68ea2e675b4e44f260a5666729f77f668e", + "reference": "89412a68ea2e675b4e44f260a5666729f77f668e", "shasum": "" }, "require": { @@ -4901,7 +4901,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.2.5" + "source": "https://github.com/symfony/var-dumper/tree/v5.2.6" }, "funding": [ { @@ -4917,7 +4917,7 @@ "type": "tidelift" } ], - "time": "2021-03-06T07:59:01+00:00" + "time": "2021-03-28T09:42:18+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -5257,16 +5257,16 @@ }, { "name": "facade/flare-client-php", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/facade/flare-client-php.git", - "reference": "ef0f5bce23b30b32d98fd9bb49c6fa37b40eb546" + "reference": "9dd6f2b56486d939c4467b3f35475d44af57cf17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/flare-client-php/zipball/ef0f5bce23b30b32d98fd9bb49c6fa37b40eb546", - "reference": "ef0f5bce23b30b32d98fd9bb49c6fa37b40eb546", + "url": "https://api.github.com/repos/facade/flare-client-php/zipball/9dd6f2b56486d939c4467b3f35475d44af57cf17", + "reference": "9dd6f2b56486d939c4467b3f35475d44af57cf17", "shasum": "" }, "require": { @@ -5310,7 +5310,7 @@ ], "support": { "issues": "https://github.com/facade/flare-client-php/issues", - "source": "https://github.com/facade/flare-client-php/tree/1.4.0" + "source": "https://github.com/facade/flare-client-php/tree/1.5.0" }, "funding": [ { @@ -5318,20 +5318,20 @@ "type": "github" } ], - "time": "2021-02-16T12:42:06+00:00" + "time": "2021-03-31T07:32:54+00:00" }, { "name": "facade/ignition", - "version": "2.5.14", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/facade/ignition.git", - "reference": "17097f7a83e200d90d1cf9f4d1b35c1001513a47" + "reference": "bdc8b0b32c888f6edc838ca641358322b3d9506d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition/zipball/17097f7a83e200d90d1cf9f4d1b35c1001513a47", - "reference": "17097f7a83e200d90d1cf9f4d1b35c1001513a47", + "url": "https://api.github.com/repos/facade/ignition/zipball/bdc8b0b32c888f6edc838ca641358322b3d9506d", + "reference": "bdc8b0b32c888f6edc838ca641358322b3d9506d", "shasum": "" }, "require": { @@ -5395,7 +5395,7 @@ "issues": "https://github.com/facade/ignition/issues", "source": "https://github.com/facade/ignition" }, - "time": "2021-03-04T08:48:01+00:00" + "time": "2021-03-30T15:55:38+00:00" }, { "name": "facade/ignition-contracts", @@ -5452,16 +5452,16 @@ }, { "name": "filp/whoops", - "version": "2.11.0", + "version": "2.12.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "f6e14679f948d8a5cfb866fa7065a30c66bd64d3" + "reference": "d501fd2658d55491a2295ff600ae5978eaad7403" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/f6e14679f948d8a5cfb866fa7065a30c66bd64d3", - "reference": "f6e14679f948d8a5cfb866fa7065a30c66bd64d3", + "url": "https://api.github.com/repos/filp/whoops/zipball/d501fd2658d55491a2295ff600ae5978eaad7403", + "reference": "d501fd2658d55491a2295ff600ae5978eaad7403", "shasum": "" }, "require": { @@ -5511,7 +5511,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.11.0" + "source": "https://github.com/filp/whoops/tree/2.12.0" }, "funding": [ { @@ -5519,7 +5519,7 @@ "type": "github" } ], - "time": "2021-03-19T12:00:00+00:00" + "time": "2021-03-30T12:00:00+00:00" }, { "name": "fzaninotto/faker", @@ -6183,16 +6183,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.5", + "version": "9.2.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1" + "reference": "f6293e1b30a2354e8428e004689671b83871edde" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f3e026641cc91909d421802dd3ac7827ebfd97e1", - "reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde", + "reference": "f6293e1b30a2354e8428e004689671b83871edde", "shasum": "" }, "require": { @@ -6248,7 +6248,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.5" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6" }, "funding": [ { @@ -6256,7 +6256,7 @@ "type": "github" } ], - "time": "2020-11-28T06:44:49+00:00" + "time": "2021-03-28T07:26:59+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/flexisip-account-manager.spec b/flexisip-account-manager.spec index 8265750..d437048 100644 --- a/flexisip-account-manager.spec +++ b/flexisip-account-manager.spec @@ -8,7 +8,7 @@ #%define _datadir %{_datarootdir} #%define _docdir %{_datadir}/doc -%define build_number 55 +%define build_number 56 %define var_dir /var/opt/belledonne-communications %define opt_dir /opt/belledonne-communications/share/flexisip-account-manager %define env_file "$RPM_BUILD_ROOT/etc/flexisip-account-manager/flexiapi.env"