mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-10 11:33:01 +00:00
raise 409 conflict on duplicate actions
Makes it easier for upstream clients to retry failed actions and ignore failure due to duplicate transactions
This commit is contained in:
@@ -357,7 +357,7 @@ def test_add_multi_user(app):
|
||||
r = yield api_request(app, 'users', method='post',
|
||||
data=json.dumps({'usernames': names}),
|
||||
)
|
||||
assert r.status_code == 400
|
||||
assert r.status_code == 409
|
||||
|
||||
names = ['a', 'b', 'ab']
|
||||
|
||||
@@ -402,6 +402,19 @@ def test_add_user_bad(app):
|
||||
assert user is None
|
||||
|
||||
|
||||
@mark.user
|
||||
@mark.gen_test
|
||||
def test_add_user_duplicate(app):
|
||||
db = app.db
|
||||
name = 'user'
|
||||
user = find_user(db, name)
|
||||
# double-check that it exists
|
||||
assert user is not None
|
||||
r = yield api_request(app, 'users', name, method='post')
|
||||
# special 409 conflict for creating a user that already exists
|
||||
assert r.status_code == 409
|
||||
|
||||
|
||||
@mark.user
|
||||
@mark.gen_test
|
||||
def test_add_admin(app):
|
||||
@@ -1005,7 +1018,7 @@ def test_add_multi_group(app):
|
||||
r = yield api_request(app, 'users', method='post',
|
||||
data=json.dumps({'groups': names}),
|
||||
)
|
||||
assert r.status_code == 400
|
||||
assert r.status_code == 409
|
||||
|
||||
|
||||
@mark.group
|
||||
@@ -1054,7 +1067,7 @@ def test_group_create_delete(app):
|
||||
|
||||
# create duplicate raises 400
|
||||
r = yield api_request(app, 'groups/omegaflight', method='post')
|
||||
assert r.status_code == 400
|
||||
assert r.status_code == 409
|
||||
|
||||
r = yield api_request(app, 'groups/omegaflight', method='delete')
|
||||
assert r.status_code == 204
|
||||
|
Reference in New Issue
Block a user