public CurrentUserController( MediaFileManager mediaFileManager, IOptionsSnapshot <ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, IPasswordChanger <BackOfficeIdentityUser> passwordChanger, IUserDataService userDataService) { _mediaFileManager = mediaFileManager; _contentSettings = contentSettings.Value; _hostingEnvironment = hostingEnvironment; _imageUrlGenerator = imageUrlGenerator; _backofficeSecurityAccessor = backofficeSecurityAccessor; _userService = userService; _umbracoMapper = umbracoMapper; _backOfficeUserManager = backOfficeUserManager; _localizedTextService = localizedTextService; _appCaches = appCaches; _shortStringHelper = shortStringHelper; _passwordChanger = passwordChanger; _userDataService = userDataService; }
public CurrentUserController( MediaFileManager mediaFileManager, IOptions <ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, ILoggerFactory loggerFactory, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, IPasswordChanger <BackOfficeIdentityUser> passwordChanger) : this( mediaFileManager, StaticServiceProvider.Instance.GetRequiredService <IOptionsSnapshot <ContentSettings> >(), hostingEnvironment, imageUrlGenerator, backofficeSecurityAccessor, userService, umbracoMapper, backOfficeUserManager, localizedTextService, appCaches, shortStringHelper, passwordChanger, StaticServiceProvider.Instance.GetRequiredService <IUserDataService>()) { }
/// <summary> /// Initializes a new instance of the <see cref="MemberController"/> class. /// </summary> /// <param name="cultureDictionary">The culture dictionary</param> /// <param name="loggerFactory">The logger factory</param> /// <param name="shortStringHelper">The string helper</param> /// <param name="eventMessages">The event messages factory</param> /// <param name="localizedTextService">The entry point for localizing key services</param> /// <param name="propertyEditors">The property editors</param> /// <param name="umbracoMapper">The mapper</param> /// <param name="memberService">The member service</param> /// <param name="memberTypeService">The member type service</param> /// <param name="memberManager">The member manager</param> /// <param name="dataTypeService">The data-type service</param> /// <param name="backOfficeSecurityAccessor">The back office security accessor</param> /// <param name="jsonSerializer">The JSON serializer</param> /// <param name="passwordChanger">The password changer</param> public MemberController( ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IUmbracoMapper umbracoMapper, IMemberService memberService, IMemberTypeService memberTypeService, IMemberManager memberManager, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IJsonSerializer jsonSerializer, IPasswordChanger <MemberIdentityUser> passwordChanger, ICoreScopeProvider scopeProvider) : base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, jsonSerializer) { _propertyEditors = propertyEditors; _umbracoMapper = umbracoMapper; _memberService = memberService; _memberTypeService = memberTypeService; _memberManager = memberManager; _dataTypeService = dataTypeService; _localizedTextService = localizedTextService; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _jsonSerializer = jsonSerializer; _shortStringHelper = shortStringHelper; _passwordChanger = passwordChanger; _scopeProvider = scopeProvider; }
private static void SetupPasswordSuccess( IMemberManager umbracoMembersUserManager, IPasswordChanger <MemberIdentityUser> passwordChanger, bool successful = true) { var passwordChanged = new PasswordChangedModel { ChangeError = null, ResetPassword = null }; if (!successful) { var attempt = Attempt.Fail(passwordChanged); Mock.Get(passwordChanger) .Setup(x => x.ChangePasswordWithIdentityAsync( It.IsAny <ChangingPasswordModel>(), umbracoMembersUserManager)) .ReturnsAsync(() => attempt); } else { var attempt = Attempt.Succeed(passwordChanged); Mock.Get(passwordChanger) .Setup(x => x.ChangePasswordWithIdentityAsync( It.IsAny <ChangingPasswordModel>(), umbracoMembersUserManager)) .ReturnsAsync(() => attempt); } }
public async Task PostSaveMember_SaveExisting_WhenAllIsSetupCorrectly_ExpectSuccessResponse( [Frozen] IMemberManager umbracoMembersUserManager, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IBackOfficeSecurity backOfficeSecurity, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { // arrange var member = SetupMemberTestData(out var fakeMemberData, out var memberDisplay, ContentSaveAction.Save); var membersIdentityUser = new MemberIdentityUser(123); Mock.Get(umbracoMembersUserManager) .Setup(x => x.FindByIdAsync(It.IsAny <string>())) .ReturnsAsync(() => membersIdentityUser); Mock.Get(umbracoMembersUserManager) .Setup(x => x.ValidatePasswordAsync(It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.UpdateAsync(It.IsAny <MemberIdentityUser>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.GetRolesAsync(It.IsAny <MemberIdentityUser>())) .ReturnsAsync(() => Array.Empty <string>()); Mock.Get(memberTypeService).Setup(x => x.GetDefault()).Returns("fakeAlias"); Mock.Get(globalSettings); SetupUserAccess(backOfficeSecurityAccessor, backOfficeSecurity, user); SetupPasswordSuccess(umbracoMembersUserManager, passwordChanger); Mock.Get(memberService).Setup(x => x.GetByUsername(It.IsAny <string>())).Returns(() => member); Mock.Get(memberService).Setup(x => x.GetById(It.IsAny <int>())).Returns(() => member); Mock.Get(memberService).SetupSequence( x => x.GetByEmail(It.IsAny <string>())) .Returns(() => null) .Returns(() => member); var sut = CreateSut( memberService, memberTypeService, memberGroupService, umbracoMembersUserManager, dataTypeService, backOfficeSecurityAccessor, passwordChanger, globalSettings); // act var result = await sut.PostSave(fakeMemberData); // assert Assert.IsNull(result.Result); Assert.IsNotNull(result.Value); AssertMemberDisplayPropertiesAreEqual(memberDisplay, result.Value); }
public void PostSaveMember_WhenModelStateIsNotValid_ExpectFailureResponse( [Frozen] IMemberManager umbracoMembersUserManager, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { // arrange Member member = SetupMemberTestData(out MemberSave fakeMemberData, out MemberDisplay memberDisplay, ContentSaveAction.SaveNew); MemberController sut = CreateSut(memberService, memberTypeService, memberGroupService, umbracoMembersUserManager, dataTypeService, backOfficeSecurityAccessor, passwordChanger, globalSettings, user); sut.ModelState.AddModelError("key", "Invalid model state"); Mock.Get(umbracoMembersUserManager) .Setup(x => x.CreateAsync(It.IsAny <MemberIdentityUser>(), It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.ValidatePasswordAsync(It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); var value = new MemberDisplay(); // act ActionResult <MemberDisplay> result = sut.PostSave(fakeMemberData).Result; var validation = result.Result as ValidationErrorResult; // assert Assert.IsNotNull(result.Result); Assert.IsNull(result.Value); Assert.AreEqual(StatusCodes.Status400BadRequest, validation?.StatusCode); }
private ToolStripMenuItem createChangePasswordMenuItem(HostPwEntry hostPwEntry) { IPasswordChanger pwChanger = null; var hostTypeMapper = new HostTypeMapper(new HostTypeSafeConverter()); var hostType = hostTypeMapper.Get(hostPwEntry); if (hostType == HostType.ESXi && QuickConnectUtils.IsVSpherePowerCLIInstalled()) { pwChanger = new ESXiPasswordChanger(); } else if (hostType == HostType.Windows && !String.IsNullOrEmpty(this.Settings.PsPasswdPath) && File.Exists(this.Settings.PsPasswdPath) && PsPasswdWrapper.IsPsPasswdUtility(this.Settings.PsPasswdPath) && PsPasswdWrapper.IsSupportedVersion(this.Settings.PsPasswdPath) ) { pwChanger = new WindowsPasswordChanger(new PsPasswdWrapper(this.Settings.PsPasswdPath)); } else if (hostType == HostType.Linux) { PuttyOptions puttyOptions = null; bool success = PuttyOptionsParser.TryParse(hostPwEntry.AdditionalOptions, out puttyOptions); // Disable change password menu item if authentication is done using SSH key file. if (!success || (success && !puttyOptions.HasKeyFile())) { int?sshPort = null; if (success) { sshPort = puttyOptions.Port; } pwChanger = new LinuxPasswordChanger() { SshPort = sshPort }; } } var menuItem = new ToolStripMenuItem() { Text = ChangePasswordMenuItemText, Enabled = hostPwEntry.HasIPAddress && pwChanger != null }; menuItem.Click += new EventHandler( delegate(object obj, EventArgs ev) { try { var pwDatabase = new PasswordDatabase(this.pluginHost.Database); var pwChangerService = new PasswordChangerServiceWrapper(pwDatabase, pwChanger); using (var formPasswordChange = new FormPasswordChanger(hostPwEntry, pwChangerService)) { formPasswordChange.ShowDialog(); } } catch (Exception ex) { log(ex); } } ); return(menuItem); }
private async void Change() { IPasswordChanger passwordProvider = (IPasswordChanger)View; string password = passwordProvider.GetPassword(); string newPassword = passwordProvider.GetNewPassword(); string confirmedPassword = passwordProvider.GetConfirmedPassword(); if (password == null || password.Length == 0) { MessageBox.Show("Password is empty!", "Hanksite", MessageBoxButton.OK); return; } if (newPassword == null || newPassword.Length == 0) { MessageBox.Show("New password is empty!", "Hanksite", MessageBoxButton.OK); return; } if (newPassword != confirmedPassword) { MessageBox.Show("New password differs from confirmed password!", "Hanksite", MessageBoxButton.OK); return; } IsPageEnabled = false; bool success; try { success = await accountProvider.ChangePassword(password, newPassword); } catch (System.Exception) { MessageBox.Show("Connection lost.", "Hanksite", MessageBoxButton.OK); Application.Current.Shutdown(); return; } IsPageEnabled = true; if (!success) { MessageBox.Show("Wrong password!", "Hanksite", MessageBoxButton.OK); return; } NavigationService.GetNavigationService(View).GoBack(); }
public void PostSaveMember_SaveNew_WhenMemberEmailAlreadyExists_ExpectFailResponse( [Frozen] IMemberManager umbracoMembersUserManager, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IBackOfficeSecurity backOfficeSecurity, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { // arrange var member = SetupMemberTestData(out var fakeMemberData, out _, ContentSaveAction.SaveNew); Mock.Get(umbracoMembersUserManager) .Setup(x => x.CreateAsync(It.IsAny <MemberIdentityUser>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(memberTypeService).Setup(x => x.GetDefault()).Returns("fakeAlias"); Mock.Get(backOfficeSecurityAccessor).Setup(x => x.BackOfficeSecurity).Returns(backOfficeSecurity); Mock.Get(umbracoMembersUserManager) .Setup(x => x.ValidatePasswordAsync(It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.AddToRolesAsync(It.IsAny <MemberIdentityUser>(), It.IsAny <IEnumerable <string> >())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(memberService).SetupSequence( x => x.GetByEmail(It.IsAny <string>())) .Returns(() => member); var sut = CreateSut( memberService, memberTypeService, memberGroupService, umbracoMembersUserManager, dataTypeService, backOfficeSecurityAccessor, passwordChanger, globalSettings); // act var result = sut.PostSave(fakeMemberData).Result; var validation = result.Result as ValidationErrorResult; // assert Assert.IsNotNull(result.Result); Assert.IsNull(result.Value); Assert.AreEqual(StatusCodes.Status400BadRequest, validation?.StatusCode); }
public UsersController( MediaFileManager mediaFileManager, IOptionsSnapshot <ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, ISqlContext sqlContext, IImageUrlGenerator imageUrlGenerator, IOptionsSnapshot <SecuritySettings> securitySettings, IEmailSender emailSender, IBackOfficeSecurityAccessor backofficeSecurityAccessor, AppCaches appCaches, IShortStringHelper shortStringHelper, IUserService userService, ILocalizedTextService localizedTextService, IUmbracoMapper umbracoMapper, IOptionsSnapshot <GlobalSettings> globalSettings, IBackOfficeUserManager backOfficeUserManager, ILoggerFactory loggerFactory, LinkGenerator linkGenerator, IBackOfficeExternalLoginProviders externalLogins, UserEditorAuthorizationHelper userEditorAuthorizationHelper, IPasswordChanger <BackOfficeIdentityUser> passwordChanger, IHttpContextAccessor httpContextAccessor, IOptions <WebRoutingSettings> webRoutingSettings) { _mediaFileManager = mediaFileManager; _contentSettings = contentSettings.Value; _hostingEnvironment = hostingEnvironment; _sqlContext = sqlContext; _imageUrlGenerator = imageUrlGenerator; _securitySettings = securitySettings.Value; _emailSender = emailSender; _backofficeSecurityAccessor = backofficeSecurityAccessor; _appCaches = appCaches; _shortStringHelper = shortStringHelper; _userService = userService; _localizedTextService = localizedTextService; _umbracoMapper = umbracoMapper; _globalSettings = globalSettings.Value; _userManager = backOfficeUserManager; _loggerFactory = loggerFactory; _linkGenerator = linkGenerator; _externalLogins = externalLogins; _userEditorAuthorizationHelper = userEditorAuthorizationHelper; _passwordChanger = passwordChanger; _logger = _loggerFactory.CreateLogger <UsersController>(); _httpContextAccessor = httpContextAccessor; _webRoutingSettings = webRoutingSettings.Value; }
public UsersController( MediaFileManager mediaFileManager, IOptions <ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, ISqlContext sqlContext, IImageUrlGenerator imageUrlGenerator, IOptions <SecuritySettings> securitySettings, IEmailSender emailSender, IBackOfficeSecurityAccessor backofficeSecurityAccessor, AppCaches appCaches, IShortStringHelper shortStringHelper, IUserService userService, ILocalizedTextService localizedTextService, IUmbracoMapper umbracoMapper, IOptions <GlobalSettings> globalSettings, IBackOfficeUserManager backOfficeUserManager, ILoggerFactory loggerFactory, LinkGenerator linkGenerator, IBackOfficeExternalLoginProviders externalLogins, UserEditorAuthorizationHelper userEditorAuthorizationHelper, IPasswordChanger <BackOfficeIdentityUser> passwordChanger) : this(mediaFileManager, contentSettings, hostingEnvironment, sqlContext, imageUrlGenerator, securitySettings, emailSender, backofficeSecurityAccessor, appCaches, shortStringHelper, userService, localizedTextService, umbracoMapper, globalSettings, backOfficeUserManager, loggerFactory, linkGenerator, externalLogins, userEditorAuthorizationHelper, passwordChanger, StaticServiceProvider.Instance.GetRequiredService <IHttpContextAccessor>(), StaticServiceProvider.Instance.GetRequiredService <IOptions <WebRoutingSettings> >()) { }
public ExtendedMemberController( ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IUmbracoMapper umbracoMapper, IMemberService memberService, IMemberTypeService memberTypeService, IMemberManager memberManager, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IJsonSerializer jsonSerializer, IPasswordChanger <MemberIdentityUser> passwordChanger, IScopeProvider scopeProvider, IMemberExtendedService memberExtendedService, IMemberGroupService memberGroupService, IConfiguration configuration) : base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, propertyEditors, umbracoMapper, memberService, memberTypeService, memberManager, dataTypeService, backOfficeSecurityAccessor, jsonSerializer, passwordChanger, scopeProvider)
public async Task PostSaveMember_SaveNew_CustomField_WhenAllIsSetupCorrectly_ExpectSuccessResponse( [Frozen] IMemberManager umbracoMembersUserManager, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IBackOfficeSecurity backOfficeSecurity, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { // arrange Member member = SetupMemberTestData(out MemberSave fakeMemberData, out MemberDisplay memberDisplay, ContentSaveAction.SaveNew); Mock.Get(umbracoMembersUserManager) .Setup(x => x.CreateAsync(It.IsAny <MemberIdentityUser>(), It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.ValidatePasswordAsync(It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(memberTypeService).Setup(x => x.GetDefault()).Returns("fakeAlias"); Mock.Get(backOfficeSecurityAccessor).Setup(x => x.BackOfficeSecurity).Returns(backOfficeSecurity); Mock.Get(memberService).SetupSequence( x => x.GetByEmail(It.IsAny <string>())) .Returns(() => null) .Returns(() => member); Mock.Get(memberService).Setup(x => x.GetByUsername(It.IsAny <string>())).Returns(() => member); MemberController sut = CreateSut(memberService, memberTypeService, memberGroupService, umbracoMembersUserManager, dataTypeService, backOfficeSecurityAccessor, passwordChanger, globalSettings, user); // act ActionResult <MemberDisplay> result = await sut.PostSave(fakeMemberData); // assert Assert.IsNull(result.Result); Assert.IsNotNull(result.Value); AssertMemberDisplayPropertiesAreEqual(memberDisplay, result.Value); }
public async Task PostSaveMember_SaveExistingMember_WithNoRoles_Add1Role_ExpectSuccessResponse( [Frozen] IMemberManager umbracoMembersUserManager, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IBackOfficeSecurity backOfficeSecurity, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { // arrange var roleName = "anyrole"; IMember member = SetupMemberTestData(out MemberSave fakeMemberData, out MemberDisplay memberDisplay, ContentSaveAction.Save); fakeMemberData.Groups = new List <string>() { roleName }; var membersIdentityUser = new MemberIdentityUser(123); Mock.Get(umbracoMembersUserManager) .Setup(x => x.FindByIdAsync(It.IsAny <string>())) .ReturnsAsync(() => membersIdentityUser); Mock.Get(umbracoMembersUserManager) .Setup(x => x.ValidatePasswordAsync(It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.UpdateAsync(It.IsAny <MemberIdentityUser>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.AddToRolesAsync(It.IsAny <MemberIdentityUser>(), It.IsAny <IEnumerable <string> >())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(memberTypeService).Setup(x => x.GetDefault()).Returns("fakeAlias"); Mock.Get(backOfficeSecurityAccessor).Setup(x => x.BackOfficeSecurity).Returns(backOfficeSecurity); Mock.Get(memberService).Setup(x => x.GetByUsername(It.IsAny <string>())).Returns(() => member); Mock.Get(memberService).Setup(x => x.GetById(It.IsAny <int>())).Returns(() => member); SetupUserAccess(backOfficeSecurityAccessor, backOfficeSecurity, user); SetupPasswordSuccess(umbracoMembersUserManager, passwordChanger); Mock.Get(memberService).SetupSequence( x => x.GetByEmail(It.IsAny <string>())) .Returns(() => null) .Returns(() => member); MemberController sut = CreateSut(memberService, memberTypeService, memberGroupService, umbracoMembersUserManager, dataTypeService, backOfficeSecurityAccessor, passwordChanger, globalSettings, user); // act ActionResult <MemberDisplay> result = await sut.PostSave(fakeMemberData); // assert Assert.IsNull(result.Result); Assert.IsNotNull(result.Value); Mock.Get(umbracoMembersUserManager) .Verify(u => u.GetRolesAsync(membersIdentityUser)); Mock.Get(umbracoMembersUserManager) .Verify(u => u.AddToRolesAsync(membersIdentityUser, new[] { roleName })); Mock.Get(memberService) .Verify(m => m.Save(It.IsAny <Member>())); AssertMemberDisplayPropertiesAreEqual(memberDisplay, result.Value); }
/// <summary> /// Registers a type of password changer. /// </summary> /// <param name="name">Name of the changer. Mostly for tracking/debugging purposes.</param> /// <param name="changer">The changer.</param> public void registerPasswordChanger(string name, IPasswordChanger changer) { mPasswordChangers.Add(name, changer); }
public PasswordChangerServiceWrapper(IPasswordDatabase passwordDatabase, IPasswordChanger passwordChanger, IClock clock) { this.passwordDatabase = passwordDatabase; this.passwordChanger = passwordChanger; this.clock = clock; }
public AccountController(IPasswordChanger manager) { this.manager = manager; }
/// <summary> /// Create member controller to test /// </summary> /// <param name="memberService">Member service</param> /// <param name="memberTypeService">Member type service</param> /// <param name="memberGroupService">Member group service</param> /// <param name="membersUserManager">Members user manager</param> /// <param name="dataTypeService">Data type service</param> /// <param name="backOfficeSecurityAccessor">Back office security accessor</param> /// <param name="mockPasswordChanger">Password changer class</param> /// <returns>A member controller for the tests</returns> private MemberController CreateSut( IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IUmbracoUserManager <MemberIdentityUser> membersUserManager, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { var httpContextAccessor = new HttpContextAccessor(); var mockShortStringHelper = new MockShortStringHelper(); var textService = new Mock <ILocalizedTextService>(); var contentTypeBaseServiceProvider = new Mock <IContentTypeBaseServiceProvider>(); contentTypeBaseServiceProvider.Setup(x => x.GetContentTypeOf(It.IsAny <IContentBase>())).Returns(new ContentType(mockShortStringHelper, 123)); var contentAppFactories = new Mock <List <IContentAppFactory> >(); var mockContentAppFactoryCollection = new Mock <ILogger <ContentAppFactoryCollection> >(); var hybridBackOfficeSecurityAccessor = new BackOfficeSecurityAccessor(httpContextAccessor); var contentAppFactoryCollection = new ContentAppFactoryCollection( () => contentAppFactories.Object, mockContentAppFactoryCollection.Object, hybridBackOfficeSecurityAccessor); var mockUserService = new Mock <IUserService>(); var commonMapper = new CommonMapper( mockUserService.Object, contentTypeBaseServiceProvider.Object, contentAppFactoryCollection, textService.Object); var mockCultureDictionary = new Mock <ICultureDictionary>(); var mockPasswordConfig = new Mock <IOptions <MemberPasswordConfigurationSettings> >(); mockPasswordConfig.Setup(x => x.Value).Returns(() => new MemberPasswordConfigurationSettings()); IDataEditor dataEditor = Mock.Of <IDataEditor>( x => x.Type == EditorType.PropertyValue && x.Alias == Constants.PropertyEditors.Aliases.Label); Mock.Get(dataEditor).Setup(x => x.GetValueEditor()).Returns(new TextOnlyValueEditor(new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"), textService.Object, Mock.Of <IShortStringHelper>(), Mock.Of <IJsonSerializer>(), Mock.Of <IIOHelper>())); var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(() => new[] { dataEditor })); IMapDefinition memberMapDefinition = new MemberMapDefinition( commonMapper, new CommonTreeNodeMapper(Mock.Of <LinkGenerator>()), new MemberTabsAndPropertiesMapper( mockCultureDictionary.Object, backOfficeSecurityAccessor, textService.Object, memberTypeService, memberService, memberGroupService, mockPasswordConfig.Object, contentTypeBaseServiceProvider.Object, propertyEditorCollection)); var map = new MapDefinitionCollection(() => new List <IMapDefinition>() { new global::Umbraco.Cms.Core.Models.Mapping.MemberMapDefinition(), memberMapDefinition, new ContentTypeMapDefinition( commonMapper, propertyEditorCollection, dataTypeService, new Mock <IFileService>().Object, new Mock <IContentTypeService>().Object, new Mock <IMediaTypeService>().Object, memberTypeService, new Mock <ILoggerFactory>().Object, mockShortStringHelper, globalSettings, new Mock <IHostingEnvironment>().Object) }); var scopeProvider = Mock.Of <IScopeProvider>(x => x.CreateScope( It.IsAny <IsolationLevel>(), It.IsAny <RepositoryCacheMode>(), It.IsAny <IEventDispatcher>(), It.IsAny <IScopedNotificationPublisher>(), It.IsAny <bool?>(), It.IsAny <bool>(), It.IsAny <bool>()) == Mock.Of <IScope>()); _mapper = new UmbracoMapper(map, scopeProvider); return(new MemberController( new DefaultCultureDictionary( new Mock <ILocalizationService>().Object, NoAppCache.Instance), new LoggerFactory(), mockShortStringHelper, new DefaultEventMessagesFactory( new Mock <IEventMessagesAccessor>().Object), textService.Object, propertyEditorCollection, _mapper, memberService, memberTypeService, (IMemberManager)membersUserManager, dataTypeService, backOfficeSecurityAccessor, new ConfigurationEditorJsonSerializer(), passwordChanger, scopeProvider )); }
public PasswordChangerServiceWrapper(IPasswordDatabase passwordDatabase, IPasswordChanger passwordChanger) { this.passwordDatabase = passwordDatabase; this.passwordChanger = passwordChanger; }
public PasswordChangerEx(IPasswordChanger passwordChanger) { this.passwordChanger = passwordChanger; }