예제 #1
0
 public DownloadEndpoint(IHttpResponseFactory httpResponseFactory, IConfigurationModelRegistry configCollection, IConfigurationSetService configurationSetService, IConfigurationClientService configClientService)
 {
     this.configurationSetService = configurationSetService;
     this.configCollection        = configCollection;
     this.httpResponseFactory     = httpResponseFactory;
     this.configClientService     = configClientService;
 }
 public ConfigurationSetModelEndpoint(IHttpResponseFactory httpResponseFactory, IConfigurationSetModelPayloadMapper modelPayloadMapper, IConfigurationModelRegistry configCollection, IConfigurationClientService configClientService)
 {
     this.httpResponseFactory = httpResponseFactory;
     this.configCollection    = configCollection;
     this.modelPayloadMapper  = modelPayloadMapper;
     this.configClientService = configClientService;
 }
예제 #3
0
 public ConfigArchiveEndPoint(IConfigurationClientService configurationClientService, IConfigurationModelRegistry registry, IConfigArchive archive, IHttpResponseFactory httpResponseFactory)
 {
     this.configurationClientService = configurationClientService;
     this.registry            = registry;
     this.archive             = archive;
     this.httpResponseFactory = httpResponseFactory;
 }
예제 #4
0
 protected virtual void AssertMocks(IApiHttpClient clientMock, IHttpResponseFactory factoryMock, IApiCommandRequest requestMock, IApiCommandResponse responseMock, IApiCommandResponse commandResponse)
 {
     Assert.Same(responseMock, commandResponse);
     _ = requestMock.Received(1).ApiUri;
     factoryMock.Received(1).CreateResponse(Arg.Any <HttpResponseMessage>());
     AssertMocks(clientMock);
 }
예제 #5
0
        private void CreateCommandTest(Func <ApiCommandFactory, IApiCommandAsync> create, Type commandType, int serializerMapCalls)
        {
            // Arrange
            IApiHttpFactory              httpFactory     = Substitute.For <IApiHttpFactory>();
            IHttpResponseFactory         responseFactory = Substitute.For <IHttpResponseFactory>();
            IApiHttpClient               httpClient      = Substitute.For <IApiHttpClient>();
            IApiCommandContentSerializer serializer      = Substitute.For <IApiCommandContentSerializer>();
            IApiCommandContentTypeMap <IApiCommandContentSerializer> serializers = Substitute.For <IApiCommandContentTypeMap <IApiCommandContentSerializer> >();

            serializers[_mediaType].Returns(serializer);
            httpFactory.NewClient(_key).Returns(httpClient);

            var factory = new ApiCommandFactory(httpFactory, responseFactory, serializers);

            // Act
            var command = create(factory);

            // Assert
            Assert.NotNull(command);
            Assert.IsType(commandType, command);

            httpFactory.Received(1).NewClient(Arg.Any <object>());
            httpFactory.Received(1).NewClient(_key);
            _ = serializers.Received(serializerMapCalls)[_mediaType];
        }
예제 #6
0
 public ResourceArchiveEndpoint(IConfigurationClientService configClientService, IConfigurationModelRegistry registry, IResourceArchive resourceArchive, IHttpResponseFactory httpResponseFactory)
 {
     this.configClientService = configClientService;
     this.resourceArchive     = resourceArchive;
     this.httpResponseFactory = httpResponseFactory;
     this.registry            = registry;
 }
예제 #7
0
 public SnapshotEndpoint(IConfigurationSnapshotRepository snapShotRepository, ICommandBus commandBus, IConfigurationClientService configurationClientService, IHttpResponseFactory httpResponseFactory)
 {
     this.httpResponseFactory        = httpResponseFactory;
     this.snapShotRepository         = snapShotRepository;
     this.commandBus                 = commandBus;
     this.configurationClientService = configurationClientService;
 }
예제 #8
0
 public UploadEnpoint(IHttpResponseFactory httpResponseFactory, IConfigurationModelRegistry configCollection, ICommandBus commandBus, IConfigurationClientService configClientService, IUploadToEditorModelMapper uploadToEditorModelMapper)
 {
     this.httpResponseFactory       = httpResponseFactory;
     this.configCollection          = configCollection;
     this.commandBus                = commandBus;
     this.configClientService       = configClientService;
     this.uploadToEditorModelMapper = uploadToEditorModelMapper;
 }
 public ConfigurationEditorEndpoint(IHttpResponseFactory httpResponseFactory, IConfigInstanceRouter configInstanceRouter, IConfigurationEditModelMapper configurationEditModelMapper, IConfigurationModelRegistry configCollection, IConfigurationClientService configClientService, ICommandBus commandBus)
 {
     this.httpResponseFactory          = httpResponseFactory;
     this.configCollection             = configCollection;
     this.configInstanceRouter         = configInstanceRouter;
     this.configurationEditModelMapper = configurationEditModelMapper;
     this.configClientService          = configClientService;
     this.commandBus = commandBus;
 }
예제 #10
0
        public JsonActionResult(IHttpRequest request, IHttpResponseFactory httpResponseFactory, object model)
            : base(request, httpResponseFactory)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            this.Model = model;
        }
예제 #11
0
        protected BaseActionResult(IHttpRequest request, IHttpResponseFactory httpResponseFactory)
        {
            if (httpResponseFactory == null)
            {
                throw new ArgumentNullException(nameof(httpResponseFactory));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            this._request             = request;
            this._httpResponseFactory = httpResponseFactory;
            this._responseHeaders     = new List <KeyValuePair <string, string> >();
        }
예제 #12
0
        public ControllerHandler(IHttpResponseFactory responseFactory,
                                 IActionInvoker actionInvoker,
                                 Func <IHttpRequest, Controller> controllerFactory)
            : base(responseFactory)
        {
            if (actionInvoker == null)
            {
                throw new ArgumentNullException(nameof(actionInvoker));
            }

            if (controllerFactory == null)
            {
                throw new ArgumentNullException(nameof(controllerFactory));
            }

            this._controllerFactory = controllerFactory;
            this._actionInvoker     = actionInvoker;
        }
예제 #13
0
        public void CreateRequest_Execute_RestursRequest()
        {
            // Arrange
            Uri    uri     = new("/", UriKind.Relative);
            object content = new();

            IApiHttpFactory              httpFactory     = Substitute.For <IApiHttpFactory>();
            IHttpResponseFactory         responseFactory = Substitute.For <IHttpResponseFactory>();
            IApiCommandContentSerializer serializer      = Substitute.For <IApiCommandContentSerializer>();
            IApiCommandContentTypeMap <IApiCommandContentSerializer> serializers = Substitute.For <IApiCommandContentTypeMap <IApiCommandContentSerializer> >();

            var factory = new ApiCommandFactory(httpFactory, responseFactory, serializers);

            // Act
            var request = factory.CreateRequest(uri, content);

            // Assert
            Assert.NotNull(request);
            Assert.Equal(uri, request.ApiUri);
            Assert.Same(content, request.Content);
        }
예제 #14
0
        public ResponseProvider(IRequestParser requestParser,
                                IHttpResponseFactory responseFactory,
                                IHandler headHandler)
        {
            if (requestParser == null)
            {
                throw new ArgumentNullException(nameof(requestParser));
            }

            if (responseFactory == null)
            {
                throw new ArgumentNullException(nameof(responseFactory));
            }

            if (headHandler == null)
            {
                throw new ArgumentNullException(nameof(headHandler));
            }

            this._requestParser   = requestParser;
            this._responseFactory = responseFactory;
            this._headHandler     = headHandler;
        }
 public WebResponseExtractor(IHttpResponseFactory httpResponseFactory)
 {
     _httpResponseFactory = httpResponseFactory;
 }
예제 #16
0
        public static bool ChallengeClientRead(this HttpContext source, ConfigServerOptions option, ConfigurationClient client, IHttpResponseFactory responseFactory)
        {
            if (client == null)
            {
                responseFactory.BuildNotFoundStatusResponse(source);
                return(false);
            }

            if (string.IsNullOrWhiteSpace(option.ClientReadClaimType) || string.IsNullOrWhiteSpace(client.ReadClaim))
            {
                return(source.ChallengeAuthentication(option.AllowAnomynousAccess, responseFactory));
            }

            //If we have an expected claim then we do not want to allow anomynous
            if (!source.ChallengeAuthentication(false, responseFactory))
            {
                return(false);
            }

            if (!source.User.HasClaim(c => option.ClientReadClaimType.Equals(c.Type, StringComparison.OrdinalIgnoreCase) && client.ReadClaim.Equals(c.Value, StringComparison.OrdinalIgnoreCase)))
            {
                responseFactory.BuildStatusResponse(source, 403);
                return(false);
            }

            return(true);
        }
예제 #17
0
 public static bool ChallengeAuthentication(this HttpContext source, bool allowAnomynous, IHttpResponseFactory responseFactory)
 {
     if (!allowAnomynous && !source.User.Identity.IsAuthenticated)
     {
         responseFactory.BuildStatusResponse(source, 401);
         return(false);
     }
     return(true);
 }
예제 #18
0
        public static bool ChallengeUser(this HttpContext source, string claimType, ICollection <string> acceptableValues, bool allowAnomynous, IHttpResponseFactory responseFactory)
        {
            if (string.IsNullOrWhiteSpace(claimType))
            {
                return(source.ChallengeAuthentication(allowAnomynous, responseFactory));
            }

            //If we have an expected claim then we do not want to allow anomynous
            if (!source.ChallengeAuthentication(false, responseFactory))
            {
                return(false);
            }

            if (!source.User.HasClaim(c => claimType.Equals(c.Type, StringComparison.OrdinalIgnoreCase) && acceptableValues.Contains(c.Value)))
            {
                responseFactory.BuildStatusResponse(source, 403);
                return(false);
            }

            return(true);
        }
예제 #19
0
 public ConfigClientEndPoint(IConfigurationClientService configurationClientService, IHttpResponseFactory httpResponseFactory, ICommandBus commandBus)
 {
     this.httpResponseFactory        = httpResponseFactory;
     this.configurationClientService = configurationClientService;
     this.commandBus = commandBus;
 }
예제 #20
0
 public HeadHandler(IHttpResponseFactory httpResponseFactory)
     : base(httpResponseFactory)
 {
 }
예제 #21
0
 public StaticFileHandler(IHttpResponseFactory httpResponseFactory)
     : base(httpResponseFactory)
 {
 }
예제 #22
0
 /// <summary>
 /// Create a new instance of the <see cref="ApiPatchCommandAsync"/>
 /// </summary>
 /// <param name="httpClient">The <see cref="IApiHttpClient"/> client used for sending the delete request.</param>
 /// <param name="serializer">The serializer that is used to serialize the <see cref="IApiCommandRequest.Content"/> to <see cref="HttpContent"/>.</param>
 /// <param name="responseFactory">The <see cref="IHttpResponseFactory"/> factory used for creating the response.</param>
 public ApiPostCommandAsync(IApiHttpClient httpClient, IApiCommandContentSerializer serializer, IHttpResponseFactory responseFactory) : base(httpClient, serializer, responseFactory)
 {
 }
예제 #23
0
 public ConfigEndpoint(IConfigInstanceRouter router, IConfigurationClientService configurationClientService, IHttpResponseFactory httpResponseFactory)
 {
     this.httpResponseFactory = httpResponseFactory;
     this.router = router;
     this.configurationClientService = configurationClientService;
 }
 public ConfigManagerEndpoint(IHttpResponseFactory httpResponseFactory)
 {
     this.httpResponseFactory = httpResponseFactory;
 }
 public GuidGeneratorEndpoint(IHttpResponseFactory httpResponseFactory)
 {
     this.httpResponseFactory = httpResponseFactory;
 }
예제 #26
0
 public PermissionEndpoint(IHttpResponseFactory httpResponseFactory, IConfigurationClientService clientService)
 {
     this.httpResponseFactory = httpResponseFactory;
     this.clientService       = clientService;
 }
예제 #27
0
        public static bool ChallengeClientConfiguratorOrAdmin(this HttpContext source, ConfigServerOptions option, ConfigurationClient client, IHttpResponseFactory responseFactory)
        {
            if (client == null)
            {
                responseFactory.BuildNotFoundStatusResponse(source);
                return(false);
            }

            if (string.IsNullOrWhiteSpace(option.ClientAdminClaimType) || string.IsNullOrWhiteSpace(option.ClientConfiguratorClaimType) || string.IsNullOrWhiteSpace(client.ConfiguratorClaim))
            {
                return(source.ChallengeAuthentication(option.AllowManagerAnomynousAccess, responseFactory));
            }

            //If we have an expected claim then we do not want to allow anomynous
            if (!source.ChallengeAuthentication(false, responseFactory))
            {
                return(false);
            }

            if (!(source.HasClaim(option.ClientConfiguratorClaimType, client.ConfiguratorClaim) || source.HasClaim(option.ClientAdminClaimType, ConfigServerConstants.AdminClaimValue)))
            {
                responseFactory.BuildStatusResponse(source, 403);
                return(false);
            }

            return(true);
        }
예제 #28
0
 public RedirectActionResult(IHttpRequest request, string location, IHttpResponseFactory httpResponseFactory)
     : base(request, httpResponseFactory)
 {
     this.ResponseHeaders.Add(new KeyValuePair <string, string>("Location", location));
 }
 public ConfigurationSetEndpoint(IHttpResponseFactory httpResponseFactory, IConfigurationModelRegistry configCollection)
 {
     this.httpResponseFactory = httpResponseFactory;
     this.configCollection    = configCollection;
 }
예제 #30
0
 public ControllerHandler(IHttpResponseFactory httpResponseFactory, Func <IHttpRequest, Controller> controllerFactory, IActionInvoker actionInvoker)
     : base(httpResponseFactory)
 {
     this.actionInvoker     = actionInvoker;
     this.controllerFactory = controllerFactory;
 }
예제 #31
0
 public WebResponseExtractor(IHttpResponseFactory httpResponseFactory)
 {
     _httpResponseFactory = httpResponseFactory;
 }