3 namespace Wallabag\CoreBundle\Tests\Controller
;
5 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
7 class WallabagRestControllerTest
extends WebTestCase
9 public function testGetSalt()
11 $client = $this->createClient();
12 $client->request('GET', '/api/salts/admin.json');
13 $this->assertEquals(200, $client->getResponse()->getStatusCode());
15 $client->request('GET', '/api/salts/notfound.json');
16 $this->assertEquals(404, $client->getResponse()->getStatusCode());
19 public function testGetEntries()
21 $client = $this->createClient();
22 $client->request('GET', '/api/salts/admin.json');
23 $content = json_decode($client->getResponse()->getContent());
29 $encryptedPassword = sha1($password.$username.$salt);
30 $nonce = substr(md5(uniqid('nonce_', true)), 0, 16);
32 $now = new \
DateTime('now', new \
DateTimeZone('UTC'));
33 $created = (string)$now->format( 'Y-m-d\TH:i:s\Z' );
34 $digest = base64_encode(sha1(base64_decode($nonce).$created.$encryptedPassword, true));
37 'PHP_AUTH_USER' => 'username',
38 'HTTP_AUTHORIZATION' => 'Authorization profile="UsernameToken"',
39 'HTTP_x-wsse' => 'X-WSSE: UsernameToken Username="'.$username.'", PasswordDigest="'.$digest.'", Nonce="'.$nonce.'", Created="'.$created.'"'
42 $client->request('GET', '/api/entries', array(), array(), $headers);
43 $this->assertContains('Mailjet', $client->getResponse()->getContent());
46 $client->getResponse()->headers
->contains(