public void Does_validate_RequiredRoles_with_UserAuthRepo_When_Role_not_in_Session() { var userWithAdminRole = new UserAuth { Id = 1, Roles = new[] { RoleNames.Admin }.ToList() }; userAuthMock.Expect(x => x.GetUserAuth(It.IsAny <IAuthSession>(), It.IsAny <IOAuthTokens>())) .Returns(userWithAdminRole); var registrationService = GetRegistrationService(); var requiredRole = new RequiredRoleAttribute(RoleNames.Admin); var requestContext = (MockRequestContext)registrationService.RequestContext; requestContext.Container.Register(userAuthMock.Object); var httpRes = requestContext.Get <IHttpResponse>(); requiredRole.Execute( requestContext.Get <IHttpRequest>(), httpRes, null); Assert.That(!httpRes.IsClosed); }
public void Does_validate_RequiredRoles_with_UserAuthRepo_When_Role_not_in_Session() { var registrationService = GetRegistrationService(); var requiredRole = new RequiredRoleAttribute(RoleNames.Admin); var request = registrationService.Request; HostContext.Container.Register(userAuth); var httpRes = request.Response; requiredRole.Execute(request, request.Response, request.OperationName); Assert.That(!httpRes.IsClosed); }
public void Does_validate_RequiredRoles_with_UserAuthRepo_When_Role_not_in_Session() { var registrationService = GetRegistrationService(); var requiredRole = new RequiredRoleAttribute(RoleNames.Admin); var requestContext = (MockRequestContext)registrationService.RequestContext; requestContext.Container.Register(userAuth); var httpRes = requestContext.Get<IHttpResponse>(); requiredRole.Execute( requestContext.Get<IHttpRequest>(), httpRes, null); Assert.That(!httpRes.IsClosed); }
public void Does_validate_RequiredRoles_with_UserAuthRepo_When_Role_not_in_Session() { var registrationService = GetRegistrationService(); var requiredRole = new RequiredRoleAttribute(RoleNames.Admin); var requestContext = (MockRequestContext)registrationService.RequestContext; requestContext.Container.Register(userAuth); var httpRes = requestContext.Get <IHttpResponse>(); requiredRole.Execute( requestContext.Get <IHttpRequest>(), httpRes, null); Assert.That(!httpRes.IsClosed); }