]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php
Use a form type for entry
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / WallabagRestControllerTest.php
index 815903fad6a759f14fcb619f3785122da824604c..d77e23037edfd5491e93f0774e494bd0146f3dd4 100644 (file)
@@ -41,6 +41,32 @@ class WallabagRestControllerTest extends WallabagTestCase
         $this->assertEquals(404, $client->getResponse()->getStatusCode());
     }
 
+    public function testWithBadHeaders()
+    {
+        $client = $this->createClient();
+        $client->request('GET', '/api/salts/admin.json');
+        $salt = json_decode($client->getResponse()->getContent());
+
+        $headers = $this->generateHeaders('admin', 'test', $salt[0]);
+
+        $entry = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findOneByIsArchived(false);
+
+        if (!$entry) {
+            $this->markTestSkipped('No content found in db.');
+        }
+
+        $badHeaders = array(
+            'HTTP_AUTHORIZATION' => 'Authorization profile="UsernameToken"',
+            'HTTP_x-wsse' => 'X-WSSE: UsernameToken Username="admin", PasswordDigest="Wr0ngDig3st", Nonce="n0Nc3", Created="2015-01-01T13:37:00Z"',
+        );
+
+        $client->request('GET', '/api/entries/'.$entry->getId().'.json', array(), array(), $badHeaders);
+        $this->assertEquals(403, $client->getResponse()->getStatusCode());
+    }
+
     public function testGetOneEntry()
     {
         $client = $this->createClient();
@@ -78,6 +104,11 @@ class WallabagRestControllerTest extends WallabagTestCase
         $headers = $this->generateHeaders('admin', 'test', $salt[0]);
 
         $client->request('GET', '/api/entries', array(), array(), $headers);
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+        $this->assertGreaterThanOrEqual(1, count(json_decode($client->getResponse()->getContent())));
+
         $this->assertContains('Mailjet', $client->getResponse()->getContent());
 
         $this->assertTrue(