From 045d139d64ada2c510ed05e177ba6f484ad68496 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Wed, 15 Jun 2011 00:58:29 -0400 Subject: Added RSS Feed tests --- tests/www/rssTest.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/www/rssTest.php (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php new file mode 100644 index 0000000..1822fc9 --- /dev/null +++ b/tests/www/rssTest.php @@ -0,0 +1,94 @@ +setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + + /* create user without RSS private Key */ + list($req, $uId) = $this->getLoggedInRequest(null, true, false, false); + + /* create private bookmark */ + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 2,//private + array(), null, null, false, false, $uId + ); + /* create public bookmark */ + $this->bs->addBookmark( + 'http://example.org', 'title', 'desc', 'priv', + 0,//public + array(), null, null, false, false, $uId + ); + + /* get user details */ + $user = $this->us->getUser($uId); + + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc')); + $response = $req->send(); + $response_body = $response->getBody(); + + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + + $this->assertEquals(1, count($items), 'Incorrect Number of RSS Items'); + $this->assertEquals('title', (string)$items[0]->title); + }//end testNoRSSPrivateKeyEnabled + + + /** + * Test a user who has RSS private key setup + * with private bookmark. + */ + public function testRSSPrivateKeyEnabled() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + + /* create user with RSS private Key */ + list($req, $uId) = $this->getLoggedInRequest(null, true, false, true); + + /* create private bookmark */ + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 2,//private + array(), null, null, false, false, $uId + ); + /* create public bookmark */ + $this->bs->addBookmark( + 'http://example.org', 'title', 'desc', 'priv', + 0,//public + array(), null, null, false, false, $uId + ); + + /* get user details */ + $user = $this->us->getUser($uId); + + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privatekey'])); + $response = $req->send(); + $response_body = $response->getBody(); + + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + + $this->assertEquals(2, count($items), 'Incorrect Number of RSS Items'); + }//end testRSSPrivateKeyEnabled + + + +}//end class www_rssTest +?> -- cgit v1.2.3 From 9eab02af5f6212b417a6aef095d55e6c5d8fc616 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:09:19 +0200 Subject: fix typo --- tests/www/rssTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 1822fc9..9d4e41b 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -78,7 +78,7 @@ class www_rssTest extends TestBaseApi $user = $this->us->getUser($uId); $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privatekey'])); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privateKey'])); $response = $req->send(); $response_body = $response->getBody(); -- cgit v1.2.3 From 6ec3b102aa896df8ddcf6323e0635dc42ac25f98 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:39:38 +0200 Subject: make the private tests really test something --- src/SemanticScuttle/Model/Bookmark.php | 17 ++++++++ tests/TestBase.php | 8 ++-- tests/TestBaseApi.php | 15 ++----- tests/www/rssTest.php | 73 +++++++++------------------------- 4 files changed, 42 insertions(+), 71 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/src/SemanticScuttle/Model/Bookmark.php b/src/SemanticScuttle/Model/Bookmark.php index 8bda0b3..1330642 100644 --- a/src/SemanticScuttle/Model/Bookmark.php +++ b/src/SemanticScuttle/Model/Bookmark.php @@ -23,6 +23,23 @@ */ class SemanticScuttle_Model_Bookmark { + /** + * Status "public" / visible for all + */ + const SPUBLIC = 0; + + /** + * Status "shared" / visible for people on your watchlist + */ + const SWATCHLIST = 1; + + /** + * Status "private" / visible for yourself only + */ + const SPRIVATE = 2; + + + /** * Checks if the given URL is valid and may be used with this * SemanticScuttle installation. diff --git a/tests/TestBase.php b/tests/TestBase.php index 5ea656c..2180d2d 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -76,8 +76,8 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Creates a new user in the database. * - * @param string $username Username - * @param string $password Password + * @param string $username Username, may be null + * @param string $password Password, may be null * @param mixed $privateKey String private key or boolean true to generate one * * @return integer ID of user @@ -95,8 +95,8 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Creates a new user in the database and returns id, username and password. * - * @param string $username Username - * @param string $password Password + * @param string $username Username, may be null + * @param string $password Password, may be null * @param mixed $privateKey String private key or boolean true to generate one * * @return array ID of user, Name of user, password of user, privatekey diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index f860d10..1052ae7 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -187,8 +187,7 @@ class TestBaseApi extends TestBase * @uses getRequest() */ protected function getLoggedInRequest( - $urlSuffix = null, $auth = true, $privateKey = false, - $setCookie = true + $urlSuffix = null, $auth = true, $privateKey = null ) { if (is_array($auth)) { list($username, $password) = $auth; @@ -196,13 +195,7 @@ class TestBaseApi extends TestBase $username = 'testuser'; $password = 'testpassword'; } - //include privatekey if requested - if ($privateKey) { - $pKey = $this->us->getNewPrivateKey(); - } else { - $pKey = null; - } - $uid = $this->addUser($username, $password, $pKey); + $uid = $this->addUser($username, $password, $privateKey); $req = new HTTP_Request2( $GLOBALS['unittestUrl'] . '/login.php?unittestMode=1', @@ -218,9 +211,7 @@ class TestBaseApi extends TestBase $this->assertEquals(302, $res->getStatus(), 'Login failure'); $req = $this->getRequest($urlSuffix); - if ($setCookie) { - $req->setCookieJar($cookies); - } + $req->setCookieJar($cookies); return array($req, $uid); } diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 9d4e41b..fc49264 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -7,44 +7,23 @@ class www_rssTest extends TestBaseApi protected $urlPart = 'rss.php'; /** - * Test a user who does not have RSS private key enabled - * and with a private bookmark. + * A private bookmark should not show up in an rss feed if the + * user is not logged in nor passes the private key */ - public function testNoRSSPrivateKeyEnabled() + public function testPrivateNotLoggedIn() { - $this->setUnittestConfig( - array('defaults' => array('privacy' => 2)) + list($uId, $username) = $this->addUserData(); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE ); - /* create user without RSS private Key */ - list($req, $uId) = $this->getLoggedInRequest(null, true, false, false); - - /* create private bookmark */ - $this->bs->addBookmark( - 'http://test', 'test', 'desc', 'note', - 2,//private - array(), null, null, false, false, $uId - ); - /* create public bookmark */ - $this->bs->addBookmark( - 'http://example.org', 'title', 'desc', 'priv', - 0,//public - array(), null, null, false, false, $uId - ); - - /* get user details */ - $user = $this->us->getUser($uId); - - $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc')); - $response = $req->send(); - $response_body = $response->getBody(); + $req = $this->getRequest('/' . $username); + $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); $items = $rss->channel->item; - $this->assertEquals(1, count($items), 'Incorrect Number of RSS Items'); - $this->assertEquals('title', (string)$items[0]->title); + $this->assertEquals(0, count($items), 'I see a private bookmark'); }//end testNoRSSPrivateKeyEnabled @@ -54,38 +33,22 @@ class www_rssTest extends TestBaseApi */ public function testRSSPrivateKeyEnabled() { - $this->setUnittestConfig( - array('defaults' => array('privacy' => 2)) + list($uId, $username, $password, $privateKey) = $this->addUserData( + null, null, true ); - - /* create user with RSS private Key */ - list($req, $uId) = $this->getLoggedInRequest(null, true, false, true); - - /* create private bookmark */ - $this->bs->addBookmark( - 'http://test', 'test', 'desc', 'note', - 2,//private - array(), null, null, false, false, $uId + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE, + null, 'private bookmark' ); - /* create public bookmark */ - $this->bs->addBookmark( - 'http://example.org', 'title', 'desc', 'priv', - 0,//public - array(), null, null, false, false, $uId - ); - - /* get user details */ - $user = $this->us->getUser($uId); - $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privateKey'])); - $response = $req->send(); - $response_body = $response->getBody(); + $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); $items = $rss->channel->item; - $this->assertEquals(2, count($items), 'Incorrect Number of RSS Items'); + $this->assertEquals(1, count($items), 'I miss the private bookmark'); + $this->assertEquals('private bookmark', (string)$items[0]->title); }//end testRSSPrivateKeyEnabled -- cgit v1.2.3 From f2ac531f2646c34c107b92cd9ff1e2c1a12c9b39 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:52:02 +0200 Subject: test that using the private key does not leave unwanted login cookies --- tests/www/rssTest.php | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index fc49264..d6891d6 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -24,14 +24,15 @@ class www_rssTest extends TestBaseApi $items = $rss->channel->item; $this->assertEquals(0, count($items), 'I see a private bookmark'); - }//end testNoRSSPrivateKeyEnabled + } + /** * Test a user who has RSS private key setup * with private bookmark. */ - public function testRSSPrivateKeyEnabled() + public function testPrivateWithPrivateKey() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true @@ -49,9 +50,43 @@ class www_rssTest extends TestBaseApi $this->assertEquals(1, count($items), 'I miss the private bookmark'); $this->assertEquals('private bookmark', (string)$items[0]->title); - }//end testRSSPrivateKeyEnabled + } + + + + /** + * Verify that fetching the feed with a private key + * does not keep you logged in + */ + public function testPrivatekeyDoesNotKeepLoggedYouIn() + { + list($uId, $username, $password, $privateKey) = $this->addUserData( + null, null, true + ); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE, + null, 'private bookmark' + ); + $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $cookies = $req->setCookieJar()->getCookieJar(); + $response_body = $req->send()->getBody(); + + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + + $this->assertEquals(1, count($items), 'I miss the private bookmark'); + $this->assertEquals('private bookmark', (string)$items[0]->title); + + //request the feed again, with the same cookies + $req = $this->getRequest('/' . $username); + $req->setCookieJar($cookies); + $response_body = $req->send()->getBody(); + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + $this->assertEquals(0, count($items), 'I still see the private bookmark'); + } }//end class www_rssTest ?> -- cgit v1.2.3 From 588d63a2c740335bb4ff7fbe7454fbe3876ea9c1 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:59:06 +0200 Subject: better method names --- tests/www/rssTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index d6891d6..63c2b3d 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -10,7 +10,7 @@ class www_rssTest extends TestBaseApi * A private bookmark should not show up in an rss feed if the * user is not logged in nor passes the private key */ - public function testPrivateNotLoggedIn() + public function testPrivateBookmarkNotLoggedIn() { list($uId, $username) = $this->addUserData(); $this->addBookmark( @@ -32,7 +32,7 @@ class www_rssTest extends TestBaseApi * Test a user who has RSS private key setup * with private bookmark. */ - public function testPrivateWithPrivateKey() + public function testPrivateBookmarkWithPrivateKey() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true @@ -58,7 +58,7 @@ class www_rssTest extends TestBaseApi * Verify that fetching the feed with a private key * does not keep you logged in */ - public function testPrivatekeyDoesNotKeepLoggedYouIn() + public function testPrivateKeyDoesNotKeepLoggedYouIn() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true -- cgit v1.2.3 From 57a5f6864d0241ab513b53a02c7e4ab9ebdeda0d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 20:04:03 +0200 Subject: add own assertion to make it easier to switch to atom --- tests/www/rssTest.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 63c2b3d..477e98c 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -6,6 +6,23 @@ class www_rssTest extends TestBaseApi { protected $urlPart = 'rss.php'; + + /** + * Verifies that the given number of feed items exist in the feed + * XML tree. + * + * @var SimpleXMLElement $simpleXml RSS feed root element + * @var integer $nCount Number of expected feed items + * @var string $msg Error message + */ + protected function assertItemCount( + SimpleXMLElement $simpleXml, $nCount, $msg = null + ) { + $this->assertEquals($nCount, count($simpleXml->channel->item), $msg); + } + + + /** * A private bookmark should not show up in an rss feed if the * user is not logged in nor passes the private key @@ -21,9 +38,7 @@ class www_rssTest extends TestBaseApi $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); - $items = $rss->channel->item; - - $this->assertEquals(0, count($items), 'I see a private bookmark'); + $this->assertItemCount($rss, 0, 'I see a private bookmark'); } @@ -46,10 +61,10 @@ class www_rssTest extends TestBaseApi $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); - $items = $rss->channel->item; - - $this->assertEquals(1, count($items), 'I miss the private bookmark'); - $this->assertEquals('private bookmark', (string)$items[0]->title); + $this->assertItemCount($rss, 1, 'I miss the private bookmark'); + $this->assertEquals( + 'private bookmark', (string)$rss->channel->item[0]->title + ); } @@ -83,9 +98,7 @@ class www_rssTest extends TestBaseApi $req->setCookieJar($cookies); $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); - $items = $rss->channel->item; - - $this->assertEquals(0, count($items), 'I still see the private bookmark'); + $this->assertItemCount($rss, 0, 'I still see the private bookmark'); } }//end class www_rssTest -- cgit v1.2.3 From 673fdc87582c2087beed8d33505213cbd83755cb Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 21:55:07 +0200 Subject: rename methods to keep them clear --- tests/www/rssTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 477e98c..4fab479 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -27,7 +27,7 @@ class www_rssTest extends TestBaseApi * A private bookmark should not show up in an rss feed if the * user is not logged in nor passes the private key */ - public function testPrivateBookmarkNotLoggedIn() + public function testUserPrivateBookmarkNotLoggedIn() { list($uId, $username) = $this->addUserData(); $this->addBookmark( @@ -47,7 +47,7 @@ class www_rssTest extends TestBaseApi * Test a user who has RSS private key setup * with private bookmark. */ - public function testPrivateBookmarkWithPrivateKey() + public function testUserPrivateBookmarkWithPrivateKey() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true @@ -73,7 +73,7 @@ class www_rssTest extends TestBaseApi * Verify that fetching the feed with a private key * does not keep you logged in */ - public function testPrivateKeyDoesNotKeepLoggedYouIn() + public function testUserPrivateKeyDoesNotKeepLoggedYouIn() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true -- cgit v1.2.3 From 763d394436dc632bf18bff8876af22be9b44e9f4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 22:27:17 +0200 Subject: test global feed with private bookmarks --- tests/www/rssTest.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 4fab479..75e4363 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -23,8 +23,29 @@ class www_rssTest extends TestBaseApi + /** - * A private bookmark should not show up in an rss feed if the + * A private bookmark should not show up in the global rss feed if the + * user is not logged in nor passes the private key + */ + public function testAllPrivateBookmarkNotLoggedIn() + { + list($uId, $username) = $this->addUserData(); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE + ); + + $req = $this->getRequest(); + $response_body = $req->send()->getBody(); + + $rss = simplexml_load_string($response_body); + $this->assertItemCount($rss, 0, 'I see a private bookmark'); + } + + + + /** + * A private bookmark should not show up in the user's rss feed if the * user is not logged in nor passes the private key */ public function testUserPrivateBookmarkNotLoggedIn() @@ -43,9 +64,34 @@ class www_rssTest extends TestBaseApi + + /** + * Test the global feed by passing the private key + */ + public function testAllPrivateBookmarkWithPrivateKey() + { + list($uId, $username, $password, $privateKey) = $this->addUserData( + null, null, true + ); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE, + null, 'private bookmark' + ); + + $req = $this->getRequest('?privatekey=' . $privateKey); + $response_body = $req->send()->getBody(); + + $rss = simplexml_load_string($response_body); + $this->assertItemCount($rss, 1, 'I miss the private bookmark'); + $this->assertEquals( + 'private bookmark', (string)$rss->channel->item[0]->title + ); + } + + + /** - * Test a user who has RSS private key setup - * with private bookmark. + * Test the user feed by passing the private key */ public function testUserPrivateBookmarkWithPrivateKey() { -- cgit v1.2.3 From 3d11286cbcc3cb35efe11f6e4a4ef5ac81620bda Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 22:31:24 +0200 Subject: privatekey -> privateKey everywhere --- src/SemanticScuttle/Service/User.php | 20 ++++++++++---------- tests/TestBase.php | 2 +- tests/UserTest.php | 24 ++++++++++++------------ tests/www/bookmarksTest.php | 4 ++-- tests/www/indexTest.php | 4 ++-- tests/www/rssTest.php | 6 +++--- www/bookmarks.php | 2 +- www/index.php | 2 +- www/rss.php | 16 ++++++++-------- www/tags.php | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) (limited to 'tests/www/rssTest.php') diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index b5b053f..7550ed2 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -51,7 +51,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService 'primary' => 'uId', 'username' => 'username', 'password' => 'password', - 'privatekey' => 'privatekey' + 'privateKey' => 'privateKey' ); protected $profileurl; @@ -219,13 +219,13 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService /** * Returns user row from database. * - * @param string $privatekey Private Key + * @param string $privateKey Private Key * * @return array User array from database, false if no user was found */ - public function getUserByPrivateKey($privatekey) + public function getUserByPrivateKey($privateKey) { - return $this->_getuser($this->getFieldName('privatekey'), $privatekey); + return $this->_getuser($this->getFieldName('privateKey'), $privateKey); } function getObjectUserByUsername($username) { @@ -539,24 +539,24 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } /** - * Try to authenticate via the privatekey + * Try to authenticate via the privateKey * - * @param string $privatekey Private Key + * @param string $privateKey Private Key * * @return boolean true if the user could be authenticated, * false if not. */ - public function loginPrivateKey($privatekey) + public function loginPrivateKey($privateKey) { /* Check if private key valid and enabled */ - if (!$this->isPrivateKeyValid($privatekey)) { + if (!$this->isPrivateKeyValid($privateKey)) { return false; } $query = 'SELECT '. $this->getFieldName('primary') .' FROM ' . $this->getTableName() .' WHERE ' - . $this->getFieldName('privatekey') .' = "' - . $this->db->sql_escape($privatekey) .'"'; + . $this->getFieldName('privateKey') .' = "' + . $this->db->sql_escape($privateKey) .'"'; if (!($dbresult = $this->db->sql_query($query))) { message_die( diff --git a/tests/TestBase.php b/tests/TestBase.php index 2180d2d..2914749 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -99,7 +99,7 @@ class TestBase extends PHPUnit_Framework_TestCase * @param string $password Password, may be null * @param mixed $privateKey String private key or boolean true to generate one * - * @return array ID of user, Name of user, password of user, privatekey + * @return array ID of user, Name of user, password of user, privateKey */ protected function addUserData( $username = null, $password = null, $privateKey = null diff --git a/tests/UserTest.php b/tests/UserTest.php index 230167d..6cd6786 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -40,7 +40,7 @@ class UserTest extends TestBase public function testAddUserPrivateKey() { $name = substr(md5(uniqid()), 0, 6); - $pkey = 'my-privatekey'; + $pkey = 'my-privateKey'; $id = $this->us->addUser( $name, uniqid(), 'foo@example.org', $pkey ); @@ -413,17 +413,17 @@ class UserTest extends TestBase $randKey2 = '-'.$this->us->getNewPrivateKey(); $this->assertFalse( $this->us->isPrivateKeyValid($randKey2), - 'disabled privatekey should return false' + 'disabled privateKey should return false' ); } public function testLoginPrivateKeyInvalid() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -436,10 +436,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyValidEnabledKey() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -453,10 +453,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyInvalidEnabledKey() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -470,10 +470,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyValidDisabledKey() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -491,10 +491,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyInvalidDisabled() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index 1e1f4eb..ae82118 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -92,7 +92,7 @@ class www_bookmarksTest extends TestBaseApi $this->assertEquals( 2, count($elements), 'Number of Links in Head not correct' ); - $this->assertContains('privatekey=', (string)$elements[1]['href']); + $this->assertContains('privateKey=', (string)$elements[1]['href']); }//end testVerifyPrivateRSSLinkExists @@ -121,7 +121,7 @@ class www_bookmarksTest extends TestBaseApi $this->assertEquals( 1, count($elements), 'Number of Links in Head not correct' ); - $this->assertNotContains('privatekey=', (string)$elements[0]['href']); + $this->assertNotContains('privateKey=', (string)$elements[0]['href']); }//end testVerifyPrivateRSSLinkDoesNotExist }//end class www_bookmarksTest diff --git a/tests/www/indexTest.php b/tests/www/indexTest.php index 18cb75a..503fd1f 100644 --- a/tests/www/indexTest.php +++ b/tests/www/indexTest.php @@ -26,7 +26,7 @@ class www_indexTest extends TestBaseApi $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); $this->assertEquals(2, count($elements), 'Number of Links in Head not correct'); - $this->assertContains('privatekey=', (string)$elements[1]['href']); + $this->assertContains('privateKey=', (string)$elements[1]['href']); }//end testVerifyPrivateRSSLinkExists @@ -50,7 +50,7 @@ class www_indexTest extends TestBaseApi $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); $this->assertEquals(1, count($elements), 'Number of Links in Head not correct'); - $this->assertNotContains('privatekey=', (string)$elements[0]['href']); + $this->assertNotContains('privateKey=', (string)$elements[0]['href']); }//end testVerifyPrivateRSSLinkDoesNotExist diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 75e4363..71d0198 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -78,7 +78,7 @@ class www_rssTest extends TestBaseApi null, 'private bookmark' ); - $req = $this->getRequest('?privatekey=' . $privateKey); + $req = $this->getRequest('?privateKey=' . $privateKey); $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); @@ -103,7 +103,7 @@ class www_rssTest extends TestBaseApi null, 'private bookmark' ); - $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $req = $this->getRequest('/' . $username . '?privateKey=' . $privateKey); $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); @@ -129,7 +129,7 @@ class www_rssTest extends TestBaseApi null, 'private bookmark' ); - $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $req = $this->getRequest('/' . $username . '?privateKey=' . $privateKey); $cookies = $req->setCookieJar()->getCookieJar(); $response_body = $req->send()->getBody(); diff --git a/www/bookmarks.php b/www/bookmarks.php index 44119db..7056fa6 100644 --- a/www/bookmarks.php +++ b/www/bookmarks.php @@ -276,7 +276,7 @@ if ($templatename == 'editbookmark.tpl') { $tplVars['rsschannels'], array( filter($sitename . $rssTitle. sprintf(T_(': (private) ')) . $currentUsername), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) ) ); } diff --git a/www/index.php b/www/index.php index 2fa21f8..f270f73 100644 --- a/www/index.php +++ b/www/index.php @@ -52,7 +52,7 @@ if ($userservice->isLoggedOn()) { $tplVars['rsschannels'], array( filter(sprintf(T_('%s: Recent bookmarks (+private) %s'), $sitename, $currentUsername)), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) ) ); } diff --git a/www/rss.php b/www/rss.php index b8f6948..d888726 100644 --- a/www/rss.php +++ b/www/rss.php @@ -64,9 +64,9 @@ if (!isset($rssEntries) || $rssEntries <= 0) { $rssEntries = $maxRssEntries; } -$privatekey = null; -if (isset($_GET['privatekey'])) { - $privatekey = $_GET['privatekey']; +$privateKey = null; +if (isset($_GET['privateKey'])) { + $privateKey = $_GET['privateKey']; } $userid = null; @@ -83,10 +83,10 @@ if ($user && $user != 'all') { } else { if ($userinfo = $userservice->getUserByUsername($user)) { $userid =& $userinfo[$userservice->getFieldName('primary')]; - /* if user is not logged in and has valid privatekey */ + /* if user is not logged in and has valid privateKey */ if (!$userservice->isLoggedOn()) { - if ($privatekey != null) { - if (!$userservice->loginPrivateKey($privatekey)) { + if ($privateKey != null) { + if (!$userservice->loginPrivateKey($privateKey)) { $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); @@ -106,8 +106,8 @@ if ($user && $user != 'all') { } $pagetitle .= ": ". $user; } else { - if ($privatekey != null) { - if (!$userservice->loginPrivateKey($privatekey)) { + if ($privateKey != null) { + if (!$userservice->loginPrivateKey($privateKey)) { $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); diff --git a/www/tags.php b/www/tags.php index 09725e4..fca8a04 100644 --- a/www/tags.php +++ b/www/tags.php @@ -77,7 +77,7 @@ if ($userservice->isLoggedOn()) { $tplVars['rsschannels'], array( filter($sitename .': Tags: '. $cat . sprintf(T_(': (private) ')) . $currentUsername), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) ) ); } -- cgit v1.2.3