mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-30 12:24:25 +02:00
Fully implement max file size
- add `repoStore.maxFileSize` key to config - use maxFileSize in ResourceCache on both header path and blob download path - make failures during commit less fragile
This commit is contained in:
@@ -95,7 +95,10 @@ public class ConfigTest {
|
||||
" \"oauth2ClientID\": \"<oauth2ClientID>\",\n" +
|
||||
" \"oauth2ClientSecret\": \"<oauth2ClientSecret>\",\n" +
|
||||
" \"oauth2Server\": \"https://www.overleaf.com\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"repoStore\": null,\n" +
|
||||
" \"swapStore\": null,\n" +
|
||||
" \"swapJob\": null\n" +
|
||||
"}";
|
||||
assertEquals(
|
||||
"sanitised config did not hide sensitive fields",
|
||||
|
||||
@@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.bridge;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import uk.ac.ic.wlgitbridge.application.config.Config;
|
||||
import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.db.ProjectState;
|
||||
import uk.ac.ic.wlgitbridge.bridge.gc.GcJob;
|
||||
@@ -50,6 +51,18 @@ public class BridgeTest {
|
||||
swapJob = mock(SwapJob.class);
|
||||
gcJob = mock(GcJob.class);
|
||||
bridge = new Bridge(
|
||||
new Config(
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null),
|
||||
lock,
|
||||
repoStore,
|
||||
dbStore,
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -42,7 +43,7 @@ public class FSGitRepoStoreTest {
|
||||
File tmp = makeTempRepoDir(tmpFolder, "rootdir");
|
||||
original = tmpFolder.newFolder("original");
|
||||
FileUtils.copyDirectory(tmp, original);
|
||||
repoStore = new FSGitRepoStore(tmp.getAbsolutePath());
|
||||
repoStore = new FSGitRepoStore(tmp.getAbsolutePath(), Optional.empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GitProjectRepoTest {
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
rootdir = makeTempRepoDir(tmpFolder, "rootdir");
|
||||
repoStore = new FSGitRepoStore(rootdir.getAbsolutePath());
|
||||
repoStore = new FSGitRepoStore(rootdir.getAbsolutePath(), Optional.empty());
|
||||
repo = fromExistingDir("repo");
|
||||
badGitignore = fromExistingDir("badgitignore");
|
||||
incoming = fromExistingDir("incoming");
|
||||
@@ -64,7 +64,7 @@ public class GitProjectRepoTest {
|
||||
}
|
||||
|
||||
private GitProjectRepo fromExistingDir(String dir) throws IOException {
|
||||
GitProjectRepo ret = new GitProjectRepo(dir);
|
||||
GitProjectRepo ret = GitProjectRepo.fromName(dir);
|
||||
ret.useExistingRepository(repoStore);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class SwapJobImplTest {
|
||||
tmpFolder,
|
||||
"repostore"
|
||||
).getAbsolutePath(),
|
||||
100_000,
|
||||
FileUtils::sizeOfDirectory
|
||||
);
|
||||
dbStore = new SqliteDBStore(tmpFolder.newFile());
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.mockserver.client.server.MockServerClient;
|
||||
import org.mockserver.junit.MockServerRule;
|
||||
import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.repo.FSGitRepoStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.repo.GitProjectRepo;
|
||||
import uk.ac.ic.wlgitbridge.bridge.repo.ProjectRepo;
|
||||
import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.resource.ResourceCache;
|
||||
@@ -20,6 +19,7 @@ import uk.ac.ic.wlgitbridge.git.exception.GitUserException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockserver.model.HttpRequest.request;
|
||||
@@ -67,12 +67,13 @@ public class ResourceFetcherTest {
|
||||
TemporaryFolder repositoryFolder = new TemporaryFolder();
|
||||
repositoryFolder.create();
|
||||
String repoStorePath = repositoryFolder.getRoot().getAbsolutePath();
|
||||
RepoStore repoStore = new FSGitRepoStore(repoStorePath);
|
||||
ProjectRepo repo = new GitProjectRepo("repo");
|
||||
repo.initRepo(repoStore);
|
||||
Map<String, RawFile> fileTable = repo.getFiles();
|
||||
Map<String, byte[]> fetchedUrls = new HashMap<String, byte[]>();
|
||||
resources.get(testProjectName, testUrl, newTestPath, fileTable, fetchedUrls);
|
||||
RepoStore repoStore = new FSGitRepoStore(repoStorePath, Optional.empty());
|
||||
ProjectRepo repo = repoStore.initRepo("repo");
|
||||
Map<String, RawFile> fileTable = repo.getDirectory().getFileTable();
|
||||
Map<String, byte[]> fetchedUrls = new HashMap<>();
|
||||
resources.get(
|
||||
testProjectName, testUrl, newTestPath,
|
||||
fileTable, fetchedUrls, Optional.empty());
|
||||
|
||||
// We don't bother caching in this case, at present.
|
||||
assertEquals(0, fetchedUrls.size());
|
||||
|
||||
Reference in New Issue
Block a user