Esempio n. 1
0
        public void TestCurrentUserAfterLogin()
        {
            try
            {
                BackendlessUser notRegisteredUseruser = GetRandomNotRegisteredUser();
                string          propertyKey           = "propertykey" + Random.Next();
                string          propertyValue         = "property_value#" + Random.Next();
                notRegisteredUseruser.SetProperty(propertyKey, propertyValue);

                BackendlessUser user = Backendless.UserService.Register(notRegisteredUseruser);
                UsedProperties.Add(propertyKey);

                user = Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);

                Assert.IsNotNull(Backendless.UserService.CurrentUser, "Current user was null");

                foreach (string key in user.Properties.Keys)
                {
                    if (key.Equals("password"))
                    {
                        continue;
                    }

                    Assert.IsTrue(Backendless.UserService.CurrentUser.Properties.ContainsKey(key), "Current user didn`t contain expected property " + key);
                    Assert.AreEqual(user.GetProperty(key), Backendless.UserService.CurrentUser.GetProperty(key), "UserService.register changed property " + key);
                }
            }
            catch (System.Exception t)
            {
                Assert.Fail(t.Message);
            }
        }
 public CustomerDetailsForm(BackendlessUser user, Reservation r)
 {
     InitializeComponent();
     //In the rare occurance that the user has deleted or deactivated his/her account
     if (user != null)
     {
         //Determines if the reservation was made by the restaurant
         if (user.ObjectId == OwnerStorage.ThisRestaurant.ownerId)
         {
             lblRestaurantLabel.Visible = true;
             lblTitle.Text = "Reservation details for " + r.Name;
         }
         //The reservation was made by a customer. His/her details will be displayed accordingly
         else
         {
             tbxContact.Text = user.GetProperty("Cellphone").ToString();
             tbxFName.Text   = user.GetProperty("FirstName").ToString();
             tbxLName.Text   = user.GetProperty("LastName").ToString();
             tbxEmail.Text   = user.GetProperty("email").ToString();
             lblTitle.Text   = "Reservation details for " + user.GetProperty("FirstName").ToString();
         }
     }
     //Displays that the account could not be located
     else
     {
         lblRestaurantLabel.Visible = true;
         lblRestaurantLabel.Text    = "This user has deactivated or deleted his/her account. No valid information about this user could be retrieved";
         lblTitle.Text = "Reservation details for " + r.Name;
     }
 }
Esempio n. 3
0
        public void TestDescribeUserProperties()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user             = GetRandomNotRegisteredUser();
            string          propertyKeySync  = "property_key#Sync";
            string          propertyKeyAsync = "property_key#Async";

            user.SetProperty(propertyKeySync, "porperty_value#" + Random.Next());
            Backendless.UserService.Register(user);
            Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);
            List <UserProperty> userProperties = Backendless.UserService.DescribeUserClass();

            Assert.IsNotNull(userProperties, "Server returned null user properties");
            Assert.IsTrue(userProperties.Count != 0, "Server returned empty user properties");

            var properties = new List <string> {
                propertyKeySync, propertyKeyAsync, ID_KEY, LOGIN_KEY, PASSWORD_KEY, EMAIL_KEY
            };

            foreach (UserProperty userProperty in userProperties)
            {
                Assert.IsNotNull(userProperty, "User property was null");
                Assert.IsTrue(properties.Contains(userProperty.Name),
                              "User properties contained unexpected property " + userProperty.Name);
                Assert.IsNotNull(userProperty.Type, "User properties type was null");
            }
        }
Esempio n. 4
0
        public void TestRestoreUserPassword()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            Backendless.UserService.RestorePassword((string)user.GetProperty(LOGIN_KEY));
        }
Esempio n. 5
0
        public void TestRegisterNewUser()
        {
            RunAndAwait(() =>
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
                BackendlessUser user = GetRandomNotRegisteredUser();
                string propertyKey   = "property_key#" + Random.Next();
                string propertyValue = "property_value#" + Random.Next();
                user.SetProperty(propertyKey, propertyValue);
                Backendless.UserService.Register(user,
                                                 new ResponseCallback <BackendlessUser>(this)
                {
                    ResponseHandler = response =>
                    {
                        UsedProperties.Add(propertyKey);
                        Assert.IsNotNull(response.GetProperty("id"),
                                         "UserService.register didn't set user ID");

                        foreach (String key in user.Properties.Keys)
                        {
                            Assert.IsTrue(response.Properties.ContainsKey(key),
                                          "Registered user didn`t contain expected property " +
                                          key);
                            Assert.AreEqual(user.GetProperty(key), response.GetProperty(key),
                                            "UserService.register changed property " + key);
                        }

                        CountDown();
                    }
                });
            });
        }
Esempio n. 6
0
        public BackendlessUser GetRandomLoggedInUser()
        {
            BackendlessUser user = GetRandomRegisteredUser();

            Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);

            return(user);
        }
Esempio n. 7
0
        public void TestUpdateRegisteredUserIdentity()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            user.SetProperty(LOGIN_KEY, "some_new_login_" + user.GetProperty(LOGIN_KEY));

            Backendless.UserService.Update(user);
        }
Esempio n. 8
0
    public BackendlessUser GetRandomNotRegisteredUser()
    {
      var timestamp = (DateTime.UtcNow.Ticks + Random.Next()).ToString();
      BackendlessUser result = new BackendlessUser();
      result.SetProperty( LOGIN_KEY, "bot" + timestamp );
      result.SetProperty( EMAIL_KEY, result.GetProperty( LOGIN_KEY ) + "@gmail.com" );
      result.Password = "******" + timestamp;

      return result;
    }
Esempio n. 9
0
        Reservation thisReservation; //The reservation being viewed

        //This constructor receives an instance of the user, the reservation an the Table. This method will populate the all the necessary information on the form
        public ReservationDetailsForm(Reservation r, BackendlessUser u, RestaurantTable t, bool active, MainForm _master)
        {
            thisReservation = r;

            InitializeComponent();

            tbxCapacity.Text = t.Capacity.ToString();
            tbxContact.Text  = u.GetProperty("Cellphone").ToString();
            tbxContact2.Text = r.Number;
            tbxEmail.Text    = u.Email;
            tbxFName.Text    = u.GetProperty("FirstName").ToString();
            tbxLName.Text    = u.GetProperty("LastName").ToString();
            tbxTable.Text    = t.Name;
            tbxTime.Text     = r.TakenFrom.ToString("dddd, dd/MM,    HH:mm") + " - " + r.TakenTo.ToString("HH:mm");
            lblTitle.Text    = "Reservation for " + r.Name;

            //Determines if the reservation was made by the Restaurant or by a customer in order to conceal critical information about the restaurant to the employees
            if (u.ObjectId == OwnerStorage.CurrentlyLoggedIn.ObjectId)
            {
                lblMadeByRestaurant.Visible = true;
            }
            else
            {
                if (u.Email == "-")
                {
                    lblMadeByRestaurant.Visible = true;
                    lblMadeByRestaurant.Text    = "This User could not be located in the database. It might be that this user has been removed completely.";
                }
                else
                {
                    lblContactNumber.Visible = false;
                    tbxContact2.Visible      = false;
                    pnlReservation.Height   += -50;
                }
            }

            if (OwnerStorage.AdminMode == true && active == true)
            {
                btnDelete.Visible = true;
            }

            this._master = _master;
        }
Esempio n. 10
0
        public BackendlessUser GetRandomNotRegisteredUser()
        {
            var timestamp = (DateTime.UtcNow.Ticks + Random.Next()).ToString();
            var result    = new BackendlessUser();

            result.SetProperty(LOGIN_KEY, "bot" + timestamp);
            result.SetProperty(EMAIL_KEY, result.GetProperty(LOGIN_KEY) + "@gmail.com");
            result.Password = "******" + timestamp;

            return(result);
        }
Esempio n. 11
0
        public void TestLoginWithoutFailedLoginsLock()
        {
            BackendlessUser user = GetRandomRegisteredUser();

            try
            {
                Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password + "foo");
            }
            catch (System.Exception t)
            {
            }

            try
            {
                Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);
            }
            catch (System.Exception t)
            {
                Assert.Fail(t.Message);
            }
        }
Esempio n. 12
0
 public void TestLoginWithProperCredentials()
 {
     try
     {
         BackendlessUser user = GetRandomRegisteredUser();
         Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);
         Backendless.UserService.DescribeUserClass();
     }
     catch (System.Exception t)
     {
         Assert.Fail(t.Message);
     }
 }
Esempio n. 13
0
        public void TestRegisterNewUser()
        {
            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user          = GetRandomNotRegisteredUser();
            String          propertyKey   = "property_key#" + Random.Next();
            String          propertyValue = "property_value#" + Random.Next();

            user.SetProperty(propertyKey, propertyValue);
            BackendlessUser registeredUser = Backendless.UserService.Register(user);

            UsedProperties.Add(propertyKey);

            Assert.IsNotNull(registeredUser.GetProperty("id"), "UserService.register didn't set user ID");

            foreach (string key in user.Properties.Keys)
            {
                Assert.IsTrue(registeredUser.Properties.ContainsKey(key),
                              "Registered user didn`t contain expected property " + key);
                Assert.AreEqual(user.GetProperty(key), registeredUser.GetProperty(key),
                                "UserService.register changed property " + key);
            }
        }
Esempio n. 14
0
 public void TestRestoreUserPasswordWithWrongLogin()
 {
     try
     {
         Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
         BackendlessUser user = GetRandomLoggedInUser();
         Backendless.UserService.RestorePassword("fake_login_" + user.GetProperty(LOGIN_KEY));
         Assert.Fail("Server accepted wrong login.");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(3020, t);
     }
 }
Esempio n. 15
0
 public void TestLoginWithDisabledAppLogin()
 {
     try
     {
         LoginDeveloper();
         DisableAppLogin();
         BackendlessUser user = GetRandomRegisteredUser();
         Backendless.UserService.Login((string)user.GetProperty(LOGIN_KEY), user.Password);
         Assert.Fail("Server accepted Login");
     }
     catch (System.Exception t)
     {
         CheckErrorCode(3034, t);
     }
 }
Esempio n. 16
0
 public void TestLoginWithProperCredentials()
 {
     RunAndAwait(() =>
     {
         BackendlessUser reguser = GetRandomRegisteredUser(null);
         Backendless.UserService.Login((string)reguser.GetProperty(LOGIN_KEY), reguser.Password,
                                       new ResponseCallback <BackendlessUser>(this)
         {
             ResponseHandler =
                 user =>
                 Backendless.UserService.DescribeUserClass(
                     new ResponseCallback <List <UserProperty> >(this))
         });
     });
 }
Esempio n. 17
0
        public void TestUpdateRegisteredUserEmailAndPassword()
        {
            const string newpassword = "******";
            const string newemail    = "*****@*****.**";

            Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
            BackendlessUser user = GetRandomLoggedInUser();

            user.Password = newpassword;
            user.SetProperty(EMAIL_KEY, newemail);

            Backendless.UserService.Update(user);

            Assert.AreEqual(newpassword, user.Password, "Updated used has a wrong password");
            Assert.AreEqual(newemail, user.GetProperty(EMAIL_KEY), "Updated used has a wrong email");
        }
Esempio n. 18
0
        public void TestRegisterNewUserWithId()
        {
            try
            {
                Backendless.InitApp(Defaults.TEST_APP_ID, Defaults.TEST_SECRET_KEY);
                BackendlessUser user = Backendless.UserService.Register(GetRandomNotRegisteredUser());

                BackendlessUser fakeUser = GetRandomNotRegisteredUser();
                fakeUser.SetProperty(ID_KEY, user.GetProperty(ID_KEY));

                Backendless.UserService.Register(fakeUser);
                Assert.Fail("Server accepted a user with id value");
            }
            catch (System.Exception t)
            {
                CheckErrorCode(3039, t);
            }
        }