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

Fix #7901: Make methods exposing ConditionalRequestOperations internal, except Set #7911

Merged
merged 3 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -412,7 +412,7 @@ public virtual Response Delete(ConfigurationSetting setting, bool onlyIfUnchange
/// <param name="label">The value used to group configuration settings.</param>
/// <param name="requestOptions"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
public virtual async Task<Response> DeleteAsync(string key, string label, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
internal virtual async Task<Response> DeleteAsync(string key, string label, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _pipeline.Diagnostics.CreateScope("Azure.Data.AppConfiguration.ConfigurationClient.Delete");
scope.AddAttribute("key", key);
Expand Down Expand Up @@ -447,7 +447,7 @@ public virtual async Task<Response> DeleteAsync(string key, string label, Condit
/// <param name="label">The value used to group configuration settings.</param>
/// <param name="requestOptions"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
public virtual Response Delete(string key, string label, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
internal virtual Response Delete(string key, string label, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _pipeline.Diagnostics.CreateScope("Azure.Data.AppConfiguration.ConfigurationClient.Delete");
scope.AddAttribute("key", key);
Expand Down Expand Up @@ -564,7 +564,7 @@ public virtual Response<ConfigurationSetting> Get(ConfigurationSetting setting,
/// <param name="acceptDateTime">The setting will be retrieved exactly as it existed at the provided time.</param>
/// <param name="requestOptions"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
public virtual async Task<Response<ConfigurationSetting>> GetAsync(string key, string label, DateTimeOffset acceptDateTime, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
internal virtual async Task<Response<ConfigurationSetting>> GetAsync(string key, string label, DateTimeOffset acceptDateTime, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _pipeline.Diagnostics.CreateScope("Azure.Data.AppConfiguration.ConfigurationClient.Get");
scope.AddAttribute("key", key);
Expand Down Expand Up @@ -597,7 +597,7 @@ public virtual async Task<Response<ConfigurationSetting>> GetAsync(string key, s
/// <param name="acceptDateTime">The setting will be retrieved exactly as it existed at the provided time.</param>
/// <param name="requestOptions"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
public virtual Response<ConfigurationSetting> Get(string key, string label, DateTimeOffset acceptDateTime, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
AlexanderSher marked this conversation as resolved.
Show resolved Hide resolved
internal virtual Response<ConfigurationSetting> Get(string key, string label, DateTimeOffset acceptDateTime, ConditionalRequestOptions requestOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _pipeline.Diagnostics.CreateScope("Azure.Data.AppConfiguration.ConfigurationClient.Get");
scope.AddAttribute(nameof(key), key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,27 +609,6 @@ public async Task GetSettingWithLabel()
}
}

[Test]
public async Task GetWithAcceptDateTime()
{
ConfigurationClient service = GetClient();
ConfigurationSetting testSetting = CreateSetting();

try
{
await service.SetAsync(testSetting);

// Test
// TODO: add a test with a more granular timestamp.
ConfigurationSetting responseSetting = await service.GetAsync(testSetting.Key, testSetting.Label, DateTimeOffset.MaxValue, requestOptions: default);
Assert.AreEqual(testSetting, responseSetting);
}
finally
{
await service.DeleteAsync(testSetting.Key, testSetting.Label);
}
}

[Test]
public async Task GetIfChangedSettingModified()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,57 +163,6 @@ public async Task GetIfChangedUnmodified()
Assert.AreEqual(304, exception.Status);
}

[Test]
public async Task GetWithAcceptDateTime()
{
var mockResponse = new MockResponse(200);
mockResponse.SetContent(SerializationHelpers.Serialize(s_testSetting, SerializeSetting));

var mockTransport = new MockTransport(mockResponse);
ConfigurationClient service = CreateTestService(mockTransport);

Response<ConfigurationSetting> response = await service.GetAsync(s_testSetting.Key, s_testSetting.Label, DateTimeOffset.MaxValue, requestOptions: default);

MockRequest request = mockTransport.SingleRequest;

AssertRequestCommon(request);
Assert.AreEqual(RequestMethod.Get, request.Method);
Assert.AreEqual($"https://contoso.appconfig.io/kv/test_key?label=test_label&api-version={s_version}", request.Uri.ToString());
Assert.True(request.Headers.TryGetValue("Accept-Datetime", out var acceptDateTime));
Assert.AreEqual(DateTimeOffset.MaxValue.UtcDateTime.ToString("R", CultureInfo.InvariantCulture), acceptDateTime);
Assert.False(request.Headers.TryGetValue("If-Match", out var ifMatch));
Assert.False(request.Headers.TryGetValue("If-None-Match", out var ifNoneMatch));
}

[Test]
public async Task GetWithRequestOptions()
{
// Get If-Match is not an expected use case, but enabled for completeness.

var testSetting = s_testSetting.Clone();
testSetting.ETag = new ETag("v1");

var mockResponse = new MockResponse(200);
mockResponse.SetContent(SerializationHelpers.Serialize(testSetting, SerializeSetting));

var mockTransport = new MockTransport(mockResponse);
ConfigurationClient service = CreateTestService(mockTransport);

var requestOptions = new ConditionalRequestOptions { IfMatch = new ETag("v1") };

ConfigurationSetting setting = await service.GetAsync(testSetting.Key, testSetting.Label, default, requestOptions);

MockRequest request = mockTransport.SingleRequest;

AssertRequestCommon(request);
Assert.AreEqual(RequestMethod.Get, request.Method);
Assert.AreEqual($"https://contoso.appconfig.io/kv/test_key?label=test_label&api-version={s_version}", request.Uri.ToString());
Assert.True(request.Headers.TryGetValue("If-Match", out var ifMatch));
Assert.AreEqual(testSetting, setting);
Assert.False(request.Headers.TryGetValue("Accept-Datetime", out var acceptDateTime));
Assert.False(request.Headers.TryGetValue("If-None-Match", out var ifNoneMatch));
}

[Test]
public async Task Add()
{
Expand Down Expand Up @@ -490,35 +439,6 @@ public void DeleteIfUnchangedModified()
Assert.AreEqual("\"v1\"", ifMatch);
}

[Test]
public async Task DeleteWithRequestOptions()
{
// Delete with multiple headers is not an expected use case, but verified for completeness.

var mockResponse = new MockResponse(200);
mockResponse.SetContent(SerializationHelpers.Serialize(s_testSetting, SerializeSetting));

var mockTransport = new MockTransport(mockResponse);
ConfigurationClient service = CreateTestService(mockTransport);

var requestOptions = new ConditionalRequestOptions
{
IfNoneMatch = new ETag("v1"),
IfMatch = new ETag("v2")
};

Response response = await service.DeleteAsync(s_testSetting.Key, s_testSetting.Label, requestOptions);
MockRequest request = mockTransport.SingleRequest;

AssertRequestCommon(request);
Assert.AreEqual(RequestMethod.Delete, request.Method);
Assert.AreEqual($"https://contoso.appconfig.io/kv/test_key?label=test_label&api-version={s_version}", request.Uri.ToString());
Assert.True(request.Headers.TryGetValue("If-None-Match", out var ifNoneMatch));
Assert.AreEqual("\"v1\"", ifNoneMatch);
Assert.True(request.Headers.TryGetValue("If-Match", out var ifMatch));
Assert.AreEqual("\"v2\"", ifMatch);
}

[Test]
public async Task GetBatch()
{
Expand Down