Skip to content

Commit 4549555

Browse files
coopernetesclaude
andcommitted
fix: use AutoApproveGateway in e2e tests to avoid 30-min approval timeout
Valid pushes were being blocked at the approval gate waiting for human review, causing e2e tests to time out. Replace UiApprovalGateway with a test-only AutoApproveGateway that immediately approves and returns so the store-and-forward pass tests complete without manual intervention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5c87fbc commit 4549555

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.finos.gitproxy.e2e;
2+
3+
import java.time.Duration;
4+
import org.finos.gitproxy.approval.ApprovalGateway;
5+
import org.finos.gitproxy.approval.ApprovalResult;
6+
import org.finos.gitproxy.approval.ProgressSender;
7+
import org.finos.gitproxy.db.PushStore;
8+
import org.finos.gitproxy.db.model.Attestation;
9+
10+
/**
11+
* Test-only {@link ApprovalGateway} that immediately approves every push without waiting for human input. Used in e2e
12+
* tests so that valid commits are forwarded without blocking.
13+
*/
14+
class AutoApproveGateway implements ApprovalGateway {
15+
16+
private final PushStore pushStore;
17+
18+
AutoApproveGateway(PushStore pushStore) {
19+
this.pushStore = pushStore;
20+
}
21+
22+
@Override
23+
public ApprovalResult waitForApproval(String pushId, ProgressSender progress, Duration timeout) {
24+
pushStore.approve(
25+
pushId,
26+
Attestation.builder()
27+
.pushId(pushId)
28+
.type(Attestation.Type.APPROVAL)
29+
.reviewerUsername("e2e-auto-approver")
30+
.reason("Automatically approved by e2e test fixture")
31+
.automated(true)
32+
.build());
33+
return ApprovalResult.APPROVED;
34+
}
35+
}

jgit-proxy-server/src/test/java/org/finos/gitproxy/e2e/JettyProxyFixture.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.eclipse.jetty.server.Server;
1313
import org.eclipse.jetty.server.ServerConnector;
1414
import org.eclipse.jgit.http.server.GitServlet;
15-
import org.finos.gitproxy.approval.UiApprovalGateway;
1615
import org.finos.gitproxy.config.CommitConfig;
1716
import org.finos.gitproxy.config.GpgConfig;
1817
import org.finos.gitproxy.db.PushStoreFactory;
@@ -59,7 +58,7 @@ class JettyProxyFixture implements AutoCloseable {
5958
var resolver = new StoreAndForwardRepositoryResolver(storeForwardCache, provider);
6059
var gitServlet = new GitServlet();
6160
gitServlet.setRepositoryResolver(resolver);
62-
var approvalGateway = new UiApprovalGateway(pushStore);
61+
var approvalGateway = new AutoApproveGateway(pushStore);
6362
gitServlet.setReceivePackFactory(
6463
new StoreAndForwardReceivePackFactory(provider, commitConfig, pushStore, approvalGateway));
6564
gitServlet.setUploadPackFactory(new StoreAndForwardUploadPackFactory());

0 commit comments

Comments
 (0)