Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b8bfef6
DoctrineEncryptStatusCommand SF 5 compatibility
metadan Jul 30, 2020
c57e1a5
DoctrineEncryptDatabaseCommand SF5 Compatibility
metadan Jul 30, 2020
a095323
DoctrineDecryptDatabaseCommand SF5 Compatibility
metadan Jul 30, 2020
c1d2420
Upgrade PHPUnit to 8+ and allow the package to be installed with PHP 8.0
Jan 23, 2021
917f3a2
Merge pull request #41 from metadan/patch-1
absolute-quantum Nov 20, 2021
d1d0157
Merge pull request #49 from sebb/upgrade-php-phpunit
absolute-quantum Nov 20, 2021
6a26176
Update composer.json
absolute-quantum Nov 20, 2021
7b82b1d
Okay github
absolute-quantum Nov 20, 2021
bc5c091
Weird bug sorry
absolute-quantum Nov 20, 2021
eb334a8
add function return type
flavou45 Jan 14, 2022
aa4aa7b
add symfony 6 support
flavou45 Jan 14, 2022
5be04a0
add symfony 6 support
flavou45 Jan 14, 2022
c5cf431
add symfony 6 support
flavou45 Jan 14, 2022
1dd6dcb
add symfony 6 support
flavou45 Jan 14, 2022
e9b5f26
add symfony 6 support
flavou45 Jan 14, 2022
d18e7e0
add symfony 6 support
flavou45 Jan 14, 2022
40e8f1c
add symfony 6 support
flavou45 Jan 14, 2022
4694b45
add symfony 6 support
flavou45 Jan 14, 2022
850e0c5
add symfony 6 support
flavou45 Jan 14, 2022
2c14e2f
add symfony 6 support
flavou45 Jan 14, 2022
8849a3e
add symfony 6 support
flavou45 Jan 14, 2022
a40c3da
add symfony 6 support
flavou45 Jan 14, 2022
bc883fc
add symfony 6 support
flavou45 Jan 14, 2022
03896aa
add symfony 6 support
flavou45 Jan 14, 2022
6ec8eba
add symfony 6 support
flavou45 Jan 18, 2022
98e218e
fix encrypt command bug
flavou45 Jan 18, 2022
dfeb64e
fix deprecated
flavou45 Jan 21, 2022
4146d88
Merge pull request #61 from flavou45/master
absolute-quantum Feb 8, 2022
63dca9f
Remove paragonie/sodium_compat dependency
brendt Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryDefuseTest::testPersistEntity":4,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryDefuseTest::testNoUpdateOnReadEncrypted":4,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryDefuseTest::testStoredDataIsEncrypted":4,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryHaliteTest::testPersistEntity":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryHaliteTest::testNoUpdateOnReadEncrypted":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryHaliteTest::testStoredDataIsEncrypted":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\DependencyInjection\\DoctrineEncryptExtensionTest::testConfigLoadCustom":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\HaliteEncryptorTest::testEncryptWithoutExtensionThrowsException":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\DefuseEncryptorTest::testEncrypt":4,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\DefuseEncryptorTest::testGenerateKey":4,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\HaliteEncryptorTest::testEncryptExtension":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\HaliteEncryptorTest::testGenerateKey":1,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsNoEncryptor":4},"times":{"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryDefuseTest::testPersistEntity":0.456,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryDefuseTest::testNoUpdateOnReadEncrypted":1.046,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryDefuseTest::testStoredDataIsEncrypted":0.654,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryHaliteTest::testPersistEntity":0.106,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryHaliteTest::testNoUpdateOnReadEncrypted":0.142,"Ambta\\DoctrineEncryptBundle\\Tests\\Functional\\BasicQueryTest\\BasicQueryHaliteTest::testStoredDataIsEncrypted":0.126,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\DependencyInjection\\DoctrineEncryptExtensionTest::testConfigLoadHalite":0.031,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\DependencyInjection\\DoctrineEncryptExtensionTest::testConfigLoadDefuse":0.012,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\DependencyInjection\\DoctrineEncryptExtensionTest::testConfigLoadCustom":0.013,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\DefuseEncryptorTest::testEncrypt":0.252,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\DefuseEncryptorTest::testGenerateKey":0.132,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\HaliteEncryptorTest::testEncryptExtension":0.005,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\HaliteEncryptorTest::testGenerateKey":0.008,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Encryptors\\HaliteEncryptorTest::testEncryptWithoutExtensionThrowsException":0.001,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testSetRestorEncryptor":0.01,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsEncrypt":0.003,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsEncryptExtend":0.003,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsEncryptEmbedded":0.004,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsEncryptNull":0.002,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsNoEncryptor":0.001,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsDecrypt":0.002,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsDecryptExtended":0.003,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsDecryptEmbedded":0.003,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsDecryptNull":0.002,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testProcessFieldsDecryptNonEncrypted":0.002,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testOnFlush":0.052,"Ambta\\DoctrineEncryptBundle\\Tests\\Unit\\Subscribers\\DoctrineEncryptSubscriberTest::testPostFlush":0.006}}
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ matrix:
- php: 7.3
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"

- php: 7.4
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"

- php: 8.0
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"

# Latest commit to master
- php: 7.3
env: STABILITY="dev"
Expand Down
7 changes: 4 additions & 3 deletions Tests/Functional/AbstractFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class AbstractFunctionalTestCase extends TestCase

abstract protected function getEncryptor(): EncryptorInterface;

public function setUp()
public function setUp(): void
{
// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = true;
Expand Down Expand Up @@ -73,8 +73,9 @@ public function setUp()
error_reporting(E_ALL);
}

public function tearDown()
public function tearDown(): void
{
$this->entityManager->getConnection()->close();
unlink($this->dbFile);
}

Expand Down Expand Up @@ -132,4 +133,4 @@ public function assertStringDoesNotContain($needle, $string, $ignoreCase = false

static::assertThat($string, $constraint, $message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

abstract class AbstractBasicQueryTestCase extends AbstractFunctionalTestCase
{
public function testPersistEntity()
public function testPersistEntity(): void
{
$user = new CascadeTarget();
$user->setNotSecret('My public information');
Expand All @@ -21,7 +21,7 @@ public function testPersistEntity()
$this->assertEquals(3,$this->getCurrentQueryCount());
}

public function testNoUpdateOnReadEncrypted()
public function testNoUpdateOnReadEncrypted(): void
{
$this->entityManager->beginTransaction();
$this->assertEquals(1,$this->getCurrentQueryCount());
Expand Down Expand Up @@ -57,7 +57,7 @@ public function testNoUpdateOnReadEncrypted()
$this->assertEquals(4,$this->getCurrentQueryCount());
}

public function testStoredDataIsEncrypted()
public function testStoredDataIsEncrypted(): void
{
$user = new CascadeTarget();
$user->setNotSecret('My public information');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

abstract class AbstractDoctrineEncryptSubscriberTestCase extends AbstractFunctionalTestCase
{
public function testEncryptionHappensOnOnlyAnnotatedFields()
public function testEncryptionHappensOnOnlyAnnotatedFields(): void
{
$secret = "It's a secret";
$notSecret = "You're all welcome to know this.";
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testEncryptionHappensOnOnlyAnnotatedFields()
$this->assertEquals($secret, $decrypted);
}

public function testEncryptionCascades()
public function testEncryptionCascades(): void
{
$secret = "It's a secret";
$notSecret = "You're all welcome to know this.";
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testEncryptionCascades()
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\ORM\OptimisticLockException
*/
public function testEncryptionDoesNotHappenWhenThereIsNoChange()
public function testEncryptionDoesNotHappenWhenThereIsNoChange(): void
{
$secret = "It's a secret";
$notSecret = "You're all welcome to know this.";
Expand Down Expand Up @@ -155,7 +155,7 @@ public function testEncryptionDoesNotHappenWhenThereIsNoChange()

}

public function testEncryptionDoesHappenWhenASecretIsChanged()
public function testEncryptionDoesHappenWhenASecretIsChanged(): void
{
$secret = "It's a secret";
$notSecret = "You're all welcome to know this.";
Expand Down Expand Up @@ -198,4 +198,4 @@ public function testEncryptionDoesHappenWhenASecretIsChanged()
$this->assertStringEndsWith('<ENC>', $shouldBeDifferentFromBefore); // is encrypted
$this->assertNotEquals($originalEncryption, $shouldBeDifferentFromBefore);
}
}
}
10 changes: 5 additions & 5 deletions Tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ class DoctrineEncryptExtensionTest extends TestCase
*/
private $extension;

protected function setUp()
protected function setUp(): void
{
$this->extension = new DoctrineEncryptExtension();
}

public function testConfigLoadHalite()
public function testConfigLoadHalite(): void
{
$container = $this->createContainer();
$this->extension->load([[]], $container);

$this->assertSame(HaliteEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name'));
}

public function testConfigLoadDefuse()
public function testConfigLoadDefuse(): void
{
$container = $this->createContainer();

Expand All @@ -41,7 +41,7 @@ public function testConfigLoadDefuse()
$this->assertSame(DefuseEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name'));
}

public function testConfigLoadCustom()
public function testConfigLoadCustom(): void
{
$container = $this->createContainer();
$config = [
Expand All @@ -54,7 +54,7 @@ public function testConfigLoadCustom()
$this->assertSame(self::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name'));
}

private function createContainer()
private function createContainer(): ContainerBuilder
{
$container = new ContainerBuilder(
new ParameterBag(['kernel.debug' => false])
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Encryptors/DefuseEncryptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DefuseEncryptorTest extends TestCase
{
private const DATA = 'foobar';

public function testEncrypt()
public function testEncrypt(): void
{
$keyfile = __DIR__.'/fixtures/defuse.key';
$key = file_get_contents($keyfile);
Expand All @@ -24,7 +24,7 @@ public function testEncrypt()
$this->assertSame($key, $newkey, 'The key must not be modified');
}

public function testGenerateKey()
public function testGenerateKey(): void
{
$keyfile = sys_get_temp_dir().'/defuse-'.md5(time());
if (file_exists($keyfile)) {
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/Encryptors/HaliteEncryptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HaliteEncryptorTest extends TestCase
{
private const DATA = 'foobar';

public function testEncryptExtension()
public function testEncryptExtension(): void
{
if (! extension_loaded('sodium')) {
$this->markTestSkipped('This test only runs when the sodium extension is enabled.');
Expand All @@ -27,7 +27,7 @@ public function testEncryptExtension()
$this->assertSame($key, $newkey, 'The key must not be modified');
}

public function testGenerateKey()
public function testGenerateKey(): void
{
if (! extension_loaded('sodium')) {
$this->markTestSkipped('This test only runs when the sodium extension is enabled.');
Expand All @@ -46,7 +46,7 @@ public function testGenerateKey()
}


public function testEncryptWithoutExtensionThrowsException()
public function testEncryptWithoutExtensionThrowsException(): void
{
if (extension_loaded('sodium')) {
$this->markTestSkipped('This only runs when the sodium extension is disabled.');
Expand Down
28 changes: 14 additions & 14 deletions Tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DoctrineEncryptSubscriberTest extends TestCase
*/
private $reader;

protected function setUp()
protected function setUp(): void
{
$this->encryptor = $this->createMock(EncryptorInterface::class);
$this->encryptor
Expand Down Expand Up @@ -71,7 +71,7 @@ protected function setUp()
$this->subscriber = new DoctrineEncryptSubscriber($this->reader, $this->encryptor);
}

public function testSetRestorEncryptor()
public function testSetRestorEncryptor(): void
{
$replaceEncryptor = $this->createMock(EncryptorInterface::class);

Expand All @@ -82,7 +82,7 @@ public function testSetRestorEncryptor()
$this->assertSame($this->encryptor, $this->subscriber->getEncryptor());
}

public function testProcessFieldsEncrypt()
public function testProcessFieldsEncrypt(): void
{
$user = new User('David', 'Switzerland');

Expand All @@ -92,7 +92,7 @@ public function testProcessFieldsEncrypt()
$this->assertStringStartsWith('encrypted-', $user->getAddress());
}

public function testProcessFieldsEncryptExtend()
public function testProcessFieldsEncryptExtend(): void
{
$user = new ExtendedUser('David', 'Switzerland', 'extra');

Expand All @@ -103,7 +103,7 @@ public function testProcessFieldsEncryptExtend()
$this->assertStringStartsWith('encrypted-', $user->extra);
}

public function testProcessFieldsEncryptEmbedded()
public function testProcessFieldsEncryptEmbedded(): void
{
$withUser = new WithUser('Thing', 'foo', new User('David', 'Switzerland'));

Expand All @@ -115,7 +115,7 @@ public function testProcessFieldsEncryptEmbedded()
$this->assertStringStartsWith('encrypted-', $withUser->user->getAddress());
}

public function testProcessFieldsEncryptNull()
public function testProcessFieldsEncryptNull(): void
{
$user = new User('David', null);

Expand All @@ -125,7 +125,7 @@ public function testProcessFieldsEncryptNull()
$this->assertNull($user->getAddress());
}

public function testProcessFieldsNoEncryptor()
public function testProcessFieldsNoEncryptor(): void
{
$user = new User('David', 'Switzerland');

Expand All @@ -136,7 +136,7 @@ public function testProcessFieldsNoEncryptor()
$this->assertSame('Switzerland', $user->getAddress());
}

public function testProcessFieldsDecrypt()
public function testProcessFieldsDecrypt(): void
{
$user = new User('encrypted-David<ENC>', 'encrypted-Switzerland<ENC>');

Expand All @@ -146,7 +146,7 @@ public function testProcessFieldsDecrypt()
$this->assertSame('Switzerland', $user->getAddress());
}

public function testProcessFieldsDecryptExtended()
public function testProcessFieldsDecryptExtended(): void
{
$user = new ExtendedUser('encrypted-David<ENC>', 'encrypted-Switzerland<ENC>', 'encrypted-extra<ENC>');

Expand All @@ -157,7 +157,7 @@ public function testProcessFieldsDecryptExtended()
$this->assertSame('extra', $user->extra);
}

public function testProcessFieldsDecryptEmbedded()
public function testProcessFieldsDecryptEmbedded(): void
{
$withUser = new WithUser('encrypted-Thing<ENC>', 'foo', new User('encrypted-David<ENC>', 'encrypted-Switzerland<ENC>'));

Expand All @@ -169,7 +169,7 @@ public function testProcessFieldsDecryptEmbedded()
$this->assertSame('Switzerland', $withUser->user->getAddress());
}

public function testProcessFieldsDecryptNull()
public function testProcessFieldsDecryptNull(): void
{
$user = new User('encrypted-David<ENC>', null);

Expand All @@ -179,7 +179,7 @@ public function testProcessFieldsDecryptNull()
$this->assertNull($user->getAddress());
}

public function testProcessFieldsDecryptNonEncrypted()
public function testProcessFieldsDecryptNonEncrypted(): void
{
// no trailing <ENC> but somethint that our mock decrypt would change if called
$user = new User('encrypted-David', 'encrypted-Switzerland');
Expand All @@ -193,7 +193,7 @@ public function testProcessFieldsDecryptNonEncrypted()
/**
* Test that fields are encrypted before flushing.
*/
public function testOnFlush()
public function testOnFlush(): void
{
$user = new User('David', 'Switzerland');

Expand Down Expand Up @@ -222,7 +222,7 @@ public function testOnFlush()
/**
* Test that fields are decrypted again after flushing
*/
public function testPostFlush()
public function testPostFlush(): void
{
$user = new User('encrypted-David<ENC>', 'encrypted-Switzerland<ENC>');

Expand Down
Loading