public void RequireCustomer_Yes_ProductionPatches() { var mockHttpContext = new Mock <HttpContext>(); Task MockRequestDelegate(HttpContext context) => Task.FromResult(mockHttpContext.Object); var mockCwsAccountClient = new Mock <ICwsAccountClient>(); var mockConfigStoreProxy = new Mock <IConfigurationStore>(); var mockLoggerFactoryProxy = new Mock <ILoggerFactory>(); var mockServiceExceptionProxy = new Mock <IServiceExceptionHandler>(); var mockProjectProxy = new Mock <IProjectProxy>(); var mockEntitlements = new Mock <IEntitlementProxy>(); var raptorAuthentication = new RaptorAuthentication(MockRequestDelegate, mockCwsAccountClient.Object, mockConfigStoreProxy.Object, mockLoggerFactoryProxy.Object, mockEntitlements.Object, mockServiceExceptionProxy.Object, mockProjectProxy.Object); var request = new DefaultHttpContext().Request; request.Path = "/productiondata/patches"; request.Headers.Add(new KeyValuePair <string, StringValues>("X-VisionLink-SomethingElse", "dontCare")); request.Method = "GET"; var isCustomerUidRequired = raptorAuthentication.RequireCustomerUid(request.HttpContext); isCustomerUidRequired.Should().BeTrue(); }
public void RequireCustomer_No_TagFilesAndHasNoCustomer() { var mockHttpContext = new Mock <HttpContext>(); Task MockRequestDelegate(HttpContext context) => Task.FromResult(mockHttpContext.Object); var mockCwsAccountClient = new Mock <ICwsAccountClient>(); var mockConfigStoreProxy = new Mock <IConfigurationStore>(); var loggerFactoryProxy = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")); var mockServiceExceptionProxy = new Mock <IServiceExceptionHandler>(); var mockProjectProxy = new Mock <IProjectProxy>(); var mockEntitlements = new Mock <IEntitlementProxy>(); var raptorAuthentication = new RaptorAuthentication(MockRequestDelegate, mockCwsAccountClient.Object, mockConfigStoreProxy.Object, loggerFactoryProxy, mockEntitlements.Object, mockServiceExceptionProxy.Object, mockProjectProxy.Object); var request = new DefaultHttpContext().Request; request.Path = "/api/v2/tagfiles"; request.Headers.Add(new KeyValuePair <string, StringValues>("X-VisionLink-SomethingElse", "SomethingElse")); request.Method = "POST"; var isCustomerUidRequired = raptorAuthentication.RequireCustomerUid(request.HttpContext); isCustomerUidRequired.Should().BeFalse(); }