public void ReloadSettings(PluginSettings newSettings)
        {
            var needToReloadApplicationServerConfigs = settings == null ||
                                                       newSettings.DiagnosticsUrl != null &&
                                                       !newSettings.DiagnosticsUrl.Equals(settings.DiagnosticsUrl) ||
                                                       !string.Equals(settings.UserName, newSettings.UserName, StringComparison.Ordinal) ||
                                                       newSettings.EncryptedPassword != null &&
                                                       !newSettings.EncryptedPassword.SequenceEqual(settings.EncryptedPassword);

            lck.EnterWriteLock();
            try {
                settings = newSettings;
                tamperer = new CustomTamperingRulesContainer(newSettings);

                if (needToReloadApplicationServerConfigs)
                {
                    serverRedirector = new ServerRedirectionRulesContainer(RetrieveApplicationServerConfigs());
                }
            } finally {
                lck.ExitWriteLock();
            }
        }
Example #2
0
        public BishopTampererTests()
        {
            settings = new PluginSettings()
            {
                UserDefinedTransformations = new [] {
                    new RequestTransformation {
                        RegexToMatchAgainstPathAndQuery = "^/sample-request",
                        DestinationHostHeader           = "www.test2.com",
                        DestinationPathAndQuery         = "/small"
                    },
                    new RequestTransformation {
                        RegexToMatchAgainstHost         = "test.com",
                        RegexToMatchAgainstPathAndQuery = @"advert/(\d+)\??",
                        DestinationPathAndQuery         = "advert?id=$1&"
                    },
                    new RequestTransformation {
                        RegexToMatchAgainstHost = "testip.com",
                        DestinationIpAddresses  = new [] { "192.168.1.10" },
                        Protocol = "http"
                    },
                    new RequestTransformation {
                        RegexToMatchAgainstHost = "testport.com",
                        DestinationPorts        = new ushort[] { 6060 }
                    },
                    new RequestTransformation {
                        RegexToMatchAgainstHost         = "www.test.com",
                        RegexToMatchAgainstPathAndQuery = "/newver",
                        DestinationHostHeader           = "www.test-newver.com",
                    }
                }
            };

            applicationConfigs = new ApplicationServerConfig[] {
                new ApplicationServerConfig {
                    AppPath        = "path1",
                    Bindings       = new [] { "http://192.168.1.10:80:", "https://192.168.1.10:443:" },
                    Server         = "SRV1",
                    ServerFqdnOrIp = "srv1.test.com"
                },
                new ApplicationServerConfig {
                    AppPath        = "path2",
                    Bindings       = new [] { "http://*:80:www.testhost.com", "https://*:80:www.testhost.com" },
                    Server         = "SRV1",
                    ServerFqdnOrIp = "srv1.test.com"
                },
                new ApplicationServerConfig {
                    AppPath        = "path3",
                    Bindings       = new [] { "http://*:6060:", "https://*:6061:" },
                    Server         = "SRV1",
                    ServerFqdnOrIp = "srv1.test.com"
                },
                new ApplicationServerConfig {
                    AppPath        = "path4",
                    Bindings       = new [] { "http://*:80:www.test-newver.com" },
                    Server         = "SRV1",
                    ServerFqdnOrIp = "srv1.test.com"
                },
            };

            tamperingRules         = new CustomTamperingRulesContainer(settings);
            serverRedirectionRules = new ServerRedirectionRulesContainer(applicationConfigs);
        }