mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Separate test methods
This commit is contained in:
parent
c6d9da1571
commit
e47f64f62d
|
@ -482,15 +482,15 @@ class AssetStoreTest extends TestCase
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEncryptedCustomField()
|
public function testEncryptedCustomFieldCanBeStored()
|
||||||
{
|
{
|
||||||
$field = CustomField::factory()->testEncrypted()->create();
|
$field = CustomField::factory()->testEncrypted()->create();
|
||||||
$asset = Asset::factory()->hasEncryptedCustomField()->create();
|
$asset = Asset::factory()->hasEncryptedCustomField()->create();
|
||||||
$superuser = User::factory()->superuser()->create();
|
$superuser = User::factory()->superuser()->create();
|
||||||
$normal_user = User::factory()->editAssets()->create();
|
|
||||||
|
|
||||||
//first, test that an Admin user can save the encrypted custom field
|
//first, test that an Admin user can save the encrypted custom field
|
||||||
$response = $this->actingAsForApi($superuser)
|
$response = $this->actingAsForApi($superuser)
|
||||||
|
// @todo: target store method
|
||||||
->patchJson(route('api.assets.update', $asset->id), [
|
->patchJson(route('api.assets.update', $asset->id), [
|
||||||
$field->db_column_name() => 'This is encrypted field'
|
$field->db_column_name() => 'This is encrypted field'
|
||||||
])
|
])
|
||||||
|
@ -499,9 +499,17 @@ class AssetStoreTest extends TestCase
|
||||||
->json();
|
->json();
|
||||||
$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 testPermissionNeededToStoreEncryptedField()
|
||||||
|
{
|
||||||
|
$field = CustomField::factory()->testEncrypted()->create();
|
||||||
|
$asset = Asset::factory()->hasEncryptedCustomField()->create();
|
||||||
|
$normal_user = User::factory()->editAssets()->create();
|
||||||
|
|
||||||
//next, test that a 'normal' user *cannot* change the encrypted custom field
|
//next, test that a 'normal' user *cannot* change the encrypted custom field
|
||||||
$response = $this->actingAsForApi($normal_user)
|
$response = $this->actingAsForApi($normal_user)
|
||||||
|
// @todo: target store method
|
||||||
->patchJson(route('api.assets.update', $asset->id), [
|
->patchJson(route('api.assets.update', $asset->id), [
|
||||||
$field->db_column_name() => 'Some Other Value Entirely!'
|
$field->db_column_name() => 'Some Other Value Entirely!'
|
||||||
])
|
])
|
||||||
|
@ -511,6 +519,5 @@ class AssetStoreTest extends TestCase
|
||||||
->json();
|
->json();
|
||||||
$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()}));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,5 @@ class AssetUpdateTest extends TestCase
|
||||||
->json();
|
->json();
|
||||||
$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()}));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue