Exemple #1
0
    public IEnumerator HandleBootAuthFailed()
    {
        Autoya.forceFailFirstBoot = true;

        Autoya.Auth_Logout();

        var bootAuthFailHandled = false;

        Autoya.Auth_SetOnBootAuthFailed(
            (code, reason) =>
        {
            bootAuthFailHandled = true;
        }
            );

        Autoya.Auth_AttemptAuthenticationIfNeed();

        yield return(WaitUntil(
                         () => bootAuthFailHandled,
                         () => { throw new TimeoutException("failed to handle bootAuthFailed."); },
                         10
                         ));

        Autoya.forceFailFirstBoot = false;
    }
Exemple #2
0
    public IEnumerator HandleLogoutThenAuthenticationAttemptSucceeded()
    {
        Autoya.Auth_Logout();

        Autoya.Auth_AttemptAuthenticationIfNeed();

        yield return(WaitUntil(
                         () => Autoya.Auth_IsAuthenticated(),
                         () => { throw new TimeoutException("failed to auth"); }
                         ));
    }
Exemple #3
0
    public IEnumerator DeleteAllUserData()
    {
        Autoya.Auth_Logout();

        var authenticated = Autoya.Auth_IsAuthenticated();

        True(!authenticated, "not deleted.");

        Autoya.Auth_AttemptAuthenticationIfNeed();

        yield return(WaitUntil(
                         () => Autoya.Auth_IsAuthenticated(),
                         () => { throw new TimeoutException("failed to firstBoot."); }
                         ));
    }
    public IEnumerator HandleLogoutThenAuthenticationAttemptSucceeded()
    {
        var logouted = false;

        Autoya.Auth_Logout(() => { logouted = true; }, reason => { });
        yield return(WaitUntil(
                         () => logouted,
                         () => { throw new TimeoutException(""); }
                         ));


        Autoya.Auth_AttemptAuthenticationIfNeed();

        yield return(WaitUntil(
                         () => Autoya.Auth_IsAuthenticated(),
                         () => { throw new TimeoutException("failed to auth"); }
                         ));
    }
    public IEnumerator HandleTokenRefreshFailedThenAttemptAuthentication()
    {
        Autoya.forceSetHttpCodeAsUnauthorized = true;
        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",
            (conId, resultData) =>
        {
            // do nothing.
        },
            (conId, code, reason, autoyaStatus) =>
        {
            Autoya.forceSetHttpCodeAsUnauthorized = false;
        }
            );

        yield return(WaitUntil(
                         () => tokenRefreshFailed,
                         () => { throw new TimeoutException("failed to handle tokenRefreshFailed."); },
                         20
                         ));

        Autoya.forceFailTokenRefresh = false;

        Autoya.Auth_AttemptAuthenticationIfNeed();

        yield return(WaitUntil(
                         () => Autoya.Auth_IsAuthenticated(),
                         () => { throw new TimeoutException("failed to handle tokenRefreshFailed."); },
                         15
                         ));
    }