Beispiel #1
0
        internal override IEnumerable <(IServirtiumServer, PlanetApi)> GenerateTestServerClientPairs(string script, IEnumerable <RegexReplacement>?transformReplacements = null)
        {
            IEnumerable <RegexReplacement> replacements = transformReplacements ?? new RegexReplacement[0];
            var targetScriptPath = Path.Combine(RECORDING_OUTPUT_DIRECTORY, script);
            var recorder         = new InteractionRecorder(
                PlanetApi.DEFAULT_SITE, targetScriptPath,
                new FindAndReplaceScriptWriter(new[] {
                new RegexReplacement(new Regex("User-Agent: .*"), "User-Agent: Servirtium-Testing")
            }, new MarkdownScriptWriter(null, loggerFactory), loggerFactory), loggerFactory);

            yield return
                (
                AspNetCoreServirtiumServer.WithTransforms(
                    1234,
                    recorder,
                    new HttpMessageTransformPipeline(
                        new SimpleHttpMessageTransforms(
                            PlanetApi.DEFAULT_SITE,
                            new Regex[0],
                            new[] {
                "Date:", "X-", "Strict-Transport-Security",
                "Content-Security-Policy", "Cache-Control", "Secure", "HttpOnly",
                "Set-Cookie: climatedata.cookie="
            }.Select(pattern => new Regex(pattern)),
                            loggerFactory
                            ),
                        new FindAndReplaceHttpMessageTransforms(replacements, loggerFactory)
                        ), loggerFactory),
                new PlanetApi(new Uri("http://localhost:1234"))
                );

            var replayer = new InteractionReplayer(null, null, null, null, loggerFactory);

            replayer.LoadScriptFile(targetScriptPath);
            yield return
                (
                AspNetCoreServirtiumServer.WithTransforms(
                    1234,
                    replayer,
                    new HttpMessageTransformPipeline(
                        new SimpleHttpMessageTransforms(
                            PlanetApi.DEFAULT_SITE,
                            new Regex[0],
                            new[] { new Regex("Date:") },
                            loggerFactory
                            ),
                        new FindAndReplaceHttpMessageTransforms(replacements, loggerFactory)
                        ), loggerFactory),
                new PlanetApi(new Uri("http://localhost:1234"))
                );
        }
Beispiel #2
0
        internal override IEnumerable <(IServirtiumServer, ClimateApi)> GenerateTestServerClientPairs(string script)
        {
            var targetScriptPath = Path.Combine(RECORDING_OUTPUT_DIRECTORY, script);
            var recorder         = new InteractionRecorder(
                ClimateApi.DEFAULT_SITE, targetScriptPath,
                new FindAndReplaceScriptWriter(new[] {
                new RegexReplacement(new Regex("Set-Cookie: AWSALB=.*"), "Set-Cookie: AWSALB=REPLACED-IN-RECORDING; Expires=Thu, 15 Jan 2099 11:11:11 GMT; Path=/"),
                new RegexReplacement(new Regex("Set-Cookie: TS0137860d=.*"), "Set-Cookie: TS0137860d=ALSO-REPLACED-IN-RECORDING; Path=/"),
                new RegexReplacement(new Regex("Set-Cookie: TS01c35ec3=.*"), "Set-Cookie: TS01c35ec3=ONE-MORE-REPLACED-IN-RECORDING; Path=/"),
                new RegexReplacement(new Regex("Set-Cookie: climatedataapi.cookie=.*"), "Set-Cookie: climatedataapi.cookie=1234567899999; Path=/"),
                new RegexReplacement(new Regex("Set-Cookie: climatedataapi_ext.cookie=.*"), "Set-Cookie: climatedataapi_ext.cookie=9876543211111; Path=/"),
                new RegexReplacement(new Regex("User-Agent: .*"), "User-Agent: Servirtium-Testing")
            }, new MarkdownScriptWriter(null, loggerFactory), loggerFactory), loggerFactory);

            yield return
                (
                AspNetCoreServirtiumServer.WithTransforms(
                    1234,
                    recorder,
                    new SimpleHttpMessageTransforms(
                        ClimateApi.DEFAULT_SITE,
                        new Regex[0],
                        new[] {
                "Date:", "X-", "Strict-Transport-Security",
                "Content-Security-Policy", "Cache-Control", "Secure", "HttpOnly",
                "Set-Cookie: climatedata.cookie="
            }.Select(pattern => new Regex(pattern)),
                        loggerFactory
                        ), loggerFactory),
                new ClimateApi(new Uri("http://localhost:1234"))
                );

            var replayer = new InteractionReplayer(null, null, null, null, loggerFactory);

            replayer.LoadScriptFile(targetScriptPath);
            yield return
                (
                AspNetCoreServirtiumServer.WithTransforms(
                    1234,
                    replayer,
                    new SimpleHttpMessageTransforms(
                        ClimateApi.DEFAULT_SITE,
                        new[] { new Regex("Cookie:") },
                        new[] { new Regex("Date:"), new Regex("Cookie:") },
                        loggerFactory
                        ), loggerFactory),
                new ClimateApi(new Uri("http://localhost:1234"))
                );
        }
        internal override IEnumerable <(IServirtiumServer, ClimateApi)> GenerateTestServerClientPairs(string script)
        {
            var replayer = new InteractionReplayer(null, null, null, null, loggerFactory);

            replayer.LoadScriptFile(Path.Combine(PREGENERATED_PLAYBACKS_DIRECTORY, script));
            yield return
                (
                AspNetCoreServirtiumServer.WithTransforms(
                    1234,
                    replayer,
                    new SimpleHttpMessageTransforms(
                        ClimateApi.DEFAULT_SITE,
                        new[] { new Regex("Cookie:") },
                        new[] { new Regex("Date:"), new Regex("Cookie:") },
                        loggerFactory
                        ), loggerFactory),
                new ClimateApi(new Uri("http://localhost:1234"))
                );
        }