Esempio n. 1
0
        public void User_Edit_As_Same_User()
        {
            BusinessPrincipal.Login();

            var user     = UserService.UserNew();
            var password = DataHelper.RandomString(10);

            user.Name      = DataHelper.RandomString(20);
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(password);

            user = UserService.UserSave(user, new EmptyMessenger());

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(user.Name, password);

            user = UserService.UserFetch(user.Name);

            var firstName = user.FirstName;

            user.FirstName = DataHelper.RandomString(10);

            user = UserService.UserSave(user, new EmptyMessenger());

            user = UserService.UserFetch(user.Name);

            Assert.IsTrue(user.FirstName != firstName);
        }
Esempio n. 2
0
        public void User_New()
        {
            BusinessPrincipal.Login();

            var user = UserService.UserNew();

            Assert.IsTrue(user.IsNew, "IsNew should be true");
            Assert.IsTrue(user.IsDirty, "IsDirty should be true");
            Assert.IsFalse(user.IsValid, "IsValid should be false");
            Assert.IsTrue(user.IsSelfDirty, "IsSelfDirty should be true");
            Assert.IsFalse(user.IsSelfValid, "IsSelfValid should be false");
            Assert.IsTrue(user.IsActive, "IsActive should be true");
            Assert.IsFalse(user.IsArchived, "IsArchived should be false");

            Assert.IsTrue(ValidationHelper.ContainsRule(user, DbType.String, "Name"),
                          "Name should be required");
            Assert.IsTrue(ValidationHelper.ContainsRule(user, DbType.String, "FirstName"),
                          "FirstName should be required");
            Assert.IsTrue(ValidationHelper.ContainsRule(user, DbType.String, "LastName"),
                          "LastName should be required");
            Assert.IsTrue(ValidationHelper.ContainsRule(user, DbType.String, "Password"),
                          "Password should be required");
            Assert.IsTrue(ValidationHelper.ContainsRule(user, DbType.String, "Salt"),
                          "Salt should be required");
            Assert.IsTrue(ValidationHelper.ContainsRule(user, "rule://epiworx.business.rolerequired/Role"),
                          "Role should be required");
        }
Esempio n. 3
0
        public void User_New_Sign_Up_And_Validate_Login_And_Password()
        {
            BusinessPrincipal.Login();

            var password = DataHelper.RandomString(10);
            var user     = UserService.UserNew();

            user.Name      = DataHelper.RandomString(20);
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(password);

            user = UserService.UserSave(user, MessengerHelper.InitMessengerForUserCreate());

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(user.Name, password);

            var identity = (BusinessIdentity)Csla.ApplicationContext.User.Identity;

            Assert.IsTrue(identity.IsAuthenticated && identity.Name == user.Name);
        }
Esempio n. 4
0
        public static Filter CreateFilterForUserAndLogon(string userName, string userPassword, int userId)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var filter = FilterService.FilterNew();

            var task = BusinessHelper.CreateTask();

            filter.Name   = DataHelper.RandomString(20);
            filter.Target = DataHelper.RandomString(20);
            filter.Query  = DataHelper.RandomString(20);

            filter = FilterService.FilterSave(filter);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(filter);
        }
Esempio n. 5
0
        public void User_Password_Reset_Password_And_Send_Message()
        {
            BusinessPrincipal.Login();

            var user     = UserService.UserNew();
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            user.Name      = name;
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(password);

            user = UserService.UserSave(user, new EmptyMessenger());

            UserService.UserFetch(user.UserId);

            BusinessPrincipal.Login(name, password);

            BusinessPrincipal.Logout();

            string newPassword;

            UserPasswordService.UserPasswordReset(name, out newPassword, MessengerHelper.InitMessengerForUserUpdatePassword());

            BusinessPrincipal.Login(name, newPassword);

            BusinessPrincipal.Logout();
        }
        public void User_Password_Update()
        {
            BusinessPrincipal.Login("User", "master");

            var userPassword = UserPasswordRepository.UserPasswordFetch();

            var password = DataHelper.RandomString(20);

            userPassword.Password             = password;
            userPassword.PasswordConfirmation = userPassword.Password;

            Assert.IsTrue(userPassword.IsValid, "IsValid should be true");

            userPassword = UserPasswordRepository.UserPasswordSave(userPassword);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login("User", password);

            userPassword.Password             = "******";
            userPassword.PasswordConfirmation = "master";

            userPassword = UserPasswordRepository.UserPasswordSave(userPassword);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login("User", "master");
        }
Esempio n. 7
0
        public void User_New_Sign_Up_With_Duplicate_Name()
        {
            BusinessPrincipal.Login();

            var user = UserService.UserNew();
            var name = DataHelper.RandomString(20);

            user.Name      = name;
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(DataHelper.RandomString(10));

            UserService.UserSave(user, new EmptyMessenger());

            user = UserService.UserNew();

            user.Name      = name;
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(DataHelper.RandomString(10));

            Assert.IsTrue(ValidationHelper.ContainsRule(user, "rule://epiworx.business.userduplicatenamecheck/Name"),
                          "Name should not be duplicated");
        }
        private void DoLogin()
        {
            Login dlg = new Login();

            dlg.ShowDialog(this);
            if (dlg.HasData)
            {
                Cursor = Cursors.WaitCursor;
                BaseMain.SetStatus("Verifying user...");
                BusinessPrincipal.Login(dlg.Username, dlg.Password);
                BaseMain.SetStatus("");
                Cursor = Cursors.Default;

                if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
                {
                    pnlUser.Text = Thread.CurrentPrincipal.Identity.Name;
                    BuildMenus();
                }
                else
                {
                    DoLogout();
                    MessageBox.Show("The username and password were not valid",
                                    "Incorrect Password", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                DoLogout();
            }
        }
Esempio n. 9
0
        public static Hour CreateHourThatIsArchivedAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var hour = HourService.HourNew();

            var task = BusinessHelper.CreateTask();

            hour.TaskId     = task.TaskId;
            hour.Date       = DateTime.Now.Date;
            hour.Duration   = 8;
            hour.Notes      = DataHelper.RandomString(100);
            hour.IsArchived = true;

            hour = HourService.HourSave(hour);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(hour);
        }
Esempio n. 10
0
        public static Task CreateTaskThatIsArchivedAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var task = TaskService.TaskNew();

            var status   = BusinessHelper.CreateStatus();
            var category = BusinessHelper.CreateCategory();
            var project  = BusinessHelper.CreateProject();

            task.Description = DataHelper.RandomString(1000);
            task.StatusId    = status.StatusId;
            task.CategoryId  = category.CategoryId;
            task.ProjectId   = project.ProjectId;
            task.IsArchived  = true;

            task = TaskService.TaskSave(task);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(task);
        }
Esempio n. 11
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     //Csla.DataPortal.ProxyTypeName = "Csla.DataPortalClient.WcfProxy, Csla";
     //Csla.DataPortalClient.WcfProxy.DefaultUrl = "http://localhost:2581/WcfPortal.svc";
     BusinessPrincipal.Login("SergeyB", "1234", "admin;user", (o2, e2) =>
     {
         this.RootVisual = new Page();
     });
 }
Esempio n. 12
0
 public void Logon_With_Good_UserName_And_Bad_Password()
 {
     try
     {
         BusinessPrincipal.Login("goodusername", "badpassword");
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex.GetBaseException() is SecurityException);
     }
 }
Esempio n. 13
0
        static void Login()
        {
            System.Console.Out.Write("Name: ");

            var name = System.Console.In.ReadLine();

            System.Console.Out.Write("Password: "******"Welcome {0}!", Csla.ApplicationContext.User.Identity.Name));
        }
Esempio n. 14
0
        public bool ValidateUser(string userName, string password)
        {
            try
            {
                var result = BusinessPrincipal.Login(userName, password);

                this.Session["EPIWORXUSER"] = Csla.ApplicationContext.User;

                return(result);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 15
0
 private void LoginFail_Click(object sender, RoutedEventArgs e)
 {
     LoginStatus.Text = "Logging in...";
     BusinessPrincipal.Login("admin", "pwd", "admin;user", (objectValue, eventArgs) =>
     {
         if (Csla.ApplicationContext.User.Identity.IsAuthenticated)
         {
             LoginStatus.Text     = "Logged in as " + Csla.ApplicationContext.User.Identity.Name;
             ItemsGrid.Visibility = Visibility.Collapsed;
         }
         else
         {
             LoginStatus.Text = "Login failed";
         }
     });
 }
Esempio n. 16
0
 private void Login_Click(object sender, RoutedEventArgs e)
 {
     LoginStatus.Text = "Logging in...";
     BusinessPrincipal.Login("SergeyB", "1234", "admin;user", (objectValue, eventArgs) =>
     {
         if (Csla.ApplicationContext.User.Identity.IsAuthenticated)
         {
             LoginStatus.Text     = "Logged in as " + Csla.ApplicationContext.User.Identity.Name;
             ItemsGrid.Visibility = Visibility.Visible;
             LoginStatus.Text     = "Getting items...";
             RootSingleItemsList.GetRootSingleItemsList(1, 100, (o, ef) =>
             {
                 if (ef.Error != null)
                 {
                     LoginStatus.Text = "Error getting items list";
                 }
                 else
                 {
                     ItemsGrid.ItemsSource = ef.Object;
                     LoginStatus.Text      = "Got data.";
                     _currentList          = ef.Object;
                     _currentList.Saved   += (o1, e1) =>
                     {
                         if (e1.Error == null)
                         {
                             Status.Text = "Saved item " + ((SingleItem)e1.NewObject).Id.ToString();
                         }
                         else
                         {
                             Status.Text = "Could not save item " + ((SingleItem)e1.NewObject).Id.ToString() + ".  Error: " + e1.Error.ToString();
                         }
                     };
                     if (_currentList.Count > 0)
                     {
                         ItemsGrid.SelectedItem = _currentList[0];
                     }
                 }
             });
         }
         else
         {
             LoginStatus.Text = "Login failed";
         }
     });
 }
Esempio n. 17
0
        public TokenData Authorize(string username, string password)
        {
            BusinessPrincipal.Login(username, password);

            var result          = new TokenData();
            var token           = new Token();
            var tokenRepository = new TokenRepository();

            token.Key            = Guid.NewGuid().ToString().ToUpper();
            token.UserName       = username;
            token.CreatedDate    = DateTime.Now;
            token.ExpirationDate = DateTime.Now.AddMinutes(30);

            tokenRepository.AddToken(token);

            result.Key = token.Key;

            return(result);
        }
Esempio n. 18
0
        public void User_New_Sign_Up()
        {
            BusinessPrincipal.Login();

            var user = UserService.UserNew();

            user.Name      = DataHelper.RandomString(20);
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(DataHelper.RandomString(10));

            Assert.IsTrue(user.IsValid, "IsValid should be true");

            user = UserService.UserSave(user, null);

            Assert.IsTrue(user != null);
        }
Esempio n. 19
0
        public static User CreateUserWithFullControl(string userName, string password)
        {
            BusinessPrincipal.Login();

            var user = UserService.UserNew();

            user.Name      = userName;
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(password);

            user = UserService.UserSave(user, new EmptyMessenger());

            BusinessPrincipal.Logout();

            return(user);
        }
Esempio n. 20
0
        public static Status CreateStatusAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var status = StatusService.StatusNew();

            status.Name = DataHelper.RandomString(20);

            status = StatusService.StatusSave(status);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(status);
        }
Esempio n. 21
0
        public static Category CreateCategoryAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var category = CategoryService.CategoryNew();

            category.Name = DataHelper.RandomString(20);

            category = CategoryService.CategorySave(category);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(category);
        }
Esempio n. 22
0
        public static Project CreateProjectAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var project = ProjectService.ProjectNew();

            project.Name = DataHelper.RandomString(20);

            project = ProjectService.ProjectSave(project);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(project);
        }
        public void User_Password_Fetch()
        {
            BusinessPrincipal.Login("User", "master");

            var user = UserPasswordRepository.UserPasswordFetch();

            Assert.IsFalse(user.IsNew, "IsNew should be false");
            Assert.IsFalse(user.IsDirty, "IsDirty should be false");
            Assert.IsFalse(user.IsValid, "IsValid should be false");
            Assert.IsFalse(user.IsSelfDirty, "IsSelfDirty should be false");
            Assert.IsFalse(user.IsSelfValid, "IsSelfValid should be false");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(user, DbType.String, "Password"),
                "Password should be required");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(user, DbType.String, "PasswordConfirmation"),
                "PasswordConfirmation should be required");

            BusinessPrincipal.Logout();
        }
Esempio n. 24
0
        public static Sprint CreateSprintAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var sprint  = SprintService.SprintNew();
            var project = BusinessHelper.CreateProject();

            sprint.ProjectId = project.ProjectId;
            sprint.Name      = DataHelper.RandomString(20);

            sprint = SprintService.SprintSave(sprint);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(sprint);
        }
Esempio n. 25
0
        public void User_Password_Change_Password_And_Send_Message()
        {
            BusinessPrincipal.Login();

            var user     = UserService.UserNew();
            var password = DataHelper.RandomString(10);

            user.Name      = DataHelper.RandomString(20);
            user.FirstName = DataHelper.RandomString(20);
            user.LastName  = DataHelper.RandomString(20);
            user.Email     = DataHelper.RandomEmail();
            user.Role      = Role.FullControl;

            user.SetPassword(password);

            user = UserService.UserSave(user, new EmptyMessenger());

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(user.Name, password);

            user = UserService.UserFetch(user.UserId);

            user.SetPassword(DataHelper.RandomString(20));

            var newPassword = DataHelper.RandomString(20);

            UserPasswordService.UserPasswordChange(newPassword, newPassword, MessengerHelper.InitMessengerForUserUpdatePassword());

            user = UserService.UserFetch(user.UserId);

            Assert.IsTrue(user.Password != password);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(user.Name, newPassword);
        }
Esempio n. 26
0
        public static Invoice CreateInvoiceAndLogon(string userName, string userPassword)
        {
            var name     = DataHelper.RandomString(20);
            var password = DataHelper.RandomString(20);

            BusinessHelper.CreateUserWithFullControl(name, password);

            BusinessPrincipal.Login(name, password);

            var invoice = InvoiceService.InvoiceNew();

            var task = BusinessHelper.CreateTask();

            invoice.Number = DataHelper.RandomString(20);
            invoice.TaskId = task.TaskId;

            invoice = InvoiceService.InvoiceSave(invoice);

            BusinessPrincipal.Logout();

            BusinessPrincipal.Login(userName, userPassword);

            return(invoice);
        }
Esempio n. 27
0
        public ActionResult Register(RegisterModel model)
        {
            if (this.ModelState.IsValid)
            {
                BusinessPrincipal.Login();

                var user = UserService.UserNew();

                user.Name      = model.UserName;
                user.FirstName = model.FirstName;
                user.LastName  = model.LastName;
                user.Email     = model.Email;
                user.Role      = Role.Review;

                user.SetPassword(model.Password);

                user = UserService.UserSave(user);

                if (user.IsValid)
                {
                    BusinessPrincipal.Logout();

                    BusinessPrincipal.LoadPrincipal(model.UserName);

                    this.FormsService.SignIn(model.UserName, false);

                    this.Session["EPIWORXUSER"] = Csla.ApplicationContext.User;

                    return(this.RedirectToAction("Index", "Home"));
                }

                this.ModelState.AddModelError(string.Empty, user.BrokenRulesCollection.ToString(","));
            }

            return(this.View(model));
        }
 public void MyTestInitialize()
 {
     BusinessPrincipal.Login(
         CategoryTestsWithRoleContribute.UserName,
         CategoryTestsWithRoleContribute.UserPassword);
 }
 public void MyTestInitialize()
 {
     BusinessPrincipal.Login(
         StatusTestsWithRoleReview.UserName,
         StatusTestsWithRoleReview.UserPassword);
 }
Esempio n. 30
0
 public void MyTestInitialize()
 {
     BusinessPrincipal.Login(
         FeedTests.UserData,
         FeedTests.UserPassword);
 }