diff options
author | jamesren <jamesren@592f7852-d20e-0410-864c-8624ca9c26a4> | 2010-02-12 00:44:31 +0000 |
---|---|---|
committer | jamesren <jamesren@592f7852-d20e-0410-864c-8624ca9c26a4> | 2010-02-12 00:44:31 +0000 |
commit | 0408c82eecc3acf0e3838b4f9ea9dbd04566debd (patch) | |
tree | ad0edf501c2fb58a21812e1cac85ae254437527c /server | |
parent | cf7f1a38c7ba8101bd1e3e76d5f1b82c45f55434 (diff) |
Move the cli RPC authorization_headers code into rpc_client_lib.
Make autotest_lib.server.frontend use it for RPC authentication.
Signed-off-by: Gregory Smith <gps@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@4231 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'server')
-rw-r--r-- | server/frontend.py | 13 | ||||
-rwxr-xr-x | server/frontend_unittest.py | 8 |
2 files changed, 14 insertions, 7 deletions
diff --git a/server/frontend.py b/server/frontend.py index 23bc8555..beafd230 100644 --- a/server/frontend.py +++ b/server/frontend.py @@ -9,8 +9,8 @@ can recursively add and manage other jobs. We turn the JSON dictionaries into real objects that are more idiomatic For docs, see: - http://autotest/afe/server/noauth/rpc/ - http://autotest/new_tko/server/noauth/rpc/ + http://autotest/afe/server/rpc_doc/ + http://autotest/new_tko/server/rpc_doc/ http://docs.djangoproject.com/en/dev/ref/models/querysets/#queryset-api """ @@ -71,8 +71,9 @@ class RpcClient(object): self.print_log = print_log self.debug = debug self.reply_debug = reply_debug - headers = {'AUTHORIZATION' : self.user} - rpc_server = 'http://' + server + path + http_server = 'http://' + server + headers = rpc_client_lib.authorization_headers(user, http_server) + rpc_server = http_server + path if debug: print 'SERVER: %s' % rpc_server print 'HEADERS: %s' % headers @@ -104,7 +105,7 @@ class RpcClient(object): class TKO(RpcClient): def __init__(self, user=None, server=None, print_log=True, debug=False, reply_debug=False): - super(TKO, self).__init__(path='/new_tko/server/noauth/rpc/', + super(TKO, self).__init__(path='/new_tko/server/rpc/', user=user, server=server, print_log=print_log, @@ -123,7 +124,7 @@ class AFE(RpcClient): def __init__(self, user=None, server=None, print_log=True, debug=False, reply_debug=False, job=None): self.job = job - super(AFE, self).__init__(path='/afe/server/noauth/rpc/', + super(AFE, self).__init__(path='/afe/server/rpc/', user=user, server=server, print_log=print_log, diff --git a/server/frontend_unittest.py b/server/frontend_unittest.py index d5b19dcd..e72ccf7b 100755 --- a/server/frontend_unittest.py +++ b/server/frontend_unittest.py @@ -37,6 +37,9 @@ class RpcClientTest(BaseRpcClientTest): def test_init(self): os.environ['LOGNAME'] = 'unittest-user' GLOBAL_CONFIG.override_config_value('SERVER', 'hostname', 'test-host') + rpc_client_lib.authorization_headers.expect_call( + 'unittest-user', 'http://test-host').and_return( + {'AUTHORIZATION': 'unittest-user'}) rpc_client_lib.get_proxy.expect_call( 'http://test-host/path', headers={'AUTHORIZATION': 'unittest-user'}) @@ -52,8 +55,11 @@ class AFETest(BaseRpcClientTest): id = 'idFoo' results_platform_map = {'NORAD' : {'Seeking_Joshua': ['WOPR']}} GLOBAL_CONFIG.override_config_value('SERVER', 'hostname', 'chess') + rpc_client_lib.authorization_headers.expect_call( + 'david', 'http://chess').and_return( + {'AUTHORIZATION': 'david'}) rpc_client_lib.get_proxy.expect_call( - 'http://chess/afe/server/noauth/rpc/', + 'http://chess/afe/server/rpc/', headers={'AUTHORIZATION': 'david'}) self.god.stub_function(utils, 'send_email') utils.send_email.expect_any_call() |