mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 08:19:38 +02:00
Fixed third-party clients calling api without Accept header
This commit is contained in:
parent
a862337ead
commit
a22c946276
51
src/NzbDrone.Integration.Test/GenericApiFixture.cs
Normal file
51
src/NzbDrone.Integration.Test/GenericApiFixture.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Integration.Test.Client;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class GenericApiFixture : IntegrationTest
|
||||
{
|
||||
[TestCase("application/json")]
|
||||
[TestCase("text/html, application/json")]
|
||||
[TestCase("application/xml, application/json")]
|
||||
[TestCase("text/html, */*")]
|
||||
[TestCase("*/*")]
|
||||
[TestCase("")]
|
||||
public void should_get_json_with_accept_header(string header)
|
||||
{
|
||||
|
||||
var request = new RestRequest("system/status")
|
||||
{
|
||||
RequestFormat = DataFormat.None
|
||||
};
|
||||
request.AddHeader("Accept", header);
|
||||
|
||||
var response = RestClient.Execute(request);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
response.ContentType.Should().Be("application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
[TestCase("application/xml")]
|
||||
[TestCase("text/html")]
|
||||
[TestCase("application/junk")]
|
||||
public void should_get_unacceptable_with_accept_header(string header)
|
||||
{
|
||||
|
||||
var request = new RestRequest("system/status")
|
||||
{
|
||||
RequestFormat = DataFormat.None
|
||||
};
|
||||
request.AddHeader("Accept", header);
|
||||
|
||||
var response = RestClient.Execute(request);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.NotAcceptable);
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,10 @@ protected override Func<ITypeCatalog, NancyInternalConfiguration> InternalConfig
|
||||
get
|
||||
{
|
||||
// We don't support Xml Serialization atm
|
||||
return NancyInternalConfiguration.WithOverrides(x => x.ResponseProcessors.Remove(typeof(XmlProcessor)));
|
||||
return NancyInternalConfiguration.WithOverrides(x => {
|
||||
x.ResponseProcessors.Remove(typeof(ViewProcessor));
|
||||
x.ResponseProcessors.Remove(typeof(XmlProcessor));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user