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

ServiceBus API renaming from PR suggestions #6578

Merged
merged 2 commits into from
Jun 13, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyN
/// <param name="authority">URL of the Azure Active Directory instance to issue token.</param>
/// <param name="state">Custom parameters that may be passed into the authentication delegate.</param>
/// <returns>The <see cref="Microsoft.ServiceBus.TokenProvider" /> for returning Json web token.</returns>
public static TokenProvider CreateAadTokenProvider(
public static TokenProvider CreateAzureActiveDirectoryTokenProvider(
AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback,
string authority = AzureActiveDirectoryTokenProvider.CommonAuthority,
object state = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public string SasToken
public TimeSpan OperationTimeout { get; set; } = Constants.DefaultOperationTimeout;

/// <summary>
/// Enables Azure Active Directory Managed Identity authentication when set to AuthenticationType.ManagedIdentity
/// Enables Azure Active Directory Managed Identity authentication when set to ServiceBusConnectionStringBuilder.AuthenticationType.ManagedIdentity
/// </summary>
public string Authentication
{
Expand All @@ -252,12 +252,14 @@ public string Authentication
{
if (!string.IsNullOrWhiteSpace(this.SasKeyName))
{
throw Fx.Exception.Argument("Authentication, SharedAccessKeyName", Resources.ArgumentInvalidCombination.FormatForUser("Authentication, SharedAccessKeyName"));
throw Fx.Exception.Argument(nameof(AuthenticationConfigName) + ", " + nameof(SharedAccessKeyConfigName),
Resources.ArgumentInvalidCombination.FormatForUser(nameof(AuthenticationConfigName) + ", " + nameof(SharedAccessKeyConfigName)));
}

if (!string.IsNullOrWhiteSpace(this.SasToken))
{
throw Fx.Exception.Argument("Authentication, SharedAccessSignature", Resources.ArgumentInvalidCombination.FormatForUser("Authentication, SharedAccessSignature"));
throw Fx.Exception.Argument(nameof(AuthenticationConfigName) + ", " + nameof(SharedAccessKeyConfigName),
Resources.ArgumentInvalidCombination.FormatForUser(nameof(AuthenticationConfigName) + ", " + nameof(SharedAccessKeyConfigName)));
}
this.authType = value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ namespace Microsoft.Azure.ServiceBus.Primitives
public abstract class TokenProvider : Microsoft.Azure.ServiceBus.Primitives.ITokenProvider
{
protected TokenProvider() { }
public static Microsoft.Azure.ServiceBus.Primitives.TokenProvider CreateAadTokenProvider(Microsoft.Azure.ServiceBus.Primitives.AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback, string authority = "https://login.microsoftonline.com/common", object state = null) { }
public static Microsoft.Azure.ServiceBus.Primitives.TokenProvider CreateAzureActiveDirectoryTokenProvider(Microsoft.Azure.ServiceBus.Primitives.AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback, string authority = "https://login.microsoftonline.com/common", object state = null) { }
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

public static Microsoft.Azure.ServiceBus.Primitives.TokenProvider CreateManagedIdentityTokenProvider() { }
public static Microsoft.Azure.ServiceBus.Primitives.TokenProvider CreateSharedAccessSignatureTokenProvider(string sharedAccessSignature) { }
public static Microsoft.Azure.ServiceBus.Primitives.TokenProvider CreateSharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,11 @@ await ServiceBusScope.UsingQueueAsync(partitioned: false, sessionEnabled: false,
});
}

[Fact]
public void InvalidAadConnectionStringTest()
[Theory]
[InlineData("Endpoint=sb://test.servicebus.windows.net/;authentication=Managed Identity;SHAREDACCESSKEYNAME=val")]
[InlineData("Endpoint=sb://test.servicebus.windows.net/;AUTHENTICATION=Managed Identity;SharedAccessSignature=sig")]
public void InvalidAzureActiveDirectoryTokenProviderConnectionStringTest(string connectionString)
{
var connectionString = "Endpoint=sb://test.servicebus.windows.net/;authentication=Managed Identity;SHAREDACCESSKEYNAME=val";
Assert.Throws<ArgumentException>(() => new ServiceBusConnectionStringBuilder(connectionString));

connectionString = "Endpoint=sb://test.servicebus.windows.net/;AUTHENTICATION=Managed Identity;SharedAccessSignature=sig";
Assert.Throws<ArgumentException>(() => new ServiceBusConnectionStringBuilder(connectionString));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ await ServiceBusScope.UsingQueueAsync(partitioned: false, sessionEnabled: false,
}

[Fact]
public async Task AadAuthCallback()
public async Task AzureActiveDirectoryTokenProviderAuthCallbackTest()
{
string TestToken = @"eyJhbGciOiJIUzI1NiJ9.e30.ZRrHA1JJJW8opsbCGfG_HACGpVUMN_a9IV7pAx_Zmeo";
string ServiceBusAudience = "https://servicebus.azure.net";

var aadTokenProvider = TokenProvider.CreateAadTokenProvider(
var aadTokenProvider = TokenProvider.CreateAzureActiveDirectoryTokenProvider(
(audience, authority, state) =>
{
Assert.Equal(ServiceBusAudience, audience);
Expand Down