Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f73a1686
Commit
f73a1686
authored
11 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Added unit test for sharing ext storage mount points
parent
28f0e630
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_sharing/tests/api.php
+55
-2
55 additions, 2 deletions
apps/files_sharing/tests/api.php
with
55 additions
and
2 deletions
apps/files_sharing/tests/api.php
+
55
−
2
View file @
f73a1686
...
...
@@ -29,10 +29,14 @@ use OCA\Files\Share;
*/
class
Test_Files_Sharing_Api
extends
Test_Files_Sharing_Base
{
const
TEST_FOLDER_NAME
=
'/folder_share_api_test'
;
private
static
$tempStorage
;
function
setUp
()
{
parent
::
setUp
();
$this
->
folder
=
'/folder_share_api_test'
;
$this
->
folder
=
self
::
TEST_FOLDER_NAME
;
$this
->
subfolder
=
'/subfolder_share_api_test'
;
$this
->
subsubfolder
=
'/subsubfolder_share_api_test'
;
...
...
@@ -51,6 +55,8 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$this
->
view
->
unlink
(
$this
->
filename
);
$this
->
view
->
deleteAll
(
$this
->
folder
);
self
::
$tempStorage
=
null
;
parent
::
tearDown
();
}
...
...
@@ -928,6 +934,54 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
}
/**
* Post init mount points hook for mounting simulated ext storage
*/
public
static
function
initTestMountPointsHook
(
$data
)
{
if
(
$data
[
'user'
]
===
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
)
{
\OC\Files\Filesystem
::
mount
(
self
::
$tempStorage
,
array
(),
'/'
.
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
.
'/files'
.
self
::
TEST_FOLDER_NAME
);
}
}
/**
* Tests mounting a folder that is an external storage mount point.
*/
public
function
testShareStorageMountPoint
()
{
self
::
$tempStorage
=
new
\OC\Files\Storage\Temporary
(
array
());
self
::
$tempStorage
->
file_put_contents
(
'test.txt'
,
'abcdef'
);
self
::
$tempStorage
->
getScanner
()
->
scan
(
''
);
// needed because the sharing code sometimes switches the user internally and mounts the user's
// storages. In our case the temp storage isn't mounted automatically, so doing it in the post hook
// (similar to how ext storage works)
OCP\Util
::
connectHook
(
'OC_Filesystem'
,
'post_initMountPoints'
,
'\Test_Files_Sharing_Api'
,
'initTestMountPointsHook'
);
// logging in will auto-mount the temp storage for user1 as well
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
);
$fileInfo
=
$this
->
view
->
getFileInfo
(
$this
->
folder
);
// user 1 shares the mount point folder with user2
$result
=
\OCP\Share
::
shareItem
(
'folder'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
,
31
);
$this
->
assertTrue
(
$result
);
// user2: check that mount point name appears correctly
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
$view
=
new
\OC\Files\View
(
'/'
.
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
.
'/files'
);
$this
->
assertTrue
(
$view
->
file_exists
(
$this
->
folder
));
$this
->
assertTrue
(
$view
->
file_exists
(
$this
->
folder
.
'/test.txt'
));
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
);
\OCP\Share
::
unshare
(
'folder'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
\OC_Hook
::
clear
(
'OC_Filesystem'
,
'post_initMountPoints'
,
'\Test_Files_Sharing_Api'
,
'initTestMountPointsHook'
);
}
/**
* @expectedException \Exception
*/
...
...
@@ -950,5 +1004,4 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
\OCP\Share
::
shareItem
(
'file'
,
$info
->
getId
(),
\OCP\Share
::
SHARE_TYPE_LINK
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
,
31
);
}
}
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