Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ohseesoftware/laravel-assert-encrypted
Adds a trait to assert an encrypted value in the database.
https://github.com/ohseesoftware/laravel-assert-encrypted
assertions encryption laravel php testing
Last synced: 20 days ago
JSON representation
Adds a trait to assert an encrypted value in the database.
- Host: GitHub
- URL: https://github.com/ohseesoftware/laravel-assert-encrypted
- Owner: ohseesoftware
- License: mit
- Created: 2020-05-03T01:49:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-30T20:17:40.000Z (about 4 years ago)
- Last Synced: 2024-12-17T18:49:21.017Z (about 1 month ago)
- Topics: assertions, encryption, laravel, php, testing
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Assert Encrypted
[![Current Release](https://img.shields.io/github/release/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://github.com/ohseesoftware/laravel-assert-encrypted/releases)
![Build Status Badge](https://github.com/ohseesoftware/laravel-assert-encrypted/workflows/Build/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/ohseesoftware/laravel-assert-encrypted/badge.svg?branch=master)](https://coveralls.io/github/ohseesoftware/laravel-assert-encrypted?branch=master)
[![Maintainability Score](https://img.shields.io/codeclimate/maintainability/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://codeclimate.com/github/ohseesoftware/laravel-assert-encrypted)
[![Downloads](https://img.shields.io/packagist/dt/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://packagist.org/packages/ohseesoftware/laravel-assert-encrypted)
[![MIT License](https://img.shields.io/github/license/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://github.com/ohseesoftware/laravel-assert-encrypted/blob/master/LICENSE)Add an assertion to test for encrypted values in your database.
## Install
```
composer require ohseesoftware/laravel-assert-encrypted
```## Usage
Say you have an encrypted value in your database:
```php
User::create([
'name' => 'John Doe',
'secret' => encrypt('api-key')
]);
```It's a bit hard to test the value of `secret` in the database because there's randomness in `encrypt()`. This means `encrypt('value') !== encrypt('value')`.
To get around this, you can use the trait exposed in this package in your tests:
```php
create([
'secret' => encrypt('api-key')
]);// Then
$this->assertEncrypted('users', ['id' => $user->id], [
'secret' => 'api-key'
]);// assertEncrypted is an alias for assertEncryptedSerialized
// since encrypt by default serializes the passed value
}
}
```If your values are not serialized before encryption, you can use the `assertEncryptedUnserialized` assertion.
```php
create([
'secret' => encrypt('api-key', false)
]);// Then
$this->assertEncryptedUnserialized('users', ['id' => $user->id], [
'secret' => 'api-key'
]);
}
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Owen Conti](https://github.com/ohseesoftware)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## Laravel Package Boilerplate
This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).