Skip to content

Commit

Permalink
Fix TranslateEndpointDescriptions (#2495)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsuciu authored Feb 6, 2024
1 parent 8a7901d commit d573eaa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Stack/Opc.Ua.Core/Stack/Server/ServerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ protected EndpointDescriptionCollection TranslateEndpointDescriptions(
continue;
}

if (endpointUrl.Scheme != baseAddress.Url.Scheme)
if ((endpointUrl.Scheme != baseAddress.Url.Scheme) || (endpointUrl.Port != baseAddress.Url.Port))
{
continue;
}
Expand Down
13 changes: 8 additions & 5 deletions Tests/Opc.Ua.Core.Tests/Stack/Server/ServerBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,19 @@ public void FilterByClientUrlTest(string endpointUrl, int baseAddressCount = Bas
/// </summary>
[Test]
[TestCase("opc.tcp://localhost:51210/UA/SampleServer")]
[TestCase("opc.tcp://externalhostname.com:50001/UA/SampleServer", 6)]
[TestCase("opc.tcp://externalhostname.com:52541/UA/SampleServer", 6)]
[TestCase("opc.tcp://externalhostname.com:50001/UA/SampleServer", 0)]
[TestCase("opc.tcp://externalhostname.com:52541/UA/SampleServer", 0)]
// [TestCase("opc.tcp://[fe80:1234::8]:51210/UA/SampleServer", 4)]
// [TestCase("opc.tcp://[fe80:1234::8%3]:51210/UA/SampleServer", 4)]
[TestCase("opc.tcp://[2003:d9:1f0c:5e00:4139:ee31:6cc3:313e]:62541/UA/SampleServer", 6)]
[TestCase("opc.tcp://myhostname.com:51210/UA/SampleServer", 6)]
[TestCase("opc.tcp://UNKNOWNHOSTNAME.COM:51210/UA/SampleServer", 4)]
[TestCase("opc.tcp://EXTERNALHOSTNAME.COM:51210/UA/SampleServer", 6)]
[TestCase("opc.tcp://EXTERNALHOSTNAME.COM:51210/UA/SampleServer", 0)]
[TestCase("opc.tcp://localhost:51210/UA/SampleServer")]
[TestCase("opc.tcp://someserver:62541/UA/SampleServer", 4)]
[TestCase("opc.tcp://192.168.1.100:62541/UA/SampleServer", 6)]
[TestCase("opc.tcp:someserver:62541:UA:SampleServer", 4)]
[TestCase("opc.https://externalhostname.com:50000/UA/SampleServer", 6)]
[TestCase("opc.https://externalhostname.com:50000/UA/SampleServer", 0)]
[TestCase("opc.https://localhost:51210/UA/SampleServer")]
[TestCase("opc.https://someserver:62541/UA/SampleServer", 4)]
[TestCase("opc.https://someserver:62540/UA/SampleServer", 4)]
Expand All @@ -257,7 +257,10 @@ public void TranslateEndpointDescriptionsTest(string endpointUrl, int count = En
Assert.Greater(BaseAddressCount, 0);
var translatedEndpoints = this.TranslateEndpointDescriptions(parsedEndpointUrl, baseAddresses, m_endpoints, m_serverDescription);
Assert.NotNull(translatedEndpoints);
Assert.Greater(translatedEndpoints.Count, 0);
if (count > 0)
{
Assert.Greater(translatedEndpoints.Count, 0);
}
foreach (var endpoint in translatedEndpoints)
{
TestContext.WriteLine($"Endpoint: {endpoint.EndpointUrl} {endpoint.SecurityMode} {endpoint.SecurityPolicyUri}");
Expand Down

0 comments on commit d573eaa

Please sign in to comment.