[MTest] public void HandleBootAuthFailed() { Autoya.forceFailFirstBoot = true; Autoya.Auth_DeleteAllUserData(); var bootAuthFailHandled = false; Autoya.Auth_SetOnBootAuthFailed( (code, reason) => { bootAuthFailHandled = true; } ); RunOnMainThread( () => Autoya.Auth_AttemptAuthentication() ); WaitUntil( () => bootAuthFailHandled, 10, "failed to handle bootAuthFailed." ); Autoya.forceFailFirstBoot = false; }
[MTest] public void HandleLogoutThenAuthenticationAttemptSucceeded() { Autoya.Auth_Logout(); RunOnMainThread( () => Autoya.Auth_AttemptAuthentication() ); WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to auth" ); }
[MTest] public void HandleTokenRefreshFailedThenAttemptAuthentication() { Autoya.forceFailTokenRefresh = true; var tokenRefreshFailed = false; Autoya.Auth_SetOnRefreshAuthFailed( (code, reason) => { tokenRefreshFailed = true; } ); // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (string conId, string resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // do nothing. } ); WaitUntil( () => tokenRefreshFailed, 10, "failed to handle tokenRefreshFailed." ); Autoya.forceFailTokenRefresh = false; RunOnMainThread( () => { Autoya.Auth_AttemptAuthentication(); } ); WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to handle tokenRefreshFailed." ); }
[MTest] public void DeleteAllUserData() { Autoya.Auth_DeleteAllUserData(); var authenticated = Autoya.Auth_IsAuthenticated(); Assert(!authenticated, "not deleted."); RunOnMainThread( () => { Autoya.Auth_AttemptAuthentication(); } ); WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to firstBoot." ); }