From 9cc2ac7e0540907c0fc1e6ae8ed22f68a0bbb9e7 Mon Sep 17 00:00:00 2001 From: Karin Borm Date: Thu, 28 Sep 2023 13:58:11 +0200 Subject: [PATCH 1/2] if student code consists of exactly one Java file, it will be retained for the Junit test --- changelog.txt | 5 +++++ src/VERSION.py | 2 +- src/checker/checker/JUnitChecker.py | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index f027a810..1695f3b9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +# 4.18.3 + +* new: if student code consists of exactly one Java file, it will be retained for the Junit test + for support of tests with Java source code parser + # 4.18.2 * bugfix nginx configuration: large requests diff --git a/src/VERSION.py b/src/VERSION.py index 35f09c79..594889de 100644 --- a/src/VERSION.py +++ b/src/VERSION.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -version = "Version 4.18.2 | 20230920" +version = "Version 4.18.3 | 20230920" diff --git a/src/checker/checker/JUnitChecker.py b/src/checker/checker/JUnitChecker.py index 2d687929..9d211dab 100644 --- a/src/checker/checker/JUnitChecker.py +++ b/src/checker/checker/JUnitChecker.py @@ -149,8 +149,22 @@ def remove_deprecated_warning(text): return text def run(self, env): + # Special treatment for test cases that want to analyze the original Java student code. + # Normally, all Java files are deleted after compilation to prevent a student from reading the test code. + # If there is only one file in this sandbox folder (student code), then it will be restored after deletion. + # This is only done if the student code consists of exactly one file, + # otherwise there is a risk that the student code contains test files that would overwrite the teacher's tests. + from pathlib import Path + files = list(Path(env.tmpdir()).rglob("*.[jJ][aA][vV][aA]")) + if len(files) == 1: + # create backup file + logger.debug(files[0]) + import shutil + shutil.copyfile(str(files[0].absolute()), str(files[0].absolute()) + '__.bak') + self.copy_files(env) + # compile test logger.debug('JUNIT Checker build') java_builder = IgnoringJavaBuilder(_flags="", _libs=self.junit_version, _file_pattern=r"^.*\.[jJ][aA][vV][aA]$", @@ -181,6 +195,11 @@ def run(self, env): logger.error(output) logger.error(error) + if len(files) == 1: + # restore single backup file in case of Java parser testcode + import shutil + shutil.copyfile(str(files[0].absolute()) + '__.bak', str(files[0].absolute())) + # run test logger.debug('JUNIT Checker run') environ = {} From 9e4560c2975e22e1eeac3f4b18b36a74a483ab2c Mon Sep 17 00:00:00 2001 From: Karin Borm Date: Wed, 4 Oct 2023 10:11:00 +0200 Subject: [PATCH 2/2] increase nginx request size --- changelog.txt | 4 ++++ nginx/nginx.conf | 6 +++--- src/VERSION.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1695f3b9..3648ef4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +# 4.18.4 + +* increase request size for nginx + # 4.18.3 * new: if student code consists of exactly one Java file, it will be retained for the Junit test diff --git a/nginx/nginx.conf b/nginx/nginx.conf index d767f814..b10a4f49 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -6,7 +6,7 @@ server { listen 80; # increase upload size to 5 MB (default: 1MB) - client_max_body_size 5M; + client_max_body_size 50M; # server_name server.domain.org; @@ -42,8 +42,8 @@ server { # ssl_certificate /etc/nginx/certs/server.crt; # ssl_certificate_key /etc/nginx/certs/server.key; - # increase upload size to 5 MB (default: 1MB) -# client_max_body_size 5M; + # increase upload size to 50 MB (default: 1MB) +# client_max_body_size 50M; # forward to django # location / { diff --git a/src/VERSION.py b/src/VERSION.py index 594889de..19372d05 100644 --- a/src/VERSION.py +++ b/src/VERSION.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -version = "Version 4.18.3 | 20230920" +version = "Version 4.18.4 | 20231004"