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
a2e16fd5
Commit
a2e16fd5
authored
8 years ago
by
Lukas Reschke
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #3418 from nextcloud/add-groups-to-userinfo
add groups to user info output
parents
9e21a555
2ca8339d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/provisioning_api/lib/Controller/UsersController.php
+6
-0
6 additions, 0 deletions
apps/provisioning_api/lib/Controller/UsersController.php
apps/provisioning_api/tests/Controller/UsersControllerTest.php
+30
-3
30 additions, 3 deletions
...provisioning_api/tests/Controller/UsersControllerTest.php
with
36 additions
and
3 deletions
apps/provisioning_api/lib/Controller/UsersController.php
+
6
−
0
View file @
a2e16fd5
...
@@ -252,6 +252,11 @@ class UsersController extends OCSController {
...
@@ -252,6 +252,11 @@ class UsersController extends OCSController {
}
}
$userAccount
=
$this
->
accountManager
->
getUser
(
$targetUserObject
);
$userAccount
=
$this
->
accountManager
->
getUser
(
$targetUserObject
);
$groups
=
$this
->
groupManager
->
getUserGroups
(
$targetUserObject
);
$gids
=
[];
foreach
(
$groups
as
$group
)
{
$gids
[]
=
$group
->
getDisplayName
();
}
// Find the data
// Find the data
$data
[
'id'
]
=
$targetUserObject
->
getUID
();
$data
[
'id'
]
=
$targetUserObject
->
getUID
();
...
@@ -262,6 +267,7 @@ class UsersController extends OCSController {
...
@@ -262,6 +267,7 @@ class UsersController extends OCSController {
$data
[
'address'
]
=
$userAccount
[
\OC\Accounts\AccountManager
::
PROPERTY_ADDRESS
][
'value'
];
$data
[
'address'
]
=
$userAccount
[
\OC\Accounts\AccountManager
::
PROPERTY_ADDRESS
][
'value'
];
$data
[
'webpage'
]
=
$userAccount
[
\OC\Accounts\AccountManager
::
PROPERTY_WEBSITE
][
'value'
];
$data
[
'webpage'
]
=
$userAccount
[
\OC\Accounts\AccountManager
::
PROPERTY_WEBSITE
][
'value'
];
$data
[
'twitter'
]
=
$userAccount
[
\OC\Accounts\AccountManager
::
PROPERTY_TWITTER
][
'value'
];
$data
[
'twitter'
]
=
$userAccount
[
\OC\Accounts\AccountManager
::
PROPERTY_TWITTER
][
'value'
];
$data
[
'groups'
]
=
$gids
;
return
$data
;
return
$data
;
}
}
...
...
This diff is collapsed.
Click to expand it.
apps/provisioning_api/tests/Controller/UsersControllerTest.php
+
30
−
3
View file @
a2e16fd5
...
@@ -635,6 +635,9 @@ class UsersControllerTest extends OriginalTest {
...
@@ -635,6 +635,9 @@ class UsersControllerTest extends OriginalTest {
}
}
public
function
testGetUserDataAsAdmin
()
{
public
function
testGetUserDataAsAdmin
()
{
$group
=
$this
->
getMockBuilder
(
IGroup
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$loggedInUser
=
$this
->
getMockBuilder
(
'OCP\IUser'
)
$loggedInUser
=
$this
->
getMockBuilder
(
'OCP\IUser'
)
->
disableOriginalConstructor
()
->
disableOriginalConstructor
()
->
getMock
();
->
getMock
();
...
@@ -662,6 +665,19 @@ class UsersControllerTest extends OriginalTest {
...
@@ -662,6 +665,19 @@ class UsersControllerTest extends OriginalTest {
->
method
(
'isAdmin'
)
->
method
(
'isAdmin'
)
->
with
(
'admin'
)
->
with
(
'admin'
)
->
will
(
$this
->
returnValue
(
true
));
->
will
(
$this
->
returnValue
(
true
));
$this
->
groupManager
->
expects
(
$this
->
any
())
->
method
(
'getUserGroups'
)
->
willReturn
([
$group
,
$group
,
$group
]);
$group
->
expects
(
$this
->
at
(
0
))
->
method
(
'getDisplayName'
)
->
willReturn
(
'group0'
);
$group
->
expects
(
$this
->
at
(
1
))
->
method
(
'getDisplayName'
)
->
willReturn
(
'group1'
);
$group
->
expects
(
$this
->
at
(
2
))
->
method
(
'getDisplayName'
)
->
willReturn
(
'group2'
);
$this
->
accountManager
->
expects
(
$this
->
any
())
->
method
(
'getUser'
)
$this
->
accountManager
->
expects
(
$this
->
any
())
->
method
(
'getUser'
)
->
with
(
$targetUser
)
->
with
(
$targetUser
)
->
willReturn
(
->
willReturn
(
...
@@ -700,7 +716,8 @@ class UsersControllerTest extends OriginalTest {
...
@@ -700,7 +716,8 @@ class UsersControllerTest extends OriginalTest {
'phone'
=>
'phone'
,
'phone'
=>
'phone'
,
'address'
=>
'address'
,
'address'
=>
'address'
,
'webpage'
=>
'website'
,
'webpage'
=>
'website'
,
'twitter'
=>
'twitter'
'twitter'
=>
'twitter'
,
'groups'
=>
[
'group0'
,
'group1'
,
'group2'
]
];
];
$this
->
assertEquals
(
$expected
,
$this
->
invokePrivate
(
$this
->
api
,
'getUserData'
,
[
'UserToGet'
]));
$this
->
assertEquals
(
$expected
,
$this
->
invokePrivate
(
$this
->
api
,
'getUserData'
,
[
'UserToGet'
]));
}
}
...
@@ -734,6 +751,10 @@ class UsersControllerTest extends OriginalTest {
...
@@ -734,6 +751,10 @@ class UsersControllerTest extends OriginalTest {
->
method
(
'isAdmin'
)
->
method
(
'isAdmin'
)
->
with
(
'subadmin'
)
->
with
(
'subadmin'
)
->
will
(
$this
->
returnValue
(
false
));
->
will
(
$this
->
returnValue
(
false
));
$this
->
groupManager
->
expects
(
$this
->
any
())
->
method
(
'getUserGroups'
)
->
willReturn
([]);
$subAdminManager
=
$this
->
getMockBuilder
(
'OC\SubAdmin'
)
$subAdminManager
=
$this
->
getMockBuilder
(
'OC\SubAdmin'
)
->
disableOriginalConstructor
()
->
disableOriginalConstructor
()
->
getMock
();
->
getMock
();
...
@@ -784,7 +805,8 @@ class UsersControllerTest extends OriginalTest {
...
@@ -784,7 +805,8 @@ class UsersControllerTest extends OriginalTest {
'phone'
=>
'phone'
,
'phone'
=>
'phone'
,
'address'
=>
'address'
,
'address'
=>
'address'
,
'webpage'
=>
'website'
,
'webpage'
=>
'website'
,
'twitter'
=>
'twitter'
'twitter'
=>
'twitter'
,
'groups'
=>
[]
];
];
$this
->
assertEquals
(
$expected
,
$this
->
invokePrivate
(
$this
->
api
,
'getUserData'
,
[
'UserToGet'
]));
$this
->
assertEquals
(
$expected
,
$this
->
invokePrivate
(
$this
->
api
,
'getUserData'
,
[
'UserToGet'
]));
}
}
...
@@ -872,6 +894,10 @@ class UsersControllerTest extends OriginalTest {
...
@@ -872,6 +894,10 @@ class UsersControllerTest extends OriginalTest {
->
expects
(
$this
->
once
())
->
expects
(
$this
->
once
())
->
method
(
'getSubAdmin'
)
->
method
(
'getSubAdmin'
)
->
will
(
$this
->
returnValue
(
$subAdminManager
));
->
will
(
$this
->
returnValue
(
$subAdminManager
));
$this
->
groupManager
->
expects
(
$this
->
any
())
->
method
(
'getUserGroups'
)
->
willReturn
([]);
$this
->
api
$this
->
api
->
expects
(
$this
->
once
())
->
expects
(
$this
->
once
())
->
method
(
'fillStorageInfo'
)
->
method
(
'fillStorageInfo'
)
...
@@ -908,7 +934,8 @@ class UsersControllerTest extends OriginalTest {
...
@@ -908,7 +934,8 @@ class UsersControllerTest extends OriginalTest {
'phone'
=>
'phone'
,
'phone'
=>
'phone'
,
'address'
=>
'address'
,
'address'
=>
'address'
,
'webpage'
=>
'website'
,
'webpage'
=>
'website'
,
'twitter'
=>
'twitter'
'twitter'
=>
'twitter'
,
'groups'
=>
[]
];
];
$this
->
assertEquals
(
$expected
,
$this
->
invokePrivate
(
$this
->
api
,
'getUserData'
,
[
'subadmin'
]));
$this
->
assertEquals
(
$expected
,
$this
->
invokePrivate
(
$this
->
api
,
'getUserData'
,
[
'subadmin'
]));
}
}
...
...
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