private void SetupPmodes() { ReceivingBasePmode = new ReceivingBasePmode() { Name = "test1", Type = PmodeType.Receiving }; SendingBasePmode = new SendingBasePmode() { Name = "test2", Type = PmodeType.Sending }; ReceivingPmodes = new List <ReceivingBasePmode> { ReceivingBasePmode }; SendingPmodes = new List <SendingBasePmode> { SendingBasePmode }; Source.GetReceivingNames().Returns(ReceivingPmodes.Select(pmode => pmode.Name)); Source.GetReceivingByName(Arg.Is(ReceivingBasePmode.Name)).Returns(ReceivingBasePmode); Source.GetSendingNames().Returns(SendingPmodes.Select(pmode => pmode.Name)); Source.GetSendingByName(Arg.Is(SendingBasePmode.Name)).Returns(SendingBasePmode); }
public void IsDynamicDiscoveryEnabled_False_When_PushConfiguration_Is_Not_Null() { var pmode = new SendingBasePmode { Pmode = new SendingProcessingMode() { PushConfiguration = new PushConfiguration() } }; Assert.False(pmode.IsDynamicDiscoveryEnabled); }
public async Task Throws_Exception_When_A_Pmode_With_The_New_Name_Already_Exists() { // Setup var test = Setup(); var newPmode = new SendingBasePmode() { Name = SendingBasePmode.Name }; // Act await Assert.ThrowsAsync <AlreadyExistsException>(() => test.Service.UpdateSending(newPmode, "NEW")); }
/// <summary> /// Create sending pmode /// </summary> /// <param name="basePmode">The pmode to create.</param> /// <returns></returns> /// <exception cref="Eu.EDelivery.AS4.Fe.AlreadyExistsException"> /// Exception thrown when a pmode with the supplied name /// already exists /// </exception> public async Task CreateSending(SendingBasePmode basePmode) { EnsureArg.IsNotNull(basePmode, nameof(basePmode)); var exists = await source.GetSendingByName(basePmode.Name); if (exists != null) { throw new AlreadyExistsException($"BasePmode with name {basePmode.Name} already exists."); } ValidateSendingPmode(basePmode); await source.CreateSending(basePmode); }
/// <summary> /// Validates the sending pmode. /// </summary> /// <param name="sendingPmode">The sending pmode.</param> /// <exception cref="InvalidPModeException">Invalid PMode</exception> private void ValidateSendingPmode(SendingBasePmode sendingPmode) { if (disableValidation) { return; } var result = SendingProcessingModeValidator.Instance.Validate(sendingPmode.Pmode); if (!result.IsValid) { throw new InvalidPModeException("Invalid PMode", result); } }
/// <summary> /// Creates the sending. /// </summary> /// <param name="basePmode">The base pmode.</param> /// <returns></returns> public async Task CreateSending(SendingBasePmode basePmode) { string fileName = FilterOutInvalidFileNameChars(basePmode.Name); string pmodeFile = Path.Combine(_settings.Value.SendingPmodeFolder, fileName + ".xml"); if (File.Exists(pmodeFile)) { pmodeFile = Path.Combine(_settings.Value.SendingPmodeFolder, fileName + "-" + Guid.NewGuid() + ".xml"); } string pmodeString = await AS4XmlSerializer.ToStringAsync(basePmode.Pmode); File.WriteAllText(pmodeFile, pmodeString); }
public void IsDynamicDiscoveryEnabled_True_Will_Set_PushConfigurationNode_To_Null() { var pmode = new SendingBasePmode { Pmode = new SendingProcessingMode { PushConfiguration = new PushConfiguration() }, IsDynamicDiscoveryEnabled = true }; Assert.Null(pmode.Pmode.PushConfiguration); }
public async Task Updates_Existing() { // Setup var test = Setup(); var newPmode = new SendingBasePmode() { Name = "NEW" }; // Act await test.Service.UpdateSending(newPmode, SendingBasePmode.Name); // Assert await test.Source.UpdateSending(Arg.Is <SendingBasePmode>(x => x.Name == "NEW"), Arg.Is(SendingBasePmode.Name)); }
public async Task Creates_The_Pmode() { // Setup var test = Setup(); var pmode = new SendingBasePmode() { Name = "newPmode" }; // Act await test.Service.CreateSending(pmode); // Assert await test.Source.Received().CreateSending(Arg.Is <SendingBasePmode>(x => x.Name == pmode.Name)); }
public void IsDynamicDiscoveryEnabled_Is_True_Then_PushConfiguration_Is_Null() { var pmode = new SendingBasePmode { Pmode = new SendingProcessingMode { PushConfiguration = new PushConfiguration(), DynamicDiscovery = new DynamicDiscoveryConfiguration() }, IsDynamicDiscoveryEnabled = true }; Assert.Null(pmode.Pmode.PushConfiguration); Assert.NotNull(pmode.Pmode.DynamicDiscovery); }
/// <summary> /// Update sending pmode /// </summary> /// <param name="basePmode">Date to update the sending pmode with</param> /// <param name="originalName">Name of the original.</param> /// <returns></returns> /// <exception cref="Eu.EDelivery.AS4.Fe.AlreadyExistsException"> /// Exception thrown when a sending pmode with the supplied /// name already exists /// </exception> public async Task UpdateSending(SendingBasePmode basePmode, string originalName) { EnsureArg.IsNotNull(basePmode, nameof(basePmode)); EnsureArg.IsNotNullOrEmpty(originalName, nameof(originalName)); if (basePmode.Name != originalName) { var newExists = await GetSendingByName(basePmode.Name); if (newExists != null) { throw new AlreadyExistsException($"BasePmode with {originalName} already exists"); } } ValidateSendingPmode(basePmode); await source.UpdateSending(basePmode, originalName); }
public void Contains_TlsConfiguration_When_Present_As_Json() { var certFindCriteria = new ClientCertificateReference { ClientCertificateFindType = X509FindType.FindBySubjectName, ClientCertificateFindValue = "subject" }; var pmode = new SendingBasePmode { Pmode = new SendingProcessingMode { PushConfiguration = new PushConfiguration { TlsConfiguration = { IsEnabled = true, ClientCertificateInformation = JObject.FromObject(certFindCriteria) } } } }; Assert.IsType <ClientCertificateReference>(pmode.Pmode.PushConfiguration.TlsConfiguration.ClientCertificateInformation); }
/// <summary> /// Updates the sending. /// </summary> /// <param name="basePmode">The base pmode.</param> /// <param name="originalName">Name of the original.</param> /// <returns></returns> public async Task UpdateSending(SendingBasePmode basePmode, string originalName) { await CreateSending(basePmode); File.Delete(_config.GetFileLocationForSendingPMode(originalName)); }
public async Task UpdateSending([FromBody] SendingBasePmode basePmode, string originalName) { await pmodeService.UpdateSending(basePmode, originalName); }
public async Task CreateSending([FromBody] SendingBasePmode basePmode) { await pmodeService.CreateSending(basePmode); }