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
99738ae0
Commit
99738ae0
authored
11 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
add test for the reshare option
parent
ab6ee79e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_sharing/tests/api.php
+59
-2
59 additions, 2 deletions
apps/files_sharing/tests/api.php
with
59 additions
and
2 deletions
apps/files_sharing/tests/api.php
+
59
−
2
View file @
99738ae0
...
...
@@ -31,6 +31,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
const
TEST_FILES_SHARING_API_USER1
=
"test-share-user1"
;
const
TEST_FILES_SHARING_API_USER2
=
"test-share-user2"
;
const
TEST_FILES_SHARING_API_USER3
=
"test-share-user3"
;
public
$stateFilesEncryption
;
public
$filename
;
...
...
@@ -54,6 +55,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
// create users
self
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
,
true
);
self
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
,
true
);
self
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER3
,
true
);
}
...
...
@@ -101,6 +103,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
// cleanup users
\OC_User
::
deleteUser
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
);
\OC_User
::
deleteUser
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
\OC_User
::
deleteUser
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER3
);
}
/**
...
...
@@ -197,9 +200,9 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
\OCP\Share
::
shareItem
(
'file'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_LINK
,
null
,
1
);
$
params
=
array
(
'path'
=
>
$this
->
filename
)
;
$
_GET
[
'path'
]
=
$this
->
filename
;
$result
=
Share\Api
::
getAllShares
(
$params
);
$result
=
Share\Api
::
getAllShares
(
array
()
);
$this
->
assertTrue
(
$result
->
succeeded
());
...
...
@@ -213,6 +216,60 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
}
/**
* @medium
* @depends testCreateShare
*/
function
testGetShareFromSourceWithReshares
()
{
$fileInfo
=
$this
->
view
->
getFileInfo
(
$this
->
filename
);
// share the file as user1 to user2
\OCP\Share
::
shareItem
(
'file'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
,
31
);
// login as user2 and reshare the file to user3
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
\OCP\Share
::
shareItem
(
'file'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER3
,
31
);
// login as user1 again
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
);
$_GET
[
'path'
]
=
$this
->
filename
;
$result
=
Share\Api
::
getAllShares
(
array
());
$this
->
assertTrue
(
$result
->
succeeded
());
// test should return one share
$this
->
assertTrue
(
count
(
$result
->
getData
())
===
1
);
// now also ask for the reshares
$_GET
[
'reshares'
]
=
'true'
;
$result
=
Share\Api
::
getAllShares
(
array
());
$this
->
assertTrue
(
$result
->
succeeded
());
// now we should get two shares, the initial share and the reshare
$this
->
assertTrue
(
count
(
$result
->
getData
())
===
2
);
// unshare files again
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
\OCP\Share
::
unshare
(
'file'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER3
);
\Test_Files_Sharing_Api
::
loginHelper
(
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER1
);
\OCP\Share
::
unshare
(
'file'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
\Test_Files_Sharing_Api
::
TEST_FILES_SHARING_API_USER2
);
}
/**
* @medium
* @depends testCreateShare
...
...
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