[autotest] Forward user when forwaring/routing RPCs.
User account information is passed to RPC server via
HTTP header. We can pass the user info to the header when
creating server.frontend.RpcClient object. We should forward
the user info when forwaring/routing RPCs not to lose the
user account info in the receiving side.
BUG=chromium:533159
TEST=puppylab. Lock a sharded host with root account and check
the host is locked by root in the master DB and the shard DB.
Change-Id: I185e49f028c8fdfdf630855412a6e370d5684491
Reviewed-on: https://chromium-review.googlesource.com/300594
Commit-Ready: Mungyung Ryu <[email protected]>
Tested-by: Mungyung Ryu <[email protected]>
Reviewed-by: Fang Deng <[email protected]>
Reviewed-by: Dan Shi <[email protected]>
diff --git a/frontend/afe/rpc_interface_unittest.py b/frontend/afe/rpc_interface_unittest.py
index 70bba4d..eec4b41 100755
--- a/frontend/afe/rpc_interface_unittest.py
+++ b/frontend/afe/rpc_interface_unittest.py
@@ -458,7 +458,7 @@
self.god.stub_with(frontend_wrappers, 'RetryingAFE', mock_afe)
mock_afe2 = frontend_wrappers.RetryingAFE.expect_new(
- server=shard_hostname)
+ server=shard_hostname, user=None)
mock_afe2.run.expect_call('modify_host_local', id=host.id,
locked=True, lock_reason='_modify_host_helper lock')
elif on_shard:
@@ -467,7 +467,7 @@
self.god.stub_with(frontend_wrappers, 'RetryingAFE', mock_afe)
mock_afe2 = frontend_wrappers.RetryingAFE.expect_new(
- server=rpc_utils.get_global_afe_hostname())
+ server=rpc_utils.get_global_afe_hostname(), user=None)
mock_afe2.run.expect_call('modify_host', id=host.id,
locked=True, lock_reason='_modify_host_helper lock')
@@ -523,14 +523,16 @@
# will be affected no matter what his status is.
filters_to_use = {'status': 'Ready'}
- mock_afe2 = frontend_wrappers.RetryingAFE.expect_new(server='shard2')
+ mock_afe2 = frontend_wrappers.RetryingAFE.expect_new(
+ server='shard2', user=None)
mock_afe2.run.expect_call(
'modify_hosts_local',
host_filter_data={'id__in': [shard1.id, shard2.id]},
update_data={'locked': True,
'lock_reason': 'Testing forward to shard'})
- mock_afe1 = frontend_wrappers.RetryingAFE.expect_new(server='shard1')
+ mock_afe1 = frontend_wrappers.RetryingAFE.expect_new(
+ server='shard1', user=None)
mock_afe1.run.expect_call(
'modify_hosts_local',
host_filter_data={'id__in': [shard1.id, shard2.id]},
@@ -561,7 +563,8 @@
'MockAFE')
self.god.stub_with(frontend_wrappers, 'RetryingAFE', mock_afe)
- mock_afe1 = frontend_wrappers.RetryingAFE.expect_new(server='shard1')
+ mock_afe1 = frontend_wrappers.RetryingAFE.expect_new(
+ server='shard1', user=None)
mock_afe1.run.expect_call('delete_host', id=host1.id)
rpc_interface.delete_host(id=host1.id)