Skip to content

Commit

Permalink
Additional tests for GH KSP-CKAN#315.
Browse files Browse the repository at this point in the history
This time testing where things should go, and more testing of bad
paths.
  • Loading branch information
pjf committed Nov 18, 2014
1 parent 917786c commit d5e2393
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CKAN/Tests/CKAN/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void FindInstallbleFilesWithBonusPath(string path)

string file = contents
.Select(x => x.destination)
.Where(x => Regex.IsMatch(x, "GameData/SuchTest/Flags/dogecoin\\.png$"))
.Where(x => Regex.IsMatch(x, "GameData/SuchTest/DogeCoinFlag/Flags/dogecoin\\.png$"))
.FirstOrDefault();

Assert.IsNotNull(file);
Expand Down Expand Up @@ -203,11 +203,17 @@ public void No_Installable_Files()
}
}

[Test]
public void FindInstallableFilesWithBadTarget()
// All of these targets should fail.
private static readonly string[] BadTargets = {
"GameDataIsTheBestData", "Shups", "GameData/../../../../etc/pwned",
"Ships/Foo", "GameRoot/saves", "GameRoot/CKAN"
};

[Test][TestCaseSource("BadTargets")]
public void FindInstallableFilesWithBadTarget(string location)
{
// This install location? It shouldn't be valid.
dogemod.install[0].install_to = "GameDataIsTheBestData";
dogemod.install[0].install_to = location;

Assert.Throws<CKAN.BadInstallLocationKraken>(delegate
{
Expand Down

0 comments on commit d5e2393

Please sign in to comment.