mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Report all 4xx from write-latex API as MissingRepositoryException
This commit is contained in:
parent
6ae6acd826
commit
82c0873743
3 changed files with 45 additions and 8 deletions
|
@ -70,14 +70,12 @@ public abstract class Request<T extends Result> {
|
|||
Throwable cause = e.getCause();
|
||||
if (cause instanceof HttpResponseException) {
|
||||
HttpResponseException httpCause = (HttpResponseException) cause;
|
||||
switch (httpCause.getStatusCode()) {
|
||||
case HttpServletResponse.SC_UNAUTHORIZED:
|
||||
case HttpServletResponse.SC_FORBIDDEN:
|
||||
int sc = httpCause.getStatusCode();
|
||||
if (sc == HttpServletResponse.SC_UNAUTHORIZED || sc == HttpServletResponse.SC_FORBIDDEN) {
|
||||
throw new ForbiddenException();
|
||||
case HttpServletResponse.SC_GONE:
|
||||
}
|
||||
if (sc >= 400 && sc < 500) {
|
||||
throw new MissingRepositoryException();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
throw new FailedConnectionException(cause);
|
||||
} else {
|
||||
|
|
|
@ -48,6 +48,9 @@ public class WLGitBridgeIntegrationTest {
|
|||
put("cannotCloneADisabledProject", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneADisabledProject/state/state.json")).build());
|
||||
}});
|
||||
put("cannotCloneAMissingProject", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAMissingProject/state/state.json")).build());
|
||||
}});
|
||||
put("canPullAModifiedTexFile", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/base/state.json")).build());
|
||||
put("withModifiedTexFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/withModifiedTexFile/state.json")).build());
|
||||
|
@ -748,6 +751,24 @@ public class WLGitBridgeIntegrationTest {
|
|||
assertNotEquals(0, gitProcess.waitFor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cannotCloneAMissingProject() throws IOException, GitAPIException, InterruptedException {
|
||||
int gitBridgePort = 33880;
|
||||
int mockServerPort = 3880;
|
||||
|
||||
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneAMissingProject").toFile());
|
||||
server.start();
|
||||
server.setState(states.get("cannotCloneAMissingProject").get("state"));
|
||||
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
|
||||
makeConfigFile(gitBridgePort, mockServerPort)
|
||||
});
|
||||
|
||||
wlgb.run();
|
||||
Process gitProcess = runtime.exec("git clone http://127.0.0.1:" + gitBridgePort + "/testproj.git", null, dir);
|
||||
wlgb.stop();
|
||||
assertNotEquals(0, gitProcess.waitFor());
|
||||
}
|
||||
|
||||
private String makeConfigFile(
|
||||
int port,
|
||||
int apiPort
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
[
|
||||
{
|
||||
"project": "missing",
|
||||
"getDoc": {
|
||||
"error": 404,
|
||||
"versionID": 1,
|
||||
"createdAt": "2018-02-06T13:29:00Z",
|
||||
"email": "michael.walker@overleaf.com",
|
||||
"name": "msw"
|
||||
},
|
||||
"getSavedVers": [],
|
||||
"getForVers": [],
|
||||
"push": "success",
|
||||
"postback": {
|
||||
"type": "outOfDate"
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue