public void Federation_ReloadOfMetadata_AddsNewIdpAndRemovesOld()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                options);

            IdentityProvider idp;

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
            .Should().BeTrue("idp1 should be loaded initially");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp2.federation.example.com/metadata"), out idp)
            .Should().BeTrue("idp2 should be loaded initially");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp3.federation.example.com/metadata"), out idp)
            .Should().BeFalse("idp3 shouldn't be loaded initially");

            StubServer.FederationVeryShortCacheDurationSecondAlternativeEnabled = true;
            var initialValidUntil = subject.MetadataValidUntil;

            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => initialValidUntil);

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
            .Should().BeTrue("idp1 should still be present after reload");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp2.federation.example.com/metadata"), out idp)
            .Should().BeFalse("idp2 should be removed after reload");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp3.federation.example.com/metadata"), out idp)
            .Should().BeTrue("idp3 should be loaded after reload");
        }
Ejemplo n.º 2
0
        public void IdentityProvider_ScheduledReloadOfMetadata()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var subject           = CreateSubjectForMetadataRefresh();
            var initialValidUntil = subject.MetadataValidUntil;

            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => initialValidUntil);
        }
Ejemplo n.º 3
0
        public void IdentityProvider_ArtifactResolutionServiceUrl_ReloadsMetadataIfNoLongerValid()
        {
            StubServer.IdpAndFederationVeryShortCacheDurationPort = 42;
            var subject = CreateSubjectForMetadataRefresh();

            subject.ArtifactResolutionServiceUrls[0].Port.Should().Be(42);
            StubServer.IdpAndFederationVeryShortCacheDurationPort = 117;

            SpinWaiter.WhileEqual(() => subject.ArtifactResolutionServiceUrls[0].Port, () => 42);

            subject.ArtifactResolutionServiceUrls[0].Port.Should().Be(117);
        }
Ejemplo n.º 4
0
        public void IdentityProvider_SingleLogoutServiceBinding_ReloadsMetadataIfNoLongerValid()
        {
            StubServer.IdpVeryShortCacheDurationBinding = Saml2Binding.HttpRedirectUri;
            var subject = CreateSubjectForMetadataRefresh();

            subject.SingleLogoutServiceBinding.Should().Be(Saml2BindingType.HttpRedirect);
            StubServer.IdpVeryShortCacheDurationBinding = Saml2Binding.HttpPostUri;

            SpinWaiter.WhileEqual(() => subject.SingleLogoutServiceBinding, () => Saml2BindingType.HttpRedirect);

            subject.SingleLogoutServiceBinding.Should().Be(Saml2BindingType.HttpPost);
        }
Ejemplo n.º 5
0
        public void IdentityProvider_SingleSignOnServiceUrl_ReloadsMetadataIfNoLongerValid()
        {
            MetadataServer.IdpAndFederationVeryShortCacheDurationSsoPort = 42;
            var subject = CreateSubjectForMetadataRefresh();

            subject.SingleSignOnServiceUrl.Port.Should().Be(42);
            MetadataServer.IdpAndFederationVeryShortCacheDurationSsoPort = 117;

            SpinWaiter.WhileEqual(() => subject.SingleSignOnServiceUrl.Port, () => 42);

            subject.SingleSignOnServiceUrl.Port.Should().Be(117);
        }
        public void Federation_ScheduledReloadOfMetadata()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                StubFactory.CreateOptions());

            var initialValidUntil = subject.MetadataValidUntil;

            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => initialValidUntil);
        }
        public void Federation_ReloadOfMetadata_RetriesAfterFailedInitialLoad()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            StubServer.IdpAndFederationShortCacheDurationAvailable = false;

            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                options);

            subject.MetadataValidUntil.Should().Be(DateTime.MinValue);

            StubServer.IdpAndFederationShortCacheDurationAvailable = true;

            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => DateTime.MinValue);

            IdentityProvider idp;

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
            .Should().BeTrue();
        }