def test_save_tokens_to_file(tmpdir, jwt, token_timestring): filepath = os.path.join(str(tmpdir), 'save_tokens.json') auth_manager = AuthenticationManager() auth_manager.access_token = AccessToken(jwt, 1000) auth_manager.xsts_token = XSTSToken(jwt, token_timestring, token_timestring) auth_manager.userinfo = XboxLiveUserInfo(xuid='2535428504476914', userhash='1674471606081042789', gamertag='xboxWebapiGamertag', age_group='Adult', privileges='123 321 432 654', user_privileges='123') auth_manager.dump(filepath) assert os.path.isfile(filepath) is True
def _do_2fa(cassette_name, strategy_index, proof=None, otc=None): auth_manager = AuthenticationManager() auth_manager.email_address = '*****@*****.**' auth_manager.password = '******' with Betamax(auth_manager.session).use_cassette(cassette_name): with pytest.raises(TwoFactorAuthRequired) as excinfo: auth_manager.authenticate() two_fa_auth = TwoFactorAuthentication( auth_manager.session, auth_manager.email_address, excinfo.value.server_data ) two_fa_auth.check_otc(strategy_index, proof) access_token, refresh_token = two_fa_auth.authenticate(strategy_index, proof, otc) auth_manager.access_token = access_token auth_manager.refresh_token = refresh_token auth_manager.authenticate(do_refresh=False) return auth_manager