コード例 #1
0
ファイル: XmlPokeTaskSpecs.cs プロジェクト: GorelH/dropkick
           public override void Context() {
              replacement_items.Add("//configuration/connectionStrings/add[@name='bob']/@connectionString", "bob");
              replacement_items.Add("//configuration/connectionStrings/add[@name='bob']/@providerName", "System.Data.OleDb");

              insert_items.Add("//configuration/connectionStrings/add[@name='newDB']/@connectionString", "newConnectionString");
              insert_items.Add("//configuration/connectionStrings/add[@name='newDB']/@providerName", "System.Data.SqlClient");

              insert_items.Add("//configuration/connectionStrings/add[@name='newConnection2']/@connectionString", "newConnectionString2");
              insert_items.Add("//configuration/connectionStrings/add[@name='newConnection2']/@providerName", "System.Data.OleDb");
                            
              task = new XmlPokeTask(file_path_insert, replacement_items, insert_items, new DotNetPath());
           }
コード例 #2
0
ファイル: XmlPokeTaskSpecs.cs プロジェクト: GorelH/dropkick
            public override void Context()
            {
                replacement_items.Add("//test:configuration/test:connectionStrings/test:add[@name='bob']/@connectionString", "bob");
                replacement_items.Add("//test:configuration/test:connectionStrings/test:add[@name='bob']/@providerName", "System.Data.OleDb");

                task = new XmlPokeTask(file_path_with_namespace, replacement_items, new DotNetPath(), namespace_prefixes);
            }
コード例 #3
0
            public override void Context()
            {
                replacement_items.Add("//test:configuration/test:connectionStrings/test:add[@name='bob']/@connectionString", "bob");
                replacement_items.Add("//test:configuration/test:connectionStrings/test:add[@name='bob']/@providerName", "System.Data.OleDb");

                insert_items.Add("//test:configuration/test:connectionStrings/test:add[@name='newDB']/@connectionString", Tuple.Create("newConnectionString", false));
                insert_items.Add("//test:configuration/test:connectionStrings/test:add[@name='newDB']/@providerName", Tuple.Create("System.Data.SqlClient", false));

                insert_items.Add("//test:configuration/test:connectionStrings/test:add[@name='newConnection2']/@connectionString", Tuple.Create("newConnectionString2", false));
                insert_items.Add("//test:configuration/test:connectionStrings/test:add[@name='newConnection2']/@providerName", Tuple.Create("System.Data.OleDb", false));

                task = new XmlPokeTask(file_path_insert_with_namespace, replacement_items, insert_items, new DotNetPath(), namespace_prefixes);
            }
コード例 #4
0
ファイル: XmlPokeTaskSpecs.cs プロジェクト: GorelH/dropkick
           public override void Context() {
              // = = = adding sectionGroups

              var sectionGroups = new Dictionary<string, string>{
                  {"//configuration/configSections/sectionGroup[@name='elmah']/section[@name='security']", "Elmah.SecuritySectionHandler, Elmah"},
                  {"//configuration/configSections/sectionGroup[@name='elmah']/section[@name='errorLog']", "Elmah.ErrorLogSectionHandler, Elmah"},
                  {"//configuration/configSections/sectionGroup[@name='elmah']/section[@name='errorMail']", "Elmah.ErrorMailSectionHandler, Elmah"},
                  {"//configuration/configSections/sectionGroup[@name='elmah']/section[@name='errorFilter']", "Elmah.ErrorFilterSectionHandler, Elmah"}
              };

              foreach(var sg in sectionGroups) {
                 insert_items.Add(sg.Key + "/@requirePermission", "false");
                 insert_items.Add(sg.Key + "/@type", sg.Value);
              }

              // = = = adding the following to system.web/httpModules
              //<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
              //<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
              //<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
              string systemWeb_httpModulesXpath = @"//configuration/system.web/httpModules";
              insert_items.Add(systemWeb_httpModulesXpath + "/add[@name='ErrorLog']/@type", "Elmah.ErrorLogModule, Elmah");
              insert_items.Add(systemWeb_httpModulesXpath + "/add[@name='ErrorMail']/@type", "Elmah.ErrorMailModule, Elmah");
              insert_items.Add(systemWeb_httpModulesXpath + "/add[@name='ErrorFilter']/@type", "Elmah.ErrorFilterModule, Elmah");


              // = = = adding the following to system.webServer/modules:
              //<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
              //<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
              //<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />

              string systemWebServer_modulesXpath = @"//configuration/system.webServer/modules";
              insert_items.Add(systemWebServer_modulesXpath + "/add[@name='ErrorLog']/@type", "Elmah.ErrorLogModule, Elmah");
              insert_items.Add(systemWebServer_modulesXpath + "/add[@name='ErrorLog']/@preCondition", "managedHandler");
              insert_items.Add(systemWebServer_modulesXpath + "/add[@name='ErrorMail']/@type", "Elmah.ErrorMailModule, Elmah");
              insert_items.Add(systemWebServer_modulesXpath + "/add[@name='ErrorMail']/@preCondition", "managedHandler");
              insert_items.Add(systemWebServer_modulesXpath + "/add[@name='ErrorFilter']/@type", "Elmah.ErrorFilterModule, Elmah");
              insert_items.Add(systemWebServer_modulesXpath + "/add[@name='ErrorFilter']/@preCondition", "managedHandler");


              // = = = adding elmah config part
              //<elmah>
              //   <security allowRemoteAccess="1" />
              //   <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Logs" />    
              //   <errorFilter>
              //   <test>
              //      <and>
              //         <equal binding="HttpStatusCode" value="404" type="Int32" />
              //      </and>
              //   </test>
              //   </errorFilter>
              //</elmah>
              string elmahXpath = @"//configuration/elmah";
              insert_items.Add(elmahXpath + "/security/@allowRemoteAccess", "1");
              insert_items.Add(elmahXpath + "/errorLog/@type", "Elmah.XmlFileErrorLog, Elmah");
              insert_items.Add(elmahXpath + "/errorLog/@logPath", "~/App_Data/Logs");

              string equalXpath = elmahXpath + "/errorFilter/test/and/equal";
              insert_items.Add(equalXpath + "/@binding", "HttpStatusCode");
              insert_items.Add(equalXpath + "/@value", "404");
              insert_items.Add(equalXpath + "/@type", "Int32");

              // = = = adding elmah.axd securely
              //<location path="elmah.axd">
              //    <system.web>
              //      <authorization>
              //         <allow users="testDomain\admin, testDomain\otherAdmin"/>
              //         <deny users="*"/>
              //      </authorization>
              //      <httpHandlers>
              //         <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
              //      </httpHandlers>
              //    </system.web>
              //   <system.webServer>
              //    <security>
              //       <authorization>
              //          <clear/>
              //          <add users="testDomain\admin, testDomain\otherAdmin" accessType="Allow"/>
              //       </authorization>
              //    </security>
              //    <handlers>
              //       <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
              //    </handlers>
              //   </system.webServer>
              //</location>
              string locationXpath = @"//configuration/location";
              string ALLOWED_USERS = @"testDomain\admin, testDomain\otherAdmin";
              string ELMAH_AXD = @"elmah.axd";
              string ELMAH_ERRORLOGPAGEFACTORY = @"Elmah.ErrorLogPageFactory, Elmah";
              string GET_POST_HEAD = @"POST,GET,HEAD";
              insert_items.Add(locationXpath + "/@path", ELMAH_AXD);

              //adding stuff to system.web
              insert_items.Add(locationXpath + "/system.web/authorization/allow/@users", ALLOWED_USERS);
              insert_items.Add(locationXpath + "/system.web/authorization/deny/@users", "*");
              insert_items.Add(locationXpath + "/system.web/httpHandlers/add/@verb", GET_POST_HEAD);
              insert_items.Add(locationXpath + "/system.web/httpHandlers/add/@path", ELMAH_AXD);
              insert_items.Add(locationXpath + "/system.web/httpHandlers/add/@type", ELMAH_ERRORLOGPAGEFACTORY);

              //addign stuff to system.webserver
              insert_items.Add(locationXpath + "/system.webServer/security/authorization/clear", "");
              insert_items.Add(locationXpath + "/system.webServer/security/authorization/add/@users", ALLOWED_USERS);
              insert_items.Add(locationXpath + "/system.webServer/security/authorization/add/@accessType", "Allow");
              insert_items.Add(locationXpath + "/system.webServer/handlers/add/@name", "Elmah");
              insert_items.Add(locationXpath + "/system.webServer/handlers/add/@path", ELMAH_AXD);
              insert_items.Add(locationXpath + "/system.webServer/handlers/add/@verb", GET_POST_HEAD);
              insert_items.Add(locationXpath + "/system.webServer/handlers/add/@type", ELMAH_ERRORLOGPAGEFACTORY);
              insert_items.Add(locationXpath + "/system.webServer/handlers/add/@preCondition", "integratedMode");


              task = new XmlPokeTask(file_path_TestAddingElmahToWebConfig, replacement_items, insert_items, new DotNetPath());
           }
コード例 #5
0
            public override void Context()
            {
                replacement_items.Add("//configuration/connectionStrings/add[@name='bob']/@connectionString", "bob");
                replacement_items.Add("//configuration/connectionStrings/add[@name='bob']/@providerName", "System.Data.OleDb");

                insert_items.Add("//configuration/connectionStrings/add[@name='newDB']/@connectionString", Tuple.Create("newConnectionString", false));
                insert_items.Add("//configuration/connectionStrings/add[@name='newDB']/@providerName", Tuple.Create("System.Data.SqlClient", false));

                insert_items.Add("//configuration/connectionStrings/add[@name='newConnection2']/@connectionString", Tuple.Create("newConnectionString2", true));//here is the difference :)
                insert_items.Add("//configuration/connectionStrings/add[@name='newConnection2']/@providerName", Tuple.Create("System.Data.OleDb", false));

                task = new XmlPokeTask(file_path_insert_shouldBeFirst, replacement_items, insert_items, new DotNetPath());
            }
コード例 #6
0
            public void throws_if_namespace_not_set_properly()
            {
                string xmlNameSpacePrefix = String.Empty;
                string errorLogXmlPath = "~/App_Data/Logs";

                var real_insert_items = XmlPokeTaskSpecs.AddElmahCore(xmlNameSpacePrefix, errorLogXmlPath);

                task = new XmlPokeTask(file_path_TestAddingElmahToWebConfigWithNamespace__fails_if_namespace_not_set_properly, replacement_items, real_insert_items, new DotNetPath());

                var thrown = Assert.Throws<Exception>(() => {
                   task.Execute();
                });

                Assert.IsInstanceOf<InvalidOperationException>(thrown.InnerException);
                Assert.IsTrue(thrown.Message.Contains("xPath:"), "UpdateOrInsertValueInFile should have added the xPath to the message.");
            }
コード例 #7
0
            public override void Context()
            {
                string xmlNameSpacePrefix = "test";
                string errorLogXmlPath = "~/App_Data/Logs";

                var real_insert_items = XmlPokeTaskSpecs.AddElmahCore(xmlNameSpacePrefix, errorLogXmlPath);

                task = new XmlPokeTask(file_path_TestAddingElmahToWebConfigWithNamespace, replacement_items, real_insert_items, new DotNetPath(), new Dictionary<string, string> { { "test", "http://schemas.microsoft.com/.NetConfiguration/v2.0" } });
            }
コード例 #8
0
            public override void Context()
            {
                string xmlNameSpacePrefix = String.Empty;
                string errorLogXmlPath = "~/App_Data/Logs";

                var real_insert_items = XmlPokeTaskSpecs.AddElmahCore(xmlNameSpacePrefix, errorLogXmlPath);

                task = new XmlPokeTask(file_path_TestAddingElmahToWebConfig, replacement_items, real_insert_items, new DotNetPath());
            }
コード例 #9
0
 public override void Context()
 {
     replacement_items.Add("//configuration/connectionStrings/add[@name='bob']/@connectionString", "bob");
     task = new XmlPokeTask(file_path, replacement_items, new DotNetPath());
 }