コード例 #1
0
        void iconControl_OnUserCredentialsEntered(bool validCredentials, UserAdminObject user)
        {
            if (validCredentials)
            {
                user.OpenedPages.Clear();
                CacheManager.ActiveUser = user;

                try
                {
                    MainWindow carDepot = new MainWindow(user);
                    carDepot.Closed += carDepot_Closed;
                    carDepot.Show();
                    this.Visibility = Visibility.Hidden;
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }

            }
            else
            {
                MessageBox.Show("FAIL FOR: " + user.Name);
            }
        }
コード例 #2
0
        public async Task AddKeywordsNotesAuthInfoAndGroupsToUserAdminObjectAsync(UserAdminObject userAdminObject, KeywordsNotesModel userKeywordsNotesModel, IEnumerable <String> groupNameList, LoginProfile userLoginProfile)
        {
            try
            {
                await Task.Run(() =>
                {
                    //add keywords and notes data to UserAdminObject instance
                    userAdminObject.Keywords.Data = userKeywordsNotesModel.Keywords;
                    userAdminObject.Notes.Data    = userKeywordsNotesModel.Notes;

                    //add groups data to UserAdminObject instance
                    userAdminObject.Groups.Data = String.Join(Constant.SemiColonSeparator, groupNameList);

                    //add integrated authentication data to UserAdminObject instance
                    if (userLoginProfile.IntegratedAuthentication != null)
                    {
                        userAdminObject.WindowsAccount.Data = userLoginProfile.IntegratedAuthentication.IsEnabled ? userLoginProfile.IntegratedAuthentication.Account : String.Empty;
                    }

                    //add password authentication data to UserAdminObject instance
                    if (userLoginProfile.Password != null)
                    {
                        //No need to set the following fields UserMustChangePasswordOnNextLogin, CanChangePassword, MaximumPasswordAgeInDays
                        userAdminObject.TwoFactorMode.Data = userLoginProfile.Password.TwoFactorMode.ToString();
                        userAdminObject.TwoFactorInfo.Data = userLoginProfile.Password.TwoFactorInfo;
                    }
                });
            }
            catch (Exception ex)
            {
                throw new AdminMigrationUtilityException(Constant.ErrorMessages.AddKeywordsNotesAuthGroupsDataToUserAdminObjectError, ex);
            }
        }
コード例 #3
0
        public static async Task <IAdminObject> GetImportObjectSelectionAsync(String objectType)
        {
            return(await Task.Run(() =>
            {
                IAdminObject migrationObject;
                var supportedObjects = String.Join(Constant.CommaSeparator, Enum.GetNames(typeof(Constant.Enums.SupportedObjects)));
                var unsupportedObjectMsg = String.Format(Constant.ErrorMessages.UnsupportedObjectError, supportedObjects);
                try
                {
                    Constant.Enums.SupportedObjects parsedObjectType;
                    if (Enum.TryParse <Constant.Enums.SupportedObjects>(objectType, out parsedObjectType))
                    {
                        switch (parsedObjectType)
                        {
                        case Constant.Enums.SupportedObjects.User:
                            migrationObject = new UserAdminObject();
                            break;

                        default:
                            throw new AdminMigrationUtilityException();
                        }
                    }
                    else
                    {
                        throw new AdminMigrationUtilityException();
                    }
                }
                catch (Exception ex)
                {
                    throw new AdminMigrationUtilityException(unsupportedObjectMsg, ex);
                    //violations.Add(new ImportJobError() { Message = unsupportedObjectMsg, Type = Constant.ImportUtilityJob.ErrorType.JobLevel, LineNumber = null, Details = ex.ToString()});
                }
                return migrationObject;
            }));
        }
コード例 #4
0
        public async Task ViolationsForMultipleFieldsAreReturnedCorrectly()
        {
            var user    = new UserAdminObject();
            var columns = await GetUserDictionary();

            await user.MapObjectColumnsAsync(columns);

            //Get the required Fields
            var requiredFields = (await user.GetColumnsAsync()).Where(x => x.Validations.Count(y => y.GetType() == typeof(ValidationNotNull)) > 0);

            //Blank out their Data property
            foreach (var field in requiredFields)
            {
                field.Data = String.Empty;
            }

            // Validate the user
            var validationResults = await user.ValidateAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            // Make sure each blanked out required column exists in the returned validation violations
            foreach (var field in requiredFields)
            {
                Assert.IsTrue(validationResults.FirstOrDefault(x => x.Contains(field.ColumnName)) != null);
            }
        }
コード例 #5
0
        private UserAdminObject GenerateValidUser()
        {
            var user = new UserAdminObject
            {
                FirstName                         = { Data = "John" },
                LastName                          = { Data = "Doe" },
                EmailAddress                      = { Data = "*****@*****.**" },
                Keywords                          = { Data = "Cool User" },
                Notes                             = { Data = "Process case after 5pm" },
                Groups                            = { Data = MockGroupName },
                Type                              = { Data = "Internal" },
                Client                            = { Data = "Acme" },
                RelativityAccess                  = { Data = "true" },
                DocumentSkip                      = { Data = "100100" },
                BetaUser                          = { Data = "false" },
                ChangeSettings                    = { Data = "true" },
                KeyboardShortcuts                 = { Data = "true" },
                ItemListPageLength                = { Data = "100" },
                DefaultSelectedFileType           = { Data = "100200" },
                SkipDefaultPreference             = { Data = "100300" },
                EnforceViewerCompatibility        = { Data = "true" },
                AdvancedSearchPublicByDefault     = { Data = "false" },
                NativeViewerCacheAhead            = { Data = "true" },
                ChangeDocumentViewer              = { Data = "true" },
                DocumentViewer                    = { Data = "100400" },
                WindowsAccount                    = { Data = "*****@*****.**" },
                CanChangePassword                 = { Data = "true" },
                MaximumPasswordAgeInDays          = { Data = "30" },
                UserMustChangePasswordOnNextLogin = { Data = "false" }
            };

            return(user);
        }
コード例 #6
0
        public async Task ViolationReportedWhenFileHasUnsupportedColumns()
        {
            // Arrange
            var unsupportedColumnName = "ExtraUnsupportedColumn";

            _importHelper = new ImportTestHelper(duringOffHours: true);
            _importHelper.Initialize();
            var user        = new UserAdminObject();
            var userColumns = (await user.GetColumnsAsync()).Select(x => x.ColumnName).ToList();

            userColumns.Add(unsupportedColumnName);
            var fileContents = String.Join(Constant.CommaSeparator, userColumns);

            var managerJob = GetManagerImportJob();

            await CreateFile(fileContents, managerJob.LocalTempFilePath);

            // Act
            await managerJob.ExecuteAsync();

            managerJob.Dispose();

            // Assert
            var expectedMsg = String.Format(Constant.ErrorMessages.ExtraColumnsError, _importHelper.ImportObjectType, unsupportedColumnName);

            Assert.IsTrue(_importHelper.RecordedImportJobErrors.Contains(expectedMsg));
        }
コード例 #7
0
        public void MockDeserializeToAdminObjectAsync()
        {
            IAdminObject userAdminObject = new UserAdminObject();

            MockSerializationHelper
            .Setup(x => x.DeserializeToAdminObjectAsync(
                       It.IsAny <String>()
                       ))
            .Returns(Task.FromResult(userAdminObject));
        }
コード例 #8
0
        public async Task UserArtifactIDIsSetAfterSuccessfullyImported()
        {
            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await user.MapObjectColumnsAsync(userValues);

            await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.AreEqual(MockUserArtifactID, user.ArtifactId);
        }
コード例 #9
0
        public async Task NoViolationsReturnedForValidUserModel()
        {
            var user    = new UserAdminObject();
            var columns = await GetUserDictionary();

            await user.MapObjectColumnsAsync(columns);

            var validationResult = await user.ValidateAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.IsTrue(!validationResult.Any());
            Assert.IsTrue(user.Validated);
        }
コード例 #10
0
        public async Task NoViolationsReturnedWhenUserSuccessfullyImported()
        {
            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await user.MapObjectColumnsAsync(userValues);

            var result = await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            MockUserRepo.Verify(x => x.CreateSingle(It.IsAny <kCura.Relativity.Client.DTOs.User>()), Times.AtLeastOnce);
            Assert.IsTrue(!result.Any());
        }
コード例 #11
0
        //Generates a dictionary populated with the user object's columns as keys and the same values as dummy data
        private async Task <Dictionary <String, String> > GetDummyUserMetaData()
        {
            var user           = new UserAdminObject();
            var userColumns    = new Stack <String>((await user.GetColumnsAsync()).Select(x => x.ColumnName).ToList());
            var userDictionary = new Dictionary <String, String>();

            foreach (var column in userColumns)
            {
                userDictionary.Add(column, column);
            }
            return(userDictionary);
        }
コード例 #12
0
        public async Task ViolationReturnedForUserWithNullEmailAddress()
        {
            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await user.MapObjectColumnsAsync(userValues);

            user.EmailAddress.Data = null;

            var result = await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.IsTrue(result.Any(x => x.Contains(Constant.Messages.Violations.NullValue)));
        }
コード例 #13
0
        public async Task ViolationReturnedWhenUserNotImported()
        {
            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await CorruptUserValues(userValues);

            await user.MapObjectColumnsAsync(userValues);

            var result = await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Any());
        }
コード例 #14
0
        public async Task LoginMethodNotCreatedWhenViolationsExist()
        {
            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            // Remove Auth Fields to force a violation
            await CorruptUserValues(userValues);

            await user.MapObjectColumnsAsync(userValues);

            await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            MockLoginManager.Verify(x => x.SaveLoginProfileAsync(It.IsAny <LoginProfile>()), Times.Never());
        }
コード例 #15
0
        public async Task PasswordValidationAutomaticallyAddedAfterValidateAsyncCalled()
        {
            var user    = new UserAdminObject();
            var columns = await GetUserDictionary();

            await user.MapObjectColumnsAsync(columns);

            var passwordColumns = (await user.GetColumnsAsync()).Where(x => x.ObjectFieldType == Constant.Enums.ObjectFieldType.PasswordLoginMethod);

            Assert.IsFalse(await ValidationExistsInSelectedColumns(passwordColumns, typeof(ValidationPasswordLoginMethod)));
            await user.ValidateAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.IsTrue(await ValidationExistsInSelectedColumns(passwordColumns, typeof(ValidationPasswordLoginMethod)));
        }
コード例 #16
0
        public async Task UserNotCreatedWhenViolationsExist()
        {
            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            // Remove Auth Fields to force a violation
            await CorruptUserValues(userValues);

            await user.MapObjectColumnsAsync(userValues);

            await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            MockUserRepo.Verify(x => x.CreateSingle(It.IsAny <kCura.Relativity.Client.DTOs.User>()), Times.Never());
            MockUserRepo.Verify(x => x.Create(It.IsAny <kCura.Relativity.Client.DTOs.User>()), Times.Never());
        }
コード例 #17
0
        public LogonTileControl(UserAdminObject user)
        {
            InitializeComponent();
            _user = user;
            if (!string.IsNullOrEmpty(user.PicturePath) && user.PicturePath != null)
            {
                BitmapImage icon = new BitmapImage();
                icon.BeginInit();
                icon.UriSource = new Uri(user.PicturePath);
                icon.EndInit();
                UserPictureBox.Source = icon;
            }

            Initialize();
        }
コード例 #18
0
        public async Task GroupValidationAutomaticallyAddedAfterValidateAsyncCalled()
        {
            var user    = new UserAdminObject();
            var columns = await GetUserDictionary();

            await user.MapObjectColumnsAsync(columns);

            var codeNameColumns = new List <IObjectColumn> {
                user.Groups
            };

            Assert.IsFalse(await ValidationExistsInSelectedColumns(codeNameColumns, typeof(ValidationGroup)));
            await user.ValidateAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.IsTrue(await ValidationExistsInSelectedColumns(codeNameColumns, typeof(ValidationGroup)));
        }
コード例 #19
0
        public async Task CodeValidationAutomaticallyAddedAfterValidateAsyncCalled()
        {
            var user    = new UserAdminObject();
            var columns = await GetUserDictionary();

            await user.MapObjectColumnsAsync(columns);

            var codeNameColumns = new List <IObjectColumn> {
                user.Type, user.DocumentSkip, user.DefaultSelectedFileType, user.SkipDefaultPreference, user.DocumentViewer
            };

            Assert.IsFalse(await ValidationExistsInSelectedColumns(codeNameColumns, typeof(ValidationCodeName)));
            await user.ValidateAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            Assert.IsTrue(await ValidationExistsInSelectedColumns(codeNameColumns, typeof(ValidationCodeName)));
        }
コード例 #20
0
        public async Task UserIsPromptedToDeletePartiallyCreatedUserWhenSaveLoginMethodThrowsButUserWasStillPartiallyCreated()
        {
            // An exception being thrown from the SaveLoginProfileAsync() method indicates the login method was unable to be saved
            MockLoginManager.Setup(x => x.SaveLoginProfileAsync(It.IsAny <LoginProfile>())).Throws(new Exception());

            MockArtifactQueries
            .SetupSequence(x => x.FindUserByEmailAddressAsync(It.IsAny <APIOptions>(), It.IsAny <IGenericRepository <kCura.Relativity.Client.DTOs.User> >(), It.IsAny <String>()))
            .Returns(Task.FromResult((Int32?)null))                                     // First the user doesn't exist
            .Returns(Task.FromResult((Int32?)MockUserArtifactID));                      // After SaveLoginMethod throws, we want the 2nd call to find the user

            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await user.MapObjectColumnsAsync(userValues);

            var result = await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            // Violations should be returned
            Assert.IsTrue(result.Any(x => x.Contains(Constant.ErrorMessages.UserPartiallyImportedPrepend)));
        }
コード例 #21
0
        public async Task UserNotAttemptedToBeImportedWhenUserAlreadyExists()
        {
            MockArtifactQueries
            .Setup(x => x.FindUserByEmailAddressAsync(It.IsAny <APIOptions>(), It.IsAny <IGenericRepository <kCura.Relativity.Client.DTOs.User> >(), It.IsAny <String>()))
            .Returns(Task.FromResult((Int32?)MockUserArtifactID));

            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await user.MapObjectColumnsAsync(userValues);

            var result = await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            var expectedMsg = String.Format(Constant.ErrorMessages.UserAlreadyExists, (String)await user.EmailAddress.GetDataValueAsync());

            Assert.IsTrue(result.Contains(expectedMsg));

            // Create Single should not be called
            MockUserRepo.Verify(x => x.CreateSingle(It.IsAny <kCura.Relativity.Client.DTOs.User>()), Times.Never);
        }
コード例 #22
0
        public async Task UserIsNotPromptedToDeletePartiallyCreatedUserWhenRsapiCreateSingleSaysUserAlreadyExists()
        {
            MockUserRepo
            .Setup(x => x.CreateSingle(It.IsAny <kCura.Relativity.Client.DTOs.User>()))
            .Throws(new Exception("The entered E-Mail Address is already associated with a user"));

            MockArtifactQueries
            .SetupSequence(x => x.FindUserByEmailAddressAsync(It.IsAny <APIOptions>(), It.IsAny <IGenericRepository <kCura.Relativity.Client.DTOs.User> >(), It.IsAny <String>()))
            .Returns(Task.FromResult((Int32?)null))                                     // First the user doesn't exist
            .Returns(Task.FromResult((Int32?)MockUserArtifactID));                      // After Create single throws, we want the 2nd call to find the user

            var user       = new UserAdminObject();
            var userValues = await GetUserDictionary();

            await user.MapObjectColumnsAsync(userValues);

            var result = await user.ImportAsync(new APIOptions(), MockRSAPIRepositoryGroup.Object, MockArtifactQueries.Object, MockHelper.Object, MockDbContext.Object, MockSqlQueryHelper.Object);

            // Violations should be returned
            Assert.IsFalse(result.Any(x => x.Contains(Constant.ErrorMessages.UserPartiallyImportedPrepend)));
        }
コード例 #23
0
        public async Task ViolationReportedWhenColumnMissing()
        {
            // Arrange
            _importHelper = new ImportTestHelper(duringOffHours: true);
            _importHelper.Initialize();
            var user          = new UserAdminObject();
            var userColumns   = new Stack <String>((await user.GetColumnsAsync()).Select(x => x.ColumnName).ToList());
            var missingColumn = userColumns.Pop();
            var fileContents  = String.Join(Constant.CommaSeparator, userColumns);

            var managerJob = GetManagerImportJob();

            await CreateFile(fileContents, managerJob.LocalTempFilePath);

            // Act
            await managerJob.ExecuteAsync();

            managerJob.Dispose();

            // Assert
            var expectedMsg = String.Format(Constant.ErrorMessages.MissingColumnsError, missingColumn);

            Assert.IsTrue(_importHelper.RecordedImportJobErrors.Contains(expectedMsg));
        }
コード例 #24
0
        public async Task ProcessSingleUserAsync(Int32 workspaceArtifactID, Int32 jobArtifactID, ExportWorkerQueueRecord exportWorkerQueueRecord)
        {
            try
            {
                RaiseAndLogDebugMessage($"Processing a single user in export worker batch. [{nameof(exportWorkerQueueRecord.ArtifactId)}] = {exportWorkerQueueRecord.ArtifactId}");

                kCura.Relativity.Client.DTOs.User userRDO = await ArtifactQueries.RetrieveUserAsync(RsapiApiOptions, RsapiRepositoryGroup.UserRepository, exportWorkerQueueRecord.ArtifactId);

                //query user Auth data
                LoginProfile userLoginProfile = await AuthenticationHelper.RetrieveExistingUserLoginProfileAsync(userRDO.ArtifactID);

                //query keywords and notes for user
                KeywordsNotesModel userKeywordsNotesModel = await SqlQueryHelper.RetrieveKeywordsAndNotesForUserAsync(
                    eddsDbContext : AgentHelper.GetDBContext(-1),
                    userArtifactId : userRDO.ArtifactID);

                //query groups user is part of
                IEnumerable <String> userGroupNameList = await QueryGroupsNamesUserIsPartOfAsync(userRDO);

                UserAdminObject userAdminObject = await ConvertUserResultToUserAdminObjectAsync(userRDO);

                //add keywords and notes, auth and groups data to UserAdminObject
                await AddKeywordsNotesAuthInfoAndGroupsToUserAdminObjectAsync(userAdminObject, userKeywordsNotesModel, userGroupNameList, userLoginProfile);

                //insert user data info into the export worker results table
                await InsertUserDataIntoExportWorkerResultsTableAsync(exportWorkerQueueRecord, userAdminObject);

                RaiseAndLogDebugMessage($"Processed a single user in export worker batch. [{nameof(exportWorkerQueueRecord.ArtifactId)}] = {exportWorkerQueueRecord.ArtifactId}");
            }
            catch (Exception ex)
            {
                //create export job error record
                String details = ExceptionMessageFormatter.GetExceptionMessageIncludingAllInnerExceptions(ex);
                await CreateExportJobErrorRecordAsync(workspaceArtifactID, jobArtifactID, exportWorkerQueueRecord.ObjectType, Constant.Status.JobErrors.ERROR, details);
            }
        }
コード例 #25
0
        public async Task InsertUserDataIntoExportWorkerResultsTableAsync(ExportWorkerQueueRecord exportWorkerQueueRecord, UserAdminObject userAdminObject)
        {
            try
            {
                //deserialize user admin object
                String metadata = await SerializationHelper.SerializeAdminObjectAsync(userAdminObject);

                //insert into export worker results table
                await SqlQueryHelper.InsertRowIntoExportWorkerResultsTableAsync(
                    eddsDbContext : AgentHelper.GetDBContext(-1),
                    exportWorkerResultTableName : exportWorkerQueueRecord.ResultTableName,
                    workspaceArtifactId : WorkspaceArtifactId,
                    exportJobArtifactId : exportWorkerQueueRecord.ExportJobArtifactId,
                    objectType : exportWorkerQueueRecord.ObjectType,
                    workspaceResourceGroupArtifactId : exportWorkerQueueRecord.WorkspaceResourceGroupArtifactId,
                    queueStatus : Constant.Status.Queue.NOT_STARTED,
                    metadata : metadata,
                    timeStampUtc : DateTime.UtcNow);
            }
            catch (Exception ex)
            {
                throw new AdminMigrationUtilityException(Constant.ErrorMessages.InsertUserDataIntoExportWorkerResultsTableError, ex);
            }
        }