From c55a069468fa2ad54f897f02e7622ca6556d93c0 Mon Sep 17 00:00:00 2001 From: gholt Date: Wed, 15 Sep 2010 13:11:06 -0700 Subject: [PATCH] auth-server: Change 400 to 409 when trying to add an existing user --- swift/auth/server.py | 6 +++--- test/unit/auth/test_server.py | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/swift/auth/server.py b/swift/auth/server.py index aafacbb2c4..87decc7116 100644 --- a/swift/auth/server.py +++ b/swift/auth/server.py @@ -23,8 +23,8 @@ from urlparse import urlparse import sqlite3 from webob import Request, Response -from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPNoContent, \ - HTTPUnauthorized, HTTPServiceUnavailable, HTTPNotFound +from webob.exc import HTTPBadRequest, HTTPConflict, HTTPForbidden, \ + HTTPNoContent, HTTPUnauthorized, HTTPServiceUnavailable, HTTPNotFound from swift.common.bufferedhttp import http_connect_raw as http_connect from swift.common.db import get_db_connection @@ -433,7 +433,7 @@ class AuthController(object): storage_url = self.create_user(account_name, user_name, password, create_account_admin, create_reseller_admin) if storage_url == 'already exists': - return HTTPBadRequest(body=storage_url) + return HTTPConflict(body=storage_url) if not storage_url: return HTTPServiceUnavailable() return HTTPNoContent(headers={'x-storage-url': storage_url}) diff --git a/test/unit/auth/test_server.py b/test/unit/auth/test_server.py index d005cfb377..0786dfd309 100644 --- a/test/unit/auth/test_server.py +++ b/test/unit/auth/test_server.py @@ -656,6 +656,11 @@ class TestAuthServer(unittest.TestCase): self.assertEquals( self.controller.create_user('test', 'tester', 'testing'), 'already exists') + req = Request.blank('/account/test/tester', + headers={'X-Auth-User-Key': 'testing'}) + resp = self.controller.handle_add_user(req) + self.assertEquals(resp.status_int, 409) + def test_create_2users_1account(self): auth_server.http_connect = fake_http_connect(201)