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
a3381b1d
Unverified
Commit
a3381b1d
authored
8 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
we need to initialize the mount points of the given user before we recover
access to his files
parent
b441d3dc
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
apps/encryption/hooks/userhooks.php
+11
-0
11 additions, 0 deletions
apps/encryption/hooks/userhooks.php
apps/encryption/tests/hooks/UserHooksTest.php
+37
-10
37 additions, 10 deletions
apps/encryption/tests/hooks/UserHooksTest.php
with
48 additions
and
10 deletions
apps/encryption/hooks/userhooks.php
+
11
−
0
View file @
a3381b1d
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
namespace
OCA\Encryption\Hooks
;
namespace
OCA\Encryption\Hooks
;
use
OC\Files\Filesystem
;
use
OCP\IUserManager
;
use
OCP\IUserManager
;
use
OCP\Util
as
OCUtil
;
use
OCP\Util
as
OCUtil
;
use
OCA\Encryption\Hooks\Contracts\IHook
;
use
OCA\Encryption\Hooks\Contracts\IHook
;
...
@@ -243,6 +244,7 @@ class UserHooks implements IHook {
...
@@ -243,6 +244,7 @@ class UserHooks implements IHook {
// used to decrypt it has changed
// used to decrypt it has changed
}
else
{
// admin changed the password for a different user, create new keys and re-encrypt file keys
}
else
{
// admin changed the password for a different user, create new keys and re-encrypt file keys
$user
=
$params
[
'uid'
];
$user
=
$params
[
'uid'
];
$this
->
initMountPoints
(
$user
);
$recoveryPassword
=
isset
(
$params
[
'recoveryPassword'
])
?
$params
[
'recoveryPassword'
]
:
null
;
$recoveryPassword
=
isset
(
$params
[
'recoveryPassword'
])
?
$params
[
'recoveryPassword'
]
:
null
;
// we generate new keys if...
// we generate new keys if...
...
@@ -281,6 +283,15 @@ class UserHooks implements IHook {
...
@@ -281,6 +283,15 @@ class UserHooks implements IHook {
}
}
}
}
/**
* init mount points for given user
*
* @param string $user
* @throws \OC\User\NoUserException
*/
protected
function
initMountPoints
(
$user
)
{
Filesystem
::
initMountPoints
(
$user
);
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
apps/encryption/tests/hooks/UserHooksTest.php
+
37
−
10
View file @
a3381b1d
...
@@ -29,6 +29,12 @@ use OCA\Encryption\Crypto\Crypt;
...
@@ -29,6 +29,12 @@ use OCA\Encryption\Crypto\Crypt;
use
OCA\Encryption\Hooks\UserHooks
;
use
OCA\Encryption\Hooks\UserHooks
;
use
Test\TestCase
;
use
Test\TestCase
;
/**
* Class UserHooksTest
*
* @group DB
* @package OCA\Encryption\Tests\Hooks
*/
class
UserHooksTest
extends
TestCase
{
class
UserHooksTest
extends
TestCase
{
/**
/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit_Framework_MockObject_MockObject
...
@@ -190,6 +196,23 @@ class UserHooksTest extends TestCase {
...
@@ -190,6 +196,23 @@ class UserHooksTest extends TestCase {
->
willReturnOnConsecutiveCalls
(
true
,
false
);
->
willReturnOnConsecutiveCalls
(
true
,
false
);
$this
->
instance
=
$this
->
getMockBuilder
(
'OCA\Encryption\Hooks\UserHooks'
)
->
setConstructorArgs
(
[
$this
->
keyManagerMock
,
$this
->
userManagerMock
,
$this
->
loggerMock
,
$this
->
userSetupMock
,
$this
->
userSessionMock
,
$this
->
utilMock
,
$this
->
sessionMock
,
$this
->
cryptMock
,
$this
->
recoveryMock
]
)
->
setMethods
([
'initMountPoints'
])
->
getMock
();
$this
->
instance
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'initMountPoints'
);
// Test first if statement
// Test first if statement
$this
->
assertNull
(
$this
->
instance
->
setPassphrase
(
$this
->
params
));
$this
->
assertNull
(
$this
->
instance
->
setPassphrase
(
$this
->
params
));
...
@@ -236,16 +259,20 @@ class UserHooksTest extends TestCase {
...
@@ -236,16 +259,20 @@ class UserHooksTest extends TestCase {
->
with
(
'testUser'
)
->
with
(
'testUser'
)
->
willReturn
(
false
);
->
willReturn
(
false
);
$userHooks
=
new
UserHooks
(
$this
->
keyManagerMock
,
$userHooks
=
$this
->
getMockBuilder
(
'OCA\Encryption\Hooks\UserHooks'
)
$this
->
userManagerMock
,
->
setConstructorArgs
(
$this
->
loggerMock
,
[
$this
->
userSetupMock
,
$this
->
keyManagerMock
,
$userSessionMock
,
$this
->
userManagerMock
,
$this
->
utilMock
,
$this
->
loggerMock
,
$this
->
sessionMock
,
$this
->
userSetupMock
,
$this
->
cryptMock
,
$userSessionMock
,
$this
->
recoveryMock
$this
->
utilMock
,
);
$this
->
sessionMock
,
$this
->
cryptMock
,
$this
->
recoveryMock
]
)
->
setMethods
([
'initMountPoints'
])
->
getMock
();
$this
->
assertNull
(
$userHooks
->
setPassphrase
(
$this
->
params
));
$this
->
assertNull
(
$userHooks
->
setPassphrase
(
$this
->
params
));
}
}
...
...
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