summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-08-06 13:56:32 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-08-06 13:56:32 +0200
commit78b0bcc19ad3aba0e1e10d7441290a8af82e63bf (patch)
treec46055c5d13bea272dcc162170e396c872954513 /tests
parent582dba7e944850d39316a15ef9e3297577fb936f (diff)
move sanitation of urls to the serverside code to also provide security for clients, fix #151
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/businesslayer/FeedBusinessLayerTest.php4
-rw-r--r--tests/unit/db/FeedTest.php23
-rw-r--r--tests/unit/db/ItemTest.php11
3 files changed, 30 insertions, 8 deletions
diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php
index c16a8c4ae..8fce4ce9d 100644
--- a/tests/unit/businesslayer/FeedBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php
@@ -113,7 +113,7 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
}
public function testCreate(){
- $url = 'test';
+ $url = 'http://test';
$folderId = 10;
$createdFeed = new Feed();
$ex = new DoesNotExistException('yo');
@@ -168,7 +168,7 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
public function testCreateItemGuidExistsAlready(){
- $url = 'test';
+ $url = 'http://test';
$folderId = 10;
$createdFeed = new Feed();
$ex = new DoesNotExistException('yo');
diff --git a/tests/unit/db/FeedTest.php b/tests/unit/db/FeedTest.php
index 57b739bfb..10c2350f9 100644
--- a/tests/unit/db/FeedTest.php
+++ b/tests/unit/db/FeedTest.php
@@ -34,24 +34,39 @@ class FeedTest extends \PHPUnit_Framework_TestCase {
public function testToAPI() {
$feed = new Feed();
$feed->setId(3);
- $feed->setUrl('url');
+ $feed->setUrl('http://google');
$feed->setTitle('title');
$feed->setFaviconLink('favicon');
$feed->setAdded(123);
$feed->setFolderId(1);
$feed->setUnreadCount(321);
- $feed->setLink('link');
+ $feed->setLink('https://google');
$this->assertEquals(array(
'id' => 3,
- 'url' => 'url',
+ 'url' => 'http://google',
'title' => 'title',
'faviconLink' => 'favicon',
'added' => 123,
'folderId' => 1,
'unreadCount' => 321,
- 'link' => 'link'
+ 'link' => 'https://google'
), $feed->toAPI());
}
+
+ public function testSetXSSUrl() {
+ $feed = new Feed();
+ $feed->setUrl('javascript:alert()');
+ $this->assertEquals('', $feed->getUrl());
+ }
+
+
+ public function testSetXSSLink() {
+ $feed = new Feed();
+ $feed->setLink('javascript:alert()');
+ $this->assertEquals('', $feed->getLink());
+ }
+
+
} \ No newline at end of file
diff --git a/tests/unit/db/ItemTest.php b/tests/unit/db/ItemTest.php
index d48c8da12..971d808f0 100644
--- a/tests/unit/db/ItemTest.php
+++ b/tests/unit/db/ItemTest.php
@@ -71,7 +71,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setId(3);
$item->setGuid('guid');
$item->setGuidHash('hash');
- $item->setUrl('url');
+ $item->setUrl('https://google');
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
@@ -88,7 +88,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'id' => 3,
'guid' => 'guid',
'guidHash' => 'hash',
- 'url' => 'url',
+ 'url' => 'https://google',
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
@@ -119,4 +119,11 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
}
+ public function testSetXSSUrl() {
+ $item = new Item();
+ $item->setUrl('javascript:alert()');
+ $this->assertEquals('', $item->getUrl());
+ }
+
+
} \ No newline at end of file