Skip to content

Commit

Permalink
Merge pull request #24 from exonet/dependabot/github_actions/actions/…
Browse files Browse the repository at this point in the history
…checkout-4

Bump actions/checkout from 3 to 4
  • Loading branch information
robbinjanssen authored Sep 5, 2023
2 parents 9755ce3 + 1d90a56 commit e7a77f9
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📦 Composer install
uses: php-actions/composer@v6
Expand All @@ -41,7 +41,7 @@ jobs:

steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 🚀 Run Label Syncer
uses: micnncim/action-label-syncer@v1
Expand Down
95 changes: 47 additions & 48 deletions src/Laravel/tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Illuminate\Contracts\Events\Dispatcher as Event;
use Illuminate\Contracts\Filesystem\Factory as Storage;
use Illuminate\Foundation\Testing\TestCase;
use Mockery;

/**
* @internal
Expand Down Expand Up @@ -50,11 +49,11 @@ public function testEncrypt()
{
Carbon::setTestNow(Carbon::create(2018, 4, 24, 9, 32, 33));

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$configMock->shouldReceive('get')->withArgs(['secure_messages.meta_key'])->once()->andReturn('metaKey');
$configMock->shouldReceive('get')->withArgs(['secure_messages.storage_disk_name'])->once()->andReturn('secure_messages');
Expand All @@ -70,7 +69,7 @@ public function testEncrypt()

$encrypterMock
->shouldReceive('encrypt')
->withArgs([Mockery::any()])
->withArgs([\Mockery::any()])
->times(4)
->andReturn('encryptedKey', 'encryptedMeta', 'encryptedContent', 'encryptedDbKey');

Expand All @@ -92,11 +91,11 @@ public function testDecryptMessage()
'content' => 'encryptedContent',
]);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand All @@ -114,7 +113,7 @@ public function testDecryptMessage()
$storageMock->shouldReceive('get')->withArgs(['unitTest'])->twice()->andReturn('encryptedStorageKey');

$secureMessageFactoryMock->shouldReceive('setMetaKey')->withArgs(['metaKey'])->once()->andReturnSelf();
$secureMessageFactoryMock->shouldReceive('decrypt')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$secureMessageFactoryMock->shouldReceive('decrypt')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('unitTest', $secureMessage->getId());
$this->assertSame('databaseKey', $secureMessage->getDatabaseKey());
$this->assertSame('storageKey', $secureMessage->getStorageKey());
Expand All @@ -140,11 +139,11 @@ public function testCheckVerificationCode()
'content' => 'encryptedContent',
]);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand All @@ -162,7 +161,7 @@ public function testCheckVerificationCode()
$storageMock->shouldReceive('get')->withArgs(['unitTest'])->once()->andReturn('encryptedStorageKey');

$secureMessageFactoryMock->shouldReceive('setMetaKey')->withArgs(['metaKey'])->once()->andReturnSelf();
$secureMessageFactoryMock->shouldReceive('validateEncryptionKey')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$secureMessageFactoryMock->shouldReceive('validateEncryptionKey')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('unitTest', $secureMessage->getId());
$this->assertSame('databaseKey', $secureMessage->getDatabaseKey());
$this->assertSame('storageKey', $secureMessage->getStorageKey());
Expand All @@ -187,11 +186,11 @@ public function testDecryptMessageStorageKeyNotFound()
'content' => 'encryptedContent',
]);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand All @@ -209,7 +208,7 @@ public function testDecryptMessageStorageKeyNotFound()

$secureMessageFactoryMock->shouldReceive('setMetaKey')->withArgs(['metaKey'])->once()->andReturnSelf();

$eventMock->shouldReceive('dispatch')->withArgs([Mockery::on(function ($event) {
$eventMock->shouldReceive('dispatch')->withArgs([\Mockery::on(function ($event) {
return get_class($event) === DecryptionFailed::class;
})])->once();

Expand All @@ -229,11 +228,11 @@ public function testDecryptMessageHitpointLimitReached()
'content' => 'encryptedContent',
]);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand All @@ -253,7 +252,7 @@ public function testDecryptMessageHitpointLimitReached()
$secureMessageFactoryMock->shouldReceive('setMetaKey')->withArgs(['metaKey'])->once()->andReturnSelf();
$secureMessageFactoryMock->shouldReceive('decrypt')->withAnyArgs()->once()->andThrow(new HitPointLimitReachedException('The maximum number of hit points is reached.'));

$eventMock->shouldReceive('dispatch')->withArgs([Mockery::on(function ($event) {
$eventMock->shouldReceive('dispatch')->withArgs([\Mockery::on(function ($event) {
return get_class($event) === HitPointLimitReached::class;
})])->once();

Expand All @@ -272,11 +271,11 @@ public function testDecryptMessageMessageExpired()
'content' => 'encryptedContent',
]);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand All @@ -296,7 +295,7 @@ public function testDecryptMessageMessageExpired()
$secureMessageFactoryMock->shouldReceive('setMetaKey')->withArgs(['metaKey'])->once()->andReturnSelf();
$secureMessageFactoryMock->shouldReceive('decrypt')->withAnyArgs()->once()->andThrow(new ExpiredException('This secure message is expired.'));

$eventMock->shouldReceive('dispatch')->withArgs([Mockery::on(function ($event) {
$eventMock->shouldReceive('dispatch')->withArgs([\Mockery::on(function ($event) {
return get_class($event) === SecureMessageExpired::class;
})])->once();

Expand All @@ -315,11 +314,11 @@ public function testDecryptMeta()
'content' => 'encryptedContent',
]);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand All @@ -332,7 +331,7 @@ public function testDecryptMeta()
$storageMock->shouldReceive('disk')->withArgs(['secure_messages'])->once()->andReturnSelf();

$secureMessageFactoryMock->shouldReceive('setMetaKey')->withArgs(['metaKey'])->once()->andReturnSelf();
$secureMessageFactoryMock->shouldReceive('decryptMeta')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$secureMessageFactoryMock->shouldReceive('decryptMeta')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('unitTest', $secureMessage->getId());
$this->assertSame('meta', $secureMessage->getEncryptedMeta());

Expand All @@ -348,11 +347,11 @@ public function testDestroy()
{
SecureMessageModel::insert(['id' => 'unitTest']);

$secureMessageFactoryMock = Mockery::mock(SecureMessageFactory::class);
$storageMock = Mockery::mock(Storage::class);
$encrypterMock = Mockery::mock(Encrypter::class);
$configMock = Mockery::mock(Config::class);
$eventMock = Mockery::mock(Event::class);
$secureMessageFactoryMock = \Mockery::mock(SecureMessageFactory::class);
$storageMock = \Mockery::mock(Storage::class);
$encrypterMock = \Mockery::mock(Encrypter::class);
$configMock = \Mockery::mock(Config::class);
$eventMock = \Mockery::mock(Event::class);

$decryptedSecureMessage = new SecureMessage();
$decryptedSecureMessage->setContent('Decrypted content');
Expand Down
7 changes: 3 additions & 4 deletions src/Laravel/tests/HousekeepingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Exonet\SecureMessage\SecureMessage;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\TestCase;
use Mockery;

/**
* @internal
Expand All @@ -25,8 +24,8 @@ public function createApplication()

public function testHandle()
{
$modelMock = Mockery::mock(SecureMessageModel::class);
$factoryMock = Mockery::mock(SecureMessageFactory::class);
$modelMock = \Mockery::mock(SecureMessageModel::class);
$factoryMock = \Mockery::mock(SecureMessageFactory::class);

$okSecureMessage = (new SecureMessage())->setId('abc')->setExpiresAt(time() + 10)->setHitPoints(3);
$expiredSecureMessage = (new SecureMessage())->setId('abc')->setExpiresAt(time() - 10)->setHitPoints(3);
Expand All @@ -42,7 +41,7 @@ public function testHandle()
$factoryMock->shouldReceive('destroy')->withArgs(['def'])->once();
$factoryMock->shouldReceive('destroy')->withArgs(['xyz'])->once();

$command = Mockery::mock(Housekeeping::class.'[getOutput,info]')->makePartial();
$command = \Mockery::mock(Housekeeping::class.'[getOutput,info]')->makePartial();
$command->shouldReceive('getOutput->isVerbose')->times(2)->andReturnTrue();
$command->shouldReceive('info')->withArgs(['Destroyed secure message [<comment>abc</comment>]'])->never();
$command->shouldReceive('info')->withArgs(['Destroyed secure message [<comment>def</comment>]'])->once();
Expand Down
17 changes: 8 additions & 9 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Exonet\SecureMessage\Exceptions\InvalidKeyLengthException;
use Exonet\SecureMessage\Factory;
use Exonet\SecureMessage\SecureMessage;
use Mockery;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -42,8 +41,8 @@ public function testEncrypt()
$factory = (new Factory('metaKey___'))->make('Unit Test', 3, 1337);
$secureMessageResult = new SecureMessage();

$cryptoMock = Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('encrypt')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$cryptoMock = \Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('encrypt')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('Unit Test', $secureMessage->getContent());
$this->assertSame(3, $secureMessage->getHitPoints());
$this->assertSame(1337, $secureMessage->getExpiresAt());
Expand All @@ -68,8 +67,8 @@ public function testDecrypt()
$secureMessage = new SecureMessage();
$secureMessage->setContent('Unit Test');

$cryptoMock = Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('decrypt')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$cryptoMock = \Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('decrypt')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('Unit Test', $secureMessage->getContent());
$this->assertNull($secureMessage->getMetaKey());

Expand All @@ -88,8 +87,8 @@ public function testDecryptMeta()
$secureMessage = new SecureMessage();
$secureMessage->setContent('Unit Test');

$cryptoMock = Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('decryptMeta')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$cryptoMock = \Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('decryptMeta')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('Unit Test', $secureMessage->getContent());
$this->assertNull($secureMessage->getMetaKey());

Expand All @@ -107,8 +106,8 @@ public function testValidateEncryptionKey()
$secureMessage = new SecureMessage();
$secureMessage->setContent('Unit Test');

$cryptoMock = Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('validateEncryptionKey')->withArgs([Mockery::on(function (SecureMessage $secureMessage) {
$cryptoMock = \Mockery::mock(Crypto::class);
$cryptoMock->shouldReceive('validateEncryptionKey')->withArgs([\Mockery::on(function (SecureMessage $secureMessage) {
$this->assertSame('Unit Test', $secureMessage->getContent());
$this->assertNull($secureMessage->getMetaKey());

Expand Down

0 comments on commit e7a77f9

Please sign in to comment.