public void sendRegistrationData(RegistrationData registrationData, MethodReferenceWithResponse responseHandler) { Response response = (Response)gameObject.AddComponent("Response"); Debug.Log("Sending registration request to Kii Cloud"); if (registrationData.password.Equals(registrationData.passwordConfirm)) { Debug.Log("Creating user builder"); KiiUser.Builder builder; builder = KiiUser.BuilderWithName(registrationData.username); builder.WithEmail(registrationData.email); KiiUser user = builder.Build(); try { Debug.Log("Registering..."); user.Register(registrationData.password); response.error = false; response.message = ""; Debug.Log("User registration successful"); } catch (Exception e) { response.error = true; response.message = e.Message; Debug.Log(e.Message); } } else { response.error = true; response.message = "Passwords don't match!"; } // Calling response handler: responseHandler(response); }
public void UpdateByUnnoticedNormalUserTest_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 user = KiiUser.BuilderWithName(username).Build(); user.Register("password"); KiiUser unnoticedNormalUser = KiiUser.CreateByUri(user.Uri); IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); KiiUser updatedUser = null; unnoticedNormalUser.Update(identityData, null, (KiiUser u, Exception e2) => { updatedUser = u; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.AreEqual(email, updatedUser.Email); Assert.AreEqual(phone, updatedUser.Phone); }
public void PutIdentityByUnnoticedNormalUserTest_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 user = KiiUser.BuilderWithName(username).WithEmail(email).WithPhone(phone).Build(); user.Register("password"); KiiUser unnoticedNormalUser = KiiUser.CreateByUri(user.Uri); IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username); builder.WithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); unnoticedNormalUser.PutIdentity(identityData, null, "123ABC", (KiiUser u, 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(AlreadyHasIdentityException), e); }
public void UpdateTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser newUser = KiiUser.BuilderWithName(username).Build(); newUser["birthday"] = "1978/7/22"; newUser.Register("123ABC"); IdentityData.Builder builder = IdentityData.Builder.CreateWithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; userFields.RemoveFromServer("birthday"); newUser.Update(identityData, userFields); Assert.IsFalse(newUser.IsPseudoUser); Assert.AreEqual(username, newUser.Username); Assert.AreEqual(email, newUser.Email); Assert.AreEqual(phone, newUser.Phone); Assert.AreEqual("disp", newUser.Displayname); Assert.AreEqual("JP", newUser.Country); Assert.IsFalse(newUser.Has("birthday")); Assert.AreEqual(30, newUser.GetInt("age")); }
public static KiiUser CreateNewUser(string username, string pass) { KiiUser testUser = KiiUser.BuilderWithName(username).Build(); testUser.Register(pass); return(testUser); }
void PerformSignup(string username, string password) { message = "Signup..."; SetButtonEnabled(false); KiiUser user = null; try { user = KiiUser.BuilderWithName(username).Build(); } catch (Exception e) { SetButtonEnabled(true); message = "Failed to signup " + e.ToString(); return; } user.Register(password, (KiiUser user2, Exception e) => { SetButtonEnabled(true); if (e != null) { message = "Failed to signup " + e.ToString(); return; } message = "Signup succeeded"; menuButtonEnable = true; }); }
static public void Signup(string username, string password, string displayName, bool autoLogin) { //先在客户端检查是否合法 if (KiiUser.IsValidUserName(username) && KiiUser.IsValidPassword(password) && KiiUser.IsValidDisplayName(displayName)) { KiiUser.Builder userBuilder = KiiUser.BuilderWithName(username); KiiUser user = userBuilder.Build(); user.Displayname = displayName; LoginUI.instance.Wait(); user.Register(password, (KiiUser registeredUser, Exception e) => { LoginUI.instance.StopWait(); if (e == null) { PlayerPrefs.SetInt("auto login", autoLogin ? 1 : 0); PlayerPrefs.SetString("access token", KiiUser.AccessToken); LoginUI.instance.OnLoginSuccess(); } //处理异常 else { HandlerLoginException(e); } }); } else { LoginUI.instance.ShowMessage("Invalid name or password"); } }
public void UpdateWithExistingPhoneTest_Async() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; KiiUser newUser = KiiUser.BuilderWithName(username).Build(); newUser.Register("123ABC"); CountDownLatch cd = new CountDownLatch(1); Exception e = null; IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone); IdentityData identityData = builder.Build(); newUser.Update(identityData, null, (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); }
//入力されたユーザID、パスワードのユーザが存在しなければ新規作成 public bool RegistUser(string userName, string password) { if (!KiiUser.IsValidUserName(userName) || !KiiUser.IsValidPassword(password)) { Debug.LogError("Invalid user name or password : "******"Success user regist : " + userName); } catch (System.Exception exception) { Debug.Log("Failed user regist : " + userName + " : " + exception); _User = null; return(false); } return(true); }
public void Test_Non_Initialize_StorageAPI() { KiiUser user = null; KiiGroup group = null; KiiBucket bucket = null; KiiObject obj = null; try { // User Management user = KiiUser.BuilderWithName("hoge").Build(); user.Register("password"); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } try { bucket = Kii.Bucket("appbucket"); bucket.Delete(); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } try { obj = bucket.NewKiiObject(); obj.Save(); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } try { KiiQuery query = new KiiQuery(); bucket.Query(query); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } try { group = Kii.Group("myGroup"); group.Save(); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } }
// Use this for initialization void Start() { Debug.Log("#####Main.Start"); this.kiiPushPlugin = GameObject.Find("KiiPushPlugin").GetComponent <KiiPushPlugin> (); this.receivedCallback = (ReceivedMessage message) => { switch (message.PushMessageType) { case ReceivedMessage.MessageType.PUSH_TO_APP: Debug.Log("#####PUSH_TO_APP Message"); this.OnPushNotificationsReceived(message); break; case ReceivedMessage.MessageType.PUSH_TO_USER: Debug.Log("#####PUSH_TO_USER Message"); this.OnPushNotificationsReceived(message); break; case ReceivedMessage.MessageType.DIRECT_PUSH: Debug.Log("#####DIRECT_PUSH Message"); this.OnPushNotificationsReceived(message); break; } }; this.kiiPushPlugin.OnPushMessageReceived += this.receivedCallback; if (KiiUser.CurrentUser != null) { Invoke("registerPush", 0); return; } KiiUser.LogIn(USER_NAME, PASSWORD, (KiiUser u1, Exception e1) => { if (e1 != null) { KiiUser newUser = KiiUser.BuilderWithName(USER_NAME).Build(); Debug.Log("#####Register"); newUser.Register(PASSWORD, (KiiUser u2, Exception e2) => { Debug.Log("#####callback Register"); if (e2 != null) { Debug.Log("#####failed to Register"); this.ShowException("Failed to register user.", e2); return; } else { Invoke("registerPush", 0); } }); } else { Invoke("registerPush", 0); } }); }
public void Test_2001_OwnerOfGrups_noId() { this.LogIn(); // set Response this.SetStandardOwnerResponse(client); KiiUser.BuilderWithName("newUser").Build().OwnerOfGroups(); }
public void Test_0001_Refresh_null_id() { // set response this.setStandardResponseForRefresh(); KiiUser user = KiiUser.BuilderWithName("kii1234").Build(); user.Refresh(); }
public void Test_0300_Builde_All() { KiiUser.Builder builder = KiiUser.BuilderWithName("kii1234").WithEmail("*****@*****.**").WithPhone("09011112222"); KiiUser user = builder.Build(); Assert.AreEqual("kii1234", user.Username); Assert.AreEqual("*****@*****.**", user.Email); Assert.AreEqual("09011112222", user.Phone); }
private IEnumerator TestStep() { string username = StringUtils.RandomAlphabetic(20); string password = StringUtils.RandomAlphabetic(20); KiiUser user = KiiUser.BuilderWithName(username).Build(); var task = RegisterUser(user, password, (KiiUser u, Exception e) => { if (e != null) { throw new TestFailException(); } Debug.Log("Register user."); }); yield return(StartCoroutine(task)); // create group string groupname = StringUtils.RandomAlphabetic(20); KiiGroup group = Kii.Group(groupname); Exception exp = null; bool endFlag = false; KiiGroupCallback callback = (KiiGroup grp, Exception e) => { exp = e; endFlag = true; }; group.Save(callback); while (!endFlag) { yield return(new WaitForSeconds(1)); } if (exp != null) { throw new TestFailException(); } // refresh KiiGroup groupWithId = KiiGroup.GroupWithID(group.ID); exp = null; endFlag = false; groupWithId.Refresh(callback); while (!endFlag) { yield return(new WaitForSeconds(1)); } if (exp != null) { throw new TestFailException(); } if (!groupname.Equals(groupWithId.Name)) { throw new TestFailException(); } resultFlag = true; }
public void Test_0020_Register_server_error_Register_callback_null() { // set response client.AddResponse(new CloudException(400, "{}")); KiiUser user = KiiUser.BuilderWithName("kiitest").Build(); user.Register("pass1234", null); }
public void Test_GetAccessTokenDictionary_WhenUserIsNotLoggedIn() { Kii.Initialize(APP_ID, APP_KEY, Kii.Site.US); KiiUser user = KiiUser.BuilderWithName("dummyName").Build(); Assert.IsNull(KiiUser.CurrentUser); IDictionary dict = user.GetAccessTokenDictionary(); Assert.IsNull(dict); }
public override void SetUp() { base.SetUp(); long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; string uname = "kiiqueryTest-" + milliseconds; testUser = KiiUser.BuilderWithName(uname).Build(); testUser.Register("pass1234"); testUser = KiiUser.LogIn(uname, "pass1234"); }
public void Test_0507_AddAndRemoveUser_notsaved_KiiUser_instance() { // Prepare KiiUser for member KiiUser memberUser1 = KiiUser.CreateByUri(new Uri("kiicloud://users/" + TextUtils.generateUUID())); KiiUser memberUser2 = KiiUser.CreateByUri(new Uri("kiicloud://users/" + TextUtils.generateUUID())); KiiUser notSavedUser = KiiUser.BuilderWithName(TextUtils.randomAlphaNumeric(10)).Build(); // Prepare group string groupName = TextUtils.randomAlphaNumeric(10); string groupID = TextUtils.randomAlphaNumeric(26); KiiGroup group = Kii.Group(groupName); SDKTestHack.SetField(group, "mId", groupID); SDKTestHack.SetField(group, "mOwnerId", TextUtils.generateUUID()); group.AddUser(memberUser1); group.RemoveUser(memberUser2); // Check value HashSet <KiiUser> addUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "addUsers"); HashSet <KiiUser> removeUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "removeUsers"); Assert.AreEqual(1, addUsers.Count); Assert.AreEqual(1, removeUsers.Count); // Add user try { group.AddUser(notSavedUser); Assert.Fail("Should throw ArgumentException"); } catch (ArgumentException) { // Pass } // Check value addUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "addUsers"); removeUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "removeUsers"); Assert.AreEqual(1, addUsers.Count); Assert.AreEqual(1, removeUsers.Count); // Remove user try { group.RemoveUser(notSavedUser); Assert.Fail("Should throw ArgumentException"); } catch (ArgumentException) { // Pass } // Check value addUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "addUsers"); removeUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "removeUsers"); Assert.AreEqual(1, addUsers.Count); Assert.AreEqual(1, removeUsers.Count); }
public override void SetUp() { base.SetUp(); string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); existingUser = KiiUser.BuilderWithName(username).WithEmail(email).WithPhone(phone).Build(); existingUser.Register("password"); }
public void UpdateWithExistingPhoneTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; KiiUser newUser = KiiUser.BuilderWithName(username).Build(); newUser.Register("123ABC"); IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone); IdentityData identityData = builder.Build(); newUser.Update(identityData, null); }
void Start() { long unixTime = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; string username = "******" + unixTime; string password = "******"; KiiUser user = KiiUser.BuilderWithName(username).Build(); user.Register(password, (KiiUser u, Exception e) => { if (e != null) { return; } Debug.Log("In callback, username: " + u.Username); testResult = username.Equals(u.Username); }); }
public void Test_0001_Register_null() { Kii.Initialize("appId", "appKey", Kii.Site.US); MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; // set response MockHttpClient client = factory.Client; this.setStandardResponse(client); KiiUser user = KiiUser.BuilderWithName("kiitest").Build(); user.Register(null); }
public void Test_0101_Refresh_null_id() { Kii.Initialize("appId", "appKey", Kii.Site.US); MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; // set response MockHttpClient client = factory.Client; this.setStandardResponseForRefresh(client); KiiUser user = KiiUser.BuilderWithName("kii1234").Build(); user.Refresh(); }
public void Test_0002_Register_server_error() { Kii.Initialize("appId", "appKey", Kii.Site.US); MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; // set response MockHttpClient client = factory.Client; client.AddResponse(new CloudException(400, "{}")); KiiUser user = KiiUser.BuilderWithName("kiitest").Build(); user.Register("pass1234"); }
public void Test_0001_BuilderWithName_invalid_name() { try { KiiUser.BuilderWithName(null); Assert.Fail("Argument Exception must be thrown"); } catch (ArgumentException) { // OK } catch { Assert.Fail("Argument Exception must be thrown"); } }
public void Test_0000_Register() { Kii.Initialize("appId", "appKey", Kii.Site.US); MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; // set response MockHttpClient client = factory.Client; this.setStandardResponse(client); this.setStandardResponseForRefresh(client); // register KiiUser user = KiiUser.BuilderWithName("kiitest") .WithEmail("*****@*****.**") .WithPhone("+819098439211") .Build(); user.Displayname = "person test000"; user.Register("pass1234"); // verify user properties Assert.AreEqual("userABCD", user.ID); Assert.AreEqual("test000", user.Username); Assert.AreEqual("person test000", user.Displayname); Assert.AreEqual("*****@*****.**", user.Email); Assert.AreEqual("+819098439211", user.Phone); Assert.AreEqual("JP", user.Country); Assert.IsTrue(user.EmailVerified); Assert.IsTrue(user.PhoneVerified); Assert.IsNotNull(KiiUser.AccessToken); // verify current user Assert.IsNotNull(KiiUser.CurrentUser); Assert.AreEqual(user, KiiUser.CurrentUser); // verify current user properties Assert.AreEqual(user.ID, KiiUser.CurrentUser.ID); Assert.AreEqual(user.Username, KiiUser.CurrentUser.Username); Assert.AreEqual(user.Displayname, KiiUser.CurrentUser.Displayname); Assert.AreEqual(user.Email, KiiUser.CurrentUser.Email); Assert.AreEqual(user.Phone, KiiUser.CurrentUser.Phone); Assert.AreEqual(user.Country, KiiUser.CurrentUser.Country); Assert.IsTrue(KiiUser.CurrentUser.EmailVerified); Assert.IsTrue(KiiUser.CurrentUser.PhoneVerified); }
public void Test_2001_OwnerOfGrups_noId() { this.LogIn(); // set Response this.SetStandardOwnerResponse(); IList <KiiGroup> groups = null; Exception exp = null; KiiUser.BuilderWithName("newUser").Build().OwnerOfGroups((IList <KiiGroup> gs, Exception e) => { groups = gs; exp = e; }); Assert.IsNull(groups); Assert.IsInstanceOfType(typeof(InvalidOperationException), exp); }
public void register() { //Espacio para que el usuario se registre userName = nameregister.value; pwd = passregister.value; emailId = mailregister.value; if (userName == "" || pwd == "" || emailId == "") { faltan.text = "One or more required field(s) are missing."; } else { /*userService = sp.BuildUserService (); * userService.CreateUser (userName, pwd, emailId, callBackUser); * cLabel.SetActive (true); * Debug.Log ("El Usuario ha sido creado."); * mystats.idplayer = userName; * Dictionary <string, object> jsonDoc = new Dictionary <string,object> (); * storageService = sp.BuildStorageService (); * storageService.FindDocumentById (dbName, collectionName, jsonid, callBack); * storageService.InsertJSONDocument(dbName, mystats.idplayer + "myDataBase", json, callBack1); */ mystats.idplayer = userName; KiiUser.Builder builder = KiiUser.BuilderWithName(userName); builder.WithEmail(emailId); KiiUser usr = builder.Build(); usr.Register(pwd, (KiiUser user, Exception e) => { if (e != null) { faltan.text = "Password must be between 4 to 50 alphanumeric characters."; Debug.LogError("Signup failed: " + e.ToString()); // process error } else { Debug.Log("Signup succeeded."); faltan.text = "Signup succeeded. Signing in..."; Save(); Application.LoadLevel("PruebaMatchList"); // do something with user, it's a valid user now } }); } }
public void UpdateTest_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 newUser = KiiUser.BuilderWithName(username).Build(); newUser["birthday"] = "1978/7/22"; newUser.Register("123ABC", (KiiUser registeredUser, Exception e1) => { IdentityData.Builder builder = IdentityData.Builder.CreateWithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; userFields.RemoveFromServer("birthday"); registeredUser.Update(identityData, userFields, (KiiUser updatedUser, Exception e2) => { actual = updatedUser; 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("JP", actual.Country); Assert.IsFalse(actual.Has("birthday")); Assert.AreEqual(30, actual.GetInt("age")); }