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; }
public ConfigArchiveEndPoint(IConfigurationClientService configurationClientService, IConfigurationModelRegistry registry, IConfigArchive archive, IHttpResponseFactory httpResponseFactory) { this.configurationClientService = configurationClientService; this.registry = registry; this.archive = archive; this.httpResponseFactory = httpResponseFactory; }
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); }
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]; }
public ResourceArchiveEndpoint(IConfigurationClientService configClientService, IConfigurationModelRegistry registry, IResourceArchive resourceArchive, IHttpResponseFactory httpResponseFactory) { this.configClientService = configClientService; this.resourceArchive = resourceArchive; this.httpResponseFactory = httpResponseFactory; this.registry = registry; }
public SnapshotEndpoint(IConfigurationSnapshotRepository snapShotRepository, ICommandBus commandBus, IConfigurationClientService configurationClientService, IHttpResponseFactory httpResponseFactory) { this.httpResponseFactory = httpResponseFactory; this.snapShotRepository = snapShotRepository; this.commandBus = commandBus; this.configurationClientService = configurationClientService; }
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; }
public JsonActionResult(IHttpRequest request, IHttpResponseFactory httpResponseFactory, object model) : base(request, httpResponseFactory) { if (model == null) { throw new ArgumentNullException(nameof(model)); } this.Model = model; }
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> >(); }
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; }
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); }
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; }
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); }
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); }
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); }
public ConfigClientEndPoint(IConfigurationClientService configurationClientService, IHttpResponseFactory httpResponseFactory, ICommandBus commandBus) { this.httpResponseFactory = httpResponseFactory; this.configurationClientService = configurationClientService; this.commandBus = commandBus; }
public HeadHandler(IHttpResponseFactory httpResponseFactory) : base(httpResponseFactory) { }
public StaticFileHandler(IHttpResponseFactory httpResponseFactory) : base(httpResponseFactory) { }
/// <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) { }
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; }
public PermissionEndpoint(IHttpResponseFactory httpResponseFactory, IConfigurationClientService clientService) { this.httpResponseFactory = httpResponseFactory; this.clientService = clientService; }
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); }
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; }
public ControllerHandler(IHttpResponseFactory httpResponseFactory, Func <IHttpRequest, Controller> controllerFactory, IActionInvoker actionInvoker) : base(httpResponseFactory) { this.actionInvoker = actionInvoker; this.controllerFactory = controllerFactory; }