|
|
@ -4,6 +4,7 @@ using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
using System.Xml.XPath;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
using NzbDrone.Common.Processes;
|
|
|
|
using NzbDrone.Common.Processes;
|
|
|
@ -56,7 +57,7 @@ namespace NzbDrone.Integration.Test
|
|
|
|
Assert.Fail("Process has exited");
|
|
|
|
Assert.Fail("Process has exited");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ApiKey = GetApiKey();
|
|
|
|
SetApiKey();
|
|
|
|
|
|
|
|
|
|
|
|
var request = new RestRequest("system/status");
|
|
|
|
var request = new RestRequest("system/status");
|
|
|
|
request.AddHeader("Authorization", ApiKey);
|
|
|
|
request.AddHeader("Authorization", ApiKey);
|
|
|
@ -98,16 +99,23 @@ namespace NzbDrone.Integration.Test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetApiKey()
|
|
|
|
private void SetApiKey()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var configFile = Path.Combine(AppData, "config.xml");
|
|
|
|
var configFile = Path.Combine(AppData, "config.xml");
|
|
|
|
|
|
|
|
|
|
|
|
if (!String.IsNullOrWhiteSpace(ApiKey)) return ApiKey;
|
|
|
|
while (ApiKey == null)
|
|
|
|
if (!File.Exists(configFile)) return null;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (File.Exists(configFile))
|
|
|
|
var xDoc = XDocument.Load(configFile);
|
|
|
|
{
|
|
|
|
var config = xDoc.Descendants(ConfigFileProvider.CONFIG_ELEMENT_NAME).Single();
|
|
|
|
var apiKeyElement = XDocument.Load(configFile)
|
|
|
|
return config.Descendants("ApiKey").Single().Value;
|
|
|
|
.XPathSelectElement("Config/ApiKey");
|
|
|
|
|
|
|
|
if (apiKeyElement != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ApiKey = apiKeyElement.Value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|