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_InvalidCredentials(test.test): 9 """Test that buffet transitions properly if refresh token is revoked.""" 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 access and refresh token and check 26 # that buffet transitions to the invalid_credentials state and clears 27 # the stored credentials/device_id. 28 self._helper._oauth_client.invalidate_all_refresh_tokens() 29 self._helper._oauth_client.invalidate_all_access_tokens() 30 self._helper.check_buffet_status_is( 31 buffet_tester.STATUS_INVALID_CREDENTIALS, 32 expected_device_id=device_id, 33 timeout_seconds=20) 34 35 36 def cleanup(self): 37 self._helper.close() 38