public void RecordedOptionalVariableNotSanitizedIfMissing()
        {
            var tempFile = Path.GetTempFileName();
            var env = new MockTestEnvironment();
            var testRecording = new TestRecording(RecordedTestMode.Record, tempFile, new RecordedTestSanitizer(), new RecordMatcher());
            env.Mode = RecordedTestMode.Record;
            env.SetRecording(testRecording);

            Assert.IsNull(env.MissingOptionalSecret);

            testRecording.Dispose();
            testRecording = new TestRecording(RecordedTestMode.Playback, tempFile, new RecordedTestSanitizer(), new RecordMatcher());

            Assert.IsNull(testRecording.GetVariable(nameof(env.MissingOptionalSecret), null));
        }
        public async Task RecordedOptionalVariableNotSanitizedIfMissing()
        {
            var tempFile      = Path.GetTempFileName();
            var env           = new MockTestEnvironment();
            var proxy         = TestProxy.Start();
            var testRecording = await TestRecording.CreateAsync(RecordedTestMode.Record, tempFile, proxy, new RecordedTestBaseTests(true));

            env.Mode = RecordedTestMode.Record;
            env.SetRecording(testRecording);

            Assert.IsNull(env.MissingOptionalSecret);

            await testRecording.DisposeAsync();

            testRecording = await TestRecording.CreateAsync(RecordedTestMode.Playback, tempFile, proxy, new RecordedTestBaseTests(true));

            Assert.IsNull(testRecording.GetVariable(nameof(env.MissingOptionalSecret), null));
        }
        public void RecordedVariableSanitized()
        {
            var tempFile = Path.GetTempFileName();
            var env = new MockTestEnvironment();
            var testRecording = new TestRecording(RecordedTestMode.Record, tempFile, new RecordedTestSanitizer(), new RecordMatcher());
            env.Mode = RecordedTestMode.Record;
            env.SetRecording(testRecording);

            Assert.AreEqual("1", env.Base64Secret);
            Assert.AreEqual("1", env.CustomSecret);
            Assert.AreEqual("1", env.DefaultSecret);
            Assert.AreEqual("endpoint=1;key=2", env.ConnectionStringWithSecret);

            testRecording.Dispose();

            testRecording = new TestRecording(RecordedTestMode.Playback, tempFile, new RecordedTestSanitizer(), new RecordMatcher());

            Assert.AreEqual("Kg==", testRecording.GetVariable("Base64Secret", ""));
            Assert.AreEqual("Custom", testRecording.GetVariable("CustomSecret", ""));
            Assert.AreEqual("Sanitized", testRecording.GetVariable("DefaultSecret", ""));
            Assert.AreEqual("endpoint=1;key=Sanitized", testRecording.GetVariable("ConnectionStringWithSecret", ""));
        }
        public async Task RecordedVariableSanitized()
        {
            var tempFile      = Path.GetTempFileName();
            var env           = new MockTestEnvironment();
            var proxy         = TestProxy.Start();
            var testRecording = await TestRecording.CreateAsync(RecordedTestMode.Record, tempFile, proxy, new RecordedTestBaseTests(true));

            env.Mode = RecordedTestMode.Record;
            env.SetRecording(testRecording);

            Assert.AreEqual("1", env.Base64Secret);
            Assert.AreEqual("1", env.CustomSecret);
            Assert.AreEqual("1", env.DefaultSecret);
            Assert.AreEqual("endpoint=1;key=2", env.ConnectionStringWithSecret);

            await testRecording.DisposeAsync();

            testRecording = await TestRecording.CreateAsync(RecordedTestMode.Playback, tempFile, proxy, new RecordedTestBaseTests(true));

            Assert.AreEqual("Kg==", testRecording.GetVariable("Base64Secret", ""));
            Assert.AreEqual("Custom", testRecording.GetVariable("CustomSecret", ""));
            Assert.AreEqual("Sanitized", testRecording.GetVariable("DefaultSecret", ""));
            Assert.AreEqual("endpoint=1;key=Sanitized", testRecording.GetVariable("ConnectionStringWithSecret", ""));
        }