1# Copyright 2015 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from autotest_lib.client.bin import test 6from autotest_lib.client.common_lib.cros.tendo import buffet_tester 7 8class buffet_RefreshAccessToken(test.test): 9 """Test that buffet can refresh its access token.""" 10 version = 1 11 12 def initialize(self): 13 self._helper = buffet_tester.BuffetTester() 14 15 16 def run_once(self): 17 # Erase all buffet state and restart it pointing to our fake 18 # server, register with the cloud and check we can poll for 19 # commands. 20 self._helper.restart_buffet(reset_state=True) 21 self._helper.check_buffet_status_is(buffet_tester.STATUS_UNCONFIGURED) 22 device_id = self._helper.register_with_server() 23 self._helper.check_buffet_is_polling(device_id) 24 25 # Now invalidate buffet's current access token and check that 26 # we can still poll for commands. This demonstrates that 27 # buffet is able to get a new access token if the one that 28 # it's been using has been revoked. 29 self._helper._oauth_client.invalidate_all_access_tokens() 30 self._helper.check_buffet_is_polling(device_id) 31 self._helper.check_buffet_status_is( 32 buffet_tester.STATUS_CONNECTED, expected_device_id=device_id) 33 34 35 def cleanup(self): 36 self._helper.close() 37