Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TranslateEndpointDescriptions functionality #2495

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cases which try to access using a configured AlternateBaseUrl are again failing, because there is no simple way to match them against an internal endpoint. We need to document that alternateBaseUrl with different port always return no matching endpoint, so the configuration should not be used.

[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
Loading