-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Explicitly call out readonly user fields (#21889)
- Loading branch information
1 parent
5963254
commit 2d25f2e
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -887,6 +887,25 @@ def assert_forbidden_url(url): | |
assert_allowed_url("https://subdomain.otherexample.com") | ||
assert_allowed_url("https://sub.subdomain.otherexample.com") | ||
|
||
def test_user_cannot_update_protected_fields(self): | ||
self.user.is_staff = False | ||
self.user.save() | ||
fields = { | ||
"date_joined": "2021-01-01T00:00:00Z", | ||
"uuid": str(uuid.uuid4()), | ||
"distinct_id": "distinct_id", | ||
"pending_email": "[email protected]", | ||
"is_email_verified": True, | ||
} | ||
|
||
initial_user = self.client.get("/api/users/@me/").json() | ||
|
||
for field, value in fields.items(): | ||
response = self.client.patch("/api/users/@me/", {field: value}) | ||
assert ( | ||
response.json()[field] == initial_user[field] | ||
), f"Updating field '{field}' to '{value}' worked when it shouldn't! Was {initial_user[field]} and is now {response.json()[field]}" | ||
|
||
|
||
class TestUserSlackWebhook(APIBaseTest): | ||
ENDPOINT: str = "/api/user/test_slack_webhook/" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters