-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EndpointCollection.TryGetEndpointByAddress and ReadOnlyEndpointCollec…
…tion.TryGetEndpointByAddress now ignore query strings in endpoint URIs to enable endpoint credentials to be found despite additional query string parameters that may be supplied in Origination, Destination, or ReplyTo headers.
- Loading branch information
1 parent
2419b54
commit 4848f7f
Showing
10 changed files
with
122 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Source/Platibus.UnitTests/EndpointAddressEqualityComparerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
| ||
using System; | ||
using NUnit.Framework; | ||
|
||
namespace Platibus.UnitTests | ||
{ | ||
public class EndpointAddressEqualityComparerTests | ||
{ | ||
[Test] | ||
public void IdenticalEndpointAddressesShouldBeEqual() | ||
{ | ||
var address1 = new Uri("http://test.example.com:8080/platibus/"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus/"); | ||
Assert.That(address1, Is.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesShouldBeEqualWithoutTerminatingPathSeparator() | ||
{ | ||
var address1 = new Uri("http://test.example.com:8080/platibus"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus/"); | ||
Assert.That(address1, Is.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesWithDifferentQueryStringsShouldBeEqual() | ||
{ | ||
var address1 = new Uri("http://test.example.com:8080/platibus/"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus/?test=true"); | ||
Assert.That(address1, Is.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesShouldBeEqualWithDifferentQueryStringsAndWithoutTerminatingPathSeparator() | ||
{ | ||
var address1 = new Uri("http://test.example.com:8080/platibus"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus/?test=true"); | ||
Assert.That(address1, Is.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesWithDifferentHostsShouldNotBeEqual() | ||
{ | ||
var address1 = new Uri("http://test1.example.com:8080/platibus/"); | ||
var address2 = new Uri("http://test2.example.com:8080/platibus/"); | ||
Assert.That(address1, Is.Not.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesWithDifferentSchemesShouldNotBeEqual() | ||
{ | ||
var address1 = new Uri("https://test.example.com:8080/platibus/"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus/"); | ||
Assert.That(address1, Is.Not.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesWithDifferentPathsShouldNotBeEqual() | ||
{ | ||
var address1 = new Uri("http://test.example.com:8080/platibus1/"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus2/"); | ||
Assert.That(address1, Is.Not.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
|
||
[Test] | ||
public void EndpointAddressesWithDifferentAuthoritiesShouldNotBeEqual() | ||
{ | ||
var address1 = new Uri("http://user:[email protected]:8080/platibus1/"); | ||
var address2 = new Uri("http://test.example.com:8080/platibus2/"); | ||
Assert.That(address1, Is.Not.EqualTo(address2).Using(new EndpointAddressEqualityComparer())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Platibus | ||
{ | ||
/// <summary> | ||
/// Determines the equality of two endpoints based on the left part of their respective address URIs | ||
/// </summary> | ||
public class EndpointAddressEqualityComparer : IEqualityComparer<Uri> | ||
{ | ||
public bool Equals(Uri x, Uri y) | ||
{ | ||
if (ReferenceEquals(x, y)) return true; | ||
if (ReferenceEquals(null, x)) return false; | ||
if (ReferenceEquals(null, y)) return false; | ||
return string.Equals( | ||
x.GetLeftPart(UriPartial.Path).TrimEnd('/'), | ||
y.GetLeftPart(UriPartial.Path).TrimEnd('/'), | ||
StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public int GetHashCode(Uri obj) | ||
{ | ||
return obj == null ? 0 : obj | ||
.GetLeftPart(UriPartial.Path).TrimEnd('/') | ||
.ToLower() | ||
.GetHashCode(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
|
||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion("2.1.9.0")] | ||
[assembly: AssemblyVersion("2.1.10.0")] |