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

[Service Bus] Admin Client emulator slug #47362

Merged
merged 1 commit into from
Nov 28, 2024
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 @@ -22,6 +22,7 @@ internal class HttpRequestAndResponse
private readonly int _port;
private readonly ClientDiagnostics _diagnostics;
private readonly string _versionQuery;
private readonly string _scheme;

/// <summary>
/// Initializes a new <see cref="HttpRequestAndResponse"/> which can be used to send http request and response.
Expand All @@ -31,14 +32,16 @@ public HttpRequestAndResponse(
ClientDiagnostics diagnostics,
TokenCredential tokenCredential,
string fullyQualifiedNamespace,
ServiceBusAdministrationClientOptions.ServiceVersion version)
ServiceBusAdministrationClientOptions.ServiceVersion version,
bool useTls)
{
_pipeline = pipeline;
_diagnostics = diagnostics;
_versionQuery = $"api-version={version.ToVersionString()}";
_tokenCredential = tokenCredential;
_fullyQualifiedNamespace = fullyQualifiedNamespace;
_port = GetPort(_fullyQualifiedNamespace);
_scheme = useTls ? Uri.UriSchemeHttps : Uri.UriSchemeHttp;
}

internal void ThrowIfRequestFailed(Request request, Response response)
Expand Down Expand Up @@ -171,7 +174,7 @@ public async Task<Response> GetEntityAsync(
Uri uri = new UriBuilder(_fullyQualifiedNamespace)
{
Path = entityPath,
Scheme = Uri.UriSchemeHttps,
Scheme = _scheme,
Port = _port,
Query = queryString
}.Uri;
Expand Down Expand Up @@ -199,7 +202,7 @@ public async Task<Response> PutEntityAsync(
{
Path = entityPath,
Port = _port,
Scheme = Uri.UriSchemeHttps,
Scheme = _scheme,
Query = _versionQuery
}.Uri;
var requestUriBuilder = new RequestUriBuilder();
Expand Down Expand Up @@ -245,7 +248,7 @@ public async Task<Response> DeleteEntityAsync(
Uri uri = new UriBuilder(_fullyQualifiedNamespace)
{
Path = entityPath,
Scheme = Uri.UriSchemeHttps,
Scheme = _scheme,
Port = _port,
Query = _versionQuery
}.Uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,16 @@ public ServiceBusAdministrationClient(
});
_clientDiagnostics = new ClientDiagnostics(options);

// The Service Bus emulator does not support TLS.
var useTls = (!connectionStringProperties.UseDevelopmentEmulator);

_httpRequestAndResponse = new HttpRequestAndResponse(
pipeline,
_clientDiagnostics,
tokenCredential,
_fullyQualifiedNamespace,
options.Version);
options.Version,
useTls);
}

/// <summary>
Expand Down Expand Up @@ -211,7 +215,8 @@ private ServiceBusAdministrationClient(
_clientDiagnostics,
credential,
_fullyQualifiedNamespace,
options.Version);
options.Version,
true);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public RequestResponseTests()
{
var options = new ServiceBusAdministrationClientOptions();
var pipeline = HttpPipelineBuilder.Build(options);
_requestResponse = new HttpRequestAndResponse(pipeline, new ClientDiagnostics(options), null, "fakeNamespace", ServiceBusAdministrationClientOptions.ServiceVersion.V2017_04);
_requestResponse = new HttpRequestAndResponse(pipeline, new ClientDiagnostics(options), null, "fakeNamespace", ServiceBusAdministrationClientOptions.ServiceVersion.V2017_04, true);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Azure.Core.TestFramework.Models;
using Azure.Messaging.ServiceBus.Administration;
using Azure.Messaging.ServiceBus.Authorization;
using Azure.Messaging.ServiceBus.Tests.Infrastructure;
using NUnit.Framework;

namespace Azure.Messaging.ServiceBus.Tests.Management
Expand Down
Loading