From 68417a4c153cf8432e048878d473eb4347cccb67 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 26 Apr 2023 13:01:42 -0700 Subject: [PATCH 01/10] Env-ify hashing variables, setting the normal defaults Signed-off-by: snipe --- .env.example | 9 +++++++++ config/hashing.php | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index c523ef0c0..fbf5c4cff 100644 --- a/.env.example +++ b/.env.example @@ -175,6 +175,15 @@ REQUIRE_SAML=false API_THROTTLE_PER_MINUTE=120 CSV_ESCAPE_FORMULAS=true +# -------------------------------------------- +# OPTIONAL: HASHING +# -------------------------------------------- +HASHING_DRIVER='bcrypt' +BCRYPT_ROUNDS=10 +ARGON_MEMORY=1024 +ARGON_THREADS=2 +ARGON_TIME=2 + # -------------------------------------------- # OPTIONAL: SCIM # -------------------------------------------- diff --git a/config/hashing.php b/config/hashing.php index d3c8e2fb2..06f18a0c6 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -15,7 +15,7 @@ return [ | */ - 'driver' => 'bcrypt', + 'driver' => env('HASHING_DRIVER', 'bcrypt'), /* |-------------------------------------------------------------------------- @@ -44,9 +44,9 @@ return [ */ 'argon' => [ - 'memory' => 1024, - 'threads' => 2, - 'time' => 2, + 'memory' => env('ARGON_MEMORY', 1024), + 'threads' => env('ARGON_THREADS', 2), + 'time' => env('ARGON_TIME', 2), ], ]; From 67a2b796a421550577a46839881f1d82daa21cb8 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 27 Apr 2023 19:19:53 -0400 Subject: [PATCH 02/10] requested edits --- app/Presenters/LicensePresenter.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.php index 5a44bf52a..f2d54549e 100644 --- a/app/Presenters/LicensePresenter.php +++ b/app/Presenters/LicensePresenter.php @@ -151,6 +151,21 @@ class LicensePresenter extends Presenter 'visible' => false, 'title' => trans('general.order_number'), ], [ + 'field' => 'created_at', + 'searchable' => false, + 'sortable' => true, + 'visible' => false, + 'title' => trans('general.created_at'), + 'formatter' => 'dateDisplayFormatter', + ], [ + 'field' => 'updated_at', + 'searchable' => false, + 'sortable' => true, + 'visible' => false, + 'title' => trans('general.updated_at'), + 'formatter' => 'dateDisplayFormatter', + ], + [ 'field' => 'notes', 'searchable' => true, 'sortable' => true, From 567e19bcc09335a9322ca4344133b1398d5bb197 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 27 Apr 2023 16:26:50 -0700 Subject: [PATCH 03/10] Added missing case for licenses for item_count Signed-off-by: snipe --- app/Http/Transformers/CategoriesTransformer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index faf05f7f4..d5e1ceb51 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -38,6 +38,9 @@ class CategoriesTransformer case 'component': $category->item_count = $category->components_count; break; + case 'license': + $category->item_count = $category->licenses_count; + break; default: $category->item_count = 0; } From aa814cf761633e3a1cb34f077b89b3b41ad5c35e Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 29 Apr 2023 13:47:52 -0700 Subject: [PATCH 04/10] Fixed #12946 - warranty lookup url was not nullable Signed-off-by: snipe --- app/Models/Manufacturer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index eb91b3b8f..da4f26b02 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -25,7 +25,7 @@ class Manufacturer extends SnipeModel 'url' => 'url|nullable', 'support_email' => 'email|nullable', 'support_url' => 'nullable|url', - 'warranty_lookup_url' => 'starts_with:http://,https://,afp://,facetime://,file://,irc://','nullable' + 'warranty_lookup_url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://' ]; protected $hidden = ['user_id']; From 8ad600085ae82857cacdcb5ee5080beccef21193 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 30 Apr 2023 18:17:56 -0700 Subject: [PATCH 05/10] Moved external link icon into link Signed-off-by: snipe --- resources/views/partials/bootstrap-table.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 3f263dd96..76e60a22a 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -514,7 +514,7 @@ if (value) { if ((value.indexOf("{") === -1) || (value.indexOf("}") ===-1)) { - return ' ' + value + ''; + return ' ' + value + ''; } return value; } From 0222a922a1366864ef9bdfd89753ba81606d2f49 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 30 Apr 2023 18:20:23 -0700 Subject: [PATCH 06/10] Added tooltip Signed-off-by: snipe --- resources/views/partials/bootstrap-table.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 76e60a22a..e02e187d1 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -514,7 +514,7 @@ if (value) { if ((value.indexOf("{") === -1) || (value.indexOf("}") ===-1)) { - return ' ' + value + ''; + return ' ' + value + ''; } return value; } From 031c9c12045b9862bdb51be4eb56df18015db546 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 30 Apr 2023 18:40:40 -0700 Subject: [PATCH 07/10] Added nobr tag to prevent external link icon and link from breaking Signed-off-by: snipe --- resources/views/partials/bootstrap-table.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index e02e187d1..5233c4b7e 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -514,7 +514,7 @@ if (value) { if ((value.indexOf("{") === -1) || (value.indexOf("}") ===-1)) { - return ' ' + value + ''; + return ' ' + value + ''; } return value; } From 6d594faae7510719d01793593fddf12cfef77c74 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 1 May 2023 16:04:43 -0700 Subject: [PATCH 08/10] Clear the settings cache on app destruction --- tests/Support/InteractsWithSettings.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Support/InteractsWithSettings.php b/tests/Support/InteractsWithSettings.php index 1de9e7bc1..aae1aab9d 100644 --- a/tests/Support/InteractsWithSettings.php +++ b/tests/Support/InteractsWithSettings.php @@ -2,6 +2,8 @@ namespace Tests\Support; +use App\Models\Setting; + trait InteractsWithSettings { protected Settings $settings; @@ -9,5 +11,7 @@ trait InteractsWithSettings public function setUpSettings() { $this->settings = Settings::initialize(); + + $this->beforeApplicationDestroyed(fn() => Setting::$_cache = null); } } From da08f6ef8cd3398d3fe09c3b642427812ebd0626 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 1 May 2023 16:05:26 -0700 Subject: [PATCH 09/10] Add InteractsWithSettings trait to required tests --- tests/Unit/AssetMaintenanceTest.php | 3 +++ tests/Unit/AssetModelTest.php | 3 +++ tests/Unit/AssetTest.php | 3 +++ tests/Unit/CategoryTest.php | 3 +++ tests/Unit/ComponentTest.php | 3 +++ tests/Unit/DepreciationTest.php | 3 +++ tests/Unit/NotificationTest.php | 3 +++ tests/Unit/SnipeModelTest.php | 3 +++ 8 files changed, 24 insertions(+) diff --git a/tests/Unit/AssetMaintenanceTest.php b/tests/Unit/AssetMaintenanceTest.php index 31b68c0cf..b5ee25cf2 100644 --- a/tests/Unit/AssetMaintenanceTest.php +++ b/tests/Unit/AssetMaintenanceTest.php @@ -3,10 +3,13 @@ namespace Tests\Unit; use App\Models\AssetMaintenance; use Carbon\Carbon; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class AssetMaintenanceTest extends TestCase { + use InteractsWithSettings; + public function testZerosOutWarrantyIfBlank() { $c = new AssetMaintenance; diff --git a/tests/Unit/AssetModelTest.php b/tests/Unit/AssetModelTest.php index 7050ea307..8771187b2 100644 --- a/tests/Unit/AssetModelTest.php +++ b/tests/Unit/AssetModelTest.php @@ -4,10 +4,13 @@ namespace Tests\Unit; use App\Models\Asset; use App\Models\Category; use App\Models\AssetModel; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class AssetModelTest extends TestCase { + use InteractsWithSettings; + public function testAnAssetModelZerosOutBlankEols() { $am = new AssetModel; diff --git a/tests/Unit/AssetTest.php b/tests/Unit/AssetTest.php index e4dc8a803..432165dc0 100644 --- a/tests/Unit/AssetTest.php +++ b/tests/Unit/AssetTest.php @@ -5,10 +5,13 @@ use App\Models\Asset; use App\Models\AssetModel; use App\Models\Category; use Carbon\Carbon; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class AssetTest extends TestCase { + use InteractsWithSettings; + // public function testAutoIncrementMixed() // { // $expected = '123411'; diff --git a/tests/Unit/CategoryTest.php b/tests/Unit/CategoryTest.php index 387ed946e..c74597b1b 100644 --- a/tests/Unit/CategoryTest.php +++ b/tests/Unit/CategoryTest.php @@ -4,10 +4,13 @@ namespace Tests\Unit; use App\Models\Category; use App\Models\AssetModel; use App\Models\Asset; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class CategoryTest extends TestCase { + use InteractsWithSettings; + public function testFailsEmptyValidation() { // An Asset requires a name, a qty, and a category_id. diff --git a/tests/Unit/ComponentTest.php b/tests/Unit/ComponentTest.php index df8f64771..8f71057bf 100644 --- a/tests/Unit/ComponentTest.php +++ b/tests/Unit/ComponentTest.php @@ -5,10 +5,13 @@ use App\Models\Category; use App\Models\Company; use App\Models\Component; use App\Models\Location; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class ComponentTest extends TestCase { + use InteractsWithSettings; + public function testAComponentBelongsToACompany() { $component = Component::factory() diff --git a/tests/Unit/DepreciationTest.php b/tests/Unit/DepreciationTest.php index 4dd842227..ed033cf44 100644 --- a/tests/Unit/DepreciationTest.php +++ b/tests/Unit/DepreciationTest.php @@ -5,10 +5,13 @@ use App\Models\Depreciation; use App\Models\Category; use App\Models\License; use App\Models\AssetModel; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class DepreciationTest extends TestCase { + use InteractsWithSettings; + public function testADepreciationHasModels() { $depreciation = Depreciation::factory()->create(); diff --git a/tests/Unit/NotificationTest.php b/tests/Unit/NotificationTest.php index 8005759a1..64cf8afb0 100644 --- a/tests/Unit/NotificationTest.php +++ b/tests/Unit/NotificationTest.php @@ -8,10 +8,13 @@ use App\Models\Category; use Carbon\Carbon; use App\Notifications\CheckoutAssetNotification; use Illuminate\Support\Facades\Notification; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class NotificationTest extends TestCase { + use InteractsWithSettings; + public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA() { $admin = User::factory()->superuser()->create(); diff --git a/tests/Unit/SnipeModelTest.php b/tests/Unit/SnipeModelTest.php index 2bc81da61..ad4231010 100644 --- a/tests/Unit/SnipeModelTest.php +++ b/tests/Unit/SnipeModelTest.php @@ -2,10 +2,13 @@ namespace Tests\Unit; use App\Models\SnipeModel; +use Tests\Support\InteractsWithSettings; use Tests\TestCase; class SnipeModelTest extends TestCase { + use InteractsWithSettings; + public function testSetsPurchaseDatesAppropriately() { $c = new SnipeModel; From f7d2b62d875c9c8f348b896a5e114243f5f5ceb2 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 1 May 2023 16:06:28 -0700 Subject: [PATCH 10/10] Improve method name --- tests/Support/InteractsWithSettings.php | 2 +- tests/TestCase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Support/InteractsWithSettings.php b/tests/Support/InteractsWithSettings.php index aae1aab9d..a8c007018 100644 --- a/tests/Support/InteractsWithSettings.php +++ b/tests/Support/InteractsWithSettings.php @@ -8,7 +8,7 @@ trait InteractsWithSettings { protected Settings $settings; - public function setUpSettings() + public function initializeSettings() { $this->settings = Settings::initialize(); diff --git a/tests/TestCase.php b/tests/TestCase.php index e3fd8a7aa..28051c7c7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -23,7 +23,7 @@ abstract class TestCase extends BaseTestCase $this->withoutMiddleware($this->globallyDisabledMiddleware); if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) { - $this->setUpSettings(); + $this->initializeSettings(); } } }