more reliable apikey for integration tests.

pull/3113/head
kayone 11 years ago
parent 1695ff7305
commit af3ffa1c48

@ -119,7 +119,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
return String.Empty;
var xDoc = XDocument.Load(new StringReader(response.Replace("&", "&")));
var xml = (from x in xDoc.Descendants("xml") select x).FirstOrDefault();
var xml = xDoc.Descendants("xml").Select(x => x).FirstOrDefault();
if (xml == null)
return null;

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
using System.Xml.XPath;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Processes;
@ -56,7 +57,7 @@ namespace NzbDrone.Integration.Test
Assert.Fail("Process has exited");
}
ApiKey = GetApiKey();
SetApiKey();
var request = new RestRequest("system/status");
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");
if (!String.IsNullOrWhiteSpace(ApiKey)) return ApiKey;
if (!File.Exists(configFile)) return null;
var xDoc = XDocument.Load(configFile);
var config = xDoc.Descendants(ConfigFileProvider.CONFIG_ELEMENT_NAME).Single();
return config.Descendants("ApiKey").Single().Value;
while (ApiKey == null)
{
if (File.Exists(configFile))
{
var apiKeyElement = XDocument.Load(configFile)
.XPathSelectElement("Config/ApiKey");
if (apiKeyElement != null)
{
ApiKey = apiKeyElement.Value;
}
}
Thread.Sleep(1000);
}
}
}
}
Loading…
Cancel
Save