Пример #1
0
        public StorageRecordedTestSanitizer()
        {
            UriRegexSanitizers.Add(UriRegexSanitizer.CreateWithQueryParameter(SignatureQueryName, SanitizeValue));

#if NETFRAMEWORK
            // Uri uses different escaping for some special characters between .NET Framework and Core. Because the Test Proxy runs on .NET
            // Core, we need to normalize to the .NET Core escaping when matching and storing the recordings when running tests on NetFramework.
            UriRegexSanitizers.Add(new UriRegexSanitizer("\\(", "%28"));
            UriRegexSanitizers.Add(new UriRegexSanitizer("\\)", "%29"));
            UriRegexSanitizers.Add(new UriRegexSanitizer("\\!", "%21"));
            UriRegexSanitizers.Add(new UriRegexSanitizer("\\'", "%27"));
            UriRegexSanitizers.Add(new UriRegexSanitizer("\\*", "%2A"));
            // Encode any colons in the Uri except for the one in the scheme
            UriRegexSanitizers.Add(new UriRegexSanitizer("(?<group>:)[^//]", "%3A")
            {
                GroupForReplace = "group"
            });
#endif

            HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("x-ms-encryption-key", SanitizeValue));
            HeaderRegexSanitizers.Add(new HeaderRegexSanitizer(CopySourceAuthorization, SanitizeValue));
            HeaderRegexSanitizers.Add(HeaderRegexSanitizer.CreateWithQueryParameter(CopySourceName, SignatureQueryName, SanitizeValue));
            HeaderRegexSanitizers.Add(HeaderRegexSanitizer.CreateWithQueryParameter(RenameSource, SignatureQueryName, SanitizeValue));
            HeaderRegexSanitizers.Add(HeaderRegexSanitizer.CreateWithQueryParameter(PreviousSnapshotUrl, SignatureQueryName, SanitizeValue));
            HeaderRegexSanitizers.Add(HeaderRegexSanitizer.CreateWithQueryParameter(FileRenameSource, SignatureQueryName, SanitizeValue));

            BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"client_secret=(?<group>.*?)(?=&|$)", SanitizeValue)
            {
                GroupForReplace = "group"
            });
        }
 public PhoneNumbersClientLiveTestBase(bool isAsync) : base(isAsync)
 {
     SanitizedHeaders.Add("location");
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(PhoneNumberRegEx, SanitizeValue));
     UriRegexSanitizers.Add(new UriRegexSanitizer(UrlEncodedPhoneNumberRegEx, SanitizeValue));
     SanitizedHeaders.Add("x-ms-content-sha256");
 }
 public IdentityRecordedTestSanitizer()
 {
     SanitizedHeaders.Add("secret");
     AddJsonPathSanitizer("$..refresh_token");
     AddJsonPathSanitizer("$..access_token");
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"=[^&|}|""]+", "=" + SanitizeValue)
     {
         Condition = new Condition {
             UriRegex = ".*/token([?].*)?$"
         }
     });
     HeaderTransforms.Add(new HeaderTransform(
                              "WWW-Authenticate",
                              $"Basic realm={Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "mock-arc-mi-key.key")}")
     {
         Condition = new Condition
         {
             ResponseHeader = new HeaderCondition
             {
                 Key        = "WWW-Authenticate",
                 ValueRegex = "Basic realm=.*"
             }
         }
     });
 }
Пример #4
0
 public MetricsAdvisorRecordedTestSanitizer()
 {
     SanitizedHeaders.Add(Constants.SubscriptionAuthorizationHeader);
     SanitizedHeaders.Add(Constants.ApiAuthorizationHeader);
     AddJsonPathSanitizer("$..password");
     AddJsonPathSanitizer("$..certificatePassword");
     AddJsonPathSanitizer("$..clientSecret");
     AddJsonPathSanitizer("$..keyVaultClientSecret");
     AddJsonPathSanitizer("$..apiKey");
     AddJsonPathSanitizer("$..accountKey");
     AddJsonPathSanitizer("$..authHeader");
     AddJsonPathSanitizer("$..httpHeader");
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"\[email protected]", "*****@*****.**"));
 }
 public MetricsAdvisorLiveTestBase(bool isAsync, RecordedTestMode?mode = default) : base(isAsync, mode)
 {
     SanitizedHeaders.Add(Constants.SubscriptionAuthorizationHeader);
     SanitizedHeaders.Add(Constants.ApiAuthorizationHeader);
     JsonPathSanitizers.Add("$..password");
     JsonPathSanitizers.Add("$..certificatePassword");
     JsonPathSanitizers.Add("$..clientSecret");
     JsonPathSanitizers.Add("$..keyVaultClientSecret");
     JsonPathSanitizers.Add("$..apiKey");
     JsonPathSanitizers.Add("$..accountKey");
     JsonPathSanitizers.Add("$..authHeader");
     JsonPathSanitizers.Add("$..httpHeader");
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"\[email protected]", "*****@*****.**"));
 }
        public ContainerRegistryRecordedTestBase(bool isAsync, RecordedTestMode?mode = default) : base(isAsync, mode)
        {
            DateTimeOffset expiresOn         = DateTimeOffset.UtcNow + TimeSpan.FromDays(365 * 30); // Never expire in software years
            string         encodedBody       = Base64Url.EncodeString($"{{\"exp\":{expiresOn.ToUnixTimeSeconds()}}}");
            var            jwtSanitizedValue = $"{SanitizeValue}.{encodedBody}.{SanitizeValue}";

            BodyKeySanitizers.Add(new BodyKeySanitizer(jwtSanitizedValue)
            {
                JsonPath = "$..refresh_token"
            });
            BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"access_token=(?<group>.*?)(?=&|$)", SanitizeValue)
            {
                GroupForReplace = "group"
            });
            BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"refresh_token=(?<group>.*?)(?=&|$)", SanitizeValue)
            {
                GroupForReplace = "group"
            });
        }
Пример #7
0
 public ServiceBusRecordedTestSanitizer()
 {
     SanitizedHeaders.Add("ServiceBusDlqSupplementaryAuthorization");
     SanitizedHeaders.Add("ServiceBusSupplementaryAuthorization");
     BodyRegexSanitizers.Add(
         new BodyRegexSanitizer(
             "\\u003CPrimaryKey\\u003E.*\\u003C/PrimaryKey\\u003E",
             $"\u003CPrimaryKey\u003E{SanitizedKeyValue}\u003C/PrimaryKey\u003E"));
     BodyRegexSanitizers.Add(
         new BodyRegexSanitizer(
             "\\u003CSecondaryKey\\u003E.*\\u003C/SecondaryKey\\u003E",
             $"\u003CSecondaryKey\u003E{SanitizedKeyValue}\u003C/SecondaryKey\u003E"));
     BodyRegexSanitizers.Add(
         new BodyRegexSanitizer(
             "[^\\r](?<break>\\n)",
             "\r\n")
     {
         GroupForReplace = "break"
     });
 }
Пример #8
0
 private void InitializeRecordingSettings()
 {
     // the following headers are added by MSAL and need to be excluded from matching for recordings
     LegacyExcludedHeaders.Add("Content-Length");
     LegacyExcludedHeaders.Add("client-request-id");
     LegacyExcludedHeaders.Add("x-client-OS");
     LegacyExcludedHeaders.Add("x-client-SKU");
     LegacyExcludedHeaders.Add("x-client-CPU");
     LegacyExcludedHeaders.Add("x-client-Ver");
     // x-ms-PKeyAuth is only added on MAC and Linux so recordings made on windows will fail on these platforms and vice-versa
     // ignoring this header as CI must run on all platforms
     LegacyExcludedHeaders.Add("x-ms-PKeyAuth");
     LegacyExcludedHeaders.Add("x-client-current-telemetry");
     LegacyExcludedHeaders.Add("x-client-last-telemetry");
     LegacyExcludedHeaders.Add("x-anchormailbox");
     // temporary until update to disable cookies in Core is shipped
     LegacyExcludedHeaders.Add("cookie");
     SanitizedHeaders.Add("secret");
     JsonPathSanitizers.Add("$..refresh_token");
     JsonPathSanitizers.Add("$..access_token");
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"=[^&|}|""]+", "=" + SanitizeValue)
     {
         Condition = new Condition {
             UriRegex = ".*/token([?].*)?$"
         }
     });
     HeaderTransforms.Add(new HeaderTransform(
                              "WWW-Authenticate",
                              $"Basic realm={Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "mock-arc-mi-key.key")}")
     {
         Condition = new Condition
         {
             ResponseHeader = new HeaderCondition
             {
                 Key        = "WWW-Authenticate",
                 ValueRegex = "Basic realm=.*"
             }
         }
     });
 }
 public CallingServerRecordedTestSanitizer()
 {
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(PhoneNumberRegEx, SanitizeValue));
 }
Пример #10
0
 public PhoneNumbersClientRecordedTestSanitizer()
 {
     SanitizedHeaders.Add("location");
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(PhoneNumberRegEx, SanitizeValue));
     UriRegexSanitizers.Add(new UriRegexSanitizer(UrlEncodedPhoneNumberRegEx, SanitizeValue));
 }
 public CallingServerLiveTestBase(bool isAsync) : base(isAsync)
 {
     BodyRegexSanitizers.Add(new BodyRegexSanitizer(PhoneNumberRegEx, SanitizeValue));
     SanitizedHeaders.Add("x-ms-content-sha256");
 }