2020use OCP \ISession ;
2121use OCP \Preview \IMimeIconProvider ;
2222use OCP \Share \Exceptions \ShareNotFound ;
23- use OCP \Share \IAttributes ;
2423use OCP \Share \IManager ;
2524use OCP \Share \IShare ;
2625use PHPUnit \Framework \MockObject \MockObject ;
@@ -114,12 +113,8 @@ public function testShareNoDownload() {
114113 $ share ->method ('getPermissions ' )
115114 ->willReturn (Constants::PERMISSION_READ );
116115
117- $ attributes = $ this ->createMock (IAttributes::class);
118- $ attributes ->method ('getAttribute ' )
119- ->with ('permissions ' , 'download ' )
116+ $ share ->method ('canSeeContent ' )
120117 ->willReturn (false );
121- $ share ->method ('getAttributes ' )
122- ->willReturn ($ attributes );
123118
124119 $ res = $ this ->controller ->getPreview ('token ' , 'file ' , 10 , 10 );
125120 $ expected = new DataResponse ([], Http::STATUS_FORBIDDEN );
@@ -136,12 +131,8 @@ public function testShareNoDownloadButPreviewHeader() {
136131 $ share ->method ('getPermissions ' )
137132 ->willReturn (Constants::PERMISSION_READ );
138133
139- $ attributes = $ this ->createMock (IAttributes::class);
140- $ attributes ->method ('getAttribute ' )
141- ->with ('permissions ' , 'download ' )
134+ $ share ->method ('canSeeContent ' )
142135 ->willReturn (false );
143- $ share ->method ('getAttributes ' )
144- ->willReturn ($ attributes );
145136
146137 $ this ->request ->method ('getHeader ' )
147138 ->with ('x-nc-preview ' )
@@ -176,12 +167,8 @@ public function testShareWithAttributes() {
176167 $ share ->method ('getPermissions ' )
177168 ->willReturn (Constants::PERMISSION_READ );
178169
179- $ attributes = $ this ->createMock (IAttributes::class);
180- $ attributes ->method ('getAttribute ' )
181- ->with ('permissions ' , 'download ' )
170+ $ share ->method ('canSeeContent ' )
182171 ->willReturn (true );
183- $ share ->method ('getAttributes ' )
184- ->willReturn ($ attributes );
185172
186173 $ this ->request ->method ('getHeader ' )
187174 ->with ('x-nc-preview ' )
@@ -220,6 +207,9 @@ public function testPreviewFile() {
220207 $ share ->method ('getNode ' )
221208 ->willReturn ($ file );
222209
210+ $ share ->method ('canSeeContent ' )
211+ ->willReturn (true );
212+
223213 $ preview = $ this ->createMock (ISimpleFile::class);
224214 $ preview ->method ('getName ' )->willReturn ('name ' );
225215 $ preview ->method ('getMTime ' )->willReturn (42 );
@@ -249,6 +239,9 @@ public function testPreviewFolderInvalidFile(): void {
249239 $ share ->method ('getNode ' )
250240 ->willReturn ($ folder );
251241
242+ $ share ->method ('canSeeContent ' )
243+ ->willReturn (true );
244+
252245 $ folder ->method ('get ' )
253246 ->with ($ this ->equalTo ('file ' ))
254247 ->willThrowException (new NotFoundException ());
@@ -272,6 +265,9 @@ public function testPreviewFolderValidFile(): void {
272265 $ share ->method ('getNode ' )
273266 ->willReturn ($ folder );
274267
268+ $ share ->method ('canSeeContent ' )
269+ ->willReturn (true );
270+
275271 $ file = $ this ->createMock (File::class);
276272 $ folder ->method ('get ' )
277273 ->with ($ this ->equalTo ('file ' ))
0 commit comments