DirCacheCheckoutMaliciousPathTest: Open Git and RevWalk in t-w-r
Change-Id: Iacb4e25f0ada74b1a01e448216cb02c7ec18b2d7 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
parent
30c9ec88d1
commit
259dca06ec
|
@ -338,7 +338,8 @@ private void testMaliciousPathGoodSecondCheckout(String... paths) throws Excepti
|
||||||
*/
|
*/
|
||||||
private void testMaliciousPath(boolean good, boolean secondCheckout,
|
private void testMaliciousPath(boolean good, boolean secondCheckout,
|
||||||
String... path) throws GitAPIException, IOException {
|
String... path) throws GitAPIException, IOException {
|
||||||
Git git = new Git(db);
|
try (Git git = new Git(db);
|
||||||
|
RevWalk revWalk = new RevWalk(git.getRepository())) {
|
||||||
ObjectInserter newObjectInserter;
|
ObjectInserter newObjectInserter;
|
||||||
newObjectInserter = git.getRepository().newObjectInserter();
|
newObjectInserter = git.getRepository().newObjectInserter();
|
||||||
ObjectId blobId = newObjectInserter.insert(Constants.OBJ_BLOB,
|
ObjectId blobId = newObjectInserter.insert(Constants.OBJ_BLOB,
|
||||||
|
@ -379,7 +380,6 @@ private void testMaliciousPath(boolean good, boolean secondCheckout,
|
||||||
commitBuilder.setParentId(firstCommitId);
|
commitBuilder.setParentId(firstCommitId);
|
||||||
ObjectId commitId = newObjectInserter.insert(commitBuilder);
|
ObjectId commitId = newObjectInserter.insert(commitBuilder);
|
||||||
|
|
||||||
RevWalk revWalk = new RevWalk(git.getRepository());
|
|
||||||
if (!secondCheckout)
|
if (!secondCheckout)
|
||||||
git.checkout().setStartPoint(revWalk.parseCommit(firstCommitId))
|
git.checkout().setStartPoint(revWalk.parseCommit(firstCommitId))
|
||||||
.setName("refs/heads/master").setCreateBranch(true).call();
|
.setName("refs/heads/master").setCreateBranch(true).call();
|
||||||
|
@ -402,5 +402,6 @@ private void testMaliciousPath(boolean good, boolean secondCheckout,
|
||||||
assertTrue(e.getMessage().startsWith("Invalid path"));
|
assertTrue(e.getMessage().startsWith("Invalid path"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue