diff options
Diffstat (limited to 'tests/Wallabag')
3 files changed, 42 insertions, 3 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 104f60f1..80380685 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -1341,7 +1341,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1341 | $credential = new SiteCredential($user); | 1341 | $credential = new SiteCredential($user); |
1342 | $credential->setHost('monde-diplomatique.fr'); | 1342 | $credential->setHost('monde-diplomatique.fr'); |
1343 | $credential->setUsername('foo'); | 1343 | $credential->setUsername('foo'); |
1344 | $credential->setPassword('bar'); | 1344 | $credential->setPassword($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); |
1345 | 1345 | ||
1346 | $em->persist($credential); | 1346 | $em->persist($credential); |
1347 | $em->flush(); | 1347 | $em->flush(); |
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php index 1e1e8989..b0c81e7b 100644 --- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php +++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php | |||
@@ -6,12 +6,11 @@ use Monolog\Handler\TestHandler; | |||
6 | use Monolog\Logger; | 6 | use Monolog\Logger; |
7 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; | 7 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; |
8 | use Graby\SiteConfig\SiteConfig as GrabySiteConfig; | 8 | use Graby\SiteConfig\SiteConfig as GrabySiteConfig; |
9 | use PHPUnit_Framework_TestCase; | ||
10 | use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder; | 9 | use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder; |
11 | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; | 10 | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; |
12 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | 11 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
13 | 12 | ||
14 | class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | 13 | class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase |
15 | { | 14 | { |
16 | /** @var \Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder */ | 15 | /** @var \Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder */ |
17 | protected $builder; | 16 | protected $builder; |
diff --git a/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php new file mode 100644 index 00000000..cede8696 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | use Psr\Log\NullLogger; | ||
6 | use Monolog\Logger; | ||
7 | use Monolog\Handler\TestHandler; | ||
8 | use Wallabag\CoreBundle\Helper\CryptoProxy; | ||
9 | |||
10 | class CryptoProxyTest extends \PHPUnit_Framework_TestCase | ||
11 | { | ||
12 | public function testCrypto() | ||
13 | { | ||
14 | $logHandler = new TestHandler(); | ||
15 | $logger = new Logger('test', [$logHandler]); | ||
16 | |||
17 | $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', $logger); | ||
18 | $crypted = $crypto->crypt('test'); | ||
19 | $decrypted = $crypto->decrypt($crypted); | ||
20 | |||
21 | $this->assertSame('test', $decrypted); | ||
22 | |||
23 | $records = $logHandler->getRecords(); | ||
24 | $this->assertCount(2, $records); | ||
25 | $this->assertContains('Crypto: crypting value', $records[0]['message']); | ||
26 | $this->assertContains('Crypto: decrypting value', $records[1]['message']); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * @expectedException RuntimeException | ||
31 | * @expectedExceptionMessage Decrypt fail | ||
32 | * | ||
33 | * @return [type] [description] | ||
34 | */ | ||
35 | public function testDecryptBadValue() | ||
36 | { | ||
37 | $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', new NullLogger()); | ||
38 | $crypto->decrypt('badvalue'); | ||
39 | } | ||
40 | } | ||