public DataTypeController( PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IOptionsSnapshot <ContentSettings> contentSettings, IUmbracoMapper umbracoMapper, PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer) : this( propertyEditors, dataTypeService, contentSettings, umbracoMapper, propertyEditorCollection, contentTypeService, mediaTypeService, memberTypeService, localizedTextService, backOfficeSecurityAccessor, serializer, StaticServiceProvider.Instance.GetRequiredService <IDataTypeUsageService>()) { }
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 ContentTreeController( ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, IEntityService entityService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, ILogger <ContentTreeController> logger, ActionCollection actionCollection, IUserService userService, IDataTypeService dataTypeService, UmbracoTreeSearcher treeSearcher, ActionCollection actions, IContentService contentService, IPublicAccessService publicAccessService, ILocalizationService localizationService, IEventAggregator eventAggregator, IEmailSender emailSender, AppCaches appCaches) : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService, eventAggregator, appCaches) { _treeSearcher = treeSearcher; _actions = actions; _menuItemCollectionFactory = menuItemCollectionFactory; _backofficeSecurityAccessor = backofficeSecurityAccessor; _contentService = contentService; _entityService = entityService; _publicAccessService = publicAccessService; _userService = userService; _localizationService = localizationService; _emailSender = emailSender; _appCaches = appCaches; }
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); }
public void Can_Lookup_Content() { var publishedSnapshot = new Mock <IPublishedSnapshot>(); publishedSnapshot.Setup(x => x.Members).Returns(Mock.Of <IPublishedMemberCache>()); var content = new Mock <IPublishedContent>(); content.Setup(x => x.Id).Returns(2); IBackOfficeSecurityAccessor backofficeSecurityAccessor = Mock.Of <IBackOfficeSecurityAccessor>(); Mock.Get(backofficeSecurityAccessor).Setup(x => x.BackOfficeSecurity).Returns(Mock.Of <IBackOfficeSecurity>()); var publishedSnapshotService = new Mock <IPublishedSnapshotService>(); IHostingEnvironment hostingEnvironment = Mock.Of <IHostingEnvironment>(); var globalSettings = new GlobalSettings(); var umbracoContextFactory = TestUmbracoContextFactory.Create(globalSettings, _umbracoContextAccessor); UmbracoContextReference umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(); IUmbracoContext umbracoContext = umbracoContextReference.UmbracoContext; var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext); IPublishedContentQuery publishedContentQuery = Mock.Of <IPublishedContentQuery>(query => query.Content(2) == content.Object); var ctrl = new TestSurfaceController(umbracoContextAccessor, publishedContentQuery, Mock.Of <IPublishedUrlProvider>()); var result = ctrl.GetContent(2) as PublishedContentResult; Assert.IsNotNull(result); Assert.IsNotNull(result.Content); Assert.AreEqual(2, result.Content.Id); }
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="ContentPermissionsResourceHandler" /> class. /// </summary> /// <param name="backOfficeSecurityAccessor">Accessor for back-office security.</param> /// <param name="contentPermissions">Helper for content authorization checks.</param> public ContentPermissionsResourceHandler( IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ContentPermissions contentPermissions) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _contentPermissions = contentPermissions; }
public DataTypeController( PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IOptionsSnapshot <ContentSettings> contentSettings, IUmbracoMapper umbracoMapper, PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer) { _propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors)); _dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService)); _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); _propertyEditorCollection = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection)); _contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService)); _mediaTypeService = mediaTypeService ?? throw new ArgumentNullException(nameof(mediaTypeService)); _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); _backOfficeSecurityAccessor = backOfficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
//private readonly MembershipProvider membershipProvider; public ExtendedMemberController(PropertyEditorCollection propertyEditors, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, Umbraco.Core.IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IMemberExtendedService memberExtendedService) : base(propertyEditors, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper) #endif { this.propertyEditors = propertyEditors; this.memberExtendedService = memberExtendedService; #if NET5_0_OR_GREATER this.dataTypeService = dataTypeService; this.memberTypeService = memberTypeService; this.memberGroupService = memberGroupService; this.memberManager = memberManager; this.umbracoMapper = umbracoMapper; this.backOfficeSecurityAccessor = backOfficeSecurityAccessor; settings = new Settings(configuration); #else dataTypeService = services.DataTypeService; memberTypeService = services.MemberTypeService; memberGroupService = services.MemberGroupService; //membershipProvider = MembershipProviderExtensions.GetMembersMembershipProvider(); settings = new Settings(); #endif }
/// <summary> /// Initializes a new instance of the <see cref="MediaPermissionsResourceHandler"/> class. /// </summary> /// <param name="backOfficeSecurityAccessor">Accessor for back-office security.</param> /// <param name="mediaPermissions">Helper for media authorization checks.</param> public MediaPermissionsResourceHandler( IBackOfficeSecurityAccessor backOfficeSecurityAccessor, MediaPermissions mediaPermissions) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _mediaPermissions = mediaPermissions; }
public GridPropertyValueEditor( IDataValueEditorFactory dataValueEditorFactory, DataEditorAttribute attribute, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ILocalizedTextService localizedTextService, HtmlImageSourceParser imageSourceParser, RichTextEditorPastedImages pastedImages, IShortStringHelper shortStringHelper, IImageUrlGenerator imageUrlGenerator, IJsonSerializer jsonSerializer, IIOHelper ioHelper) : this( dataValueEditorFactory, attribute, backOfficeSecurityAccessor, localizedTextService, imageSourceParser, pastedImages, shortStringHelper, imageUrlGenerator, jsonSerializer, ioHelper, StaticServiceProvider.Instance.GetRequiredService <IHtmlMacroParameterParser>()) { }
public MemberTypeController( ICultureDictionary cultureDictionary, EditorValidatorCollection editorValidatorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IUmbracoMapper umbracoMapper, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IShortStringHelper shortStringHelper) : base(cultureDictionary, editorValidatorCollection, contentTypeService, mediaTypeService, memberTypeService, umbracoMapper, localizedTextService) { _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); _shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); }
/// <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; }
public RichTextPropertyEditor( IDataValueEditorFactory dataValueEditorFactory, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, HtmlImageSourceParser imageSourceParser, HtmlLocalLinkParser localLinkParser, RichTextEditorPastedImages pastedImages, IIOHelper ioHelper, IImageUrlGenerator imageUrlGenerator, IHtmlMacroParameterParser macroParameterParser) : this( dataValueEditorFactory, backOfficeSecurityAccessor, imageSourceParser, localLinkParser, pastedImages, ioHelper, imageUrlGenerator, macroParameterParser, StaticServiceProvider.Instance.GetRequiredService <IEditorConfigurationParser>()) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; _localLinkParser = localLinkParser; _pastedImages = pastedImages; _ioHelper = ioHelper; _imageUrlGenerator = imageUrlGenerator; _macroParameterParser = macroParameterParser; }
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 ContentAppFactoryCollection( Func <IEnumerable <IContentAppFactory> > items, ILogger <ContentAppFactoryCollection> logger, IBackOfficeSecurityAccessor backOfficeSecurityAccessor) : base(items) { _logger = logger; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; }
/// <summary> /// Initializes a new instance of the <see cref="PermissionsQueryStringHandler{T}"/> class. /// </summary> /// <param name="backOfficeSecurityAccessor">Accessor for back-office security.</param> /// <param name="httpContextAccessor">Accessor for the HTTP context of the current request.</param> /// <param name="entityService">Service for entity operations.</param> public PermissionsQueryStringHandler( IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IHttpContextAccessor httpContextAccessor, IEntityService entityService) { BackOfficeSecurityAccessor = backOfficeSecurityAccessor; HttpContextAccessor = httpContextAccessor; EntityService = entityService; }
/// <summary> /// Initializes a new instance of the <see cref="ContentPermissionsPublishBranchHandler" /> class. /// </summary> /// <param name="entityService">Service for entity operations.</param> /// <param name="contentPermissions">per for user content authorization checks.</param> /// <param name="backOfficeSecurityAccessor">Accessor for back-office security.</param> public ContentPermissionsPublishBranchHandler( IEntityService entityService, ContentPermissions contentPermissions, IBackOfficeSecurityAccessor backOfficeSecurityAccessor) { _entityService = entityService; _contentPermissions = contentPermissions; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; }
// need to inject dependencies in the collection, so override creation public override ContentAppFactoryCollection CreateCollection(IServiceProvider factory) { // get the logger factory just-in-time - see note below for manifest parser ILoggerFactory loggerFactory = factory.GetRequiredService <ILoggerFactory>(); IBackOfficeSecurityAccessor backOfficeSecurityAccessor = factory.GetRequiredService <IBackOfficeSecurityAccessor>(); return(new ContentAppFactoryCollection(() => CreateItems(factory), loggerFactory.CreateLogger <ContentAppFactoryCollection>(), backOfficeSecurityAccessor)); }
public MetricsConsentService( IKeyValueService keyValueService, ILogger <MetricsConsentService> logger, IBackOfficeSecurityAccessor backOfficeSecurityAccessor) { _keyValueService = keyValueService; _logger = logger; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; }
public OutgoingEditorModelEventFilter( IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IEventAggregator eventAggregator) : this( umbracoContextAccessor, backOfficeSecurityAccessor, eventAggregator, StaticServiceProvider.Instance.GetRequiredService <IUmbracoMapper>()) { }
public GridPropertyEditor( IDataValueEditorFactory dataValueEditorFactory, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, HtmlImageSourceParser imageSourceParser, RichTextEditorPastedImages pastedImages, HtmlLocalLinkParser localLinkParser, IIOHelper ioHelper, IImageUrlGenerator imageUrlGenerator) : this(dataValueEditorFactory, backOfficeSecurityAccessor, imageSourceParser, pastedImages, localLinkParser, ioHelper, imageUrlGenerator, StaticServiceProvider.Instance.GetRequiredService <IHtmlMacroParameterParser>()) { }
public OutgoingEditorModelEventFilter( IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IEventAggregator eventAggregator) { _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); _backOfficeSecurityAccessor = backOfficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor)); _eventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator)); }
public MetricsConsentService( IKeyValueService keyValueService, ILogger <MetricsConsentService> logger, IBackOfficeSecurityAccessor backOfficeSecurityAccessor) : this( keyValueService, logger, backOfficeSecurityAccessor, StaticServiceProvider.Instance.GetRequiredService <IUserService>()) { }
public PackageController( IPackagingService packagingService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, PackageMigrationRunner packageMigrationRunner, ILogger <PackageController> logger) { _packagingService = packagingService ?? throw new ArgumentNullException(nameof(packagingService)); _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); _packageMigrationRunner = packageMigrationRunner; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="AdminUsersHandler"/> class. /// </summary> /// <param name="httpContextAccessor">Accessor for the HTTP context of the current request.</param> /// <param name="userService">Service for user related operations.</param> /// <param name="backOfficeSecurityAccessor">Accessor for back-office security.</param> /// <param name="userEditorAuthorizationHelper">Helper for user authorization checks.</param> public AdminUsersHandler( IHttpContextAccessor httpContextAccessor, IUserService userService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, UserEditorAuthorizationHelper userEditorAuthorizationHelper) { _httpContextAccessor = httpContextAccessor; _userService = userService; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _userEditorAuthorizationHelper = userEditorAuthorizationHelper; }
public UpdateCheckController( IUpgradeService upgradeService, IUmbracoVersion umbracoVersion, ICookieManager cookieManager, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IOptionsSnapshot <GlobalSettings> globalSettings) { _upgradeService = upgradeService ?? throw new ArgumentNullException(nameof(upgradeService)); _umbracoVersion = umbracoVersion ?? throw new ArgumentNullException(nameof(umbracoVersion)); _cookieManager = cookieManager ?? throw new ArgumentNullException(nameof(cookieManager)); _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); _globalSettings = globalSettings.Value ?? throw new ArgumentNullException(nameof(globalSettings)); }
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 FilterAllowedOutgoingMediaFilter( IEntityService entityService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, AppCaches appCaches, Type outgoingType, string propertyName) { _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); _appCaches = appCaches; _propertyName = propertyName; _outgoingType = outgoingType; }
public TourController( TourFilterCollection filters, IHostingEnvironment hostingEnvironment, IOptionsSnapshot <TourSettings> tourSettings, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IContentTypeService contentTypeService) { _filters = filters; _hostingEnvironment = hostingEnvironment; _tourSettings = tourSettings.Value; _backofficeSecurityAccessor = backofficeSecurityAccessor; _contentTypeService = contentTypeService; }