private void SetupWhoAmIHandlers(Mock <IOrganizationService> orgSvc) { // Who Am I Response var whoAmIResponse = new WhoAmIResponse(); whoAmIResponse.Results = new ParameterCollection(); whoAmIResponse.Results.Add("UserId", _UserId); whoAmIResponse.Results.Add("BusinessUnitId", _BusinessUnitId); whoAmIResponse.Results.Add("OrganizationId", _OrganizationId); orgSvc.Setup(req => req.Execute(It.IsAny <WhoAmIRequest>())).Returns(whoAmIResponse); string _baseWebApiUriFormat = @"{0}/api/data/v{1}/"; string _baseSoapOrgUriFormat = @"{0}/XRMServices/2011/Organization.svc"; string directConnectUri = "https://testorg.crm.dynamics.com"; EndpointCollection ep = new EndpointCollection(); ep.Add(EndpointType.WebApplication, directConnectUri); ep.Add(EndpointType.OrganizationDataService, string.Format(_baseWebApiUriFormat, directConnectUri, "9.1")); ep.Add(EndpointType.OrganizationService, string.Format(_baseSoapOrgUriFormat, directConnectUri)); OrganizationDetail d = new OrganizationDetail(); d.FriendlyName = "DIRECTSET"; d.OrganizationId = _OrganizationId; d.OrganizationVersion = "9.1.2.0"; d.Geo = "NAM"; d.State = OrganizationState.Enabled; d.UniqueName = "HOLD"; d.UrlName = "HOLD"; System.Reflection.PropertyInfo proInfo = d.GetType().GetProperty("Endpoints"); if (proInfo != null) { proInfo.SetValue(d, ep, null); } RetrieveCurrentOrganizationResponse rawResp = new RetrieveCurrentOrganizationResponse(); rawResp.ResponseName = "RetrieveCurrentOrganization"; rawResp.Results.AddOrUpdateIfNotNull("Detail", d); RetrieveCurrentOrganizationResponse CurrentOrgResp = (RetrieveCurrentOrganizationResponse)rawResp; orgSvc.Setup(f => f.Execute(It.IsAny <RetrieveCurrentOrganizationRequest>())).Returns(CurrentOrgResp); }
/// <summary> /// Initializes a new <see cref="PlatibusConfiguration"/> with a preconfigured /// <paramref name="diagnosticService"/> and an initial set of <paramref name="endpoints"/> /// </summary> /// <param name="diagnosticService">(Optional) The service through which diagnostic events /// are reported and processed</param> /// <param name="endpoints">(Optional) An initial set of default endpoints</param> /// <remarks> /// If a custom <paramref name="diagnosticService"/> is not specified, then the default /// singleton instance <see cref="Diagnostics.DiagnosticService.DefaultInstance"/> will /// be used. /// </remarks> public PlatibusConfiguration(IDiagnosticService diagnosticService, EndpointCollection endpoints) { MessageNamingService = new DefaultMessageNamingService(); SerializationService = new DefaultSerializationService(); DefaultContentType = "application/json"; DiagnosticService = diagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance; _endpoints = endpoints ?? new EndpointCollection(); }
public TestWebUI(ITestOutputHelper output) { this.output = output; endpointCollectionProvider = new EndpointCollectionProvider("examples/example1"); endpointCollection = endpointCollectionProvider.EndpointCollection; testRunner = new WebTestRunner(endpointCollection); CreateServerAndClient(); }
public SSBIEndpointCollection(EndpointCollection epc) { foreach (Endpoint ep in epc) { if (ep.EndpointType == EndpointType.ServiceBroker) { this.Add(new SSBIEndpoint(ep)); } } }
public Task Invoke(HttpContext context, EndpointCollection endpoints) { var endpoint = endpoints.Find(context); if (endpoint != null) { return(endpoint.ProcessAsync(context)); } return(_next.Invoke(context)); }
private void InitializeEndpointCollectionWithGlobalDefaultsOnly() { var jsonEndpoint1 = new JSONEndpoint { name = "foobar", pathregex = "foobar", responses = new[] { new JSONResponse { match = new JSONRequestMatcher(), file = "myfile.xml" } } }; var jsonEndpoint2 = new JSONEndpoint { name = "baz", pathregex = "baz", responses = new[] { new JSONResponse { match = new JSONRequestMatcher(), file = "myfile.xml", contenttype = "text/xml", charset = "utf-8" } } }; var jsonEndpoint3 = new JSONEndpoint { name = "lorem", pathregex = "ipsum", responses = new[] { new JSONResponse { match = new JSONRequestMatcher(), file = "myfile.xml", contenttype = "text/xml", statuscode = "200" } } }; directoryCreator.AddFile("defaults.json", JsonConvert.SerializeObject(new JSONDefaults { charset = "ascii", contenttype = "application/xml" })); directoryCreator.AddFile("endpoint1/endpoint.json", JsonConvert.SerializeObject(jsonEndpoint1)); directoryCreator.AddFile("endpoint2/endpoint.json", JsonConvert.SerializeObject(jsonEndpoint2)); directoryCreator.AddFile("endpoint3/endpoint.json", JsonConvert.SerializeObject(jsonEndpoint3)); endpointCollection = EndpointCollectionReader.ReadFromDirectory(directoryCreator.DirectoryName); }
public Organisation(string uniqueName, string friendlyName, string version, EndpointCollection endPoints) { UniqueName = uniqueName; FriendlyName = friendlyName; Version = version; if (endPoints.ContainsKey(EndpointType.WebApplication)) { WebUrl = endPoints[EndpointType.WebApplication]; if (WebUrl != null && WebUrl.EndsWith("/")) { WebUrl = WebUrl.Substring(0, WebUrl.Length - 1); } } }
public TestsController(EndpointCollection endpoints, IHttpContextAccessor contextAccessor) { this.endpoints = endpoints; // contextAccessor is injected so that Request is available inside constructor (via TestAgainstUrl property) httpContext = contextAccessor.HttpContext; if (TestRunner.HasTestSuite(endpoints.SourceDirectory)) { testRunner = new WebTestRunner(endpoints); if (TestAgainstUrl) { testRunner.Url = "http://localhost:5000"; } } }
private void InitializeEndpointCollectionWithoutDefaults() { var jsonEndpoint1 = new JSONEndpoint { name = "foobar", pathregex = "foobar", responses = new[] { new JSONResponse { match = new JSONRequestMatcher(), file = "myfile.xml" } } }; directoryCreator.AddFile("endpoint1/endpoint.json", JsonConvert.SerializeObject(jsonEndpoint1)); endpointCollection = EndpointCollectionReader.ReadFromDirectory(directoryCreator.DirectoryName); }
public static void UseLightweightApi(this IServiceCollection services, params Assembly[] assemblies) { var endpointCollection = new EndpointCollection(); foreach (var assembly in assemblies) { foreach (var type in assembly.GetTypes()) { if (!EndpointCollection.IsHandler(type)) { continue; } services.AddScoped(type); endpointCollection.Add(type); } } services.AddSingleton(endpointCollection); }
private void InitializeEndpointCollectionWithGlobalAndEndpointDefaults() { var jsonEndpoint1 = new JSONEndpoint { name = "noendpointdefaults", pathregex = "noendpointdefaults", responses = new[] { new JSONResponse { match = new JSONRequestMatcher(), file = "myfile.xml" } } }; var jsonEndpoint2 = new JSONEndpoint { name = "endpointdefaults", pathregex = "endpointdefaults", responses = new[] { new JSONResponse { match = new JSONRequestMatcher(), file = "myfile.xml", } } }; var globalDefaults = new JSONDefaults { charset = "ascii", contenttype = "application/xml" }; var endpointDefaults = new JSONDefaults { charset = "UTF-7", contenttype = "text/plain" }; directoryCreator.AddFile("defaults.json", JsonConvert.SerializeObject(globalDefaults)); directoryCreator.AddFile("endpoint1/endpoint.json", JsonConvert.SerializeObject(jsonEndpoint1)); directoryCreator.AddFile("endpoint2/endpoint.json", JsonConvert.SerializeObject(jsonEndpoint2)); directoryCreator.AddFile("endpoint2/defaults.json", JsonConvert.SerializeObject(endpointDefaults)); endpointCollection = EndpointCollectionReader.ReadFromDirectory(directoryCreator.DirectoryName); }
private static EndpointCollection DiscoverEndpoints() { var pluginsDirectory = Path.Combine(AppContext.BaseDirectory, "plugins"); var loaders = new List <PluginLoader>(); var endpoints = new EndpointCollection(); foreach (var file in Directory.EnumerateFiles(pluginsDirectory, "*.dll", SearchOption.AllDirectories)) { if (File.Exists(file)) { var loader = PluginLoader.CreateFromAssemblyFile(file, sharedTypes: new[] { typeof(IEndpoint) }, configure: (pc) => { pc.SharedAssemblies.Add(typeof(JsonConvert).Assembly.GetName()); }); loaders.Add(loader); } } foreach (var loader in loaders) { var types = loader.LoadDefaultAssembly().GetTypes(); foreach (var endpointType in types .Where(t => typeof(IEndpoint).IsAssignableFrom(t) && !t.IsAbstract)) { var endpoint = (IEndpoint?)Activator.CreateInstance(endpointType); if (endpoint != null) { endpoints.Add(endpoint); } } } return(endpoints); }
public async Task Foo() { var endpoint = (new JSONEndpoint { name = "endpoint", pathregex = "/", responses = new[] { new JSONResponse { match = new JSONRequestMatcher { methods = "POST" }, literal = "Response from POST" }, new JSONResponse { match = new JSONRequestMatcher { methods = "GET" }, literal = "Response from GET" } } }).CreateEndpoint(".", null); Assert.NotNull(endpoint); Assert.Equal(2, endpoint.Responses.Count()); var getTestCase = new NetmockeryTestCase { Method = "GET", RequestPath = "/", ExpectedResponseBody = "Response from GET" }; Assert.True((await getTestCase.ExecuteAsync(EndpointCollection.WithEndpoints(endpoint))).OK); var postTestCase = new NetmockeryTestCase { Method = "POST", RequestPath = "/", ExpectedResponseBody = "Response from POST" }; Assert.True((await postTestCase.ExecuteAsync(EndpointCollection.WithEndpoints(endpoint))).OK); }
public EndpointsController(EndpointCollectionProvider endpointCollectionProvider, ResponseRegistry responseRegistry) { _endpointCollectionProvider = endpointCollectionProvider; _endpointCollection = _endpointCollectionProvider.EndpointCollection; _responseRegistry = responseRegistry; }
public HomeController(EndpointCollection endpointCollection) { _endpointCollection = endpointCollection; }
private SqlMessageReader( string server, string unformatedConnectionString ) { _server = server; _unformatedConnectionString = unformatedConnectionString; _endpoints = new EndpointCollection( ); }
//- ~LoadEndpointData -// internal static void LoadEndpointData(WebDomainData data, EndpointCollection collection) { List<EndpointElement> elementList = collection.ToList(); var matchTextList = new List<String>(); var referenceKeyList = new List<String>(); if (collection.Count(p => p.Text == "*") > 1) { throw new ConfigurationErrorsException(ResourceAccessor.GetString("WebDomain_DuplicateCatchAll")); } foreach (EndpointElement element in elementList) { if (element.Disabled) { continue; } String matchText = element.Text; Boolean requireSlash = element.RequireSlash; String withoutSlash = EndpointData.GetTextWithoutSlash(matchText); SelectorType matchType = element.Selector; String originalMatchText = matchText; EndpointData newElement = AdjustMatchType(element.Text); if (newElement != null) { matchText = newElement.Text; matchType = newElement.Selector; } matchTextList.Add(matchText); if (element.Text == "*") { data.CatchAllEndpoint = new EndpointData { AccessRuleGroup = element.AccessRuleGroup, OriginalMatchText = originalMatchText, Text = matchText, TextWithoutSlash = withoutSlash, Selector = matchType, Type = element.Type, ParameterValue = element.Parameter, ParameterMap = element.GetParameterMap(), Source = Info.System }; } else { var endpointData = new EndpointData { AccessRuleGroup = element.AccessRuleGroup, OriginalMatchText = originalMatchText, Text = matchText, TextWithoutSlash = withoutSlash, Selector = matchType, Type = element.Type, RequireSlash = element.RequireSlash, ParameterValue = element.Parameter, ParameterMap = element.GetParameterMap(), Source = Info.System }; endpointData.SubEndpointDataList = new EndpointDataList(); foreach (EndpointElement subElement in element.SubEndpoints) { String subWithoutSlash = EndpointData.GetTextWithoutSlash(matchText); endpointData.SubEndpointDataList.Add(new EndpointData { Text = subElement.Text, TextWithoutSlash = subWithoutSlash, Selector = subElement.Selector, Type = subElement.Type, ParameterValue = subElement.Parameter, ParameterMap = subElement.GetParameterMap(), Source = Info.System }); } data.EndpointDataList.Add(endpointData); } } EndpointDataList handlerList = data.EndpointDataList.Clone(); data.EndpointDataList = new EndpointDataList(); handlerList.Where(p => p.Selector == SelectorType.PathEquals).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.EndsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.WebDomainPathStartsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.WebDomainPathEquals).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.PathStartsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.StartsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.PathContains).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); handlerList.Where(p => p.Selector == SelectorType.Contains).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p)); //+ data.EndpointDataList.OriginalCount = data.EndpointDataList.Count; }
public WebTestRunner(EndpointCollection endpointCollection) : base(endpointCollection) { }
public SSBIEndpointCollection(EndpointCollection epc) { foreach (Endpoint ep in epc) { if (ep.EndpointType == EndpointType.ServiceBroker) this.Add(new SSBIEndpoint(ep)); } }
public EndpointsController(EndpointCollection endpoints, ILogger <EndpointsController> logger) => (_endpoints, _logger) = (endpoints, logger);
public ListEndpointsHandler(EndpointCollection endpointCollection) { _endpointCollection = endpointCollection; }