public void PutIdentityByDeletedUserTest_Async() { CountDownLatch cd = new CountDownLatch(1); string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); Exception e = null; KiiUser.RegisterAsPseudoUser(null, (KiiUser registeredUser, Exception e1) => { IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); string currentUserId = Kii.CurrentUser.ID; string currentUserAccessToken = KiiUser.AccessToken; KiiUser.CurrentUser.Delete(); Kii.CurrentUser = KiiUser.GetById(currentUserId); KiiCloudEngine.UpdateAccessToken(currentUserAccessToken); Kii.CurrentUser.PutIdentity(identityData, null, "123ABC", (KiiUser user, Exception e2) => { e = e2; cd.Signal(); }); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsNotNull(e); Assert.IsInstanceOfType(typeof(ForbiddenException), e); }
public void Test_PseudoUserDisabledStatus() { // refresh response string response = @" { ""userID"" : ""dummyID"", ""internalUserID"" : 87442786592227328, ""_accessToken"" : ""abcd1234"", ""_disabled"" : ""false"" } "; client.AddResponse(200, response); KiiUser user = KiiUser.RegisterAsPseudoUser(null); Assert.IsFalse(user.Disabled); // verify request. string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "users"); Assert.AreEqual(url, client.RequestUrl [0]); Assert.AreEqual(KiiHttpMethod.POST, client.RequestMethod [0]); MockHttpHeaderList headerList = client.RequestHeader [0]; Assert.AreEqual("appId", headerList ["X-Kii-AppID"]); Assert.AreEqual("appKey", headerList ["X-Kii-AppKey"]); Assert.IsTrue(headerList ["X-Kii-SDK"].StartsWith("sn=cs;sv=")); }
public void UpdateByDeletedPseudoUserTest_Async() { CountDownLatch cd = new CountDownLatch(1); Exception e = null; KiiUser.RegisterAsPseudoUser(null, (KiiUser registeredUser, Exception e1) => { string currentUserId = Kii.CurrentUser.ID; string currentUserAccessToken = KiiUser.AccessToken; KiiUser.CurrentUser.Delete(); Kii.CurrentUser = KiiUser.GetById(currentUserId); KiiCloudEngine.UpdateAccessToken(currentUserAccessToken); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; userFields.RemoveFromServer("birthday"); Kii.CurrentUser.Update(null, userFields, (KiiUser updatedUser, Exception e2) => { e = e2; cd.Signal(); }); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsNotNull(e); Assert.IsInstanceOfType(typeof(ForbiddenException), e); }
public void UpdateWithoutIdentityDataByPseudoUserTest_Async() { CountDownLatch cd = new CountDownLatch(1); KiiUser actual = null; KiiUser.RegisterAsPseudoUser(null, (KiiUser registeredUser, Exception e1) => { UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; registeredUser.Update(null, userFields, (KiiUser updatedUser, Exception e2) => { actual = updatedUser; cd.Signal(); }); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsTrue(actual.IsPseudoUser); Assert.IsNull(actual.Username); Assert.IsNull(actual.Email); Assert.IsNull(actual.Phone); Assert.AreEqual("disp", actual.Displayname); Assert.AreEqual("JP", actual.Country); Assert.AreEqual(30, actual.GetInt("age")); }
void Start() { Debug.Log("##### Start Demo"); string token = PlayerPrefs.GetString("token"); if (string.IsNullOrEmpty(token)) { KiiUser.RegisterAsPseudoUser(null, (KiiUser user, Exception e) => { if (e != null) { Debug.Log("##### Failed to register user"); return; } PlayerPrefs.SetString("token", KiiUser.AccessToken); ShowLogo(); }); } else { KiiUser.LoginWithToken(token, (KiiUser user, Exception e) => { if (e != null) { Debug.Log("##### Failed to login"); return; } ShowLogo(); }); } }
public void PutIdentityTest_Async() { CountDownLatch cd = new CountDownLatch(1); string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser actual = null; KiiUser.RegisterAsPseudoUser(null, (KiiUser registeredUser, Exception e1) => { IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); registeredUser.PutIdentity(identityData, null, "123ABC", (KiiUser user, Exception e2) => { actual = user; cd.Signal(); }); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsFalse(actual.IsPseudoUser); Assert.AreEqual(username, actual.Username); Assert.AreEqual(email, actual.Email); Assert.AreEqual(phone, actual.Phone); Assert.IsNull(actual.Displayname); Assert.IsNull(actual.Country); Assert.IsFalse(actual.Has("age")); }
public void PutIdentityWithUserFieldsTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser.RegisterAsPseudoUser(null); IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; KiiUser.CurrentUser.PutIdentity(identityData, userFields, "123ABC"); Assert.IsFalse(KiiUser.CurrentUser.IsPseudoUser); Assert.AreEqual(username, KiiUser.CurrentUser.Username); Assert.AreEqual(email, KiiUser.CurrentUser.Email); Assert.AreEqual(phone, KiiUser.CurrentUser.Phone); Assert.AreEqual("disp", KiiUser.CurrentUser.Displayname); Assert.AreEqual("JP", KiiUser.CurrentUser.Country); Assert.AreEqual(30, KiiUser.CurrentUser.GetInt("age")); }
public void PutIdentityWithExistingPhoneTest() { KiiUser.RegisterAsPseudoUser(null); IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone); IdentityData identityData = builder.Build(); KiiUser.CurrentUser.PutIdentity(identityData, null, "123ABC"); }
public void RegisterAsPseudoUserTest() { KiiUser.RegisterAsPseudoUser(null); Assert.IsNotNull(KiiUser.AccessToken); Assert.IsNull(KiiUser.CurrentUser.Displayname); Assert.IsNull(KiiUser.CurrentUser.Country); Assert.IsTrue(KiiUser.AccessToken.Length > 10); Assert.IsTrue(KiiUser.CurrentUser.IsPseudoUser); }
public void RegisterAsPseudoUserWithUserFieldsTest() { UserFields userFields = new UserFields(); userFields.Displayname = "LargeTestUser"; KiiUser.RegisterAsPseudoUser(userFields); Assert.IsNotNull(KiiUser.AccessToken); Assert.IsTrue(KiiUser.AccessToken.Length > 10); Assert.IsTrue(KiiUser.CurrentUser.IsPseudoUser); Assert.AreEqual(userFields.Displayname, KiiUser.CurrentUser.Displayname); Assert.IsNull(KiiUser.CurrentUser.Country); }
/// <summary> /// 仮ユーザの作成 /// </summary> /// <param name="action"></param> static void RegisterAsPseudoUser(Action <KiiUser> action) { KiiUser.RegisterAsPseudoUser(new UserFields(), (user, e) => { if (e == null) { AccessToken = KiiUser.AccessToken; action(user); } else { action(null); } }); }
public void PutIdentityWithRemoveFieldsTest_Async() { CountDownLatch cd = new CountDownLatch(1); string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser actual = null; UserFields userFields = new UserFields(); userFields.Country = "US"; userFields.Displayname = "disp"; userFields["birthday"] = "1978/7/22"; userFields["age"] = 30; KiiUser.RegisterAsPseudoUser(userFields, (KiiUser registeredUser, Exception e1) => { IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); UserFields removeFields = new UserFields(); removeFields.RemoveDisplayname(); // remove displayname only local. removeFields.RemoveFromServer("birthday"); removeFields["newFields"] = "new!!"; registeredUser.PutIdentity(identityData, removeFields, "123ABC", (KiiUser user, Exception e2) => { actual = user; cd.Signal(); }); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsFalse(actual.IsPseudoUser); Assert.AreEqual(username, actual.Username); Assert.AreEqual(email, actual.Email); Assert.AreEqual(phone, actual.Phone); Assert.AreEqual("disp", actual.Displayname); Assert.AreEqual("US", actual.Country); Assert.IsFalse(actual.Has("birthday")); Assert.AreEqual(30, actual.GetInt("age")); }
public void RegisterAsPseudoUserTest_Async() { CountDownLatch cd = new CountDownLatch(1); KiiUser.RegisterAsPseudoUser(null, (KiiUser user, Exception e) => { cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsNotNull(KiiUser.AccessToken); Assert.IsNull(KiiUser.CurrentUser.Displayname); Assert.IsNull(KiiUser.CurrentUser.Country); Assert.IsTrue(KiiUser.AccessToken.Length > 10); Assert.IsTrue(KiiUser.CurrentUser.IsPseudoUser); }
public void UpdateByDeletedPseudoUserTest() { KiiUser.RegisterAsPseudoUser(null); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; userFields.RemoveFromServer("birthday"); string currentUserId = Kii.CurrentUser.ID; string currentUserAccessToken = KiiUser.AccessToken; KiiUser.CurrentUser.Delete(); Kii.CurrentUser = KiiUser.GetById(currentUserId); KiiCloudEngine.UpdateAccessToken(currentUserAccessToken); KiiUser.CurrentUser.Update(userFields); }
public void UpdateWithoutIdentityDataByPseudoUserTest() { KiiUser.RegisterAsPseudoUser(null); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; KiiUser.CurrentUser.Update(null, userFields); Assert.IsTrue(KiiUser.CurrentUser.IsPseudoUser); Assert.IsNull(KiiUser.CurrentUser.Username); Assert.IsNull(KiiUser.CurrentUser.Email); Assert.IsNull(KiiUser.CurrentUser.Phone); Assert.AreEqual("disp", KiiUser.CurrentUser.Displayname); Assert.AreEqual("JP", KiiUser.CurrentUser.Country); Assert.AreEqual(30, KiiUser.CurrentUser.GetInt("age")); }
public void PutIdentityWithExistingPhoneTest_Async() { CountDownLatch cd = new CountDownLatch(1); Exception e = null; KiiUser.RegisterAsPseudoUser(null, (KiiUser registeredUser, Exception e1) => { IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone); IdentityData identityData = builder.Build(); registeredUser.PutIdentity(identityData, null, "123ABC", (KiiUser user, Exception e2) => { e = e2; cd.Signal(); }); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsNotNull(e); Assert.IsInstanceOfType(typeof(ConflictException), e); }
public void RegisterAsPseudoUserWithUserFieldsTest_Async() { CountDownLatch cd = new CountDownLatch(1); UserFields userFields = new UserFields(); userFields.Displayname = "LargeTestUser"; KiiUser.RegisterAsPseudoUser(userFields, (KiiUser user, Exception e) => { cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.IsNotNull(KiiUser.AccessToken); Assert.IsTrue(KiiUser.AccessToken.Length > 10); Assert.IsTrue(KiiUser.CurrentUser.IsPseudoUser); Assert.AreEqual(userFields.Displayname, KiiUser.CurrentUser.Displayname); Assert.IsNull(KiiUser.CurrentUser.Country); }
public void PutIdentityByDeletedUserTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser.RegisterAsPseudoUser(null); IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); string currentUserId = Kii.CurrentUser.ID; string currentUserAccessToken = KiiUser.AccessToken; KiiUser.CurrentUser.Delete(); Kii.CurrentUser = KiiUser.GetById(currentUserId); KiiCloudEngine.UpdateAccessToken(currentUserAccessToken); KiiUser.CurrentUser.PutIdentity(identityData, null, "123ABC"); }
public void PutIdentityTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser.RegisterAsPseudoUser(null); IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); KiiUser.CurrentUser.PutIdentity(identityData, null, "123ABC"); Assert.IsFalse(KiiUser.CurrentUser.IsPseudoUser); Assert.AreEqual(username, KiiUser.CurrentUser.Username); Assert.AreEqual(email, KiiUser.CurrentUser.Email); Assert.AreEqual(phone, KiiUser.CurrentUser.Phone); Assert.IsNull(KiiUser.CurrentUser.Displayname); Assert.IsNull(KiiUser.CurrentUser.Country); Assert.IsFalse(KiiUser.CurrentUser.Has("age")); }
public void Test_FBLogin_After_PseudoUserCreation() { // setup mock http client MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; MockHttpClient client = (MockHttpClient)factory.Client; // set response this.setPseudoUserCreationResponse(client); this.setFBLoginResponse(client); this.setRefreshResponse(client); KiiUser user = KiiUser.RegisterAsPseudoUser(null); Assert.AreEqual("user11111", user.ID); Assert.AreEqual("dummyAccessToken1", user.GetAccessTokenDictionary() ["access_token"]); KiiUser.LoginWithFacebookToken("fbtoken-dummy"); System.Collections.Generic.IList <MockHttpHeaderList> l = client.RequestHeader; string auth = l[2]["Authorization"]; Assert.AreEqual("Bearer " + "dummyAccessToken2", auth); user = KiiUser.CurrentUser; Assert.AreEqual("user22222", user.ID); Assert.AreEqual("dummyAccessToken2", user.GetAccessTokenDictionary() ["access_token"]); Assert.AreEqual("User 2", user.Displayname); // verify social access token dictionary. Dictionary <string, object> dict = user.GetSocialAccessTokenDictionary(); Assert.AreEqual(true, dict["kii_new_user"]); Assert.AreEqual("100000188475423", dict["provider_user_id"]); Assert.AreEqual(KiiCorp.Cloud.Storage.Connector.Provider.FACEBOOK, dict["provider"]); Assert.AreEqual("fbtoken-dummy", dict["oauth_token"]); }
public void PutIdentityWithRemoveFieldsTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); UserFields userFields = new UserFields(); userFields.Country = "US"; userFields.Displayname = "disp"; userFields["birthday"] = "1978/7/22"; userFields["age"] = 30; KiiUser.RegisterAsPseudoUser(userFields); IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); UserFields removeFields = new UserFields(); removeFields.RemoveDisplayname(); // remove displayname only local. removeFields.RemoveFromServer("birthday"); removeFields["newFields"] = "new!!"; KiiUser.CurrentUser.PutIdentity(identityData, removeFields, "123ABC"); Assert.IsFalse(KiiUser.CurrentUser.IsPseudoUser); Assert.AreEqual(username, KiiUser.CurrentUser.Username); Assert.AreEqual(email, KiiUser.CurrentUser.Email); Assert.AreEqual(phone, KiiUser.CurrentUser.Phone); Assert.AreEqual("disp", KiiUser.CurrentUser.Displayname); Assert.AreEqual("US", KiiUser.CurrentUser.Country); Assert.IsFalse(KiiUser.CurrentUser.Has("birthday")); Assert.AreEqual(30, KiiUser.CurrentUser.GetInt("age")); }
public void guest() //Espacio para que el usuario se loguee como invitado { numero = 1; mystats.idplayer = "Guest"; Debug.Log("Creando nuevo Guest..."); // Creating Pseudouser. UserFields userFields = new UserFields(); userFields.Displayname = mystats.idplayer; userFields["Guest_number"] = numero; KiiUser.RegisterAsPseudoUser(userFields, (KiiUser pseudoUser, Exception e) => { if (e != null) { // handle error return; } else { Debug.Log("GUEST CREADO."); message.SetActive(true); Debug.Log("STARTING reading from the cloud..."); // Retrieving Guest number from cloud. KiiObject obj = KiiObject.CreateByUri(new Uri("kiicloud://buckets/GuestList/objects/05c8b620-8b07-11e5-ac4d-22000af941bb")); obj.Refresh((KiiObject refreshedObj, Exception e2) => { if (e2 != null) { Debug.LogError("Retreving Object failed: " + e2.ToString()); // handle error return; } else { // Get key-value pairs. guestnumber = (int)refreshedObj["Guestnumber"]; Debug.Log("Guestnumber in cloud: " + guestnumber); Debug.Log("FINISHED reading from the cloud..."); numero += guestnumber; //Updating cloud with +1 Guestnumber. KiiObject obj2 = KiiObject.CreateByUri(new Uri("kiicloud://buckets/GuestList/objects/05c8b620-8b07-11e5-ac4d-22000af941bb")); obj2.Refresh((KiiObject obj3, Exception e3) => { if (e3 != null) { Debug.LogError("Retreving Object failed: " + e3.ToString()); // handle error return; } obj3["Guestnumber"] = numero; obj3.SaveAllFields(false, (KiiObject updatedObj, Exception e4) => { if (e4 != null) { Debug.LogError("Update Object failed: " + e4.ToString()); // handle error } else { Debug.Log("Object updated successfully: Guestnumber " + numero); mystats.idplayer = "Guest" + numero; Save(); Application.LoadLevel("PruebaMatchList"); } }); }); } // Get key-value pairs. guestnumber = (int)refreshedObj["Guestnumber"]; }); } // Must save the token. // If it's lost the user will not be able to access KiiCloud. PlayerPrefs.SetString("token", KiiUser.AccessToken); userToken = KiiUser.AccessToken; }); }