public IObservable <IMessageStream> GetMessageStream(IEndpointDetails endpointDetails)
 {
     return(Extensions.ObservableExtensions.ReturnAsync(() =>
     {
         return _endpointProvider.GetEndpoint(endpointDetails).MessageStream;
     }));
 }
示例#2
0
 public void SetUp()
 {
     _successor = MockRepository.GenerateStub<IHandler>();
     _handler = new OptionsHandler(_successor);
     _endpointDetails = MockRepository.GenerateStub<IEndpointDetails>();
     _credentials = MockRepository.GenerateStub<ICredentials>();
 }
示例#3
0
        public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
        {
            // _endpointDetails: Authorize against endpoint?

            return httpMethod == HttpMethod.Options
                       ? new OptionsResult(endpoint)
                       : _successor.Handle(endpoint, credentials, httpMethod);
        }
 public void SetUp()
 {
     _resourceFoundSuccessor = MockRepository.GenerateStub<IHandler>();
     _resourceNotFoundSuccessor = MockRepository.GenerateStub<IHandler>();
     _handler = new ResourceExistsHandler(_resourceFoundSuccessor, _resourceNotFoundSuccessor);
     _endpointDetails = MockRepository.GenerateStub<IEndpointDetails>();
     _credentials = MockRepository.GenerateStub<ICredentials>();
 }
示例#5
0
        public void TestFixtureSetUp()
        {
            _endpointDetails = MockRepository.GenerateStub<IEndpointDetails>();
            _endpointDetails.Stub(ed => ed.AllowHeader).Return(AllowAllTheThings);
            _result = new CreatedResult(_endpointDetails);
            _responseDetails = MockRepository.GenerateStub<IResponseDetails>();

            _result.Update(_responseDetails);
        }
示例#6
0
 public bool Equals(IEndpointDetails other)
 {
     if (string.CompareOrdinal(Address, other.Address) == 0 &&
         Type == ((RabbitMqEndpointDetails)other).Type)
     {
         return(true);
     }
     return(false);
 }
示例#7
0
        public void Returns_not_found_result()
        {
            _notFoundHandler = new NotFoundHandler(null);
            _endpointDetails = MockRepository.GenerateStub<IEndpointDetails>();
            _credentials = MockRepository.GenerateStub<ICredentials>();

            var result = _notFoundHandler.Handle(_endpointDetails, _credentials, null);

            Assert.That(result, Is.TypeOf<NotFoundResult>());
        }
 public IObservable <Unit> Send(
     IMessage message,
     IEndpointDetails endpointDetails,
     string targetSessionId = null)
 {
     return(Extensions.ObservableExtensions.ReturnAsync(() =>
     {
         var endpoint = _endpointProvider.GetEndpoint(endpointDetails);
         endpoint.Send(message, targetSessionId);
         return new Unit();
     }));
 }
示例#9
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return endpoint.Exists
                ? _successor.Handle(endpoint, credentials, httpMethod)
                : NotFoundResult.ForUnknownAddress();
 }
示例#10
0
 private IResult CheckCredentials(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return credentials.IsAuthenticated
                ? _successor.Handle(endpoint, credentials, httpMethod)
                : new UnauthorizedResult(credentials.FailureMessage);
 }
示例#11
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return endpoint.ResourceExists
         ? _resourceFoundSuccessor.Handle(endpoint, credentials, httpMethod)
         : _resourceNotFoundSuccessor.Handle(endpoint, credentials, httpMethod);
 }
示例#12
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return httpMethod == HttpMethod.Put
         ? _putHandler.Handle(endpoint, credentials, httpMethod)
         : NotFoundResult.ForNonexistentResource();
 }
示例#13
0
 public MethodNotAllowedResult(IEndpointDetails endpointDetails)
 {
     _endpointDetails = endpointDetails;
 }
示例#14
0
 public CreatedResult(IEndpointDetails endpointDetails)
 {
     _endpointDetails = endpointDetails;
 }
示例#15
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     endpoint.Save();
     return new CreatedResult(endpoint);
 }
示例#16
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return new OkResult(endpoint);
 }
示例#17
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return endpoint.Allows(httpMethod)
                ? _successor.Handle(endpoint, credentials, httpMethod)
                : new MethodNotAllowedResult(endpoint);
 }
示例#18
0
 public bool TryGetEndpointDetails(
     string endpointKey,
     out IEndpointDetails endpointDetails)
 {
     return(_endpoints.TryGetValue(endpointKey, out endpointDetails));
 }
示例#19
0
 public OptionsResult(IEndpointDetails endpointDetails)
 {
     _endpointDetails = endpointDetails;
 }
示例#20
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return !credentials.IsAnonymous
                ? CheckCredentials(endpoint, credentials, httpMethod)
                : _successor.Handle(endpoint, credentials, httpMethod);
 }
示例#21
0
 public OkResult(IEndpointDetails endpointDetails)
 {
     _endpointDetails = endpointDetails;
 }
示例#22
0
 public IResult Handle(IEndpointDetails endpoint, ICredentials credentials, HttpMethod httpMethod)
 {
     return endpoint.IsAuthorizedFor(credentials)
                ? _successor.Handle(endpoint, credentials, httpMethod)
                : UnauthorizedResult.ForInsufficientPrivileges();
 }