-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connection recovery should not try to handle UnauthorizedAccess #221
- Loading branch information
Showing
4 changed files
with
61 additions
and
11 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
37 changes: 37 additions & 0 deletions
37
test/ActiveMQ.Artemis.Client.IntegrationTests/CreateConnectionSpec.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,37 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using ActiveMQ.Artemis.Client.Exceptions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ActiveMQ.Artemis.Client.IntegrationTests | ||
{ | ||
public class CreateConnectionSpec : ActiveMQNetIntegrationSpec | ||
{ | ||
public CreateConnectionSpec(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task Should_throw_security_exception_when_wrong_credentials_provided_and_connection_auto_recovery_enabled() | ||
{ | ||
var defaultEndpoint = GetEndpoint(); | ||
var endpoint = Endpoint.Create( | ||
password: "wrongPassword", | ||
user: defaultEndpoint.User, | ||
host: defaultEndpoint.Host, | ||
port: defaultEndpoint.Port, | ||
scheme: defaultEndpoint.Scheme | ||
); | ||
|
||
var connectionFactory = new ConnectionFactory | ||
{ | ||
AutomaticRecoveryEnabled = true | ||
}; | ||
|
||
var createConnectionException = await Assert.ThrowsAnyAsync<CreateConnectionException>(() => connectionFactory.CreateAsync(endpoint)); | ||
Assert.Equal("amqp:unauthorized-access", createConnectionException.ErrorCode); | ||
} | ||
} | ||
} |