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

Key Vault test proxy migration #34321

Merged
merged 24 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1baaf19
Updated Key vault tests to use TestProxyTestBase instead of TestBase.
vcolin7 Apr 4, 2023
21b840f
Re-recorded Key Vault tests.
vcolin7 Apr 4, 2023
48546db
Merge branch 'upstream-main' into kv-test-proxy-migration
vcolin7 Apr 5, 2023
178f8c2
Fixed CredScan issues.
vcolin7 Apr 6, 2023
b497073
Merge branch 'upstream-main' into kv-test-proxy-migration
vcolin7 Apr 6, 2023
67c203f
Added custom matchers to avoid body issues during playback.
vcolin7 Apr 6, 2023
2073901
Merge branch 'upstream-main' into kv-test-proxy-migration
vcolin7 Apr 12, 2023
408b176
Ensured we clear the token cache of tests before running them.
vcolin7 Apr 12, 2023
64aa274
Re-recorded tests.
vcolin7 Apr 12, 2023
80fbe5a
Fixed Checkstyle issue.
vcolin7 Apr 12, 2023
c4b9ddd
Fixed playback issues.
vcolin7 Apr 12, 2023
b51baef
Fixed CheckStyle issues.
vcolin7 Apr 13, 2023
2161755
Fixed CredScan issues.
vcolin7 Apr 13, 2023
35abf88
Made JsonWebKey's logger static and fixed some test playback issues.
vcolin7 Apr 13, 2023
8a718b4
Removed the "logger" key from request bodies.
vcolin7 Apr 14, 2023
098d727
Made all ClientLogger instances static.
vcolin7 Apr 14, 2023
e47c0d1
Added matchers to avoid comparing the body of requests.
vcolin7 Apr 14, 2023
2f00f9e
Added custom matcher to avoid comparing authorization headers.
vcolin7 Apr 14, 2023
c8ba9b6
Merge branch 'main' into kv-test-proxy-migration
vcolin7 Apr 17, 2023
455d0a0
Updated tests to use MockTokenCredential in playback mode.
vcolin7 Apr 17, 2023
677cb76
Removed unused imports.
vcolin7 Apr 17, 2023
fcfb16c
Merge branch 'upstream-main' into kv-test-proxy-migration
vcolin7 Apr 20, 2023
e82f3d0
Removed custom matcher for authorization header.
vcolin7 Apr 20, 2023
50369ed
Revert "Removed custom matcher for authorization header."
vcolin7 Apr 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class KeyVaultAccessControlAsyncClient {
/**
* The logger to be used.
*/
private final ClientLogger logger = new ClientLogger(KeyVaultAccessControlAsyncClient.class);
private static final ClientLogger LOGGER = new ClientLogger(KeyVaultAccessControlAsyncClient.class);

/**
* The underlying AutoRest client used to interact with the Key Vault service.
Expand Down Expand Up @@ -196,14 +196,14 @@ Mono<PagedResponse<KeyVaultRoleDefinition>> listRoleDefinitionsFirstPage(String
return clientImpl.getRoleDefinitions()
.listSinglePageAsync(vaultUrl, roleScope.toString(), null,
context)
.doOnRequest(ignored -> logger.verbose("Listing role definitions for roleScope - {}", roleScope))
.doOnSuccess(response -> logger.verbose("Listed role definitions for roleScope - {}", roleScope))
.doOnError(error -> logger.warning("Failed to list role definitions for roleScope - {}", roleScope,
.doOnRequest(ignored -> LOGGER.verbose("Listing role definitions for roleScope - {}", roleScope))
.doOnSuccess(response -> LOGGER.verbose("Listed role definitions for roleScope - {}", roleScope))
.doOnError(error -> LOGGER.warning("Failed to list role definitions for roleScope - {}", roleScope,
error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleDefinitionsPagedResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand All @@ -226,15 +226,15 @@ Mono<PagedResponse<KeyVaultRoleDefinition>> listRoleDefinitionsNextPage(String c
return clientImpl.getRoleDefinitions()
.listNextSinglePageAsync(continuationToken, vaultUrl, context)
.doOnRequest(ignored ->
logger.verbose("Listing next role definitions page - Page {}", continuationToken))
LOGGER.verbose("Listing next role definitions page - Page {}", continuationToken))
.doOnSuccess(response ->
logger.verbose("Listed next role definitions page - Page {}", continuationToken))
LOGGER.verbose("Listed next role definitions page - Page {}", continuationToken))
.doOnError(error ->
logger.warning("Failed to list next role definitions page - Page {}", continuationToken, error))
LOGGER.warning("Failed to list next role definitions page - Page {}", continuationToken, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleDefinitionsPagedResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -380,14 +380,14 @@ Mono<Response<KeyVaultRoleDefinition>> setRoleDefinitionWithResponse(SetRoleDefi
options.getRoleDefinitionName(), parameters,
context)
.doOnRequest(ignored ->
logger.verbose("Creating role definition - {}", options.getRoleDefinitionName()))
.doOnSuccess(response -> logger.verbose("Created role definition - {}", response.getValue().getName()))
LOGGER.verbose("Creating role definition - {}", options.getRoleDefinitionName()))
.doOnSuccess(response -> LOGGER.verbose("Created role definition - {}", response.getValue().getName()))
.doOnError(error ->
logger.warning("Failed to create role definition - {}", options.getRoleDefinitionName(), error))
LOGGER.warning("Failed to create role definition - {}", options.getRoleDefinitionName(), error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleDefinitionResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -481,15 +481,15 @@ Mono<Response<KeyVaultRoleDefinition>> getRoleDefinitionWithResponse(KeyVaultRol
return clientImpl.getRoleDefinitions()
.getWithResponseAsync(vaultUrl, roleScope.toString(), roleDefinitionName,
context)
.doOnRequest(ignored -> logger.verbose("Retrieving role definition - {}", roleDefinitionName))
.doOnRequest(ignored -> LOGGER.verbose("Retrieving role definition - {}", roleDefinitionName))
.doOnSuccess(response ->
logger.verbose("Retrieved role definition - {}", response.getValue().getName()))
LOGGER.verbose("Retrieved role definition - {}", response.getValue().getName()))
.doOnError(error ->
logger.warning("Failed to retrieved role definition - {}", roleDefinitionName, error))
LOGGER.warning("Failed to retrieved role definition - {}", roleDefinitionName, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleDefinitionResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -576,15 +576,15 @@ Mono<Response<Void>> deleteRoleDefinitionWithResponse(KeyVaultRoleScope roleScop
return clientImpl.getRoleDefinitions()
.deleteWithResponseAsync(vaultUrl, roleScope.toString(), roleDefinitionName,
context)
.doOnRequest(ignored -> logger.verbose("Deleting role definition - {}", roleDefinitionName))
.doOnSuccess(response -> logger.verbose("Deleted role definition - {}", response.getValue().getName()))
.doOnError(error -> logger.warning("Failed to delete role definition - {}", roleDefinitionName, error))
.doOnRequest(ignored -> LOGGER.verbose("Deleting role definition - {}", roleDefinitionName))
.doOnSuccess(response -> LOGGER.verbose("Deleted role definition - {}", response.getValue().getName()))
.doOnError(error -> LOGGER.warning("Failed to delete role definition - {}", roleDefinitionName, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(response -> (Response<Void>) new SimpleResponse<Void>(response, null))
.onErrorResume(KeyVaultAdministrationException.class, e ->
swallowExceptionForStatusCodeAsync(404, e, logger));
swallowExceptionForStatusCodeAsync(404, e, LOGGER));
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -651,14 +651,14 @@ Mono<PagedResponse<KeyVaultRoleAssignment>> listRoleAssignmentsFirstPage(String
return clientImpl.getRoleAssignments()
.listForScopeSinglePageAsync(vaultUrl, roleScope.toString(), null,
context)
.doOnRequest(ignored -> logger.verbose("Listing role assignments for roleScope - {}", roleScope))
.doOnSuccess(response -> logger.verbose("Listed role assignments for roleScope - {}", roleScope))
.doOnError(error -> logger.warning("Failed to list role assignments for roleScope - {}", roleScope,
.doOnRequest(ignored -> LOGGER.verbose("Listing role assignments for roleScope - {}", roleScope))
.doOnSuccess(response -> LOGGER.verbose("Listed role assignments for roleScope - {}", roleScope))
.doOnError(error -> LOGGER.warning("Failed to list role assignments for roleScope - {}", roleScope,
error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleAssignmentsPagedResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand All @@ -681,15 +681,15 @@ Mono<PagedResponse<KeyVaultRoleAssignment>> listRoleAssignmentsNextPage(String c
.listForScopeNextSinglePageAsync(continuationToken, vaultUrl,
context)
.doOnRequest(ignored ->
logger.verbose("Listing next role assignments page - Page {}", continuationToken))
LOGGER.verbose("Listing next role assignments page - Page {}", continuationToken))
.doOnSuccess(response ->
logger.verbose("Listed next role assignments page - Page {}", continuationToken))
.doOnError(error -> logger.warning("Failed to list next role assignments page - Page {}",
LOGGER.verbose("Listed next role assignments page - Page {}", continuationToken))
.doOnError(error -> LOGGER.warning("Failed to list next role assignments page - Page {}",
continuationToken, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleAssignmentsPagedResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -845,13 +845,13 @@ Mono<Response<KeyVaultRoleAssignment>> createRoleAssignmentWithResponse(KeyVault
return clientImpl.getRoleAssignments()
.createWithResponseAsync(vaultUrl, roleScope.toString(), roleAssignmentName, parameters,
context)
.doOnRequest(ignored -> logger.verbose("Creating role assignment - {}", roleAssignmentName))
.doOnSuccess(response -> logger.verbose("Created role assignment - {}", response.getValue().getName()))
.doOnError(error -> logger.warning("Failed to create role assignment - {}", roleAssignmentName, error))
.doOnRequest(ignored -> LOGGER.verbose("Creating role assignment - {}", roleAssignmentName))
.doOnSuccess(response -> LOGGER.verbose("Created role assignment - {}", response.getValue().getName()))
.doOnError(error -> LOGGER.warning("Failed to create role assignment - {}", roleAssignmentName, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleAssignmentResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -942,15 +942,15 @@ Mono<Response<KeyVaultRoleAssignment>> getRoleAssignmentWithResponse(KeyVaultRol
return clientImpl.getRoleAssignments()
.getWithResponseAsync(vaultUrl, roleScope.toString(), roleAssignmentName,
context)
.doOnRequest(ignored -> logger.verbose("Retrieving role assignment - {}", roleAssignmentName))
.doOnRequest(ignored -> LOGGER.verbose("Retrieving role assignment - {}", roleAssignmentName))
.doOnSuccess(response ->
logger.verbose("Retrieved role assignment - {}", response.getValue().getName()))
LOGGER.verbose("Retrieved role assignment - {}", response.getValue().getName()))
.doOnError(error ->
logger.warning("Failed to retrieve role assignment - {}", roleAssignmentName, error))
LOGGER.warning("Failed to retrieve role assignment - {}", roleAssignmentName, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(KeyVaultAdministrationUtil::transformRoleAssignmentResponse);
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}

Expand Down Expand Up @@ -1036,15 +1036,15 @@ Mono<Response<Void>> deleteRoleAssignmentWithResponse(KeyVaultRoleScope roleScop
return clientImpl.getRoleAssignments()
.deleteWithResponseAsync(vaultUrl, roleScope.toString(), roleAssignmentName,
context)
.doOnRequest(ignored -> logger.verbose("Deleting role assignment - {}", roleAssignmentName))
.doOnSuccess(response -> logger.verbose("Deleted role assignment - {}", response.getValue().getName()))
.doOnError(error -> logger.warning("Failed to delete role assignment - {}", roleAssignmentName, error))
.doOnRequest(ignored -> LOGGER.verbose("Deleting role assignment - {}", roleAssignmentName))
.doOnSuccess(response -> LOGGER.verbose("Deleted role assignment - {}", response.getValue().getName()))
.doOnError(error -> LOGGER.warning("Failed to delete role assignment - {}", roleAssignmentName, error))
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
.map(response -> (Response<Void>) new SimpleResponse<Void>(response, null))
.onErrorResume(KeyVaultAdministrationException.class, e ->
swallowExceptionForStatusCodeAsync(404, e, logger));
swallowExceptionForStatusCodeAsync(404, e, LOGGER));
} catch (RuntimeException e) {
return monoError(logger, e);
return monoError(LOGGER, e);
}
}
}
Loading