From 5e08f6f5c6a6208c1c21917a98b839c0f7961d43 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Mon, 5 Feb 2018 15:32:01 +0000 Subject: [PATCH] Add a test for cloning disabled projects --- .../WLGitBridgeIntegrationTest.java | 21 +++++++++++++++++++ .../state/state.json | 18 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/cannotCloneADisabledProject/state/state.json diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java index 20b1fb85ed..59a4406130 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java @@ -45,6 +45,9 @@ public class WLGitBridgeIntegrationTest { put("cannotCloneAProtectedProject", new HashMap() {{ put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAProtectedProject/state/state.json")).build()); }}); + put("cannotCloneADisabledProject", new HashMap() {{ + put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneADisabledProject/state/state.json")).build()); + }}); put("canPullAModifiedTexFile", new HashMap() {{ put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/base/state.json")).build()); put("withModifiedTexFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/withModifiedTexFile/state.json")).build()); @@ -727,6 +730,24 @@ public class WLGitBridgeIntegrationTest { wlgb.stop(); } + @Test + public void cannotCloneADisabledProject() throws IOException, GitAPIException, InterruptedException { + int gitBridgePort = 33879; + int mockServerPort = 3879; + + MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneADisabledProject").toFile()); + server.start(); + server.setState(states.get("cannotCloneADisabledProject").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 diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/cannotCloneADisabledProject/state/state.json b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/cannotCloneADisabledProject/state/state.json new file mode 100644 index 0000000000..05fa040b14 --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/cannotCloneADisabledProject/state/state.json @@ -0,0 +1,18 @@ +[ + { + "project": "disabled", + "getDoc": { + "error": 410, + "versionID": 1, + "createdAt": "2018-02-05T15:30:00Z", + "email": "michael.walker@overleaf.com", + "name": "msw" + }, + "getSavedVers": [], + "getForVers": [], + "push": "success", + "postback": { + "type": "outOfDate" + } + } +]