Пример #1
0
        public void TestResetTargetsSessionOnly()
        {
            RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
            var httpContext = new DefaultHttpContext();

            testRecordingHandler.StartRecording("recordingings/cool.json", httpContext.Response);
            var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();

            testRecordingHandler.Sanitizers.Clear();
            testRecordingHandler.Sanitizers.Add(new BodyRegexSanitizer("sanitized", ".*"));
            testRecordingHandler.Transforms.Clear();
            testRecordingHandler.AddSanitizerToRecording(recordingId, new GeneralRegexSanitizer("sanitized", ".*"));
            testRecordingHandler.SetDefaultExtensions(recordingId);
            var session = testRecordingHandler.RecordingSessions.First().Value;

            // check that the individual session had reset sanitizers
            Assert.Empty(session.AdditionalSanitizers);

            // stop the recording to clear out the session cache
            testRecordingHandler.StopRecording(recordingId);

            // then verify that the session level is NOT reset.
            Assert.Single(testRecordingHandler.Sanitizers);
            Assert.IsType <BodyRegexSanitizer>(testRecordingHandler.Sanitizers.First());
        }
Пример #2
0
        public void TestResetTargetsSessionOnly()
        {
            RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
            var httpContext = new DefaultHttpContext();

            testRecordingHandler.StartRecording("recordingings/cool.json", httpContext.Response);
            var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();

            testRecordingHandler.Sanitizers.Clear();
            testRecordingHandler.Sanitizers.Add(new BodyRegexSanitizer("sanitized", ".*"));
            testRecordingHandler.Transforms.Clear();
            testRecordingHandler.AddSanitizerToRecording(recordingId, new GeneralRegexSanitizer("sanitized", ".*"));
            testRecordingHandler.SetDefaultExtensions();
            var session = testRecordingHandler.RecordingSessions.First().Value;

            Assert.Single(session.ModifiableSession.AdditionalSanitizers);
            Assert.IsType <GeneralRegexSanitizer>(session.ModifiableSession.AdditionalSanitizers[0]);

            _checkDefaultExtensions(testRecordingHandler);
        }
Пример #3
0
        public void TestResetTargetsRecordingOnly()
        {
            RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
            var httpContext = new DefaultHttpContext();

            testRecordingHandler.StartRecording("recordingings/cool.json", httpContext.Response);
            var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();


            testRecordingHandler.Sanitizers.Clear();
            testRecordingHandler.Sanitizers.Add(new BodyRegexSanitizer("sanitized", ".*"));
            testRecordingHandler.AddSanitizerToRecording(recordingId, new GeneralRegexSanitizer("sanitized", ".*"));
            testRecordingHandler.SetDefaultExtensions(recordingId);
            var session = testRecordingHandler.RecordingSessions.First().Value;

            // session sanitizer is still set to a single one
            Assert.Single(testRecordingHandler.Sanitizers);
            Assert.IsType <BodyRegexSanitizer>(testRecordingHandler.Sanitizers[0]);
            _checkDefaultExtensions(testRecordingHandler, CheckSkips.IncludeMatcher | CheckSkips.IncludeTransforms);
            Assert.Empty(session.ModifiableSession.AdditionalSanitizers);
            Assert.Empty(session.ModifiableSession.AdditionalTransforms);
            Assert.Null(session.ModifiableSession.CustomMatcher);
        }