mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
fixed more tests.
This commit is contained in:
parent
6a5c10a456
commit
9fdfd13dbf
23 changed files with 261 additions and 490 deletions
|
@ -2,8 +2,6 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Model;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
|
@ -11,10 +9,9 @@ namespace NzbDrone.Common
|
|||
public class ConfigFileProvider
|
||||
{
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly string _configFile;
|
||||
|
||||
|
||||
public ConfigFileProvider(EnvironmentProvider environmentProvider)
|
||||
{
|
||||
_environmentProvider = environmentProvider;
|
||||
|
@ -25,7 +22,7 @@ namespace NzbDrone.Common
|
|||
|
||||
public ConfigFileProvider()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual Guid Guid
|
||||
|
@ -60,11 +57,6 @@ namespace NzbDrone.Common
|
|||
set { SetValue("AuthenticationType", (int)value); }
|
||||
}
|
||||
|
||||
public virtual bool EnableProfiler
|
||||
{
|
||||
get { return GetValueBoolean("EnableProfiler", false); }
|
||||
set { SetValue("EnableProfiler", value); }
|
||||
}
|
||||
|
||||
public virtual int GetValueInt(string key, int defaultValue)
|
||||
{
|
||||
|
@ -126,50 +118,5 @@ namespace NzbDrone.Common
|
|||
xDoc.Save(_configFile);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateIISConfig(string configPath)
|
||||
{
|
||||
logger.Info(@"Server configuration file: {0}", configPath);
|
||||
logger.Info(@"Configuring server to: [http://localhost:{0}]", Port);
|
||||
|
||||
var configXml = XDocument.Load(configPath);
|
||||
|
||||
var bindings =
|
||||
configXml.XPathSelectElement("configuration/system.applicationHost/sites").Elements("site").Where(
|
||||
d => d.Attribute("name").Value.ToLowerInvariant() == "nzbdrone").First().Element("bindings");
|
||||
bindings.Descendants().Remove();
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:localhost", Port))
|
||||
));
|
||||
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", Port))
|
||||
));
|
||||
|
||||
//Update the authenticationTypes
|
||||
|
||||
var location = configXml.XPathSelectElement("configuration").Elements("location").Where(
|
||||
d => d.Attribute("path").Value.ToLowerInvariant() == "nzbdrone").First();
|
||||
|
||||
|
||||
var authenticationTypes = location.XPathSelectElements("system.webServer/security/authentication").First().Descendants();
|
||||
|
||||
//Set all authentication types enabled to false
|
||||
foreach (var child in authenticationTypes)
|
||||
{
|
||||
child.Attribute("enabled").Value = "false";
|
||||
}
|
||||
|
||||
var configuredAuthType = String.Format("{0}Authentication", AuthenticationType.ToString()).ToLowerInvariant();
|
||||
|
||||
//Set the users authenticationType to true
|
||||
authenticationTypes.Where(t => t.Name.ToString().ToLowerInvariant() == configuredAuthType).Single().Attribute("enabled").Value = "true";
|
||||
|
||||
configXml.Save(configPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue