Skip to content

Commit 839e28f

Browse files
Migrate personalizer to test-proxy (Azure#25696)
1 parent 0cdaf0f commit 839e28f

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

sdk/personalizer/Azure.AI.Personalizer/tests/Infrastructure/PersonalizerRecordedTestSanitizer.cs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,9 @@ public PersonalizerRecordedTestSanitizer() : base()
1212
{
1313
AddJsonPathSanitizer("$..accessToken");
1414
AddJsonPathSanitizer("$..source");
15+
SanitizedHeaders.Add("Ocp-Apim-Subscription-Key");
1516
// TODO: Remove when re-recording
1617
LegacyConvertJsonDateTokens = true;
1718
}
18-
19-
public override void SanitizeHeaders(IDictionary<string, string[]> headers)
20-
{
21-
if (headers.ContainsKey("Ocp-Apim-Subscription-Key"))
22-
{
23-
headers["Ocp-Apim-Subscription-Key"] = new[] { SanitizeValue };
24-
}
25-
26-
base.SanitizeHeaders(headers);
27-
}
28-
29-
public override string SanitizeVariable(string variableName, string environmentVariableValue)
30-
{
31-
return variableName switch
32-
{
33-
PersonalizerTestEnvironment.MultiSlotApiKeyEnvironmentVariableName => SanitizeValue,
34-
PersonalizerTestEnvironment.SingleSlotApiKeyEnvironmentVariableName => SanitizeValue,
35-
_ => base.SanitizeVariable(variableName, environmentVariableValue)
36-
};
37-
}
3819
}
3920
}

sdk/personalizer/Azure.AI.Personalizer/tests/Infrastructure/PersonalizerTestEnvironment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class PersonalizerTestEnvironment: TestEnvironment
1919
/// <summary>The name of the environment variable from which the Personalizer resource's API key will be extracted for the live tests.</summary>
2020
internal const string SingleSlotApiKeyEnvironmentVariableName = "PERSONALIZER_API_KEY_SINGLE_SLOT";
2121

22-
public string SingleSlotApiKey => GetRecordedVariable(SingleSlotApiKeyEnvironmentVariableName);
22+
public string SingleSlotApiKey => GetRecordedVariable(SingleSlotApiKeyEnvironmentVariableName, options => options.IsSecret());
2323
public string SingleSlotEndpoint => GetRecordedVariable(SingleSlotEndpointEnvironmentVariableName);
2424

25-
public string MultiSlotApiKey => GetRecordedVariable(MultiSlotApiKeyEnvironmentVariableName);
25+
public string MultiSlotApiKey => GetRecordedVariable(MultiSlotApiKeyEnvironmentVariableName, options => options.IsSecret());
2626
public string MultiSlotEndpoint => GetRecordedVariable(MultiSlotEndpointEnvironmentVariableName);
2727
}
2828
}

0 commit comments

Comments
 (0)