Esempio n. 1
0
        public void GetExpiringAndExpired_SingleApplicationWithXDaysRemaining_InputsThirtyOrLessAreExpiringIsReturned(int daysRemaining)
        {
            // Arrange
            var application  = GetApplication(displayName: "App1");
            var dateInFuture = new DateTimeOffset(DateTime.UtcNow.AddDays(daysRemaining));

            application.ServicePrincipals.Add(GetServicePrincipal(endDateTime: dateInFuture));

            var applications = new List <ActiveDirectoryApplication> {
                application
            };
            var filterServicePrincipals = new FilterServicePrincipals();

            // Act
            var servicePrincipals = filterServicePrincipals.GetExpiringAndExpired(applications);

            // Assert
            if (daysRemaining <= 30)
            {
                Assert.That(servicePrincipals.Expiring, Has.Count.EqualTo(1));
                Assert.That(servicePrincipals.Expiring[0].ServicePrincipals, Has.Count.EqualTo(1));
            }
            else
            {
                Assert.That(servicePrincipals.Expiring, Has.Count.EqualTo(0));
            }

            Assert.That(servicePrincipals.Expired, Is.Empty);
        }
Esempio n. 2
0
        public void GetExpiringAndExpired_SingleApplicationWithActiveExpiringAndExpired_InputNumberMatchesReturned(
            [Values(0, 1, 2, 3)] int numberOfActiveSPs,
            [Values(0, 1, 2, 3)] int numberOfExpiredSPs,
            [Values(0, 1, 2, 3)] int numberOfExpiringSPs)
        {
            // Arrange
            var application = GetApplication(displayName: "App1");

            for (var i = 0; i < numberOfActiveSPs; i++)
            {
                application.ServicePrincipals.Add(GetActiveServicePrincipal());
            }
            for (var i = 0; i < numberOfExpiredSPs; i++)
            {
                application.ServicePrincipals.Add(GetExpiredServicePrincipal());
            }
            for (var i = 0; i < numberOfExpiringSPs; i++)
            {
                application.ServicePrincipals.Add(GetExpiringServicePrincipal());
            }

            var applications = new List <ActiveDirectoryApplication> {
                application
            };
            var filterServicePrincipals = new FilterServicePrincipals();

            // Act
            var servicePrincipals = filterServicePrincipals.GetExpiringAndExpired(applications);

            // Assert
            if (numberOfExpiredSPs > 0)
            {
                Assert.That(servicePrincipals.Expired, Has.Count.EqualTo(1));
                Assert.That(servicePrincipals.Expired[0].ServicePrincipals, Has.Count.EqualTo(numberOfExpiredSPs));
            }
            else
            {
                Assert.That(servicePrincipals.Expired, Has.Count.EqualTo(0));
            }

            if (numberOfExpiringSPs > 0)
            {
                Assert.That(servicePrincipals.Expiring, Has.Count.EqualTo(1));
                Assert.That(servicePrincipals.Expiring[0].ServicePrincipals, Has.Count.EqualTo(numberOfExpiringSPs));
            }
            else
            {
                Assert.That(servicePrincipals.Expiring, Has.Count.EqualTo(0));
            }
        }
Esempio n. 3
0
        public void GetExpiringAndExpired_XApplicationWithZeroCredentials_ExpiringPropertyReturnsEmpty(int numberOfApplications)
        {
            // Arrange
            var applications = new List <ActiveDirectoryApplication>();

            for (var i = 0; i < numberOfApplications; i++)
            {
                applications.Add(GetApplication());
            }

            var filterServicePrincipals = new FilterServicePrincipals();

            // Act
            var servicePrincipals = filterServicePrincipals.GetExpiringAndExpired(applications);

            // Assert
            Assert.That(servicePrincipals.Expiring, Is.Empty);
        }
Esempio n. 4
0
        public void GetExpiringAndExpired_XApplicationsWithActiveCredentials_ExpiringPropertyReturnsEmpty(int numberOfApps)
        {
            // Arrange
            var applications = new List <ActiveDirectoryApplication>();

            for (var i = 0; i < numberOfApps; i++)
            {
                var application = GetApplication(displayName: $"App{i}");
                application.ServicePrincipals.Add(GetActiveServicePrincipal());
            }

            var filterServicePrincipals = new FilterServicePrincipals();

            // Act
            var servicePrincipals = filterServicePrincipals.GetExpiringAndExpired(applications);

            // Assert
            Assert.That(servicePrincipals.Expiring, Is.Empty);
        }