|
|
|
@ -47,9 +47,6 @@ import org.eclipse.jgit.revwalk.RevTag;
|
|
|
|
|
import org.eclipse.jgit.revwalk.RevTree; |
|
|
|
|
import org.eclipse.jgit.storage.pack.PackStatistics; |
|
|
|
|
import org.eclipse.jgit.transport.UploadPack.RequestPolicy; |
|
|
|
|
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; |
|
|
|
|
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; |
|
|
|
|
import org.eclipse.jgit.transport.resolver.UploadPackFactory; |
|
|
|
|
import org.eclipse.jgit.util.io.NullOutputStream; |
|
|
|
|
import org.hamcrest.Matchers; |
|
|
|
|
import org.junit.After; |
|
|
|
@ -102,16 +99,10 @@ public class UploadPackTest {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static TestProtocol<Object> generateReachableCommitUploadPackProtocol() { |
|
|
|
|
return new TestProtocol<>( |
|
|
|
|
new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
return new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
up.setRequestPolicy(RequestPolicy.REACHABLE_COMMIT); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -122,19 +113,13 @@ public class UploadPackTest {
|
|
|
|
|
RevCommit tip = remote.commit().message("2").parent(commit1).create(); |
|
|
|
|
remote.update("master", tip); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>( |
|
|
|
|
new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
up.setRequestPolicy(RequestPolicy.REACHABLE_COMMIT); |
|
|
|
|
// assume client has a shallow commit
|
|
|
|
|
up.getRevWalk().assumeShallow( |
|
|
|
|
Collections.singleton(commit1.getId())); |
|
|
|
|
up.getRevWalk() |
|
|
|
|
.assumeShallow(Collections.singleton(commit1.getId())); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server); |
|
|
|
|
|
|
|
|
@ -222,14 +207,9 @@ public class UploadPackTest {
|
|
|
|
|
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", |
|
|
|
|
true); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server2); |
|
|
|
|
|
|
|
|
@ -260,14 +240,9 @@ public class UploadPackTest {
|
|
|
|
|
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", |
|
|
|
|
true); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server2); |
|
|
|
|
|
|
|
|
@ -297,14 +272,9 @@ public class UploadPackTest {
|
|
|
|
|
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", |
|
|
|
|
true); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server2); |
|
|
|
|
|
|
|
|
@ -340,14 +310,9 @@ public class UploadPackTest {
|
|
|
|
|
new DfsGarbageCollector(server2).pack(null); |
|
|
|
|
server2.scanForRepoChanges(); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server2); |
|
|
|
|
|
|
|
|
@ -380,14 +345,9 @@ public class UploadPackTest {
|
|
|
|
|
new DfsGarbageCollector(server2).pack(null); |
|
|
|
|
server2.scanForRepoChanges(); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server2); |
|
|
|
|
|
|
|
|
@ -416,14 +376,9 @@ public class UploadPackTest {
|
|
|
|
|
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", |
|
|
|
|
false); |
|
|
|
|
|
|
|
|
|
testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public UploadPack create(Object req, Repository db) |
|
|
|
|
throws ServiceNotEnabledException, |
|
|
|
|
ServiceNotAuthorizedException { |
|
|
|
|
testProtocol = new TestProtocol<>((Object req, Repository db) -> { |
|
|
|
|
UploadPack up = new UploadPack(db); |
|
|
|
|
return up; |
|
|
|
|
} |
|
|
|
|
}, null); |
|
|
|
|
uri = testProtocol.register(ctx, server2); |
|
|
|
|
|
|
|
|
|