forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from samvaity/it-works
Add record sanitizers to test proxy
- Loading branch information
Showing
12 changed files
with
556 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
sdk/core/azure-core-test/src/main/java/com/azure/core/test/models/TestProxySanitizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.core.test.models; | ||
|
||
/** | ||
* Keeps track of different sanitizers that redact the sensitive information when recording | ||
*/ | ||
public class TestProxySanitizer { | ||
private final TestProxySanitizerType testProxySanitizerType; | ||
private final String regexKey; | ||
private final String redactedValue; | ||
|
||
/** | ||
* Creates an instance of TestProxySanitizer | ||
* @param regexKey the regex key to lookup for redaction | ||
* @param redactedValue the replacement for regex matched content | ||
* @param testProxySanitizerType the type of sanitizer | ||
*/ | ||
public TestProxySanitizer(String regexKey, String redactedValue, TestProxySanitizerType testProxySanitizerType) { | ||
this.testProxySanitizerType = testProxySanitizerType; | ||
this.regexKey = regexKey; | ||
this.redactedValue = redactedValue; | ||
} | ||
|
||
/** | ||
* Get the type of proxy sanitizer | ||
* @return the type of proxy sanitizer | ||
*/ | ||
public TestProxySanitizerType getType() { | ||
return testProxySanitizerType; | ||
} | ||
|
||
/** | ||
* Get the regex key to lookup for redaction | ||
* @return the regex key to lookup for redaction | ||
*/ | ||
public String getRegex() { | ||
return regexKey; | ||
} | ||
|
||
/** | ||
* Get the replacement for regex matched content | ||
* @return the replacement for regex matched content | ||
*/ | ||
public String getRedactedValue() { | ||
return redactedValue; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...core/azure-core-test/src/main/java/com/azure/core/test/models/TestProxySanitizerType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.core.test.models; | ||
|
||
/** | ||
* The possible record sanitizer types. | ||
* Each sanitizer is optionally prefaced with the specific part of the request/response pair that it applies to. | ||
*/ | ||
public enum TestProxySanitizerType { | ||
/** | ||
* Sanitize the request url. | ||
*/ | ||
URL("UriRegexSanitizer"), | ||
/** | ||
* Sanitize the response body. | ||
*/ | ||
BODY("BodyKeySanitizer"), | ||
/** | ||
* Sanitize the request/response headers. | ||
*/ | ||
HEADER("HeaderRegexSanitizer"); | ||
|
||
public final String name; | ||
|
||
TestProxySanitizerType(String name) { | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.