public CustomerAuthorizeFilter(IEnumerable <IManagerService> managerServices, ConnectionMultiplexer multiplexer) : base(_policy_) { roleService = GetService <RoleService>(managerServices); resourceService = GetService <ResourceService>(managerServices); accessLogService = GetService <AccessLogService>(managerServices); redisClient = multiplexer; }
public async Task ListAccessLogs_ReturnsAllAccessLogs() { // Arrange var service = new AccessLogService(_context); // Act var result = await service.ListAccessLogsAsync("SubmittedDateTime", "desc"); // Assert Assert.AreEqual((result as List <AccessLog>).Count, 3); }
public async Task ListAccessLogs_ReturnsCorrectType() { // Arrange var service = new AccessLogService(_context); // Act var result = await service.ListAccessLogsAsync("SubmittedDateTime", "desc"); // Assert Assert.IsInstanceOfType(result, typeof(IEnumerable <AccessLog>)); }
public async Task VerifyNewRequestAsync_ReturnsFalse_WhenLockedOut() { // Arrange var service = new AccessLogService(_context); var previousAttempts = new List <AccessLog>() { new AccessLog { IsSuccess = false, IsLockedOut = false, SubmittedDateTime = DateTime.Now.AddMinutes(-3), UserName = "******", EmailAddress = "*****@*****.**", DOB = DateTime.Now.AddYears(-10) }, new AccessLog { IsSuccess = false, IsLockedOut = false, SubmittedDateTime = DateTime.Now.AddMinutes(-2), UserName = "******", EmailAddress = "*****@*****.**", DOB = DateTime.Now.AddYears(-10) }, new AccessLog { IsSuccess = false, IsLockedOut = false, SubmittedDateTime = DateTime.Now.AddMinutes(-1), UserName = "******", EmailAddress = "*****@*****.**", DOB = DateTime.Now.AddYears(-10) } }; _context.AddRange(previousAttempts); _context.SaveChanges(); var lockoutAttempt = new AccessLog { UserName = "******", EmailAddress = "*****@*****.**", DOB = DateTime.Now.AddYears(-20) }; // Act var result = await service.VerifyNewRequestAsync(lockoutAttempt); // Assert Assert.IsFalse(result); }
public async Task ListAccessLogs_ReturnsAccessLogsInExpectedOrder_SortedOnEmail() { // Arrange var service = new AccessLogService(_context); // Act var result = await service.ListAccessLogsAsync("EmailAddress", "asc"); // Assert Assert.AreEqual((result as List <AccessLog>)[0].UserName, "seeded_user1"); Assert.AreEqual((result as List <AccessLog>)[1].UserName, "seeded_user2"); Assert.AreEqual((result as List <AccessLog>)[2].UserName, "seeded_user3"); }
public async Task VerifyNewRequestAsync_ReturnsFalse_WhenNotPermissible() { // Arrange var service = new AccessLogService(_context); var accessLog = new AccessLog { UserName = "******", EmailAddress = "*****@*****.**", DOB = DateTime.Now.AddYears(-10) }; // Act var result = await service.VerifyNewRequestAsync(accessLog); // Assert Assert.IsFalse(result); }