Import facade

This commit is contained in:
Marcus Moore 2024-04-16 17:14:17 -07:00
parent f763aea4fc
commit 9d0ea857fe
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View file

@ -10,6 +10,7 @@ use App\Models\Location;
use App\Models\Statuslabel; use App\Models\Statuslabel;
use App\Models\Supplier; use App\Models\Supplier;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Testing\Fluent\AssertableJson; use Illuminate\Testing\Fluent\AssertableJson;
use Tests\TestCase; use Tests\TestCase;
@ -500,7 +501,7 @@ class AssetStoreTest extends TestCase
->json(); ->json();
$asset = Asset::findOrFail($response['payload']['id']); $asset = Asset::findOrFail($response['payload']['id']);
$this->assertEquals('This is encrypted field', \Crypt::decrypt($asset->{$field->db_column_name()})); $this->assertEquals('This is encrypted field', Crypt::decrypt($asset->{$field->db_column_name()}));
} }
public function testPermissionNeededToStoreEncryptedField() public function testPermissionNeededToStoreEncryptedField()
@ -527,6 +528,6 @@ class AssetStoreTest extends TestCase
->json(); ->json();
$asset = Asset::findOrFail($response['payload']['id']); $asset = Asset::findOrFail($response['payload']['id']);
$this->assertEquals('This is encrypted field', \Crypt::decrypt($asset->{$field->db_column_name()})); $this->assertEquals('This is encrypted field', Crypt::decrypt($asset->{$field->db_column_name()}));
} }
} }

View file

@ -5,6 +5,7 @@ namespace Tests\Feature\Api\Assets;
use App\Models\Asset; use App\Models\Asset;
use App\Models\CustomField; use App\Models\CustomField;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Crypt;
use Tests\TestCase; use Tests\TestCase;
class AssetUpdateTest extends TestCase class AssetUpdateTest extends TestCase
@ -23,7 +24,7 @@ class AssetUpdateTest extends TestCase
->assertOk(); ->assertOk();
$asset->refresh(); $asset->refresh();
$this->assertEquals('This is encrypted field', \Crypt::decrypt($asset->{$field->db_column_name()})); $this->assertEquals('This is encrypted field', Crypt::decrypt($asset->{$field->db_column_name()}));
} }
public function testPermissionNeededToUpdateEncryptedField() public function testPermissionNeededToUpdateEncryptedField()
@ -32,7 +33,7 @@ class AssetUpdateTest extends TestCase
$asset = Asset::factory()->hasEncryptedCustomField($field)->create(); $asset = Asset::factory()->hasEncryptedCustomField($field)->create();
$normal_user = User::factory()->editAssets()->create(); $normal_user = User::factory()->editAssets()->create();
$asset->{$field->db_column_name()} = \Crypt::encrypt("encrypted value should not change"); $asset->{$field->db_column_name()} = Crypt::encrypt("encrypted value should not change");
$asset->save(); $asset->save();
// test that a 'normal' user *cannot* change the encrypted custom field // test that a 'normal' user *cannot* change the encrypted custom field
@ -45,6 +46,6 @@ class AssetUpdateTest extends TestCase
->assertMessagesAre('Asset updated successfully, but encrypted custom fields were not due to permissions'); ->assertMessagesAre('Asset updated successfully, but encrypted custom fields were not due to permissions');
$asset->refresh(); $asset->refresh();
$this->assertEquals("encrypted value should not change", \Crypt::decrypt($asset->{$field->db_column_name()})); $this->assertEquals("encrypted value should not change", Crypt::decrypt($asset->{$field->db_column_name()}));
} }
} }