Skip to content

Commit

Permalink
cleanup + re-recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
samvaity committed Mar 9, 2023
1 parent 0e9f29e commit 4001c6c
Show file tree
Hide file tree
Showing 112 changed files with 253,834 additions and 168,900 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.test.TestBase;
import com.azure.core.test.TestProxyTestBase;
import com.azure.core.test.models.CustomMatcher;
import com.azure.core.test.models.TestProxySanitizer;
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.util.Configuration;
import com.azure.data.appconfiguration.implementation.ConfigurationClientCredentials;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
Expand All @@ -19,11 +15,8 @@

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

import static com.azure.data.appconfiguration.ConfigurationClientTestBase.FAKE_CONNECTION_STRING;
import static com.azure.data.appconfiguration.ConfigurationClientTestBase.customMatcher;
import static com.azure.data.appconfiguration.ConfigurationClientTestBase.customSanitizer;
import static com.azure.data.appconfiguration.TestHelper.DISPLAY_NAME_WITH_ARGUMENTS;

/**
Expand All @@ -33,28 +26,20 @@ public class AadCredentialTest extends TestProxyTestBase {
private static ConfigurationClient client;
private static final String AZURE_APPCONFIG_CONNECTION_STRING = "AZURE_APPCONFIG_CONNECTION_STRING";
static String connectionString;
static TokenCredential tokenCredential;
private static final String REDACTED = "REDACTED";
static {
customSanitizer.add(new TestProxySanitizer("Connection", REDACTED, TestProxySanitizerType.HEADER));
customSanitizer.add(new TestProxySanitizer("Sync-Token", REDACTED, TestProxySanitizerType.HEADER));
customMatcher.add(new CustomMatcher().setHeadersKeyOnlyMatch(Arrays.asList("Content-Length")));
}
static TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();;
private void setup(HttpClient httpClient, ConfigurationServiceVersion serviceVersion)
throws InvalidKeyException, NoSuchAlgorithmException {
if (interceptorManager.isPlaybackMode()) {
connectionString = FAKE_CONNECTION_STRING;
String endpoint = new ConfigurationClientCredentials(connectionString).getBaseUri();
// In playback mode use connection string because CI environment doesn't set up to support AAD
client = new ConfigurationClientBuilder()
.connectionString(connectionString)
.credential(tokenCredential)
.endpoint(endpoint)
.httpClient(interceptorManager.getPlaybackClient())
.buildClient();
interceptorManager.addMatchers(customMatcher);
} else {
connectionString = Configuration.getGlobalConfiguration().get(AZURE_APPCONFIG_CONNECTION_STRING);
tokenCredential = new DefaultAzureCredentialBuilder().build();

String endpoint = new ConfigurationClientCredentials(connectionString).getBaseUri();
client = new ConfigurationClientBuilder()
Expand All @@ -65,7 +50,6 @@ private void setup(HttpClient httpClient, ConfigurationServiceVersion serviceVer
.serviceVersion(serviceVersion)
.buildClient();
}
interceptorManager.addSanitizers(customSanitizer);
}

@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,14 @@ private ConfigurationAsyncClient getConfigurationAsyncClient(HttpClient httpClie
return clientSetup(credentials -> {
ConfigurationClientBuilder builder = new ConfigurationClientBuilder()
.connectionString(connectionString)
.httpClient(buildAsyncAssertingClient(httpClient == null ? interceptorManager.getPlaybackClient() : httpClient))
.httpClient(buildAsyncAssertingClient(interceptorManager.isPlaybackMode() ? interceptorManager.getPlaybackClient() : httpClient))
.serviceVersion(serviceVersion)
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS));
if (getTestMode() == TestMode.PLAYBACK) {
interceptorManager.addMatchers(customMatcher);
} else {
if (getTestMode() != TestMode.PLAYBACK) {
builder
.addPolicy(interceptorManager.getRecordPolicy())
.addPolicy(new RetryPolicy());
}
interceptorManager.addSanitizers(customSanitizer);
return builder.buildAsyncClient();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void nullServiceVersion(HttpClient httpClient) {
.retryPolicy(new RetryPolicy())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.serviceVersion(null)
.httpClient(httpClient == null ? interceptorManager.getPlaybackClient() : httpClient);
.httpClient(interceptorManager.isPlaybackMode() ? interceptorManager.getPlaybackClient() : httpClient);

if (!interceptorManager.isPlaybackMode()) {
clientBuilder.addPolicy(interceptorManager.getRecordPolicy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,14 @@ private ConfigurationClient getConfigurationClient(HttpClient httpClient,
return clientSetup(credentials -> {
ConfigurationClientBuilder builder = new ConfigurationClientBuilder()
.connectionString(connectionString)
.httpClient(buildSyncAssertingClient(httpClient == null ? interceptorManager.getPlaybackClient() : httpClient))
.httpClient(buildSyncAssertingClient(getTestMode() == TestMode.PLAYBACK ? interceptorManager.getPlaybackClient() : httpClient))
.serviceVersion(serviceVersion)
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS));
if (getTestMode() == TestMode.PLAYBACK) {
interceptorManager.addMatchers(customMatcher);
} else {
if (getTestMode() != TestMode.PLAYBACK) {
builder
.addPolicy(interceptorManager.getRecordPolicy())
.addPolicy(new RetryPolicy());
}
interceptorManager.addSanitizers(customSanitizer);
return builder.buildClient();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.rest.Response;
import com.azure.core.test.TestBase;
import com.azure.core.test.TestProxyTestBase;
import com.azure.core.test.models.CustomMatcher;
import com.azure.core.test.models.TestProxyRequestMatcher;
import com.azure.core.test.models.TestProxySanitizer;
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
Expand Down Expand Up @@ -60,14 +55,6 @@ public abstract class ConfigurationClientTestBase extends TestProxyTestBase {
static String connectionString;

private final ClientLogger logger = new ClientLogger(ConfigurationClientTestBase.class);
static List<TestProxySanitizer> customSanitizer = new ArrayList<>();
static List<TestProxyRequestMatcher> customMatcher = new ArrayList<>();
private static final String REDACTED = "REDACTED";
static {
customSanitizer.add(new TestProxySanitizer("Connection", REDACTED, TestProxySanitizerType.HEADER));
customSanitizer.add(new TestProxySanitizer("Sync-Token", REDACTED, TestProxySanitizerType.HEADER));
customMatcher.add(new CustomMatcher().setHeadersKeyOnlyMatch(Arrays.asList("Content-Length")));
}
String keyPrefix;
String labelPrefix;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"Authorization": "Sanitized",
"Content-Length": "92",
"Content-Type": "application/json",
"Date": "Tue, 07 Mar 2023 20:47:53 GMT",
"Date": "Thu, 09 Mar 2023 22:16:58 GMT",
"Sync-Token": "",
"User-Agent": "azsdk-java-azure-data-appconfiguration/1.5.0-beta.1 (11.0.9; Windows 10; 10.0)",
"x-ms-client-request-id": "a34cd9fc-ea68-4694-9009-b986ed2ca65a",
"User-Agent": "azsdk-java-azure-data-appconfiguration/1.5.0-beta.1 (17.0.1; Windows 11; 10.0)",
"x-ms-client-request-id": "41194a2f-cb47-4644-be88-feb842864f29",
"x-ms-return-client-request-id": "true"
},
"RequestBody": {
Expand All @@ -27,28 +27,28 @@
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate",
"Connection": "REDACTED",
"Connection": "keep-alive",
"Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8",
"Date": "Tue, 07 Mar 2023 20:47:54 GMT",
"ETag": "\u0022MKpDu8t9jl2XFWIKmVrTAaeu5q4ELHVsln9jOGjRy9g\u0022",
"Last-Modified": "Tue, 07 Mar 2023 20:47:54 GMT",
"Date": "Thu, 09 Mar 2023 22:17:01 GMT",
"ETag": "\u00226bpTn97p9iW_hkcD9P8XUzTjvaowJYumF-bHTQC66j8\u0022",
"Last-Modified": "Thu, 09 Mar 2023 22:17:01 GMT",
"Server": "openresty/1.21.4.1",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains",
"Sync-Token": "REDACTED",
"Sync-Token": "zAJw6V16=MjoyMCM0MjI4NTY0;sn=4228564",
"Transfer-Encoding": "chunked",
"x-ms-client-request-id": "a34cd9fc-ea68-4694-9009-b986ed2ca65a",
"x-ms-correlation-request-id": "bd22a2fd-4a15-4720-af62-172e0c6f3a23",
"x-ms-request-id": "bd22a2fd-4a15-4720-af62-172e0c6f3a23"
"x-ms-client-request-id": "41194a2f-cb47-4644-be88-feb842864f29",
"x-ms-correlation-request-id": "47860f36-754d-48a8-9083-1f12e2c8af9e",
"x-ms-request-id": "47860f36-754d-48a8-9083-1f12e2c8af9e"
},
"ResponseBody": {
"etag": "MKpDu8t9jl2XFWIKmVrTAaeu5q4ELHVsln9jOGjRy9g",
"etag": "6bpTn97p9iW_hkcD9P8XUzTjvaowJYumF-bHTQC66j8",
"key": "newKey",
"label": null,
"content_type": null,
"value": "newValue",
"tags": {},
"locked": false,
"last_modified": "2023-03-07T20:47:54\u002B00:00"
"last_modified": "2023-03-09T22:17:01\u002B00:00"
}
}
],
Expand Down
Loading

0 comments on commit 4001c6c

Please sign in to comment.