{"id":23879552,"url":"https://github.com/ohseesoftware/laravel-assert-encrypted","last_synced_at":"2025-04-09T17:45:12.601Z","repository":{"id":56169800,"uuid":"260809309","full_name":"ohseesoftware/laravel-assert-encrypted","owner":"ohseesoftware","description":"Adds a trait to assert an encrypted value in the database.","archived":false,"fork":false,"pushed_at":"2020-12-30T20:17:40.000Z","size":29,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T19:51:20.581Z","etag":null,"topics":["assertions","encryption","laravel","php","testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohseesoftware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-03T01:49:42.000Z","updated_at":"2022-05-30T11:34:16.000Z","dependencies_parsed_at":"2022-08-15T14:00:44.930Z","dependency_job_id":null,"html_url":"https://github.com/ohseesoftware/laravel-assert-encrypted","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":"ohseesoftware/laravel-package-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Flaravel-assert-encrypted","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Flaravel-assert-encrypted/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Flaravel-assert-encrypted/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Flaravel-assert-encrypted/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohseesoftware","download_url":"https://codeload.github.com/ohseesoftware/laravel-assert-encrypted/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248080747,"owners_count":21044551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","encryption","laravel","php","testing"],"created_at":"2025-01-03T23:17:59.032Z","updated_at":"2025-04-09T17:45:12.557Z","avatar_url":"https://github.com/ohseesoftware.png","language":"PHP","readme":"# Laravel Assert Encrypted\n\n[![Current Release](https://img.shields.io/github/release/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://github.com/ohseesoftware/laravel-assert-encrypted/releases)\n![Build Status Badge](https://github.com/ohseesoftware/laravel-assert-encrypted/workflows/Build/badge.svg)\n[![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)\n[![Maintainability Score](https://img.shields.io/codeclimate/maintainability/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://codeclimate.com/github/ohseesoftware/laravel-assert-encrypted)\n[![Downloads](https://img.shields.io/packagist/dt/ohseesoftware/laravel-assert-encrypted.svg?style=flat-square)](https://packagist.org/packages/ohseesoftware/laravel-assert-encrypted)\n[![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)\n\nAdd an assertion to test for encrypted values in your database.\n\n## Install\n\n```\ncomposer require ohseesoftware/laravel-assert-encrypted\n```\n\n## Usage\n\nSay you have an encrypted value in your database:\n\n```php\nUser::create([\n    'name' =\u003e 'John Doe',\n    'secret' =\u003e encrypt('api-key')\n]);\n```\n\nIt'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')`.\n\nTo get around this, you can use the trait exposed in this package in your tests:\n\n```php\n\u003c?php\n\nnamespace Tests;\n\nuse OhSeeSoftware\\LaravelAssertEncrypted\\Traits\\AssertEncrypted;\n\nclass SomeTest extends TestCase\n{\n    use AssertEncrypted;\n\n    /** @test */\n    public function it_stores_users_secrets()\n    {\n        // Given\n        $user = factory(User::class)-\u003ecreate([\n            'secret' =\u003e encrypt('api-key')\n        ]);\n\n        // Then\n        $this-\u003eassertEncrypted('users', ['id' =\u003e $user-\u003eid], [\n            'secret' =\u003e 'api-key'\n        ]);\n\n        // assertEncrypted is an alias for assertEncryptedSerialized\n        // since encrypt by default serializes the passed value\n    }\n}\n```\n\nIf your values are not serialized before encryption, you can use the `assertEncryptedUnserialized` assertion.\n\n```php\n\u003c?php\n\n /** @test */\npublic function it_stores_users_secrets()\n{\n    // Given\n    $user = factory(User::class)-\u003ecreate([\n        'secret' =\u003e encrypt('api-key', false)\n    ]);\n\n    // Then\n    $this-\u003eassertEncryptedUnserialized('users', ['id' =\u003e $user-\u003eid], [\n        'secret' =\u003e 'api-key'\n    ]);\n}\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email security@ohseesoftware.com instead of using the issue tracker.\n\n## Credits\n\n-   [Owen Conti](https://github.com/ohseesoftware)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Laravel Package Boilerplate\n\nThis package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohseesoftware%2Flaravel-assert-encrypted","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohseesoftware%2Flaravel-assert-encrypted","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohseesoftware%2Flaravel-assert-encrypted/lists"}