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
5b6c3634
Commit
5b6c3634
authored
11 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Fixed ext storage unit test for groups
Now creating real users and groups for testing external storage mounts
parent
8e0a5ed5
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_external/tests/mountconfig.php
+46
-30
46 additions, 30 deletions
apps/files_external/tests/mountconfig.php
with
46 additions
and
30 deletions
apps/files_external/tests/mountconfig.php
+
46
−
30
View file @
5b6c3634
...
...
@@ -40,9 +40,22 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
private
$oldAllowedBackends
;
private
$allBackends
;
const
TEST_USER1
=
'user1'
;
const
TEST_USER2
=
'user2'
;
const
TEST_GROUP1
=
'group1'
;
const
TEST_GROUP2
=
'group2'
;
public
function
setUp
()
{
\OC_User
::
setUserId
(
'test'
);
$this
->
userHome
=
\OC_User
::
getHome
(
'test'
);
\OC_User
::
createUser
(
self
::
TEST_USER1
,
self
::
TEST_USER1
);
\OC_User
::
createUser
(
self
::
TEST_USER2
,
self
::
TEST_USER2
);
\OC_Group
::
createGroup
(
self
::
TEST_GROUP1
);
\OC_Group
::
addToGroup
(
self
::
TEST_USER1
,
self
::
TEST_GROUP1
);
\OC_Group
::
createGroup
(
self
::
TEST_GROUP2
);
\OC_Group
::
addToGroup
(
self
::
TEST_USER2
,
self
::
TEST_GROUP2
);
\OC_User
::
setUserId
(
self
::
TEST_USER1
);
$this
->
userHome
=
\OC_User
::
getHome
(
self
::
TEST_USER1
);
mkdir
(
$this
->
userHome
);
$this
->
dataDir
=
\OC_Config
::
getValue
(
...
...
@@ -67,9 +80,12 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
public
function
tearDown
()
{
OC_Mount_Config
::
$skipTest
=
false
;
\OC_User
::
deleteUser
(
self
::
TEST_USER2
);
\OC_User
::
deleteUser
(
self
::
TEST_USER1
);
\OC_Group
::
deleteGroup
(
self
::
TEST_GROUP1
);
\OC_Group
::
deleteGroup
(
self
::
TEST_GROUP2
);
@
unlink
(
$this
->
dataDir
.
'/mount.json'
);
@
unlink
(
$this
->
userHome
.
'/mount.json'
);
rmdir
(
$this
->
userHome
);
OCP\Config
::
setAppValue
(
'files_external'
,
...
...
@@ -143,7 +159,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
*/
public
function
testAddMountPointSingleUser
()
{
$mountType
=
OC_Mount_Config
::
MOUNT_TYPE_USER
;
$applicable
=
'test'
;
$applicable
=
self
::
TEST_USER1
;
$isPersonal
=
true
;
$this
->
assertEquals
(
true
,
OC_Mount_Config
::
addMountPoint
(
'/ext'
,
'\OC\Files\Storage\SFTP'
,
array
(),
$mountType
,
$applicable
,
$isPersonal
));
...
...
@@ -152,10 +168,10 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
1
,
count
(
$config
));
$this
->
assertTrue
(
isset
(
$config
[
$mountType
]));
$this
->
assertTrue
(
isset
(
$config
[
$mountType
][
$applicable
]));
$this
->
assertTrue
(
isset
(
$config
[
$mountType
][
$applicable
][
'/
test
/files/ext'
]));
$this
->
assertTrue
(
isset
(
$config
[
$mountType
][
$applicable
][
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
]));
$this
->
assertEquals
(
'\OC\Files\Storage\SFTP'
,
$config
[
$mountType
][
$applicable
][
'/
test
/files/ext'
][
'class'
]
$config
[
$mountType
][
$applicable
][
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
][
'class'
]
);
}
...
...
@@ -164,7 +180,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
*/
public
function
testAddDisallowedBackendMountPointSingleUser
()
{
$mountType
=
OC_Mount_Config
::
MOUNT_TYPE_USER
;
$applicable
=
'test'
;
$applicable
=
self
::
TEST_USER1
;
$isPersonal
=
true
;
// local
...
...
@@ -189,7 +205,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
public
function
testAddMountPointUnexistClass
()
{
$storageClass
=
'Unexist_Storage'
;
$mountType
=
OC_Mount_Config
::
MOUNT_TYPE_USER
;
$applicable
=
'test'
;
$applicable
=
self
::
TEST_USER1
;
$isPersonal
=
false
;
$this
->
assertFalse
(
OC_Mount_Config
::
addMountPoint
(
'/ext'
,
$storageClass
,
array
(),
$mountType
,
$applicable
,
$isPersonal
));
...
...
@@ -236,7 +252,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
*/
public
function
testReadWritePersonalConfig
()
{
$mountType
=
OC_Mount_Config
::
MOUNT_TYPE_USER
;
$applicable
=
'test'
;
$applicable
=
self
::
TEST_USER1
;
$isPersonal
=
true
;
$mountConfig
=
array
(
'host'
=>
'smbhost'
,
...
...
@@ -272,7 +288,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
*/
public
function
testPasswordObfuscation
()
{
$mountType
=
OC_Mount_Config
::
MOUNT_TYPE_USER
;
$applicable
=
'test'
;
$applicable
=
self
::
TEST_USER1
;
$isPersonal
=
true
;
$mountConfig
=
array
(
'host'
=>
'smbhost'
,
...
...
@@ -298,7 +314,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
// check that password inside the file is NOT in plain text
$config
=
$this
->
readUserConfig
();
$savedConfig
=
$config
[
$mountType
][
$applicable
][
'/
test
/files/ext'
][
'options'
];
$savedConfig
=
$config
[
$mountType
][
$applicable
][
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
][
'options'
];
// no more clear text password in file
$this
->
assertFalse
(
isset
(
$savedConfig
[
'password'
]));
...
...
@@ -312,7 +328,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
*/
public
function
testReadLegacyPassword
()
{
$mountType
=
OC_Mount_Config
::
MOUNT_TYPE_USER
;
$applicable
=
'test'
;
$applicable
=
self
::
TEST_USER1
;
$isPersonal
=
true
;
$mountConfig
=
array
(
'host'
=>
'smbhost'
,
...
...
@@ -336,7 +352,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
$config
=
$this
->
readUserConfig
();
// simulate non-encrypted password situation
$config
[
$mountType
][
$applicable
][
'/
test
/files/ext'
][
'options'
][
'password'
]
=
'smbpasswd'
;
$config
[
$mountType
][
$applicable
][
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
][
'options'
][
'password'
]
=
'smbpasswd'
;
$this
->
writeUserConfig
(
$config
);
...
...
@@ -354,31 +370,31 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
false
,
OC_Mount_Config
::
MOUNT_TYPE_USER
,
'all'
,
'test'
,
self
::
TEST_USER1
,
true
,
),
// system mount point for a specific user
array
(
false
,
OC_Mount_Config
::
MOUNT_TYPE_USER
,
'test'
,
'test'
,
self
::
TEST_USER1
,
self
::
TEST_USER1
,
true
,
),
// system mount point for a specific group
array
(
false
,
OC_Mount_Config
::
MOUNT_TYPE_GROUP
,
'testgroup1'
,
'test'
,
self
::
TEST_GROUP1
,
self
::
TEST_USER1
,
true
,
),
// user mount point
array
(
true
,
OC_Mount_Config
::
MOUNT_TYPE_USER
,
'test'
,
'test'
,
self
::
TEST_USER1
,
self
::
TEST_USER1
,
true
,
),
...
...
@@ -387,24 +403,24 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
array
(
false
,
OC_Mount_Config
::
MOUNT_TYPE_USER
,
'anotheruser'
,
'test'
,
self
::
TEST_USER2
,
self
::
TEST_USER1
,
false
,
),
// system mount point for a specific group
array
(
false
,
OC_Mount_Config
::
MOUNT_TYPE_GROUP
,
'anothergroup'
,
'test'
,
self
::
TEST_GROUP2
,
self
::
TEST_USER1
,
false
,
),
// user mount point
array
(
true
,
OC_Mount_Config
::
MOUNT_TYPE_USER
,
'test'
,
'anotheruser'
,
self
::
TEST_USER1
,
self
::
TEST_USER2
,
false
,
),
);
...
...
@@ -447,9 +463,9 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
$mountPoints
=
OC_Mount_Config
::
getAbsoluteMountPoints
(
$testUser
);
if
(
$expectVisible
)
{
$this
->
assertEquals
(
1
,
count
(
$mountPoints
));
$this
->
assertTrue
(
isset
(
$mountPoints
[
'/
test
/files/ext'
]));
$this
->
assertEquals
(
'\OC\Files\Storage\SMB'
,
$mountPoints
[
'/
test
/files/ext'
][
'class'
]);
$this
->
assertEquals
(
$mountConfig
,
$mountPoints
[
'/
test
/files/ext'
][
'options'
]);
$this
->
assertTrue
(
isset
(
$mountPoints
[
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
]));
$this
->
assertEquals
(
'\OC\Files\Storage\SMB'
,
$mountPoints
[
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
][
'class'
]);
$this
->
assertEquals
(
$mountConfig
,
$mountPoints
[
'/
'
.
self
::
TEST_USER1
.
'
/files/ext'
][
'options'
]);
}
else
{
$this
->
assertEquals
(
0
,
count
(
$mountPoints
));
...
...
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