mirror of
https://github.com/Radarr/Radarr
synced 2025-02-27 08:33:21 +00:00
fixed newznab validation when URL is null.
This commit is contained in:
parent
bd157b794b
commit
37ae2d04e3
2 changed files with 24 additions and 1 deletions
|
@ -21,7 +21,25 @@ public void requires_apikey(string url)
|
||||||
|
|
||||||
setting.Validate().IsValid.Should().BeFalse();
|
setting.Validate().IsValid.Should().BeFalse();
|
||||||
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ApiKey");
|
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ApiKey");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("")]
|
||||||
|
[TestCase(" ")]
|
||||||
|
[TestCase(null)]
|
||||||
|
public void invalid_url_should_not_apikey(string url)
|
||||||
|
{
|
||||||
|
var setting = new NewznabSettings
|
||||||
|
{
|
||||||
|
ApiKey = "",
|
||||||
|
Url = url
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
setting.Validate().IsValid.Should().BeFalse();
|
||||||
|
setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ApiKey");
|
||||||
|
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "Url");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,11 @@ public class NewznabSettingsValidator : AbstractValidator<NewznabSettings>
|
||||||
|
|
||||||
private static bool ShouldHaveApiKey(NewznabSettings settings)
|
private static bool ShouldHaveApiKey(NewznabSettings settings)
|
||||||
{
|
{
|
||||||
|
if (settings.Url == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ApiKeyWhiteList.Any(c => settings.Url.ToLowerInvariant().Contains(c));
|
return ApiKeyWhiteList.Any(c => settings.Url.ToLowerInvariant().Contains(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue