Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
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
Value stream analytics
Contributor analytics
CI/CD 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
Maunium
synapse
Commits
d8994942
Unverified
Commit
d8994942
authored
5 years ago
by
Andrew Morgan
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Return a 404 for admin api user lookup if user not found (#6901)
parent
47acbc51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/6901.misc
+1
-0
1 addition, 0 deletions
changelog.d/6901.misc
synapse/rest/admin/users.py
+4
-1
4 additions, 1 deletion
synapse/rest/admin/users.py
tests/rest/admin/test_user.py
+16
-0
16 additions, 0 deletions
tests/rest/admin/test_user.py
with
21 additions
and
1 deletion
changelog.d/6901.misc
0 → 100644
+
1
−
0
View file @
d8994942
Return a 404 instead of 200 for querying information of a non-existant user through the admin API.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/rest/admin/users.py
+
4
−
1
View file @
d8994942
...
@@ -21,7 +21,7 @@ from six import text_type
...
@@ -21,7 +21,7 @@ from six import text_type
from
six.moves
import
http_client
from
six.moves
import
http_client
from
synapse.api.constants
import
UserTypes
from
synapse.api.constants
import
UserTypes
from
synapse.api.errors
import
Codes
,
SynapseError
from
synapse.api.errors
import
Codes
,
NotFoundError
,
SynapseError
from
synapse.http.servlet
import
(
from
synapse.http.servlet
import
(
RestServlet
,
RestServlet
,
assert_params_in_dict
,
assert_params_in_dict
,
...
@@ -152,6 +152,9 @@ class UserRestServletV2(RestServlet):
...
@@ -152,6 +152,9 @@ class UserRestServletV2(RestServlet):
ret
=
await
self
.
admin_handler
.
get_user
(
target_user
)
ret
=
await
self
.
admin_handler
.
get_user
(
target_user
)
if
not
ret
:
raise
NotFoundError
(
"
User not found
"
)
return
200
,
ret
return
200
,
ret
async
def
on_PUT
(
self
,
request
,
user_id
):
async
def
on_PUT
(
self
,
request
,
user_id
):
...
...
This diff is collapsed.
Click to expand it.
tests/rest/admin/test_user.py
+
16
−
0
View file @
d8994942
...
@@ -401,6 +401,22 @@ class UserRestTestCase(unittest.HomeserverTestCase):
...
@@ -401,6 +401,22 @@ class UserRestTestCase(unittest.HomeserverTestCase):
self
.
assertEqual
(
403
,
int
(
channel
.
result
[
"
code
"
]),
msg
=
channel
.
result
[
"
body
"
])
self
.
assertEqual
(
403
,
int
(
channel
.
result
[
"
code
"
]),
msg
=
channel
.
result
[
"
body
"
])
self
.
assertEqual
(
"
You are not a server admin
"
,
channel
.
json_body
[
"
error
"
])
self
.
assertEqual
(
"
You are not a server admin
"
,
channel
.
json_body
[
"
error
"
])
def
test_user_does_not_exist
(
self
):
"""
Tests that a lookup for a user that does not exist returns a 404
"""
self
.
hs
.
config
.
registration_shared_secret
=
None
request
,
channel
=
self
.
make_request
(
"
GET
"
,
"
/_synapse/admin/v2/users/@unknown_person:test
"
,
access_token
=
self
.
admin_user_tok
,
)
self
.
render
(
request
)
self
.
assertEqual
(
404
,
channel
.
code
,
msg
=
channel
.
json_body
)
self
.
assertEqual
(
"
M_NOT_FOUND
"
,
channel
.
json_body
[
"
errcode
"
])
def
test_requester_is_admin
(
self
):
def
test_requester_is_admin
(
self
):
"""
"""
If the user is a server admin, a new user is created.
If the user is a server admin, a new user is created.
...
...
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