Integration tests use the api key now

This commit is contained in:
Mark McDowall
2013-09-20 19:07:42 -07:00
parent e19e523824
commit d19a755fb1
8 changed files with 54 additions and 40 deletions
@@ -14,10 +14,10 @@ namespace NzbDrone.Integration.Test.Client
{
private readonly IRestClient _restClient;
private readonly string _resource;
private readonly string _apiKey;
private readonly Logger _logger;
public ClientBase(IRestClient restClient, string resource = null)
public ClientBase(IRestClient restClient, string apiKey, string resource = null)
{
if (resource == null)
{
@@ -26,6 +26,7 @@ namespace NzbDrone.Integration.Test.Client
_restClient = restClient;
_resource = resource;
_apiKey = apiKey;
_logger = LogManager.GetLogger("REST");
}
@@ -88,10 +89,14 @@ namespace NzbDrone.Integration.Test.Client
public RestRequest BuildRequest(string command = "")
{
return new RestRequest(_resource + "/" + command.Trim('/'))
var request = new RestRequest(_resource + "/" + command.Trim('/'))
{
RequestFormat = DataFormat.Json
RequestFormat = DataFormat.Json,
};
request.AddHeader("Authorization", _apiKey);
return request;
}
public T Get<T>(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.OK) where T : class, new()
@@ -6,8 +6,8 @@ namespace NzbDrone.Integration.Test.Client
{
public class EpisodeClient : ClientBase<EpisodeResource>
{
public EpisodeClient(IRestClient restClient)
: base(restClient, "episodes")
public EpisodeClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey, "episodes")
{
}
@@ -5,12 +5,9 @@ namespace NzbDrone.Integration.Test.Client
{
public class IndexerClient : ClientBase<IndexerResource>
{
public IndexerClient(IRestClient restClient)
: base(restClient)
public IndexerClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey)
{
}
}
}
@@ -5,12 +5,9 @@ namespace NzbDrone.Integration.Test.Client
{
public class ReleaseClient : ClientBase<ReleaseResource>
{
public ReleaseClient(IRestClient restClient)
: base(restClient)
public ReleaseClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey)
{
}
}
}
@@ -7,8 +7,8 @@ namespace NzbDrone.Integration.Test.Client
{
public class SeriesClient : ClientBase<SeriesResource>
{
public SeriesClient(IRestClient restClient)
: base(restClient)
public SeriesClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey)
{
}
@@ -27,14 +27,11 @@ namespace NzbDrone.Integration.Test.Client
}
public class SystemInfoClient : ClientBase<SeriesResource>
{
public SystemInfoClient(IRestClient restClient)
: base(restClient)
public SystemInfoClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey)
{
}
}
}