From 029ea8da296c0b6121dc62e1d212019d1b872b8c Mon Sep 17 00:00:00 2001 From: Jesse Squire Date: Fri, 30 Oct 2020 08:29:22 -0400 Subject: [PATCH] [Event Hubs Client] Hide Shared Key Credential (#16429) The focus of these changes is to hide the shared key credential. The credential types will be retired when the concept is added to Azure.Core, and the client constructors are converted over to the shared types. --- ...ging.EventHubs.Processor.netstandard2.0.cs | 1 - ...Azure.Messaging.EventHubs.Processor.csproj | 1 + .../src/EventProcessorClient.cs | 16 +++++++------- .../EventProcessorClientLiveTests.cs | 7 +++++-- .../Processor/EventProcessorClientTests.cs | 20 +++++++++++++----- ...zure.Messaging.EventHubs.netstandard2.0.cs | 21 ------------------- .../EventHubsSharedAccessKeyCredential.cs | 2 +- .../src/Consumer/EventHubConsumerClient.cs | 10 ++++----- .../src/EventHubConnection.cs | 14 ++++++------- .../Primitives/EventProcessor{TPartition}.cs | 12 +++++------ .../src/Primitives/PartitionReceiver.cs | 14 ++++++------- .../src/Producer/EventHubProducerClient.cs | 8 +++---- .../Connection/EventHubConnectionTests.cs | 20 +++++++++--------- .../tests/Primitives/EventProcessorTests.cs | 12 +++++------ 14 files changed, 76 insertions(+), 82 deletions(-) diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/api/Azure.Messaging.EventHubs.Processor.netstandard2.0.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/api/Azure.Messaging.EventHubs.Processor.netstandard2.0.cs index ff8ed3c52970..a5aa8f6c0c14 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/api/Azure.Messaging.EventHubs.Processor.netstandard2.0.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/api/Azure.Messaging.EventHubs.Processor.netstandard2.0.cs @@ -7,7 +7,6 @@ public EventProcessorClient(Azure.Storage.Blobs.BlobContainerClient checkpointSt public EventProcessorClient(Azure.Storage.Blobs.BlobContainerClient checkpointStore, string consumerGroup, string connectionString, Azure.Messaging.EventHubs.EventProcessorClientOptions clientOptions) { } public EventProcessorClient(Azure.Storage.Blobs.BlobContainerClient checkpointStore, string consumerGroup, string connectionString, string eventHubName) { } public EventProcessorClient(Azure.Storage.Blobs.BlobContainerClient checkpointStore, string consumerGroup, string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.EventProcessorClientOptions clientOptions = null) { } - public EventProcessorClient(Azure.Storage.Blobs.BlobContainerClient checkpointStore, string consumerGroup, string fullyQualifiedNamespace, string eventHubName, Azure.Messaging.EventHubs.EventHubsSharedAccessKeyCredential credential, Azure.Messaging.EventHubs.EventProcessorClientOptions clientOptions = null) { } public EventProcessorClient(Azure.Storage.Blobs.BlobContainerClient checkpointStore, string consumerGroup, string connectionString, string eventHubName, Azure.Messaging.EventHubs.EventProcessorClientOptions clientOptions) { } public new string ConsumerGroup { get { throw null; } } public new string EventHubName { get { throw null; } } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj index d96374d26b55..4295b484d845 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj @@ -44,6 +44,7 @@ + diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs index 470b2bf4403c..d400e46c8b09 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs @@ -421,13 +421,14 @@ public EventProcessorClient(BlobContainerClient checkpointStore, /// does not assume the ability to manage the storage account and is safe to run with only read/write permission for blobs in the container. /// /// - public EventProcessorClient(BlobContainerClient checkpointStore, - string consumerGroup, - string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventProcessorClientOptions clientOptions = default) : base((clientOptions ?? DefaultClientOptions).CacheEventCount, consumerGroup, fullyQualifiedNamespace, eventHubName, credential, CreateOptions(clientOptions)) + internal EventProcessorClient(BlobContainerClient checkpointStore, + string consumerGroup, + string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventProcessorClientOptions clientOptions = default) : base((clientOptions ?? DefaultClientOptions).CacheEventCount, consumerGroup, fullyQualifiedNamespace, eventHubName, (TokenCredential)(object)credential, CreateOptions(clientOptions)) { + // TODO: Update the credential type and base class constructor invocation. Argument.AssertNotNull(checkpointStore, nameof(checkpointStore)); StorageManager = CreateStorageManager(checkpointStore); } @@ -481,8 +482,9 @@ internal EventProcessorClient(StorageManager storageManager, string eventHubName, int cacheEventCount, EventHubsSharedAccessKeyCredential credential, - EventProcessorOptions clientOptions) : base(cacheEventCount, consumerGroup, fullyQualifiedNamespace, eventHubName, credential, clientOptions) + EventProcessorOptions clientOptions) : base(cacheEventCount, consumerGroup, fullyQualifiedNamespace, eventHubName, (TokenCredential)(object)credential, clientOptions) { + // TODO: Update the credential type and base class constructor invocation. Argument.AssertNotNull(storageManager, nameof(storageManager)); DefaultStartingPosition = (clientOptions?.DefaultStartingPosition ?? DefaultStartingPosition); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientLiveTests.cs index cf513a24b803..f83add6dff32 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientLiveTests.cs @@ -139,6 +139,7 @@ public async Task EventsCanBeReadByOneProcessorClientUsingAnIdentityCredential() /// /// [Test] + [Ignore("Waiting on Azure.Core shared key credential")] public async Task EventsCanBeReadByOneProcessorClientUsingTheSharedKeyCredential() { // Setup the environment. @@ -543,8 +544,9 @@ private EventProcessorClient CreateProcessorWithSharedAccessKey(string consumerG StorageManager storageManager = default, EventProcessorOptions options = default) { + // TODO: Update the credential type and connection construction. var credential = new EventHubsSharedAccessKeyCredential(EventHubsTestEnvironment.Instance.SharedAccessKeyName, EventHubsTestEnvironment.Instance.SharedAccessKey); - EventHubConnection createConnection() => new EventHubConnection(EventHubsTestEnvironment.Instance.FullyQualifiedNamespace, eventHubName, credential); + EventHubConnection createConnection() => null; //new EventHubConnection(EventHubsTestEnvironment.Instance.FullyQualifiedNamespace, eventHubName, credential); storageManager ??= new InMemoryStorageManager(_=> {}); return new TestEventProcessorClient(storageManager, consumerGroup, EventHubsTestEnvironment.Instance.FullyQualifiedNamespace, eventHubName, credential, createConnection, options); @@ -654,8 +656,9 @@ internal TestEventProcessorClient(StorageManager storageManager, string eventHubName, EventHubsSharedAccessKeyCredential credential, Func connectionFactory, - EventProcessorOptions options) : base(storageManager, consumerGroup, fullyQualifiedNamespace, eventHubName, 100, credential, options) + EventProcessorOptions options) : base(storageManager, consumerGroup, fullyQualifiedNamespace, eventHubName, 100, (TokenCredential)(object)credential, options) { + // TODO: Update the credential type and base class constructor invocation. InjectedConnectionFactory = connectionFactory; } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientTests.cs index 053781ca4f96..4d268db208f9 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientTests.cs @@ -38,7 +38,9 @@ public void ConstructorsValidateTheConsumerGroup(string consumerGroup) { Assert.That(() => new EventProcessorClient(Mock.Of(), consumerGroup, "dummyConnection", new EventProcessorClientOptions()), Throws.InstanceOf(), "The connection string constructor should validate the consumer group."); Assert.That(() => new EventProcessorClient(Mock.Of(), consumerGroup, "dummyNamespace", "dummyEventHub", Mock.Of(), new EventProcessorClientOptions()), Throws.InstanceOf(), "The token credential constructor should validate the consumer group."); - Assert.That(() => new EventProcessorClient(Mock.Of(), consumerGroup, "dummyNamespace", "dummyEventHub", new EventHubsSharedAccessKeyCredential("key", "value"), new EventProcessorClientOptions()), Throws.InstanceOf(), "The shared key credential constructor should validate the consumer group."); + + // TODO: Update the credential type and uncomment. + //Assert.That(() => new EventProcessorClient(Mock.Of(), consumerGroup, "dummyNamespace", "dummyEventHub", new EventHubsSharedAccessKeyCredential("key", "value"), new EventProcessorClientOptions()), Throws.InstanceOf(), "The shared key credential constructor should validate the consumer group."); } /// @@ -53,7 +55,9 @@ public void ConstructorsValidateTheBlobContainerClient() Assert.That(() => new EventProcessorClient(null, "consumerGroup", fakeConnection, new EventProcessorClientOptions()), Throws.InstanceOf(), "The connection string constructor should validate the blob container client."); Assert.That(() => new EventProcessorClient(null, "consumerGroup", "dummyNamespace", "dummyEventHub", Mock.Of(), new EventProcessorClientOptions()), Throws.InstanceOf(), "The token credential constructor should validate the blob container client."); - Assert.That(() => new EventProcessorClient(null, "consumerGroup", "dummyNamespace", "dummyEventHub", new EventHubsSharedAccessKeyCredential("key", "value"), new EventProcessorClientOptions()), Throws.InstanceOf(), "The shared key credential constructor should validate the blob container client."); + + // TODO: Update the credential type and uncomment. + //Assert.That(() => new EventProcessorClient(null, "consumerGroup", "dummyNamespace", "dummyEventHub", new EventHubsSharedAccessKeyCredential("key", "value"), new EventProcessorClientOptions()), Throws.InstanceOf(), "The shared key credential constructor should validate the blob container client."); } /// @@ -80,7 +84,9 @@ public void ConstructorsValidateTheConnectionString(string connectionString) public void ConstructorValidatesTheNamespace(string constructorArgument) { Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, constructorArgument, "dummy", Mock.Of()), Throws.InstanceOf(), "The token credential should validate."); - Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, constructorArgument, "dummy", new EventHubsSharedAccessKeyCredential("key", "value")), Throws.InstanceOf(), "The shared key credential should validate."); + + // TODO: Update the credential type and uncomment. + //Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, constructorArgument, "dummy", new EventHubsSharedAccessKeyCredential("key", "value")), Throws.InstanceOf(), "The shared key credential should validate."); } /// @@ -93,7 +99,9 @@ public void ConstructorValidatesTheNamespace(string constructorArgument) public void ConstructorValidatesTheEventHub(string constructorArgument) { Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, "namespace", constructorArgument, Mock.Of()), Throws.InstanceOf(), "The token credential should validate."); - Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, "namespace", constructorArgument, new EventHubsSharedAccessKeyCredential("key", "value")), Throws.InstanceOf(), "The shared key credential should validate."); + + // TODO: Update the credential type and uncomment. + //Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, "namespace", constructorArgument, new EventHubsSharedAccessKeyCredential("key", "value")), Throws.InstanceOf(), "The shared key credential should validate."); } /// @@ -104,7 +112,9 @@ public void ConstructorValidatesTheEventHub(string constructorArgument) public void ConstructorValidatesTheCredential() { Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, "namespace", "hubName", default(TokenCredential)), Throws.ArgumentNullException, "The token credential should validate."); - Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, "namespace", "hubName", default(EventHubsSharedAccessKeyCredential)), Throws.ArgumentNullException, "The shared key credential should validate."); + + // TODO: Update the credential type and uncomment. + //Assert.That(() => new EventProcessorClient(Mock.Of(), EventHubConsumerClient.DefaultConsumerGroupName, "namespace", "hubName", default(EventHubsSharedAccessKeyCredential)), Throws.ArgumentNullException, "The shared key credential should validate."); } /// diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/api/Azure.Messaging.EventHubs.netstandard2.0.cs b/sdk/eventhub/Azure.Messaging.EventHubs/api/Azure.Messaging.EventHubs.netstandard2.0.cs index 34074c03f942..7db02027a063 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/api/Azure.Messaging.EventHubs.netstandard2.0.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/api/Azure.Messaging.EventHubs.netstandard2.0.cs @@ -34,7 +34,6 @@ public EventHubConnection(string connectionString, Azure.Messaging.EventHubs.Eve public EventHubConnection(string connectionString, string eventHubName) { } public EventHubConnection(string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.EventHubConnectionOptions connectionOptions = null) { } public EventHubConnection(string connectionString, string eventHubName, Azure.Messaging.EventHubs.EventHubConnectionOptions connectionOptions) { } - public EventHubConnection(string fullyQualifiedNamespace, string eventHubName, Azure.Messaging.EventHubs.EventHubsSharedAccessKeyCredential credential, Azure.Messaging.EventHubs.EventHubConnectionOptions connectionOptions = null) { } public string EventHubName { get { throw null; } } public string FullyQualifiedNamespace { get { throw null; } } public bool IsClosed { get { throw null; } } @@ -145,22 +144,6 @@ protected EventHubsRetryPolicy() { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } - public sealed partial class EventHubsSharedAccessKeyCredential - { - public EventHubsSharedAccessKeyCredential(string sharedAccessSignature) { } - public EventHubsSharedAccessKeyCredential(string sharedAccessKeyName, string sharedAccessKey) { } - public string SharedAccessKey { get { throw null; } } - public string SharedAccessKeyName { get { throw null; } } - public string SharedAccessSignature { get { throw null; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override string ToString() { throw null; } - public void UpdateSharedAccessKey(string keyName, string keyValue) { } - public void UpdateSharedAccessSignature(string sharedAccessSignature) { } - } public enum EventHubsTransportType { AmqpTcp = 0, @@ -196,7 +179,6 @@ public EventHubConsumerClient(string consumerGroup, string connectionString, Azu public EventHubConsumerClient(string consumerGroup, string connectionString, string eventHubName) { } public EventHubConsumerClient(string consumerGroup, string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.Consumer.EventHubConsumerClientOptions clientOptions = null) { } public EventHubConsumerClient(string consumerGroup, string connectionString, string eventHubName, Azure.Messaging.EventHubs.Consumer.EventHubConsumerClientOptions clientOptions) { } - public EventHubConsumerClient(string consumerGroup, string fullyQualifiedNamespace, string eventHubName, Azure.Messaging.EventHubs.EventHubsSharedAccessKeyCredential credential, Azure.Messaging.EventHubs.Consumer.EventHubConsumerClientOptions clientOptions = null) { } public string ConsumerGroup { get { throw null; } } public string EventHubName { get { throw null; } } public string FullyQualifiedNamespace { get { throw null; } } @@ -353,7 +335,6 @@ public EventProcessorPartitionOwnership() { } protected EventProcessor() { } protected EventProcessor(int eventBatchMaximumCount, string consumerGroup, string connectionString, Azure.Messaging.EventHubs.Primitives.EventProcessorOptions options = null) { } protected EventProcessor(int eventBatchMaximumCount, string consumerGroup, string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.Primitives.EventProcessorOptions options = null) { } - protected EventProcessor(int eventBatchMaximumCount, string consumerGroup, string fullyQualifiedNamespace, string eventHubName, Azure.Messaging.EventHubs.EventHubsSharedAccessKeyCredential credential, Azure.Messaging.EventHubs.Primitives.EventProcessorOptions options = null) { } protected EventProcessor(int eventBatchMaximumCount, string consumerGroup, string connectionString, string eventHubName, Azure.Messaging.EventHubs.Primitives.EventProcessorOptions options = null) { } public string ConsumerGroup { get { throw null; } } public string EventHubName { get { throw null; } } @@ -387,7 +368,6 @@ protected PartitionReceiver() { } public PartitionReceiver(string consumerGroup, string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition eventPosition, Azure.Messaging.EventHubs.EventHubConnection connection, Azure.Messaging.EventHubs.Primitives.PartitionReceiverOptions options = null) { } public PartitionReceiver(string consumerGroup, string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition eventPosition, string connectionString, Azure.Messaging.EventHubs.Primitives.PartitionReceiverOptions options = null) { } public PartitionReceiver(string consumerGroup, string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition eventPosition, string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.Primitives.PartitionReceiverOptions options = null) { } - public PartitionReceiver(string consumerGroup, string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition eventPosition, string fullyQualifiedNamespace, string eventHubName, Azure.Messaging.EventHubs.EventHubsSharedAccessKeyCredential credential, Azure.Messaging.EventHubs.Primitives.PartitionReceiverOptions options = null) { } public PartitionReceiver(string consumerGroup, string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition eventPosition, string connectionString, string eventHubName, Azure.Messaging.EventHubs.Primitives.PartitionReceiverOptions options = null) { } public string ConsumerGroup { get { throw null; } } public string EventHubName { get { throw null; } } @@ -507,7 +487,6 @@ public EventHubProducerClient(string connectionString) { } public EventHubProducerClient(string connectionString, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions) { } public EventHubProducerClient(string connectionString, string eventHubName) { } public EventHubProducerClient(string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions = null) { } - public EventHubProducerClient(string fullyQualifiedNamespace, string eventHubName, Azure.Messaging.EventHubs.EventHubsSharedAccessKeyCredential credential, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions = null) { } public EventHubProducerClient(string connectionString, string eventHubName, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions) { } public string EventHubName { get { throw null; } } public string FullyQualifiedNamespace { get { throw null; } } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Authorization/EventHubsSharedAccessKeyCredential.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Authorization/EventHubsSharedAccessKeyCredential.cs index 3964ef651302..ff06d11c0dfc 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Authorization/EventHubsSharedAccessKeyCredential.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Authorization/EventHubsSharedAccessKeyCredential.cs @@ -13,7 +13,7 @@ namespace Azure.Messaging.EventHubs /// Event Hub instance. /// /// - public sealed class EventHubsSharedAccessKeyCredential + internal sealed class EventHubsSharedAccessKeyCredential { /// /// The name of the shared access key to be used for authorization, as diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Consumer/EventHubConsumerClient.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Consumer/EventHubConsumerClient.cs index 48a6f3e8fc5e..8b39cc256271 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Consumer/EventHubConsumerClient.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Consumer/EventHubConsumerClient.cs @@ -225,11 +225,11 @@ public EventHubConsumerClient(string consumerGroup, /// The Event Hubs shared access key credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration. /// A set of options to apply when configuring the consumer. /// - public EventHubConsumerClient(string consumerGroup, - string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventHubConsumerClientOptions clientOptions = default) + internal EventHubConsumerClient(string consumerGroup, + string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventHubConsumerClientOptions clientOptions = default) { Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup)); Argument.AssertWellFormedEventHubsNamespace(fullyQualifiedNamespace, nameof(fullyQualifiedNamespace)); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubConnection.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubConnection.cs index 32011b64db13..5647933412f9 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubConnection.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubConnection.cs @@ -202,13 +202,13 @@ public EventHubConnection(string connectionString, /// The to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration. /// A set of options to apply when configuring the connection. /// - public EventHubConnection(string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventHubConnectionOptions connectionOptions = default) : this(fullyQualifiedNamespace, - eventHubName, - TranslateSharedKeyCredential(credential, fullyQualifiedNamespace, eventHubName, connectionOptions?.TransportType), - connectionOptions) + internal EventHubConnection(string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventHubConnectionOptions connectionOptions = default) : this(fullyQualifiedNamespace, + eventHubName, + TranslateSharedKeyCredential(credential, fullyQualifiedNamespace, eventHubName, connectionOptions?.TransportType), + connectionOptions) { } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/EventProcessor{TPartition}.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/EventProcessor{TPartition}.cs index 0512721dcfb9..0c3ba737d86a 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/EventProcessor{TPartition}.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/EventProcessor{TPartition}.cs @@ -328,12 +328,12 @@ protected EventProcessor(int eventBatchMaximumCount, /// The Event Hubs shared access key credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration. /// The set of options to use for the processor. /// - protected EventProcessor(int eventBatchMaximumCount, - string consumerGroup, - string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventProcessorOptions options = default) + internal EventProcessor(int eventBatchMaximumCount, + string consumerGroup, + string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventProcessorOptions options = default) { Argument.AssertInRange(eventBatchMaximumCount, 1, int.MaxValue, nameof(eventBatchMaximumCount)); Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup)); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/PartitionReceiver.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/PartitionReceiver.cs index fef7fac9cb18..5ff839d7e5a8 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/PartitionReceiver.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/PartitionReceiver.cs @@ -214,13 +214,13 @@ public PartitionReceiver(string consumerGroup, /// The Event Hubs shared key credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration. /// A set of options to apply when configuring the client. /// - public PartitionReceiver(string consumerGroup, - string partitionId, - EventPosition eventPosition, - string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - PartitionReceiverOptions options = default) + internal PartitionReceiver(string consumerGroup, + string partitionId, + EventPosition eventPosition, + string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + PartitionReceiverOptions options = default) { Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup)); Argument.AssertNotNullOrEmpty(partitionId, nameof(partitionId)); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs index d8e94e812f88..1def09c7e06d 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs @@ -248,10 +248,10 @@ public EventHubProducerClient(string connectionString, /// The Event Hubs shared access key credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration. /// A set of options to apply when configuring the producer. /// - public EventHubProducerClient(string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventHubProducerClientOptions clientOptions = default) + internal EventHubProducerClient(string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventHubProducerClientOptions clientOptions = default) { Argument.AssertWellFormedEventHubsNamespace(fullyQualifiedNamespace, nameof(fullyQualifiedNamespace)); Argument.AssertNotNullOrEmpty(eventHubName, nameof(eventHubName)); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Connection/EventHubConnectionTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Connection/EventHubConnectionTests.cs index a826e70e1da4..b367e749b561 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Connection/EventHubConnectionTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Connection/EventHubConnectionTests.cs @@ -228,9 +228,9 @@ public void ConstructorValidatesExpandedArgumentsForTokenCredential(string fully [TestCaseSource(nameof(ConstructorSharedKeyCredentialInvalidCases))] public void ConstructorValidatesExpandedArgumentsForSharedKeyCredential(string fullyQualifiedNamespace, string eventHubName, - EventHubsSharedAccessKeyCredential credential) + object credential) { - Assert.That(() => new EventHubConnection(fullyQualifiedNamespace, eventHubName, credential), Throws.InstanceOf()); + Assert.That(() => new EventHubConnection(fullyQualifiedNamespace, eventHubName, (EventHubsSharedAccessKeyCredential)credential), Throws.InstanceOf()); } /// @@ -788,10 +788,10 @@ public ReadableOptionsMock(string fullyQualifiedNamespace, { } - public ReadableOptionsMock(string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventHubConnectionOptions clientOptions = default) : base(fullyQualifiedNamespace, eventHubName, credential, clientOptions) + internal ReadableOptionsMock(string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventHubConnectionOptions clientOptions = default) : base(fullyQualifiedNamespace, eventHubName, credential, clientOptions) { } @@ -823,10 +823,10 @@ public ObservableOperationsMock(string fullyQualifiedNamespace, { } - public ObservableOperationsMock(string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventHubConnectionOptions clientOptions = default) : base(fullyQualifiedNamespace, eventHubName, credential, clientOptions) + internal ObservableOperationsMock(string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventHubConnectionOptions clientOptions = default) : base(fullyQualifiedNamespace, eventHubName, credential, clientOptions) { } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.cs index 4bcd36917a3f..069db98dde66 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.cs @@ -123,12 +123,12 @@ public MinimalProcessorMock(int eventBatchMaximumCount, string eventHubName, EventProcessorOptions options = default) : base(eventBatchMaximumCount, consumerGroup, connectionString, eventHubName, options) { } - public MinimalProcessorMock(int eventBatchMaximumCount, - string consumerGroup, - string fullyQualifiedNamespace, - string eventHubName, - EventHubsSharedAccessKeyCredential credential, - EventProcessorOptions options = default) : base(eventBatchMaximumCount, consumerGroup, fullyQualifiedNamespace, eventHubName, credential, options) { } + internal MinimalProcessorMock(int eventBatchMaximumCount, + string consumerGroup, + string fullyQualifiedNamespace, + string eventHubName, + EventHubsSharedAccessKeyCredential credential, + EventProcessorOptions options = default) : base(eventBatchMaximumCount, consumerGroup, fullyQualifiedNamespace, eventHubName, credential, options) { } public MinimalProcessorMock(int eventBatchMaximumCount, string consumerGroup,