Ejemplo n.º 1
0
        public void GetSets()
        {
            FileDocumentRetriever docRetriever = new FileDocumentRetriever();
            ConfigurationManager <OpenIdConnectConfiguration> configManager = new ConfigurationManager <OpenIdConnectConfiguration>("OpenIdConnectMetadata.json", new OpenIdConnectConfigurationRetriever(), docRetriever);
            Type type = typeof(ConfigurationManager <OpenIdConnectConfiguration>);

            PropertyInfo[] properties = type.GetProperties();
            if (properties.Length != 2)
            {
                Assert.True(false, "Number of properties has changed from 2 to: " + properties.Length + ", adjust tests");
            }

            TimeSpan defaultAutomaticRefreshInterval = ConfigurationManager <OpenIdConnectConfiguration> .DefaultAutomaticRefreshInterval;
            TimeSpan defaultRefreshInterval          = ConfigurationManager <OpenIdConnectConfiguration> .DefaultRefreshInterval;

            GetSetContext context =
                new GetSetContext
            {
                PropertyNamesAndSetGetValue = new List <KeyValuePair <string, List <object> > >
                {
                    new KeyValuePair <string, List <object> >("AutomaticRefreshInterval", new List <object> {
                        defaultAutomaticRefreshInterval, TimeSpan.FromHours(1), TimeSpan.FromHours(10)
                    }),
                    new KeyValuePair <string, List <object> >("RefreshInterval", new List <object> {
                        defaultRefreshInterval, TimeSpan.FromHours(1), TimeSpan.FromHours(10)
                    }),
                },
                Object = configManager,
            };

            TestUtilities.GetSet(context);
            TestUtilities.AssertFailIfErrors("ConfigurationManager_GetSets", context.Errors);

            TestUtilities.SetGet(configManager, "AutomaticRefreshInterval", TimeSpan.FromMilliseconds(1), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10107:"));
            TestUtilities.SetGet(configManager, "RefreshInterval", TimeSpan.FromMilliseconds(1), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10106:"));
            TestUtilities.SetGet(configManager, "RefreshInterval", Timeout.InfiniteTimeSpan, ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10106:"));
        }
        public void GetSets()
        {
            Saml2SecurityTokenHandler samlSecurityTokenHandler = new Saml2SecurityTokenHandler();

            TestUtilities.SetGet(samlSecurityTokenHandler, "MaximumTokenSizeInBytes", (object)0, ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10101"));
            TestUtilities.SetGet(samlSecurityTokenHandler, "MaximumTokenSizeInBytes", (object)1, ExpectedException.NoExceptionExpected);
        }
Ejemplo n.º 3
0
        public void GetSets()
        {
            var context = new GetSetContext
            {
                PropertyNamesAndSetGetValue = new List <KeyValuePair <string, List <object> > >
                {
                    new KeyValuePair <string, List <object> >("TransformFactory", new List <object> {
                        TransformFactory.Default
                    }),
                    new KeyValuePair <string, List <object> >("MaximumReferenceTransforms", new List <object> {
                        5, 11, 1
                    })
                },
                Object = new DSigSerializer()
            };

            TestUtilities.GetSet(context);
            TestUtilities.SetGet(new DSigSerializer(), "MaximumReferenceTransforms", 0, ExpectedException.NoExceptionExpected, context);
            TestUtilities.SetGet(new DSigSerializer(), "MaximumReferenceTransforms", -1, ExpectedException.ArgumentOutOfRangeException("IDX30600:"), context);

            TestUtilities.AssertFailIfErrors("DSigSerializerTests_GetSets", context.Errors);
        }
Ejemplo n.º 4
0
        public void GetSets()
        {
            var samlSecurityTokenHandler = new Saml2SecurityTokenHandler();
            var context = new GetSetContext
            {
                PropertyNamesAndSetGetValue = new List <KeyValuePair <string, List <object> > >
                {
                    new KeyValuePair <string, List <object> >("MaximumTokenSizeInBytes", new List <object> {
                        (object)TokenValidationParameters.DefaultMaximumTokenSizeInBytes, (object)1000, (object)10
                    }),
                    new KeyValuePair <string, List <object> >("SetDefaultTimesOnTokenCreation", new List <object> {
                        true, false, true
                    }),
                    new KeyValuePair <string, List <object> >("TokenLifetimeInMinutes", new List <object> {
                        (object)60, (object)1000, (object)10
                    }),
                },
                Object = samlSecurityTokenHandler
            };

            TestUtilities.GetSet(context);

            samlSecurityTokenHandler = new Saml2SecurityTokenHandler();
            TestUtilities.SetGet(samlSecurityTokenHandler, "MaximumTokenSizeInBytes", (object)0, ExpectedException.ArgumentOutOfRangeException("IDX10101:"), context);
            TestUtilities.SetGet(samlSecurityTokenHandler, "MaximumTokenSizeInBytes", (object)1, ExpectedException.NoExceptionExpected, context);
            TestUtilities.SetGet(samlSecurityTokenHandler, "Serializer", null, ExpectedException.ArgumentNullException(), context);

            TestUtilities.AssertFailIfErrors("Saml2SecurityTokenHandlerTests_GetSets", context.Errors);
        }
        public void GetSets()
        {
            TestUtilities.WriteHeader($"{this}.GetSets", "GetSets", true);

            var  configManager = new ConfigurationManager <OpenIdConnectConfiguration>("OpenIdConnectMetadata.json", new OpenIdConnectConfigurationRetriever(), new FileDocumentRetriever());
            Type type          = typeof(ConfigurationManager <OpenIdConnectConfiguration>);

            PropertyInfo[] properties = type.GetProperties();
            if (properties.Length != 7)
            {
                Assert.True(false, "Number of properties has changed from 7 to: " + properties.Length + ", adjust tests");
            }

            var defaultAutomaticRefreshInterval = ConfigurationManager <OpenIdConnectConfiguration> .DefaultAutomaticRefreshInterval;
            var defaultRefreshInterval          = ConfigurationManager <OpenIdConnectConfiguration> .DefaultRefreshInterval;
            var context = new GetSetContext
            {
                PropertyNamesAndSetGetValue = new List <KeyValuePair <string, List <object> > >
                {
                    new KeyValuePair <string, List <object> >("RefreshInterval", new List <object> {
                        defaultRefreshInterval, TimeSpan.FromHours(1), TimeSpan.FromHours(10)
                    }),
                },
                Object = configManager,
            };

            TestUtilities.GetSet(context);
            TestUtilities.SetGet(configManager, "AutomaticRefreshInterval", TimeSpan.FromMilliseconds(1), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10108:"), context);
            TestUtilities.SetGet(configManager, "RefreshInterval", TimeSpan.FromMilliseconds(1), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10107:"), context);
            TestUtilities.SetGet(configManager, "RefreshInterval", Timeout.InfiniteTimeSpan, ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10107:"), context);
            TestUtilities.SetGet(configManager, "LastKnownGoodConfiguration", new OpenIdConnectConfiguration(), ExpectedException.NoExceptionExpected, context);
            TestUtilities.SetGet(configManager, "UseLastKnownGoodConfiguration", true, ExpectedException.NoExceptionExpected, context);
            TestUtilities.SetGet(configManager, "MetadataAddress", "OpenIdConnectMetadata2.json", ExpectedException.NoExceptionExpected, context);
            TestUtilities.SetGet(configManager, "LastKnownGoodLifetime", TimeSpan.FromDays(5) - TimeSpan.FromDays(15), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10110:"), context);
            TestUtilities.AssertFailIfErrors("ConfigurationManager_GetSets", context.Errors);
        }