public void AddOrchestration(Orchestration orchestration) { if (Orchestrations == null) { Orchestrations = new List <Orchestration>(); } Orchestrations.Add(orchestration); }
protected override void ApplyEnvironmentOverrides(string environment) { base.ApplyEnvironmentOverrides(environment); Orchestrations.Add( new Orchestrations.Direct.ProcessOrchestrationBinding( o => { o.Host = CommonSettings.ReceiveHost; }), new Orchestrations.Dummy.ProcessOrchestrationBinding( o => { o.ReceivePort = ReceivePorts.Find <BatchReceivePort>(); o.RequestResponsePort = _twoWayReceivePort; o.SendPort = SendPorts.Find <BatchAddPartSendPort>(); o.SolicitResponsePort = _twoWaySendPort; o.Host = CommonSettings.ReceiveHost; o.State = ServiceState.Unenlisted; })); }
public async Task OnGet() { HttpClient adminApiClient = _api.InitBiztalkAdminAPI(); HttpClient adminSrvClient = _api.InitBiztalkMgmtSrv(); HttpResponseMessage resRL = await adminApiClient.GetAsync("ReceiveLocation"); if (resRL.IsSuccessStatusCode) { var resultRL = resRL.Content.ReadAsStringAsync().Result; ReceiveLocations2 = JsonConvert.DeserializeObject <IEnumerable <ReceiveLocation2> >(resultRL); } HttpResponseMessage resSP = await adminApiClient.GetAsync("SendPort"); if (resSP.IsSuccessStatusCode) { var resultSP = resSP.Content.ReadAsStringAsync().Result; SendPorts = JsonConvert.DeserializeObject <IEnumerable <SendPort> >(resultSP); } HttpResponseMessage resOrc = await adminApiClient.GetAsync("Orchestration"); if (resOrc.IsSuccessStatusCode) { var resultOrc = resOrc.Content.ReadAsStringAsync().Result; Orchestrations = JsonConvert.DeserializeObject <IEnumerable <Orchestration> >(resultOrc); } HttpResponseMessage resApp = await adminSrvClient.GetAsync("Applications"); if (resApp.IsSuccessStatusCode) { var resultApp = resApp.Content.ReadAsStringAsync().Result; Applications = JsonConvert.DeserializeObject <IEnumerable <Application> >(resultApp); AppTree = new List <ApplicationTree>(); foreach (Application app in Applications) { AppTree.Add(new ApplicationTree { applicationName = app.Name, orchestrations = Orchestrations.Where(o => o.applicationName == app.Name).ToList(), receiveLocations = ReceiveLocations2.Where(o => o.applicationName == app.Name).ToList(), sendPorts = SendPorts.Where(o => o.applicationName == app.Name).ToList() }); } } }
public async Task ReturnsUnauthorizedResultIfNotAuthenticated() { // Arrange var request = new DefaultHttpContext().Request; var durableClientMoq = new Mock <IDurableClient>(); var logMoq = new Mock <ILogger>(); // Getting the list of all functions to be validated var functionsToBeCalled = typeof(DfmEndpoint).Assembly.DefinedTypes .Where(t => t.IsClass) .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public)) .Where(m => m.CustomAttributes.Any(a => a.AttributeType == typeof(FunctionNameAttribute))) .Select(m => m.Name) .ToHashSet(); // Only these two methods should be publicly accessible as of today functionsToBeCalled.Remove(nameof(ServeStatics.DfmServeStaticsFunction)); functionsToBeCalled.Remove(nameof(EasyAuthConfig.DfmGetEasyAuthConfigFunction)); // Collecting the list of functions that were actually called by this test var functionsThatWereCalled = new HashSet <string>(); var methodExtractionRegex = new Regex(@"\.(\w+)\(HttpRequest req,"); logMoq.Setup(log => log.Log(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <It.IsAnyType>(), It.IsAny <Exception>(), It.IsAny <Func <It.IsAnyType, Exception, string> >())) .Callback((LogLevel l, EventId i, object s, Exception ex, object o) => { // Ensuring the correct type of exception was raised internally Assert.IsInstanceOfType(ex, typeof(UnauthorizedAccessException)); Assert.AreEqual("No access token provided. Call is rejected.", ex.Message); // Also extracting the function name that was called functionsThatWereCalled.Add(methodExtractionRegex.Match(ex.StackTrace).Groups[1].Value); }); Environment.SetEnvironmentVariable(EnvVariableNames.DFM_HUB_NAME, string.Empty); // Act var results = new List <IActionResult>() { await About.DfmAboutFunction(request, "TestHub", logMoq.Object), await CleanEntityStorage.DfmCleanEntityStorageFunction(request, durableClientMoq.Object, logMoq.Object), await DeleteTaskHub.DfmDeleteTaskHubFunction(request, "TestHub", logMoq.Object), await IdSuggestions.DfmGetIdSuggestionsFunction(request, durableClientMoq.Object, "abc", logMoq.Object), await ManageConnection.DfmManageConnectionFunction(request, "TestHub", new Microsoft.Azure.WebJobs.ExecutionContext(), logMoq.Object), await IdSuggestions.DfmGetIdSuggestionsFunction(request, durableClientMoq.Object, "abc", logMoq.Object), await Orchestration.DfmGetOrchestrationFunction(request, "abc", durableClientMoq.Object, logMoq.Object), await Orchestration.DfmGetOrchestrationHistoryFunction(request, "abc", durableClientMoq.Object, logMoq.Object), await Orchestration.DfmPostOrchestrationFunction(request, "abc", "todo", durableClientMoq.Object, logMoq.Object), await Orchestration.DfmGetOrchestrationTabMarkupFunction(request, "abc", "todo", durableClientMoq.Object, logMoq.Object), await Orchestrations.DfmGetOrchestrationsFunction(request, durableClientMoq.Object, logMoq.Object), await PurgeHistory.DfmPurgeHistoryFunction(request, durableClientMoq.Object, logMoq.Object), await TaskHubNames.DfmGetTaskHubNamesFunction(request, logMoq.Object), }; // Assert results.ForEach(r => Assert.IsInstanceOfType(r, typeof(UnauthorizedResult))); functionsToBeCalled.ExceptWith(functionsThatWereCalled); Assert.IsTrue(functionsToBeCalled.Count == 0, "You forgot to test " + string.Join(", ", functionsToBeCalled)); }
public SampleApplication() { Name = ApplicationName.Is("Detailed.SampleApplication"); ReceivePorts.Add( CustomerOneWayReceivePort = ReceivePort( p => { p.Name = ReceivePortName.Offwards(Party.Customer); p.ReceiveLocations .Add( ReceiveLocation( l => { l.Name = ReceiveLocationName.About(MessageName.Invoice).FormattedAs.Xml; l.Enabled = false; l.ReceivePipeline = new ReceivePipeline <XmlReceive>(); l.Transport.Adapter = new FileAdapter.Inbound(a => { a.ReceiveFolder = @"c:\files\drops"; }); l.Transport.Host = Host.RECEIVING_HOST; }), ReceiveLocation( l => { l.Name = ReceiveLocationName.About(MessageName.CreditNote).FormattedAs.Edi; l.Enabled = false; l.ReceivePipeline = new ReceivePipeline <XmlReceive>(); l.Transport.Adapter = new FileAdapter.Inbound(a => { a.ReceiveFolder = @"c:\files\drops"; }); l.Transport.Host = Host.RECEIVING_HOST; }) ); }), CustomerTwoWayReceivePort = ReceivePort( p => { p.Name = ReceivePortName.Offwards(Party.Customer); p.Description = "Receives ledgers from customers"; p.ReceiveLocations.Add( ReceiveLocation( l => { l.Name = ReceiveLocationName.About(MessageName.Statement).FormattedAs.Csv; l.Enabled = true; l.ReceivePipeline = new ReceivePipeline <PassThruReceive>(pl => { pl.Decoder <FailedMessageRoutingEnablerComponent>(c => { c.Enabled = false; }); }); l.SendPipeline = new SendPipeline <PassThruTransmit>(pl => { pl.PreAssembler <FailedMessageRoutingEnablerComponent>(c => { c.Enabled = false; }); }); l.Transport.Adapter = new FileAdapter.Inbound(a => { a.ReceiveFolder = @"c:\files\drops"; }); l.Transport.Host = Host.RECEIVING_HOST; })); }), ReceivePort( p => { p.Name = ReceivePortName.Offwards(Party.Bank); p.Description = "Receives financial movements from bank"; p.ReceiveLocations.Add( ReceiveLocation( l => { l.Name = ReceiveLocationName.About(MessageName.Statement).FormattedAs.Xml; l.Enabled = true; l.ReceivePipeline = new ReceivePipeline <MicroPipelines.XmlReceive>( pl => { pl.Decoder <MicroPipelineComponent>( c => { c.Enabled = false; c.Components = new IMicroPipelineComponent[] { new FailedMessageRoutingEnabler { EnableFailedMessageRouting = true, SuppressRoutingFailureReport = false }, new ActivityTracker { TrackingModes = ActivityTrackingModes.Claim, TrackingContextCacheDuration = TimeSpan.FromSeconds(120) } }; }); }); l.Transport.Adapter = new WcfSqlAdapter.Inbound( a => { a.Address = new SqlAdapterConnectionUri { InboundId = "FinancialMovements", InitialCatalog = "BankDb", Server = "localhost" }; a.InboundOperationType = InboundOperation.XmlPolling; a.PolledDataAvailableStatement = "select count(1) from data"; a.PollingStatement = "select * from data for XML"; a.PollingInterval = TimeSpan.FromHours(2); a.PollWhileDataFound = true; }); l.Transport.Host = Host.RECEIVING_HOST; })); }), TaxAgencyOneWayReceivePort = new TaxAgencyReceivePort()); SendPorts.Add( BankOneWaySendPort = new BankSendPort(), CustomerTwoWaySendPort = SendPort( p => { p.Name = SendPortName.Towards(Party.Customer).About(MessageName.Statement).FormattedAs.Csv; p.SendPipeline = new SendPipeline <PassThruTransmit>(pl => { pl.PreAssembler <FailedMessageRoutingEnablerComponent>(c => { c.Enabled = false; }); }); p.ReceivePipeline = new ReceivePipeline <PassThruReceive>(pl => { pl.Decoder <FailedMessageRoutingEnablerComponent>(c => { c.Enabled = false; }); }); p.Transport.Adapter = new FileAdapter.Outbound(a => { a.DestinationFolder = @"c:\files\drops"; }); p.Transport.RetryPolicy = RetryPolicy.LongRunning; p.Transport.Host = Host.SENDING_HOST; })); Orchestrations.Add( new ProcessOrchestrationBinding( o => { o.ReceivePort = CustomerOneWayReceivePort; o.RequestResponsePort = CustomerTwoWayReceivePort; o.SendPort = BankOneWaySendPort; o.SolicitResponsePort = CustomerTwoWaySendPort; o.Host = Host.PROCESSING_HOST; })); }