@@ -553,6 +553,11 @@ public function testCreateShareUserNoShareWith() {
553553 ->willReturn ($ userFolder );
554554
555555 $ path = $ this ->getMock ('\OCP\Files\File ' );
556+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
557+ $ storage ->method ('instanceOfStorage ' )
558+ ->with ('OCA\Files_Sharing\External\Storage ' )
559+ ->willReturn (false );
560+ $ path ->method ('getStorage ' )->willReturn ($ storage );
556561 $ userFolder ->expects ($ this ->once ())
557562 ->method ('get ' )
558563 ->with ('valid-path ' )
@@ -586,6 +591,11 @@ public function testCreateShareUserNoValidShareWith() {
586591 ->willReturn ($ userFolder );
587592
588593 $ path = $ this ->getMock ('\OCP\Files\File ' );
594+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
595+ $ storage ->method ('instanceOfStorage ' )
596+ ->with ('OCA\Files_Sharing\External\Storage ' )
597+ ->willReturn (false );
598+ $ path ->method ('getStorage ' )->willReturn ($ storage );
589599 $ userFolder ->expects ($ this ->once ())
590600 ->method ('get ' )
591601 ->with ('valid-path ' )
@@ -632,6 +642,11 @@ public function testCreateShareUser() {
632642 ->willReturn ($ userFolder );
633643
634644 $ path = $ this ->getMock ('\OCP\Files\File ' );
645+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
646+ $ storage ->method ('instanceOfStorage ' )
647+ ->with ('OCA\Files_Sharing\External\Storage ' )
648+ ->willReturn (false );
649+ $ path ->method ('getStorage ' )->willReturn ($ storage );
635650 $ userFolder ->expects ($ this ->once ())
636651 ->method ('get ' )
637652 ->with ('valid-path ' )
@@ -678,6 +693,11 @@ public function testCreateShareGroupNoValidShareWith() {
678693 ->willReturn ($ userFolder );
679694
680695 $ path = $ this ->getMock ('\OCP\Files\File ' );
696+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
697+ $ storage ->method ('instanceOfStorage ' )
698+ ->with ('OCA\Files_Sharing\External\Storage ' )
699+ ->willReturn (false );
700+ $ path ->method ('getStorage ' )->willReturn ($ storage );
681701 $ userFolder ->expects ($ this ->once ())
682702 ->method ('get ' )
683703 ->with ('valid-path ' )
@@ -724,6 +744,11 @@ public function testCreateShareGroup() {
724744 ->willReturn ($ userFolder );
725745
726746 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
747+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
748+ $ storage ->method ('instanceOfStorage ' )
749+ ->with ('OCA\Files_Sharing\External\Storage ' )
750+ ->willReturn (false );
751+ $ path ->method ('getStorage ' )->willReturn ($ storage );
727752 $ userFolder ->expects ($ this ->once ())
728753 ->method ('get ' )
729754 ->with ('valid-path ' )
@@ -754,6 +779,11 @@ public function testCreateShareLinkNoLinksAllowed() {
754779 ]));
755780
756781 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
782+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
783+ $ storage ->method ('instanceOfStorage ' )
784+ ->with ('OCA\Files_Sharing\External\Storage ' )
785+ ->willReturn (false );
786+ $ path ->method ('getStorage ' )->willReturn ($ storage );
757787 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
758788 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
759789
@@ -776,6 +806,11 @@ public function testCreateShareLinkNoPublicUpload() {
776806 ]));
777807
778808 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
809+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
810+ $ storage ->method ('instanceOfStorage ' )
811+ ->with ('OCA\Files_Sharing\External\Storage ' )
812+ ->willReturn (false );
813+ $ path ->method ('getStorage ' )->willReturn ($ storage );
779814 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
780815 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
781816
@@ -799,6 +834,11 @@ public function testCreateShareLinkPublicUploadFile() {
799834 ]));
800835
801836 $ path = $ this ->getMock ('\OCP\Files\File ' );
837+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
838+ $ storage ->method ('instanceOfStorage ' )
839+ ->with ('OCA\Files_Sharing\External\Storage ' )
840+ ->willReturn (false );
841+ $ path ->method ('getStorage ' )->willReturn ($ storage );
802842 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
803843 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
804844
@@ -827,6 +867,11 @@ public function testCreateShareLinkPublicUploadFolder() {
827867 ]));
828868
829869 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
870+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
871+ $ storage ->method ('instanceOfStorage ' )
872+ ->with ('OCA\Files_Sharing\External\Storage ' )
873+ ->willReturn (false );
874+ $ path ->method ('getStorage ' )->willReturn ($ storage );
830875 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
831876 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
832877
@@ -866,6 +911,11 @@ public function testCreateShareLinkPassword() {
866911 ]));
867912
868913 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
914+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
915+ $ storage ->method ('instanceOfStorage ' )
916+ ->with ('OCA\Files_Sharing\External\Storage ' )
917+ ->willReturn (false );
918+ $ path ->method ('getStorage ' )->willReturn ($ storage );
869919 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
870920 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
871921
@@ -905,6 +955,11 @@ public function testCreateShareValidExpireDate() {
905955 ]));
906956
907957 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
958+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
959+ $ storage ->method ('instanceOfStorage ' )
960+ ->with ('OCA\Files_Sharing\External\Storage ' )
961+ ->willReturn (false );
962+ $ path ->method ('getStorage ' )->willReturn ($ storage );
908963 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
909964 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
910965
@@ -947,6 +1002,11 @@ public function testCreateShareInvalidExpireDate() {
9471002 ]));
9481003
9491004 $ path = $ this ->getMock ('\OCP\Files\Folder ' );
1005+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
1006+ $ storage ->method ('instanceOfStorage ' )
1007+ ->with ('OCA\Files_Sharing\External\Storage ' )
1008+ ->willReturn (false );
1009+ $ path ->method ('getStorage ' )->willReturn ($ storage );
9501010 $ this ->rootFolder ->method ('getUserFolder ' )->with ($ this ->currentUser ->getUID ())->will ($ this ->returnSelf ());
9511011 $ this ->rootFolder ->method ('get ' )->with ('valid-path ' )->willReturn ($ path );
9521012
@@ -961,6 +1021,66 @@ public function testCreateShareInvalidExpireDate() {
9611021 $ this ->assertEquals ($ expected ->getData (), $ result ->getData ());
9621022 }
9631023
1024+ /**
1025+ * Test for https://github.com/owncloud/core/issues/22587
1026+ * TODO: Remove once proper solution is in place
1027+ */
1028+ public function testCreateReshareOfFederatedMountNoDeletePermissions () {
1029+ $ share = \OC ::$ server ->getShareManager ()->newShare ();
1030+ $ this ->shareManager ->method ('newShare ' )->willReturn ($ share );
1031+
1032+ $ ocs = $ this ->getMockBuilder ('OCA\Files_Sharing\API\Share20OCS ' )
1033+ ->setConstructorArgs ([
1034+ $ this ->shareManager ,
1035+ $ this ->groupManager ,
1036+ $ this ->userManager ,
1037+ $ this ->request ,
1038+ $ this ->rootFolder ,
1039+ $ this ->urlGenerator ,
1040+ $ this ->currentUser
1041+ ])->setMethods (['formatShare ' ])
1042+ ->getMock ();
1043+
1044+ $ this ->request
1045+ ->method ('getParam ' )
1046+ ->will ($ this ->returnValueMap ([
1047+ ['path ' , null , 'valid-path ' ],
1048+ ['permissions ' , null , \OCP \Constants::PERMISSION_ALL ],
1049+ ['shareType ' , $ this ->any (), \OCP \Share::SHARE_TYPE_USER ],
1050+ ['shareWith ' , null , 'validUser ' ],
1051+ ]));
1052+
1053+ $ userFolder = $ this ->getMock ('\OCP\Files\Folder ' );
1054+ $ this ->rootFolder ->expects ($ this ->once ())
1055+ ->method ('getUserFolder ' )
1056+ ->with ('currentUser ' )
1057+ ->willReturn ($ userFolder );
1058+
1059+ $ path = $ this ->getMock ('\OCP\Files\Folder ' );
1060+ $ storage = $ this ->getMock ('OCP\Files\Storage ' );
1061+ $ storage ->method ('instanceOfStorage ' )
1062+ ->with ('OCA\Files_Sharing\External\Storage ' )
1063+ ->willReturn (true );
1064+ $ path ->method ('getStorage ' )->willReturn ($ storage );
1065+ $ path ->method ('getPermissions ' )->willReturn (\OCP \Constants::PERMISSION_READ );
1066+ $ userFolder ->expects ($ this ->once ())
1067+ ->method ('get ' )
1068+ ->with ('valid-path ' )
1069+ ->willReturn ($ path );
1070+
1071+ $ this ->userManager ->method ('userExists ' )->with ('validUser ' )->willReturn (true );
1072+
1073+ $ this ->shareManager
1074+ ->expects ($ this ->once ())
1075+ ->method ('createShare ' )
1076+ ->with ($ this ->callback (function (\OCP \Share \IShare $ share ) {
1077+ return $ share ->getPermissions () === \OCP \Constants::PERMISSION_READ ;
1078+ }))
1079+ ->will ($ this ->returnArgument (0 ));
1080+
1081+ $ ocs ->createShare ();
1082+ }
1083+
9641084 public function testUpdateShareCantAccess () {
9651085 $ share = \OC ::$ server ->getShareManager ()->newShare ();
9661086
0 commit comments