public void SecureDataCleaner_CleanHttpResult_ClearMultipleSecureKeysInUrlProperty_MultipleSecureKeysInMultiplePropertiesCleared()
        {
            // Arrange
            var httpResult = new HttpResult
            {
                Url          = "http://test.com/users/max/info?pass=123456",
                RequestBody  = "http://test.com?user=max&pass=123456",
                ResponseBody = "http://test.com?user=max&pass=123456"
            };

            var secureKey1     = "pass";
            var locationsInfo1 = new Dictionary <PropertyType, HashSet <string> >();
            var dataLocations1 = new HashSet <string>
            {
                SecureDataLocation.UrlQuery,
            };

            locationsInfo1.Add(PropertyType.Url, dataLocations1);
            var secureDataInfo1 = new SecureDataInfo
            {
                SecureKey     = secureKey1,
                LocationsInfo = locationsInfo1
            };

            var secureKey2     = "users";
            var locationsInfo2 = new Dictionary <PropertyType, HashSet <string> >();
            var dataLocations2 = new HashSet <string>
            {
                SecureDataLocation.UrlRest
            };

            locationsInfo2.Add(PropertyType.Url, dataLocations2);
            var secureDataInfo2 = new SecureDataInfo
            {
                SecureKey     = secureKey2,
                LocationsInfo = locationsInfo2
            };

            var secureDataInfoList = new List <SecureDataInfo>();

            secureDataInfoList.Add(secureDataInfo1);
            secureDataInfoList.Add(secureDataInfo2);

            var secureDataCleaner = new SecureDataCleaner(secureDataInfoList);

            var expectedResult = "http://test.com/users/XXX/info?pass=XXXXXX";

            // Act
            var cleanedHttpResult = secureDataCleaner.CleanHttpResult(httpResult);

            // Assert
            Assert.Equal(expectedResult, cleanedHttpResult.Url);
        }
        public void SecureDataCleaner_CleanHttpResult_ClearOneSecureKeyInMultipleDataLocationsInMultipleProperties_OneSecureKeyInMultipleDataLocationsInMultiplePropertiesCleared()
        {
            // Arrange
            var httpResult = new HttpResult
            {
                Url          = "http://test.com/users/max/pass/123/info?pass=123456",
                RequestBody  = "http://test.com/pass/123?user=max&pass=123456",
                ResponseBody = "http://test.com/pass/123?user=max&pass=123456"
            };

            var secureKey     = "pass";
            var locationsInfo = new Dictionary <PropertyType, HashSet <string> >();
            var dataLocations = new HashSet <string>
            {
                SecureDataLocation.UrlQuery,
                SecureDataLocation.UrlRest
            };

            locationsInfo.Add(PropertyType.Url, dataLocations);
            locationsInfo.Add(PropertyType.RequestBody, dataLocations);
            locationsInfo.Add(PropertyType.ResponseBody, dataLocations);

            var secureDataInfoList = new List <SecureDataInfo>();
            var secureDataInfo     = new SecureDataInfo
            {
                SecureKey     = secureKey,
                LocationsInfo = locationsInfo
            };

            secureDataInfoList.Add(secureDataInfo);

            var secureDataCleaner = new SecureDataCleaner(secureDataInfoList);

            var expectedUrl          = "http://test.com/users/max/pass/XXX/info?pass=XXXXXX";
            var expectedRequestBody  = "http://test.com/pass/XXX?user=max&pass=XXXXXX";
            var expectedResponseBody = "http://test.com/pass/XXX?user=max&pass=XXXXXX";

            // Act
            var cleanedHttpResult = secureDataCleaner.CleanHttpResult(httpResult);

            // Assert
            Assert.Equal(expectedUrl, cleanedHttpResult.Url);
            Assert.Equal(expectedRequestBody, cleanedHttpResult.RequestBody);
            Assert.Equal(expectedResponseBody, cleanedHttpResult.ResponseBody);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var httpResult = new HttpResult
            {
                Url          = "http://test.com/users/max/info?pass=123456",
                RequestBody  = "http://test.com?user=max&pass=123456",
                ResponseBody = "http://test.com?user=max&pass=123456"
            };

            var dataLocationCustom = new HashSet <string>
            {
                "OtherLocation",
            };

            var secureKey      = "user";
            var locationsInfo1 = new Dictionary <PropertyType, HashSet <string> >();

            locationsInfo1.Add(PropertyType.Url, dataLocationCustom);
            locationsInfo1.Add(PropertyType.RequestBody, dataLocationCustom);
            locationsInfo1.Add(PropertyType.ResponseBody, dataLocationCustom);
            var secureDataInfo1 = new SecureDataInfo
            {
                SecureKey     = secureKey,
                LocationsInfo = locationsInfo1
            };

            var secureDataInfoList = new List <SecureDataInfo>
            {
                secureDataInfo1,
            };

            var clientCleaner     = new ClientCleaner();
            var secureDataCleaner = new SecureDataCleaner(secureDataInfoList, clientCleaner);

            httpResult = secureDataCleaner.CleanHttpResult(httpResult);

            Console.WriteLine(httpResult.Url);
            Console.WriteLine(httpResult.RequestBody);
            Console.WriteLine(httpResult.ResponseBody);
        }