示例#1
0
        public async Task MaskingService_UnMaskAsync_WorksWithDifferentObjects(bool isTemp, string username, string name, string email,
                                                                               string phoneNumber, string password, string userType, string salt, string ipAddress)
        {
            await _userManagementService.CreateIPAsync(ipAddress).ConfigureAwait(false);

            UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, Constants.EnabledStatus, userType,
                                                   salt, Constants.NoValueLong, Constants.NoValueString, Constants.NoValueLong, Constants.NoValueInt, Constants.NoValueLong, Constants.NoValueInt, Constants.NoValueInt);

            await _userManagementService.CreateUserAsync(isTemp, userRecord).ConfigureAwait(false);

            string id = username;

            if (Constants.UserDAOIsColumnMasked[Constants.UserDAOusernameColumn])
            {
                id = _maskingService.MaskString(username);
            }

            UserObject rawUser = (UserObject)await _userDAO.ReadByIdAsync(id).ConfigureAwait(false);

            id = ipAddress;

            if (Constants.AnonymousUserDAOIsColumnMasked[Constants.AnonymousUserDAOIPColumn])
            {
                id = _maskingService.MaskString(ipAddress);
            }

            // Cast the return result of asynchronously reading by the ip address into the IP object.
            IPAddressObject rawIP = (IPAddressObject)await _ipDAO.ReadByIdAsync(id).ConfigureAwait(false);

            IPAddressObject ip = (IPAddressObject)await _maskingService.UnMaskAsync(rawIP).ConfigureAwait(false);

            UserObject user = (UserObject)await _maskingService.UnMaskAsync(rawUser).ConfigureAwait(false);

            Assert.IsTrue(ip.IsUnMasked());
            Assert.IsTrue(user.IsUnMasked());

            await _userManagementService.DeleteIPAsync(ipAddress).ConfigureAwait(false);

            await _userManagementService.DeleteUserAsync(username).ConfigureAwait(false);
        }