public IEnumerator Setup() { while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } }
public IEnumerator Setup() { Autoya.ResetAllForceSetting(); DeleteAllData(AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); var authorized = false; var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authorized = true; } ); yield return(WaitUntil( () => { return authorized; }, () => { throw new TimeoutException("timeout in setup."); } )); True(Autoya.Auth_IsAuthenticated(), "not logged in."); Autoya.forceMaintenance = true; }
[MSetup] public void Setup() { var authenticated = false; Action onMainThread = () => { var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); }; RunOnMainThread(onMainThread); WaitUntil( () => { return(authenticated); }, 5, "failed to auth." ); Assert(Autoya.Auth_IsAuthenticated(), "not logged in."); }
[MTest] public void AutoyaHTTPPostFailWithUnauth() { var unauthorized = false; /* * dummy server returns 401 forcibly. */ Autoya.Http_Post( "https://httpbin.org/status/401", "dummy_data", (string conId, string resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { unauthorized = autoyaStatus.isAuthFailed; } ); WaitUntil( () => unauthorized, 5 ); // token refresh feature is already running. wait end. WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to refresh token." ); }
public IEnumerator Setup() { var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); var authenticated = false; Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); yield return(WaitUntil( () => authenticated, () => { throw new TimeoutException("failed to auth."); } )); True(Autoya.Auth_IsAuthenticated(), "not logged in."); }
public IEnumerator AutoyaHTTPPostFailWithUnauth() { var unauthorized = false; /* * dummy server returns 401 forcibly. */ Autoya.Http_Post( "https://httpbin.org/status/401", "dummy_data", (conId, resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { unauthorized = autoyaStatus.isAuthFailed; } ); yield return(WaitUntil( () => unauthorized, () => { throw new TimeoutException("timeout."); } )); // token refresh feature is already running. wait end. yield return(WaitUntil( () => Autoya.Auth_IsAuthenticated(), () => { throw new TimeoutException("failed to refresh token."); } )); }
public IEnumerator HandleBootAuthFailedThenAttemptAuthentication() { 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; Autoya.Auth_AttemptAuthenticationIfNeed(); yield return(WaitUntil( () => Autoya.Auth_IsAuthenticated(), () => { throw new TimeoutException("failed to attempt auth."); } )); }
public IEnumerator AutoyaHTTPGetFailWithUnauth() { Autoya.forceSetHttpCodeAsUnauthorized = true; var unauthorized = false; /* * dummy server returns 401 forcibly. */ Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { Fail("never succeed."); }, (conId, code, reason, autoyaStatus) => { unauthorized = autoyaStatus.isAuthFailed; Autoya.forceSetHttpCodeAsUnauthorized = false; } ); yield return(WaitUntil( () => unauthorized, () => { throw new TimeoutException("timeout."); } )); // token refresh feature is already running. wait end. yield return(WaitUntil( () => Autoya.Auth_IsAuthenticated(), () => { throw new TimeoutException("failed to refresh token."); } )); }
[MSetup] public void Setup() { Autoya.ResetAllForceSetting(); DeleteAllData(AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); var authorized = false; Action onMainThread = () => { var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authorized = true; } ); }; RunOnMainThread(onMainThread); WaitUntil( () => { return(authorized); }, 5, "timeout in setup." ); Assert(Autoya.Auth_IsAuthenticated(), "not logged in."); Autoya.forceMaintenance = true; }
// Use this for initialization IEnumerator Start() { while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } var connectionId1 = Autoya.Http_Get( "https://httpbin.org/get", // url (conId, data) => { // on succeeded Debug.Log("get data:" + data); }, (conId, code, reason, autoyaStatus) => { // on failed Debug.LogError("code:" + code + " reason:" + reason); }, new Dictionary <string, string>(), // headers 3.0 // timeout ); Debug.Log("start get with connectionId:" + connectionId1); var postData = "hello world."; var connectionId2 = Autoya.Http_Post( "https://httpbin.org/post", postData, (conId, resultData) => { Debug.Log("post data:" + resultData); }, (conId, code, reason, autoyaStatus) => { Debug.LogError("code:" + code + " reason:" + reason); } ); Debug.Log("start post with connectionId:" + connectionId2); }
[MTest] public void IntentionalLogout() { Autoya.Auth_Logout(); var loggedIn = Autoya.Auth_IsAuthenticated(); Assert(!loggedIn, "state does not match."); }
public IEnumerator Setup() { baseUrl = EndPointSelectorSettings.ENDPOINT_INFO_URL; while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } }
public IEnumerator IntentionalLogout() { Autoya.Auth_Logout(); var loggedIn = Autoya.Auth_IsAuthenticated(); True(!loggedIn, "state does not match."); yield break; }
public IEnumerator HandleLogoutThenAuthenticationAttemptSucceeded() { Autoya.Auth_Logout(); Autoya.Auth_AttemptAuthenticationIfNeed(); yield return(WaitUntil( () => Autoya.Auth_IsAuthenticated(), () => { throw new TimeoutException("failed to auth"); } )); }
IEnumerator Start() { // need to wait finish authentication. while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } /* * Autoya manages whole assetBundle information as the "AssetBundleList". * latest file is located at url that is generated by * OverridePoints.OnAssetBundleListDownloadUrlRequired method. * */ Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( (status) => { Debug.Log("assetBundleList download succeeded. status:" + status); /* * then, you can load asset from web. * * assetBundleList has the information which asset is contained by specific assetBundle. * (asset <-containes-- assetBundle <-info contains-- assetBundleList) * * the downloaded assetBundleList is stored in device. you can set the location and the way of read/write the list via OverridePoints.cs. */ /* * load asset from web or cache. * automatically download bundle then load asset on memory. */ Autoya.AssetBundle_LoadAsset <GameObject>( "Assets/AutoyaTests/RuntimeData/AssetBundles/MainResources/textureName1.prefab", (assetName, prefab) => { Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab); // instantiate asset. Instantiate(prefab); }, (assetName, err, reason, autoyaStatus) => { Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason + " autoyaStatus:" + autoyaStatus); } ); }, (code, reason, autoyaStatus) => { Debug.LogError("failed to download assetBundleList from OverridePoints.AssetBundleListDownloadUrl() supplied url. code:" + code + " reason:" + reason); } ); }
public IEnumerator EndPointUpdateRetry() { // 必ず失敗するURLを実行 EndPointSelectorSettings.ENDPOINT_INFO_URL = "https://127.0.0.1/" + Guid.NewGuid().ToString("N"); // Autoyaの起動と、起動直後にEndPointの更新、 // Retryするかどうかのポイントをリトライが完了したかどうかの確認ポイントとして、一度実行されたら更新が発生するようにセットする // こうすることで、リトライの直後にURLが書き換わり、認証まで終わるのを待てばEpの更新が完了する。 var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Debug_OnEndPointInstanceRequired( () => { return(new AutoyaFramework.EndPointSelect.IEndPoint[] { new main(), new sub() }); } ); var done = false; Autoya.Debug_SetShouldRetryEndPointGetRequest( () => { done = true; return(true); } ); while (!done) { yield return(null); } // change to valid url. EndPointSelectorSettings.ENDPOINT_INFO_URL = "https://raw.githubusercontent.com/sassembla/Autoya/master/Assets/AutoyaTests/RuntimeData/EndPoints/mainAndSub.json"; while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } // epUpdate succeeded and updated. var mainEp = Autoya.EndPoint_GetEndPoint <main>(); Assert.True(mainEp.key0 == "val0", "not match. mainEp.key0:" + mainEp.key0); Assert.True(mainEp.key1 == "default_val1", "not match. mainEp.key1:" + mainEp.key1); var subEp = Autoya.EndPoint_GetEndPoint <sub>(); Assert.True(subEp.key0 == "default_val0", "not match. subEp.key0:" + subEp.key0); }
[MTest] public void HandleLogoutThenAuthenticationAttemptSucceeded() { Autoya.Auth_Logout(); RunOnMainThread( () => Autoya.Auth_AttemptAuthentication() ); WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to auth" ); }
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."); } )); }
void Update() { var isAuthenticated = Autoya.Auth_IsAuthenticated(); if (isAuthenticated && !done) { done = true; Debug.Log("log in is done! welcome again."); } // let's type "Autoya." , // maybe autocompletion tells you something luckey. // Autoya. }
public IEnumerator IntentionalLogout() { var logouted = false; Autoya.Auth_Logout(() => { logouted = true; }, reason => { }); yield return(WaitUntil( () => logouted, () => { throw new TimeoutException(""); } )); var loggedIn = Autoya.Auth_IsAuthenticated(); True(!loggedIn, "state does not match."); yield break; }
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 )); }
[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." ); }
public IEnumerator Setup() { Autoya.ResetAllForceSetting(); var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); while (!Autoya.Auth_IsAuthenticated()) { yield return(false); } var authenticated = false; Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); Autoya.Auth_SetOnBootAuthFailed( (code, reason) => { Debug.LogError("code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => authenticated, () => { throw new TimeoutException("failed to auth."); } )); True(Autoya.Auth_IsAuthenticated(), "not logged in."); }
[MTest] public void HandleBootAuthFailedThenAttemptAuthentication() { 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; RunOnMainThread( () => Autoya.Auth_AttemptAuthentication() ); WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to attempt auth." ); }
public IEnumerator AuthFailedInPurchase() { var failed = false; var purchaseId = "myPurchaseId_" + Guid.NewGuid().ToString(); Autoya.forceFailAuthentication = true; Autoya.Purchase( purchaseId, "1000_gold_coins", pId => { Fail(); }, (pId, err, reason, autoyaStatus) => { True(autoyaStatus.isAuthFailed); failed = true; } ); yield return(WaitUntil( () => failed, () => { throw new TimeoutException("failed to fail."); }, 10 )); Autoya.forceFailAuthentication = false; yield return(WaitUntil( () => Autoya.Auth_IsAuthenticated(), () => { throw new TimeoutException("failed to fail."); }, 10 )); }
// Use this for initialization IEnumerator Start() { // need to wait finish authentication. while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } /* * this is sample of "preload assetBundles feature". * * the word "preload" in this sample means "download assetBundles without use." * preloaded assetBundles are stored in storage cache. no difference between preloaded and downloaded assetBundles. * * case1:generate preloadList from assetBundleList, then get described assetBundles. */ Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { }); // wait downloading assetBundleList. while (!Autoya.AssetBundle_IsAssetBundleFeatureReady()) { yield return(null); } /* * let's preload specific assetBundle into device storage. */ // get assetBundleList. var assetBundleLists = Autoya.AssetBundle_AssetBundleLists(); // create sample preloadList which contains all assetBundle names in assetBundleList. var assetBundleNames = assetBundleLists.SelectMany(list => list.assetBundles).Select(abInfo => abInfo.bundleName).ToArray(); var newPreloadList = new PreloadList("samplePreloadList", assetBundleNames); Autoya.AssetBundle_PreloadByList( newPreloadList, (willLoadBundleNames, proceed, cancel) => { proceed(); }, progress => { Debug.Log("progress:" + progress); }, () => { Debug.Log("preloading all listed assetBundles is finished."); // then, you can use these assetBundles immediately. without any downloading. Autoya.AssetBundle_LoadAsset <GameObject>( "Assets/AutoyaTests/RuntimeData/AssetBundles/MainResources/textureName1.prefab", (assetName, prefab) => { Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab); // instantiate asset. Instantiate(prefab); }, (assetName, err, reason, status) => { Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason); } ); }, (code, reason, autoyaStatus) => { Debug.LogError("preload failed. code:" + code + " reason:" + reason); }, (downloadFailedAssetBundleName, code, reason, autoyaStatus) => { Debug.LogError("failed to preload assetBundle:" + downloadFailedAssetBundleName + ". code:" + code + " reason:" + reason); }, 10 // 10 parallel download! you can set more than 0. ); }
// Use this for initialization IEnumerator Start() { // need to wait finish authentication. while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } /* * this is sample of "preload assetBundles feature". * * the word "preload" in this sample means "download assetBundles without use." * preloaded assetBundles are stored in storage cache. no difference between preloaded and downloaded assetBundles. * * case2:get preloadList from web, then get described assetBundles. */ Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { }); // wait downloading assetBundleList. while (!Autoya.AssetBundle_IsAssetBundleFeatureReady()) { yield return(null); } /* * get preloadList from web. * the base filePath settings is located at AssetBundlesSettings.ASSETBUNDLES_URL_DOWNLOAD_PRELOADLIST. * * this preloadList contains 1 assetBundleName, "bundlename", contains 1 asset, "textureName.png" * * note that: * this feature requires the condition:"assetBundleList is stored." for getting assetBundleInfo. (crc, hash, and dependencies.) */ var preloadListPath = "sample.preloadList.json"; // this will become ASSETBUNDLES_URL_DOWNLOAD_PRELOADLIST + sample.preloadList.json. // download preloadList from web then preload described assetBundles. Autoya.AssetBundle_Preload( preloadListPath, (willLoadBundleNames, proceed, cancel) => { var totalWeight = Autoya.AssetBundle_GetAssetBundlesWeight(willLoadBundleNames); Debug.Log("start downloading bundles. total weight:" + totalWeight); proceed(); }, progress => { Debug.Log("progress:" + progress); }, () => { Debug.Log("preloading 1 listed assetBundles is finished."); // then, you can use these assetBundles immediately. without any downloading. Autoya.AssetBundle_LoadAsset <Texture2D>( "Assets/AutoyaTests/RuntimeData/AssetBundles/MainResources/textureName.png", (assetName, image) => { Debug.Log("asset:" + assetName + " is successfully loaded as:" + image); // create gameObject, then set tex to it as sprite. var gameObj = new GameObject("createdGameObject"); var imageComponent = gameObj.AddComponent <Image>(); imageComponent.sprite = Sprite.Create(image, new Rect(0.0f, 0.0f, image.width, image.height), new Vector2(0.5f, 0.5f), 100.0f); // find uGUI canvas then set. var canvas = GameObject.Find("Canvas"); gameObj.transform.SetParent(canvas.transform, false); }, (assetName, err, reason, status) => { Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason); } ); }, (code, reason, autoyaStatus) => { Debug.LogError("preload failed. code:" + code + " reason:" + reason); }, (downloadFailedAssetBundleName, code, reason, autoyaStatus) => { Debug.LogError("failed to preload assetBundle:" + downloadFailedAssetBundleName + ". code:" + code + " reason:" + reason); }, 10 // 10 parallel download! you can set more than 0. ); }
[MTest] public void WaitDefaultAuthenticate() { Assert(Autoya.Auth_IsAuthenticated(), "not yet logged in."); }