diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-16 20:17:08 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-27 19:32:57 +0100 |
commit | 9c04921a8c28c18ef757f2d43ba35e7e2a7f1a4b (patch) | |
tree | bcc2cb0dbad3ea27c38e676a20f3a377b50e9066 /tests/bookmark/BookmarkFileServiceTest.php | |
parent | e6215a2ad97182efcf88ef532ec6bd65ae35fd19 (diff) | |
download | Shaarli-9c04921a8c28c18ef757f2d43ba35e7e2a7f1a4b.tar.gz Shaarli-9c04921a8c28c18ef757f2d43ba35e7e2a7f1a4b.tar.zst Shaarli-9c04921a8c28c18ef757f2d43ba35e7e2a7f1a4b.zip |
Feature: Share private bookmarks using a URL containing a private key
- Add a share link next to « Permalink » in linklist (using share icon
from fork awesome)
- This link generates a private key associated to the bookmark
- Accessing the bookmark while logged out with the proper key will
display it
Fixes #475
Diffstat (limited to 'tests/bookmark/BookmarkFileServiceTest.php')
-rw-r--r-- | tests/bookmark/BookmarkFileServiceTest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index daafd250..47970117 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php | |||
@@ -898,6 +898,37 @@ class BookmarkFileServiceTest extends TestCase | |||
898 | } | 898 | } |
899 | 899 | ||
900 | /** | 900 | /** |
901 | * Test filterHash() on a private bookmark while logged out. | ||
902 | */ | ||
903 | public function testFilterHashPrivateWhileLoggedOut() | ||
904 | { | ||
905 | $this->expectException(\Exception::class); | ||
906 | $this->expectExceptionMessage('Not authorized'); | ||
907 | |||
908 | $hash = smallHash('20141125_084734' . 6); | ||
909 | |||
910 | $this->publicLinkDB->findByHash($hash); | ||
911 | } | ||
912 | |||
913 | /** | ||
914 | * Test filterHash() with private key. | ||
915 | */ | ||
916 | public function testFilterHashWithPrivateKey() | ||
917 | { | ||
918 | $hash = smallHash('20141125_084734' . 6); | ||
919 | $privateKey = 'this is usually auto generated'; | ||
920 | |||
921 | $bookmark = $this->privateLinkDB->findByHash($hash); | ||
922 | $bookmark->addAdditionalContentEntry('private_key', $privateKey); | ||
923 | $this->privateLinkDB->save(); | ||
924 | |||
925 | $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, false); | ||
926 | $bookmark = $this->privateLinkDB->findByHash($hash, $privateKey); | ||
927 | |||
928 | static::assertSame(6, $bookmark->getId()); | ||
929 | } | ||
930 | |||
931 | /** | ||
901 | * Test linksCountPerTag all tags without filter. | 932 | * Test linksCountPerTag all tags without filter. |
902 | * Equal occurrences should be sorted alphabetically. | 933 | * Equal occurrences should be sorted alphabetically. |
903 | */ | 934 | */ |