Esempio n. 1
0
        /// <summary>
        /// Create the call handler.
        /// </summary>
        /// <param name="context">ObjectBuilder context.</param>
        /// <param name="objectConfiguration">The call handler data.</param>
        /// <param name="configurationSource">Configuration source.</param>
        /// <param name="reflectionCache">ObjectBuild reflection cache.</param>
        /// <returns>The constructed call handler.</returns>
        public ICallHandler Assemble(IBuilderContext context, CallHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            AuthorizationCallHandlerData castedConfiguration = (AuthorizationCallHandlerData)objectConfiguration;

            AuthorizationCallHandler callHandler = new AuthorizationCallHandler(castedConfiguration.AuthorizationProvider, castedConfiguration.OperationName, configurationSource);

            return(callHandler);
        }
Esempio n. 2
0
        public void ShouldCreateHandlerWithReasonableDefaults()
        {
            string ruleName = "Some Rule";
            AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName);
            AuthorizationCallHandler          handler   = GetHandlerFromAttribute(attribute);

            Assert.AreEqual(string.Empty, handler.ProviderName);
            Assert.AreEqual(ruleName, handler.OperationName);
        }
Esempio n. 3
0
        public void ShouldBeAbleToSetProviderName()
        {
            string ruleName     = "Some other rule - {namespace}";
            string providerName = "MyRules";
            AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName);

            attribute.ProviderName = providerName;
            AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute);

            Assert.AreEqual(ruleName, handler.OperationName);
            Assert.AreEqual(providerName, handler.ProviderName);
        }
        public void ShouldBeAbleToSetProviderName()
        {
            container.RegisterInstance("MyRules", authorizationProvider);

            string ruleName     = "Some other rule - {namespace}";
            string providerName = "MyRules";
            AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName);

            attribute.ProviderName = providerName;
            AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute);

            Assert.AreSame(authorizationProvider, handler.AuthorizationProvider);
            Assert.AreEqual(ruleName, handler.OperationName);
        }
        public void ShouldCreateHandlerWithReasonableDefaults()
        {
            container.RegisterInstance(authorizationProvider);

            string ruleName = "Some Rule";
            AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName);

            attribute.Order = 500;

            AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute);

            Assert.AreSame(authorizationProvider, handler.AuthorizationProvider);
            Assert.AreEqual(ruleName, handler.OperationName);
            Assert.AreEqual(500, handler.Order);
        }