Skip to content

Commit ee5bba9

Browse files
authored
Merge pull request #39 from DEFRA/bug/CDMS-450-missing-routes
Added missing routes and matching tests.
2 parents 406b3fc + 0e8e7dc commit ee5bba9

8 files changed

+173
-11
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Net;
2+
using System.Net.Mime;
3+
using System.Text;
4+
using BtmsGateway.Test.TestUtils;
5+
using FluentAssertions;
6+
7+
namespace BtmsGateway.Test.EndToEnd;
8+
9+
public class DecisionNotificationFromAlvsToIpaffsTests : TargetRoutingTestBase
10+
{
11+
private const string UrlPath = "/soapsearch/pre/sanco/traces_ws/sendALVSDecisionNotification";
12+
13+
private readonly string _alvsRequestSoap = File.ReadAllText(Path.Combine(FixturesPath, "AlvsToIpaffsDecisionNotificationRequest.xml"));
14+
private readonly string _ipaffsResponseSoap = File.ReadAllText(Path.Combine(FixturesPath, "IpaffsResponse.xml"));
15+
private readonly StringContent _alvsRequestSoapContent;
16+
17+
public DecisionNotificationFromAlvsToIpaffsTests()
18+
{
19+
_alvsRequestSoapContent = new StringContent(_alvsRequestSoap, Encoding.UTF8, MediaTypeNames.Application.Soap);
20+
TestWebServer.RoutedHttpHandler.SetNextResponse(content: _ipaffsResponseSoap, statusFunc: () => HttpStatusCode.Accepted);
21+
}
22+
23+
[Fact]
24+
public async Task When_receiving_decision_notification_from_alvs_Then_should_forward_to_ipaffs()
25+
{
26+
await HttpClient.PostAsync(UrlPath, _alvsRequestSoapContent);
27+
28+
TestWebServer.RoutedHttpHandler.LastRequest!.RequestUri!.AbsoluteUri.Should().Be($"http://alvs-ipaffs-host{UrlPath}");
29+
(await TestWebServer.RoutedHttpHandler.LastRequest!.Content!.ReadAsStringAsync()).Should().Be(_alvsRequestSoap);
30+
}
31+
32+
[Fact]
33+
public async Task When_receiving_decision_notification_from_alvs_Then_should_respond_with_ipaffs_response()
34+
{
35+
var response = await HttpClient.PostAsync(UrlPath, _alvsRequestSoapContent);
36+
37+
response.StatusCode.Should().Be(HttpStatusCode.Accepted);
38+
(await response.Content.ReadAsStringAsync()).Should().Be(_ipaffsResponseSoap);
39+
}
40+
41+
}

BtmsGateway.Test/EndToEnd/FinalisationNotificationFromAlvsToIpaffsTests.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class FinalisationNotificationFromAlvsToIpaffsTests : TargetRoutingTestBa
1212

1313
private readonly string _alvsRequestSoap = File.ReadAllText(Path.Combine(FixturesPath, "AlvsToIpaffsFinalisationNotification.xml"));
1414
private readonly string _alvsResponseSoap = File.ReadAllText(Path.Combine(FixturesPath, "IpaffsResponse.xml"));
15-
private readonly string _btmsRequestJson = File.ReadAllText(Path.Combine(FixturesPath, "FinalisationNotification.json")).LinuxLineEndings();
1615
private readonly StringContent _alvsRequestSoapContent;
1716

1817
public FinalisationNotificationFromAlvsToIpaffsTests()
@@ -22,7 +21,7 @@ public FinalisationNotificationFromAlvsToIpaffsTests()
2221
}
2322

2423
[Fact]
25-
public async Task When_receiving_request_from_alvs_Then_should_forward_to_cds()
24+
public async Task When_receiving_request_from_alvs_Then_should_forward_to_ipaffs()
2625
{
2726
await HttpClient.PostAsync(UrlPath, _alvsRequestSoapContent);
2827

@@ -39,12 +38,4 @@ public async Task When_receiving_request_from_alvs_Then_should_respond_with_ipaf
3938
(await response.Content.ReadAsStringAsync()).Should().Be(_alvsResponseSoap);
4039
}
4140

42-
[Fact]
43-
public async Task When_receiving_request_from_alvs_Then_should_forward_converted_json_to_btms()
44-
{
45-
await HttpClient.PostAsync(UrlPath, _alvsRequestSoapContent);
46-
47-
TestWebServer.ForkedHttpHandler.LastRequest!.RequestUri!.AbsoluteUri.Should().Be($"http://btms-host{UrlPath}");
48-
(await TestWebServer.ForkedHttpHandler.LastRequest!.Content!.ReadAsStringAsync()).LinuxLineEndings().Should().Be(_btmsRequestJson);
49-
}
5041
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/">
3+
<NS1:Header/>
4+
<NS1:Body>
5+
<NS2:DecisionNotificationRequestPost xmlns:NS2="traceswsns">
6+
<NS2:XMLSchemaVersion>2.0</NS2:XMLSchemaVersion>
7+
<NS2:UserIdentification>username</NS2:UserIdentification>
8+
<NS2:UserPassword>password</NS2:UserPassword>
9+
<NS2:SendingDate>2025-03-27 11:07</NS2:SendingDate>
10+
<NS2:DecisionNotification xmlns:NS2="traceswsns">
11+
<NS2:ServiceHeader>
12+
<NS2:SourceSystem>ALVS</NS2:SourceSystem>
13+
<NS2:DestinationSystem>CDS</NS2:DestinationSystem>
14+
<NS2:CorrelationId>000</NS2:CorrelationId>
15+
<NS2:ServiceCallTimestamp>2025-03-27T11:07:34.822837</NS2:ServiceCallTimestamp>
16+
</NS2:ServiceHeader>
17+
<NS2:Header>
18+
<NS2:EntryReference>123-123456A-01/01/2025</NS2:EntryReference>
19+
<NS2:EntryVersionNumber>1</NS2:EntryVersionNumber>
20+
<NS2:DecisionNumber>1</NS2:DecisionNumber>
21+
</NS2:Header>
22+
<NS2:Item>
23+
<NS2:ItemNumber>1</NS2:ItemNumber>
24+
<NS2:Check>
25+
<NS2:CheckCode>H222</NS2:CheckCode>
26+
<NS2:DecisionCode>C03</NS2:DecisionCode>
27+
</NS2:Check>
28+
</NS2:Item>
29+
</NS2:DecisionNotification>
30+
</NS2:DecisionNotificationRequestPost>
31+
</NS1:Body>
32+
</NS1:Envelope>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<NS1:Envelope xmlns:NS1="http://www.w3.org/2003/05/soap-envelope">
3+
<NS1:Header/>
4+
<NS1:Body>
5+
<NS2:CertificateRequest xmlns:NS2="traceswsns">
6+
<NS2:XMLSchemaVersion>2.0</NS2:XMLSchemaVersion>
7+
<NS2:UserIdentification>username</NS2:UserIdentification>
8+
<NS2:UserPassword>password</NS2:UserPassword>
9+
<NS2:SendingDate>2025-03-27 11:07</NS2:SendingDate>
10+
<NS2:Request>
11+
<NS2:SearchCriterionCVEDAnimal>
12+
<NS2:ModifiedBetween>
13+
<NS2:StartDate>2025-03-27 11:06</NS2:StartDate>
14+
<NS2:EndDate>2025-03-27 12:06</NS2:EndDate>
15+
</NS2:ModifiedBetween>
16+
<NS2:CountryOfDestination>GB</NS2:CountryOfDestination>
17+
<NS2:FetchAmount>100</NS2:FetchAmount>
18+
</NS2:SearchCriterionCVEDAnimal>
19+
</NS2:Request>
20+
</NS2:CertificateRequest>
21+
</NS1:Body>
22+
</NS1:Envelope>

BtmsGateway.Test/EndToEnd/Fixtures/TargetRoutingConfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@
6060
"MessageBodyDepth": 2,
6161
"RouteTo": "Legacy"
6262
},
63+
"ALVSSearchCertificateToIpaffs": {
64+
"RoutePath": "/soapsearch/pre/sanco/traces_ws/searchCertificate",
65+
"MessageSubXPath": "CertificateRequest/Request",
66+
"Legend": "Legend",
67+
"LegacyLinkName": "AlvsIpaffs",
68+
"BtmsLinkName": "None",
69+
"MessageBodyDepth": 2,
70+
"RouteTo": "Legacy"
71+
},
72+
"ALVSDecisionNotificationToIpaffs": {
73+
"RoutePath": "/soapsearch/pre/sanco/traces_ws/sendALVSDecisionNotification",
74+
"MessageSubXPath": "DecisionNotificationRequestPost/DecisionNotification",
75+
"Legend": "Legend",
76+
"LegacyLinkName": "AlvsIpaffs",
77+
"BtmsLinkName": "None",
78+
"MessageBodyDepth": 2,
79+
"RouteTo": "Legacy"
80+
},
6381
"BTMSDecisionNotificationToCds": {
6482
"RoutePath": "/route/path/btms-cds/decision-notification",
6583
"MessageSubXPath": "DecisionNotification/DecisionNotification",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Net;
2+
using System.Net.Mime;
3+
using System.Text;
4+
using BtmsGateway.Test.TestUtils;
5+
using FluentAssertions;
6+
7+
namespace BtmsGateway.Test.EndToEnd;
8+
9+
public class SearchCertificateFromAlvsToIpaffsTests : TargetRoutingTestBase
10+
{
11+
private const string UrlPath = "/soapsearch/pre/sanco/traces_ws/searchCertificate";
12+
13+
private readonly string _alvsRequestSoap = File.ReadAllText(Path.Combine(FixturesPath, "AlvsToIpaffsSearchCertificateRequest.xml"));
14+
private readonly string _ipaffsResponseSoap = File.ReadAllText(Path.Combine(FixturesPath, "IpaffsResponse.xml"));
15+
private readonly StringContent _alvsRequestSoapContent;
16+
17+
public SearchCertificateFromAlvsToIpaffsTests()
18+
{
19+
_alvsRequestSoapContent = new StringContent(_alvsRequestSoap, Encoding.UTF8, MediaTypeNames.Application.Soap);
20+
TestWebServer.RoutedHttpHandler.SetNextResponse(content: _ipaffsResponseSoap, statusFunc: () => HttpStatusCode.Accepted);
21+
}
22+
23+
[Fact]
24+
public async Task When_receiving_search_certificate_from_alvs_Then_should_forward_to_ipaffs()
25+
{
26+
await HttpClient.PostAsync(UrlPath, _alvsRequestSoapContent);
27+
28+
TestWebServer.RoutedHttpHandler.LastRequest!.RequestUri!.AbsoluteUri.Should().Be($"http://alvs-ipaffs-host{UrlPath}");
29+
(await TestWebServer.RoutedHttpHandler.LastRequest!.Content!.ReadAsStringAsync()).Should().Be(_alvsRequestSoap);
30+
}
31+
32+
[Fact]
33+
public async Task When_receiving_search_certificate_from_alvs_Then_should_respond_with_ipaffs_response()
34+
{
35+
var response = await HttpClient.PostAsync(UrlPath, _alvsRequestSoapContent);
36+
37+
response.StatusCode.Should().Be(HttpStatusCode.Accepted);
38+
(await response.Content.ReadAsStringAsync()).Should().Be(_ipaffsResponseSoap);
39+
}
40+
}

BtmsGateway/appsettings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@
9191
"MessageBodyDepth": 2,
9292
"RouteTo": "Legacy"
9393
},
94+
"ALVSSearchCertificateToIpaffs": {
95+
"RoutePath": "/soapsearch/pre/sanco/traces_ws/searchCertificate",
96+
"MessageSubXPath": "CertificateRequest/Request",
97+
"Legend": "IPAFFS Search Certificate",
98+
"LegacyLinkName": "Stub",
99+
"BtmsLinkName": "ForkedStub",
100+
"MessageBodyDepth": 2,
101+
"RouteTo": "Legacy"
102+
},
103+
"ALVSDecisionNotificationToIpaffs": {
104+
"RoutePath": "/soapsearch/pre/sanco/traces_ws/sendALVSDecisionNotification",
105+
"MessageSubXPath": "DecisionNotificationRequestPost/DecisionNotification",
106+
"Legend": "IPAFFS ALVS Decision Notification",
107+
"LegacyLinkName": "Stub",
108+
"BtmsLinkName": "ForkedStub",
109+
"MessageBodyDepth": 2,
110+
"RouteTo": "Legacy"
111+
},
94112
"test": {
95113
"RoutePath": "/test",
96114
"MessageSubXPath": "",

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The Open Government Licence (OGL) Version 3
22

3-
Copyright (c) 2023 Defra
3+
Copyright (c) 2025 Defra
44

55
This source code is licensed under the Open Government Licence v3.0. To view this
66
licence, visit www.nationalarchives.gov.uk/doc/open-government-licence/version/3

0 commit comments

Comments
 (0)