aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/visitor/BookmarkListControllerTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-16 20:17:08 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-27 19:32:57 +0100
commit9c04921a8c28c18ef757f2d43ba35e7e2a7f1a4b (patch)
treebcc2cb0dbad3ea27c38e676a20f3a377b50e9066 /tests/front/controller/visitor/BookmarkListControllerTest.php
parente6215a2ad97182efcf88ef532ec6bd65ae35fd19 (diff)
downloadShaarli-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/front/controller/visitor/BookmarkListControllerTest.php')
-rw-r--r--tests/front/controller/visitor/BookmarkListControllerTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/front/controller/visitor/BookmarkListControllerTest.php b/tests/front/controller/visitor/BookmarkListControllerTest.php
index 5ca92507..5cbc8c73 100644
--- a/tests/front/controller/visitor/BookmarkListControllerTest.php
+++ b/tests/front/controller/visitor/BookmarkListControllerTest.php
@@ -292,6 +292,37 @@ class BookmarkListControllerTest extends TestCase
292 } 292 }
293 293
294 /** 294 /**
295 * Test GET /shaare/{hash}?key={key} - Find a link by hash using a private link.
296 */
297 public function testPermalinkWithPrivateKey(): void
298 {
299 $hash = 'abcdef';
300 $privateKey = 'this is a private key';
301
302 $assignedVariables = [];
303 $this->assignTemplateVars($assignedVariables);
304
305 $request = $this->createMock(Request::class);
306 $request->method('getParam')->willReturnCallback(function (string $key, $default = null) use ($privateKey) {
307 return $key === 'key' ? $privateKey : $default;
308 });
309 $response = new Response();
310
311 $this->container->bookmarkService
312 ->expects(static::once())
313 ->method('findByHash')
314 ->with($hash, $privateKey)
315 ->willReturn((new Bookmark())->setId(123)->setTitle('Title 1')->setUrl('http://url1.tld'))
316 ;
317
318 $result = $this->controller->permalink($request, $response, ['hash' => $hash]);
319
320 static::assertSame(200, $result->getStatusCode());
321 static::assertSame('linklist', (string) $result->getBody());
322 static::assertCount(1, $assignedVariables['links']);
323 }
324
325 /**
295 * Test getting link list with thumbnail updates. 326 * Test getting link list with thumbnail updates.
296 * -> 2 thumbnails update, only 1 datastore write 327 * -> 2 thumbnails update, only 1 datastore write
297 */ 328 */