Esempio n. 1
0
        public void MockRetrieveKeywordsAndNotesForUserAsync()
        {
            KeywordsNotesModel userKeywordsNotesModel = new KeywordsNotesModel();

            MockSqlQueryHelper
            .Setup(x => x.RetrieveKeywordsAndNotesForUserAsync(
                       It.IsAny <IDBContext>(),
                       It.IsAny <Int32>()
                       ))
            .Returns(Task.FromResult(userKeywordsNotesModel));
        }
Esempio n. 2
0
        public async Task RetrieveValidKeywordsAndNotesForUserTest_PassesWithValidUser()
        {
            //Arrange
            MockExecuteSqlStatementAsDataTable_ToReturnUserKeywordsAndNotes_ReturnsOneUser();

            //Act
            KeywordsNotesModel keywordsNotesModel = await Sut.RetrieveKeywordsAndNotesForUserAsync(MockEddsDbContext.Object, 123);

            //Assert
            VerifyExecuteSqlStatementAsDataTableWasCalled(1);
            Assert.That(keywordsNotesModel, Is.Not.Null);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }