Exemple #1
0
        public async Task ShouldEncryptUserPassword()
        {
            var obj = new CB.CloudUser();

            obj.Set("username", CB.Test.Util.Methods.MakeEmail());
            obj.Set("password", CB.Test.Util.Methods.MakeEmail());
            obj.Set("email", Util.Methods.MakeEmail());
            await obj.SaveAsync();

            Assert.IsTrue(true);
        }
Exemple #2
0
        public async Task loginUser()
        {
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            await obj.Login();

            if (obj.Username == username)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("user login error");
            }
        }
Exemple #3
0
        public async Task shouldEncryptUserPassword()
        {
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            obj.Set("email", Util.Methods._makeEmail());
            await obj.SaveAsync();

            if (obj.Password == username)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Error Creating User");
            }
        }
Exemple #4
0
        public async Task createNewUser()
        {
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            obj.Set("email", Util.Methods._makeEmail());
            await obj.Signup();

            if (obj.Username == username)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Error Creating User");
            }
        }
Exemple #5
0
        public async Task assignRoleToUser()
        {
            var roleName = Util.Methods._makeString();
            var role     = new CB.CloudRole(roleName);

            role.Set("name", roleName);
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            await obj.Login();

            await role.SaveAsync();

            await obj.AddToRole(role);

            Assert.IsTrue(true);
        }
Exemple #6
0
        public async Task createNewUserWithVersion()
        {
            var username = "******";
            var passwd   = "abcd";
            var email    = "*****@*****.**";
            var user     = new CB.CloudUser();

            user.Set("username", username);
            user.Set("password", passwd);
            user.Set("email", email);
            user = await user.Signup();

            if (user.Get("username").ToString() == username && (int)user.Get("_version") >= 0)
            {
                Assert.IsTrue(true);
            }
            Assert.IsFalse(true);
        }
Exemple #7
0
        public async Task createUserAndGetVersion()
        {
            username = Util.Methods._makeString();
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            obj.Set("email", Util.Methods._makeEmail());
            await obj.Signup();

            if (obj.Username == username && (int)obj.Get("_version") >= 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Error Creating User");
            }
        }
Exemple #8
0
        public async Task CreateUserAndGetVersion()
        {
            username = Util.Methods.MakeString();
            var obj = new CB.CloudUser();

            obj.Set("username", Util.Methods.MakeEmail());
            obj.Set("password", Util.Methods.MakeEmail());
            obj.Set("email", Util.Methods.MakeEmail());
            await obj.SignupAsync();

            if (Int32.Parse(obj.Get("_version").ToString()) >= 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Error Creating User");
            }
        }
Exemple #9
0
        public async Task AssignRoleToUser()
        {
            var roleName = Util.Methods.MakeString();
            var role     = new CB.CloudRole(roleName);

            role.Set("name", roleName);
            var obj = new CB.CloudUser();

            obj.Set("username", CB.Test.Util.Methods.MakeEmail());
            obj.Set("password", CB.Test.Util.Methods.MakeEmail());
            obj.Set("email", CB.Test.Util.Methods.MakeEmail());
            await obj.SignupAsync();

            await role.SaveAsync();

            await obj.AddToRoleAsync(role);

            Assert.IsTrue(true);
        }
Exemple #10
0
        public async Task createNewUserSave()
        {
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            obj.Set("email", Util.Methods._makeEmail());
            await obj.SaveAsync();

            var query    = new CB.CloudQuery("User");
            var response = await query.GetAsync(obj.ID);

            if (response != null)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Unable to retrieve User");
            }
        }
Exemple #11
0
        public async Task CreateNewUserWithVersion()
        {
            var username = CB.Test.Util.Methods.MakeEmail();
            var passwd   = "abcd";
            var email    = CB.Test.Util.Methods.MakeEmail();
            var user     = new CB.CloudUser();

            user.Set("username", username);
            user.Set("password", passwd);
            user.Set("email", email);
            user = await user.SignupAsync();

            if (user.Get("username").ToString() == username && Int32.Parse(user.Get("_version").ToString()) >= 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Exemple #12
0
        public async Task queryOnUser()
        {
            username = Util.Methods._makeString();
            var obj = new CB.CloudUser();

            obj.Set("username", username);
            obj.Set("password", password);
            obj.Set("email", Util.Methods._makeEmail());
            await obj.Signup();

            if (obj.Username == username && (int)obj.Get("_version") >= 0)
            {
                var query    = new CB.CloudQuery("User");
                var response = await query.GetAsync(obj.ID);

                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Error Creating User");
            }
        }
Exemple #13
0
        public async Task QueryOnUser()
        {
            username = Util.Methods.MakeString();
            var obj = new CB.CloudUser();

            obj.Set("username", Util.Methods.MakeEmail());
            obj.Set("password", Util.Methods.MakeEmail());
            obj.Set("email", Util.Methods.MakeEmail());
            await obj.SignupAsync();

            if (Int32.Parse(obj.Get("_version").ToString()) >= 0)
            {
                var query    = new CB.CloudQuery("User");
                var response = await query.GetAsync <CB.CloudUser>(obj.ID);

                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Error Creating User");
            }
        }
Exemple #14
0
        public async Task LoginUser()
        {
            var obj = new CB.CloudUser();

            obj.Set("username", CB.Test.Util.Methods.MakeEmail());
            obj.Set("password", CB.Test.Util.Methods.MakeEmail());
            obj.Set("email", CB.Test.Util.Methods.MakeEmail());

            await obj.SignupAsync();

            await obj.LogoutAsync();

            await obj.LoginAsync();

            if (obj.Username == username && CB.CloudUser.Current != null)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("User Login Error");
            }
        }
Exemple #15
0
        internal static object Deserialize(object data)
        {
            if (data.GetType() == typeof(ArrayList))
            {
                ArrayList newList = new ArrayList();

                for (int i = 0; i < ((ArrayList)data).Count; i++)
                {
                    newList.Add(Deserialize((((ArrayList)data)[i])));
                }

                return(newList);
            }
            else if (data.GetType().IsArray || data.GetType() == typeof(JArray))
            {
                ArrayList newList = new ArrayList(((IEnumerable)data).Cast <object>()
                                                  .Select(x => Deserialize(x))
                                                  .ToList());
                return(newList);
            }
            else if (data.GetType() == typeof(Dictionary <string, Object>) || data.GetType() == typeof(JObject))
            {
                CB.CloudObject obj = null;

                Dictionary <string, Object> tempData = null;

                if (data.GetType() == typeof(JObject))
                {
                    tempData = ((JObject)data).ToObject <Dictionary <string, object> >();
                }
                else
                {
                    tempData = (Dictionary <string, Object>)data;
                }

                if (((Dictionary <string, Object>)(tempData)).ContainsKey("_type"))
                {
                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "custom")
                    {
                        obj = new CloudObject(((Dictionary <string, Object>)(tempData))["_tableName"].ToString());
                    }

                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "user")
                    {
                        obj = new CloudUser();
                    }

                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "role")
                    {
                        obj = new CloudRole(((Dictionary <string, Object>)(tempData))["name"].ToString());
                    }

                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "point")
                    {
                        //return geopoint dictionary.
                        CloudGeoPoint point = new CloudGeoPoint(Decimal.Parse(((Dictionary <string, Object>)(tempData))["longitude"].ToString()), Decimal.Parse(((Dictionary <string, Object>)(tempData))["latitude"].ToString()));
                        return(point);
                    }

                    foreach (var param in ((Dictionary <string, Object>)(tempData)))
                    {
                        if (param.Value == null)
                        {
                            obj.dictionary[param.Key] = null;
                        }
                        else if (param.Key == "ACL")
                        {
                            var acl = new CB.ACL();
                            obj.dictionary[param.Key] = acl;
                        }
                        else if (param.Key == "expires")
                        {
                            obj.dictionary["expires"] = ((Dictionary <string, Object>)(tempData))["expires"];
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "custom")
                        {
                            CB.CloudObject cbObj = new CB.CloudObject(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_tableName"].ToString());
                            cbObj = (CloudObject)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >());
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "user")
                        {
                            CB.CloudUser cbObj = new CB.CloudUser();
                            cbObj = (CloudUser)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >());
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "custom")
                        {
                            CB.CloudRole cbObj = new CB.CloudRole(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["name"].ToString());
                            cbObj = (CloudRole)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >());
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "point")
                        {
                            CB.CloudGeoPoint cbObj = new CB.CloudGeoPoint(Decimal.Parse(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["longitude"].ToString()), Decimal.Parse(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["latitude"].ToString()));
                            cbObj = (CloudGeoPoint)(Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()));
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value.GetType() == typeof(ArrayList))
                        {
                            obj.dictionary[param.Key] = Deserialize(param.Value);
                        }
                        else if (param.Value.GetType().IsArray)
                        {
                            obj.dictionary[param.Key] = Deserialize(param.Value);
                        }
                        else if (param.Value.GetType() == typeof(JArray))
                        {
                            obj.dictionary[param.Key] = Deserialize(param.Value);
                        }
                        else
                        {
                            obj.dictionary[param.Key] = param.Value;
                        }
                    }

                    return(obj);
                }
                else
                {
                    return(tempData);
                }
            }

            return(data);
        }