diff --git a/NzbDrone.Api/NancyBootstrapper.cs b/NzbDrone.Api/NancyBootstrapper.cs index f338dd079a..348d0acbef 100644 --- a/NzbDrone.Api/NancyBootstrapper.cs +++ b/NzbDrone.Api/NancyBootstrapper.cs @@ -38,7 +38,7 @@ protected override void ApplicationStartup(TinyIoCContainer container, IPipeline container.Resolve().Register(); container.Resolve().PublishEvent(new ApplicationStartedEvent()); - + if (container.Resolve().AuthenticationType == AuthenticationType.Basic) { pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration( diff --git a/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/NzbDrone.Common.Test/ConfigFileProviderTest.cs index 066d8653b3..2312c61bec 100644 --- a/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -127,25 +127,19 @@ public void GetValue_New_Key() [Test] public void GetAuthenticationType_No_Existing_Value() { - - var result = Subject.AuthenticationType; - result.Should().Be(AuthenticationType.Anonymous); } [Test] - public void GetAuthenticationType_Windows() + public void GetAuthenticationType_Basic() { - - Subject.SetValue("AuthenticationType", 1); - - + Subject.SetValue("AuthenticationType", AuthenticationType.Basic); + var result = Subject.AuthenticationType; - - - result.Should().Be(AuthenticationType.Windows); + + result.Should().Be(AuthenticationType.Basic); } [Test] diff --git a/NzbDrone.Common/IConfigFileProvider.cs b/NzbDrone.Common/IConfigFileProvider.cs index 7fe7e30ebb..968580ab65 100644 --- a/NzbDrone.Common/IConfigFileProvider.cs +++ b/NzbDrone.Common/IConfigFileProvider.cs @@ -17,6 +17,7 @@ public interface IConfigFileProvider int GetValueInt(string key, int defaultValue); bool GetValueBoolean(string key, bool defaultValue); string GetValue(string key, object defaultValue); + T GetValueEnum(string key, T defaultValue); void SetValue(string key, object value); } @@ -88,7 +89,7 @@ public virtual bool GetValueBoolean(string key, bool defaultValue) return Convert.ToBoolean(GetValue(key, defaultValue)); } - private T GetValueEnum(string key, T defaultValue) + public T GetValueEnum(string key, T defaultValue) { return (T)Enum.Parse(typeof(T), GetValue(key, defaultValue), true); } @@ -100,7 +101,6 @@ public virtual string GetValue(string key, object defaultValue) var parentContainer = config; - var valueHolder = parentContainer.Descendants(key).ToList(); if (valueHolder.Count() == 1) @@ -131,7 +131,7 @@ public virtual void SetValue(string key, object value) xDoc.Save(_configFile); } - private void SetValue(string key, Enum value) + public void SetValue(string key, Enum value) { SetValue(key, value.ToString().ToLower()); }