예제 #1
0
        public OController()
        {
            oAuthContextBuilder = new OAuthContextBuilder();
             tr = new MVC.Sample.Models.TokenRepository();
             tokenstore = new MVC.Sample.Models.SampleMemoryTokenStore(tr);

             iCStore = new SampleConsumerStore();

             Inspector = new ConsumerValidationInspector(iCStore);

             oAuthProvider = new OAuthProvider(tokenstore, Inspector);
             target = new OAuthController(oAuthContextBuilder, oAuthProvider);
        }
예제 #2
0
            public void SetFixture(MockRepository mocks)
            {
                mockRepository        = mocks;
                DefaultProvider       = mocks.DynamicMock <IOAuthProvider>();
                DefaultcontextBuilder = mocks.DynamicMock <IOAuthContextBuilder>();
                var httpRequest     = mocks.DynamicMock <HttpRequestBase>();
                var httpContextMock = mocks.DynamicMock <HttpContextBase>();

                mockOAuthContext = mocks.DynamicMock <IOAuthContext>();
                DefaultcontextBuilder.Stub(contextBuilder => contextBuilder.FromHttpRequest(httpRequest)).Return(mockOAuthContext);
                DefaultProvider.Stub(provider => provider.ExchangeRequestTokenForAccessToken(mockOAuthContext)).Return(requestToken);
                httpContextMock.Stub(httpcontext => httpcontext.Request).Return(httpRequest);
                var controller        = new OAuthController(ContextBuilder, Provider);
                var controllerContext = new ControllerContext(httpContextMock, new RouteData(), controller);

                controller.ControllerContext = controllerContext;
                mocks.ReplayAll();
                result = controller.AccessToken();
            }
예제 #3
0
            public void SetFixture(MockRepository mocks)
            {
                var securedFilter      = new OAuthSecuredAttribute();
                var mockControllerBase = mocks.DynamicMock <ControllerBase>();
                var mockHttpContext    = mocks.DynamicMock <HttpContextBase>();

                mockResponse   = mocks.DynamicMock <HttpResponseBase>();
                contextBuilder = mocks.DynamicMock <IOAuthContextBuilder>();
                oauthContext   = mocks.DynamicMock <IOAuthContext>();
                var httpRequest       = mocks.DynamicMock <HttpRequestBase>();
                var controllerContext = new ControllerContext(mockHttpContext, new RouteData(), mockControllerBase);
                var filterContext     = new ResultExecutedContext(controllerContext, new EmptyResult(), false, null);

                mockHttpContext.Stub(context => context.Response).Return(mockResponse);
                mockHttpContext.Stub(context => context.Request).Return(httpRequest);
                mockResponse.Stub(response => response.Headers).Return(Headers);
                contextBuilder.Stub(builder => builder.FromHttpRequest(httpRequest)).Return(oauthContext);
                oauthContext.Stub(context => context.Realm).Return(DefaultRealm);
                mocks.ReplayAll();
                securedFilter.OAuthContextBuilder = contextBuilder;
                securedFilter.OnResultExecuted(filterContext);
            }
예제 #4
0
            public void SetFixture(MockRepository mocks)
            {
                AuthFiliter = new OAuthSecuredAttribute();
                DefaultoAuthContextBuilder = mocks.DynamicMock <IOAuthContextBuilder>();
                DefaultoAuthPovider        = mocks.DynamicMock <IOAuthProvider>();
                var controllerBase  = mocks.DynamicMock <ControllerBase>();
                var httpContext     = mocks.DynamicMock <HttpContextBase>();
                var mockHttpRequest = mocks.DynamicMock <HttpRequestBase>();

                DefaultoAuthContext = mocks.DynamicMock <IOAuthContext>();

                var controllerContext = new ControllerContext(httpContext, new RouteData(), controllerBase);

                httpContext.Stub(context => context.Request).Return(mockHttpRequest);

                DefaultoAuthContextBuilder.Stub(contextBuilder => contextBuilder.FromHttpRequest(mockHttpRequest)).Return(OAuthContext);
                SetupExpectations();
                FilterContext = new AuthorizationContext(controllerContext);
                AuthFiliter.OAuthContextBuilder = OAuthContextBuilder;
                AuthFiliter.OAuthProvider       = OAuthPovider;
                mocks.ReplayAll();
                Exception = Record.Exception(() => AuthFiliter.OnAuthorization(FilterContext));
            }
예제 #5
0
 public OAuthController(IOAuthContextBuilder oAuthContextBuilder,IOAuthProvider oAuthProvider)
 {
     _oAuthContextBuilder = oAuthContextBuilder;
       _oAuthProvider = oAuthProvider;
 }
예제 #6
0
 public OAuthController(IOAuthContextBuilder oAuthContextBuilder, IOAuthProvider oAuthProvider)
 {
     _oAuthContextBuilder = oAuthContextBuilder;
     _oAuthProvider       = oAuthProvider;
 }