Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
c77f74e1
Commit
c77f74e1
authored
11 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
adding check isDeletable() on $sourcePath
parent
2123ef57
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/connector/sabre/objecttree.php
+3
-0
3 additions, 0 deletions
lib/private/connector/sabre/objecttree.php
tests/lib/connector/sabre/objecttree.php
+19
-13
19 additions, 13 deletions
tests/lib/connector/sabre/objecttree.php
with
22 additions
and
13 deletions
lib/private/connector/sabre/objecttree.php
+
3
−
0
View file @
c77f74e1
...
@@ -87,6 +87,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
...
@@ -87,6 +87,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
if
(
!
$fs
->
isUpdatable
(
$destinationDir
))
{
if
(
!
$fs
->
isUpdatable
(
$destinationDir
))
{
throw
new
\Sabre_DAV_Exception_Forbidden
();
throw
new
\Sabre_DAV_Exception_Forbidden
();
}
}
if
(
!
$fs
->
isDeletable
(
$sourcePath
))
{
throw
new
\Sabre_DAV_Exception_Forbidden
();
}
}
}
$renameOkay
=
$fs
->
rename
(
$sourcePath
,
$destinationPath
);
$renameOkay
=
$fs
->
rename
(
$sourcePath
,
$destinationPath
);
...
...
This diff is collapsed.
Click to expand it.
tests/lib/connector/sabre/objecttree.php
+
19
−
13
View file @
c77f74e1
...
@@ -15,8 +15,9 @@ use Sabre_DAV_Exception_Forbidden;
...
@@ -15,8 +15,9 @@ use Sabre_DAV_Exception_Forbidden;
class
TestDoubleFileView
extends
\OC\Files\View
{
class
TestDoubleFileView
extends
\OC\Files\View
{
public
function
__construct
(
$updatables
,
$canRename
=
true
)
{
public
function
__construct
(
$updatables
,
$deletables
,
$canRename
=
true
)
{
$this
->
updatables
=
$updatables
;
$this
->
updatables
=
$updatables
;
$this
->
deletables
=
$deletables
;
$this
->
canRename
=
$canRename
;
$this
->
canRename
=
$canRename
;
}
}
...
@@ -24,6 +25,10 @@ class TestDoubleFileView extends \OC\Files\View{
...
@@ -24,6 +25,10 @@ class TestDoubleFileView extends \OC\Files\View{
return
$this
->
updatables
[
$path
];
return
$this
->
updatables
[
$path
];
}
}
public
function
isDeletable
(
$path
)
{
return
$this
->
deletables
[
$path
];
}
public
function
rename
(
$path1
,
$path2
)
{
public
function
rename
(
$path1
,
$path2
)
{
return
$this
->
canRename
;
return
$this
->
canRename
;
}
}
...
@@ -35,31 +40,32 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
...
@@ -35,31 +40,32 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
* @dataProvider moveFailedProvider
* @dataProvider moveFailedProvider
* @expectedException Sabre_DAV_Exception_Forbidden
* @expectedException Sabre_DAV_Exception_Forbidden
*/
*/
public
function
testMoveFailed
(
$source
,
$dest
,
$updatables
)
{
public
function
testMoveFailed
(
$source
,
$dest
,
$updatables
,
$deletables
)
{
$this
->
moveTest
(
$source
,
$dest
,
$updatables
);
$this
->
moveTest
(
$source
,
$dest
,
$updatables
,
$deletables
);
}
}
/**
/**
* @dataProvider moveSuccessProvider
* @dataProvider moveSuccessProvider
*/
*/
public
function
testMoveSuccess
(
$source
,
$dest
,
$updatables
)
{
public
function
testMoveSuccess
(
$source
,
$dest
,
$updatables
,
$deletables
)
{
$this
->
moveTest
(
$source
,
$dest
,
$updatables
);
$this
->
moveTest
(
$source
,
$dest
,
$updatables
,
$deletables
);
$this
->
assertTrue
(
true
);
$this
->
assertTrue
(
true
);
}
}
function
moveFailedProvider
()
{
function
moveFailedProvider
()
{
return
array
(
return
array
(
array
(
'a/b'
,
'a/c'
,
array
(
'a'
=>
false
,
'a/b'
=>
false
,
'a/c'
=>
false
)),
array
(
'a/b'
,
'a/c'
,
array
(
'a'
=>
false
,
'a/b'
=>
false
,
'a/c'
=>
false
),
array
()),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
false
,
'a/b'
=>
false
,
'b'
=>
false
,
'b/b'
=>
false
)),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
false
,
'a/b'
=>
false
,
'b'
=>
false
,
'b/b'
=>
false
),
array
()),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
false
,
'a/b'
=>
true
,
'b'
=>
false
,
'b/b'
=>
false
)),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
false
,
'a/b'
=>
true
,
'b'
=>
false
,
'b/b'
=>
false
),
array
()),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
true
,
'a/b'
=>
true
,
'b'
=>
false
,
'b/b'
=>
false
)),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
true
,
'a/b'
=>
true
,
'b'
=>
false
,
'b/b'
=>
false
),
array
()),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
true
,
'a/b'
=>
true
,
'b'
=>
true
,
'b/b'
=>
false
),
array
(
'a/b'
=>
false
)),
);
);
}
}
function
moveSuccessProvider
()
{
function
moveSuccessProvider
()
{
return
array
(
return
array
(
array
(
'a/b'
,
'a/c'
,
array
(
'a'
=>
false
,
'a/b'
=>
true
,
'a/c'
=>
false
)),
array
(
'a/b'
,
'a/c'
,
array
(
'a'
=>
false
,
'a/b'
=>
true
,
'a/c'
=>
false
)
,
array
()
),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
true
,
'a/b'
=>
true
,
'b'
=>
true
,
'b/b'
=>
false
)),
array
(
'a/b'
,
'b/b'
,
array
(
'a'
=>
true
,
'a/b'
=>
true
,
'b'
=>
true
,
'b/b'
=>
false
)
,
array
(
'a/b'
=>
true
)
),
);
);
}
}
...
@@ -68,7 +74,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
...
@@ -68,7 +74,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
* @param $dest
* @param $dest
* @param $updatables
* @param $updatables
*/
*/
private
function
moveTest
(
$source
,
$dest
,
$updatables
)
{
private
function
moveTest
(
$source
,
$dest
,
$updatables
,
$deletables
)
{
$rootDir
=
new
OC_Connector_Sabre_Directory
(
''
);
$rootDir
=
new
OC_Connector_Sabre_Directory
(
''
);
$objectTree
=
$this
->
getMock
(
'\OC\Connector\Sabre\ObjectTree'
,
$objectTree
=
$this
->
getMock
(
'\OC\Connector\Sabre\ObjectTree'
,
array
(
'nodeExists'
,
'getNodeForPath'
),
array
(
'nodeExists'
,
'getNodeForPath'
),
...
@@ -80,7 +86,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
...
@@ -80,7 +86,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
->
will
(
$this
->
returnValue
(
false
));
->
will
(
$this
->
returnValue
(
false
));
/** @var $objectTree \OC\Connector\Sabre\ObjectTree */
/** @var $objectTree \OC\Connector\Sabre\ObjectTree */
$objectTree
->
fileView
=
new
TestDoubleFileView
(
$updatables
);
$objectTree
->
fileView
=
new
TestDoubleFileView
(
$updatables
,
$deletables
);
$objectTree
->
move
(
$source
,
$dest
);
$objectTree
->
move
(
$source
,
$dest
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment