Skip to content

Commit

Permalink
fix metadata overritting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gregbell26 committed Feb 4, 2025
1 parent f9f835a commit 913089e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
19 changes: 18 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ services:
- "./tests/e2e/test_requirements_in_submission/submission_metadata.json:/autograder/submission_metadata.json"
- "./tests/e2e/integration_config.toml:/autograder/source/config.toml"

test_metadata_attack_volume_holder:
build:
context: ./tests/e2e/test_metadata_attack
dockerfile_inline: |
FROM busybox
ADD submission_metadata.json /cache/submission_metadata.json
CMD ["cp", "/cache/submission_metadata.json", "/autograder/submission_metadata.json"]
volumes:
- "metadata_attack_vol:/autograder/"


test_metadata_attack:
build:
dockerfile: docker/generic.dockerfile
Expand All @@ -35,11 +46,14 @@ services:
- run_gradescope
working_dir: /autograder/source
volumes:
- "metadata_attack_vol:/autograder"
- "./tests/e2e/test_metadata_attack/results:/autograder/results"
- "./tests/e2e/test_metadata_attack/student_tests:/autograder/source/student_tests"
- "./tests/e2e/test_metadata_attack/submission:/autograder/submission"
- "./tests/e2e/test_metadata_attack/submission_metadata.json:/autograder/submission_metadata.json"
- "./tests/e2e/integration_config.toml:/autograder/source/config.toml"
depends_on:
test_metadata_attack_volume_holder:
condition: service_completed_successfully

test_data_file_in_submission:
build:
Expand Down Expand Up @@ -111,3 +125,6 @@ services:
- "./tests/e2e/test_run_with_prairie_learn/submission:/grade/student"
- "./tests/e2e/test_run_with_prairie_learn/data.json:/grade/data/data.json"
- "./tests/e2e/integration_config.toml:/grade/data/config.toml"

volumes:
metadata_attack_vol:
11 changes: 3 additions & 8 deletions tests/e2e/test_metadata_attack/student_tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from autograder_platform.config.Config import AutograderConfigurationProvider
from autograder_platform.StudentSubmissionImpl.Python.Runners import PythonRunnerBuilder

class RequirementsTest(unittest.TestCase):
class MetadataAttackTests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.autograderConfig = AutograderConfigurationProvider.get()
Expand All @@ -22,8 +22,7 @@ def setUp(self) -> None:
self.environmentBuilder = ExecutionEnvironmentBuilder()

@Weight(10)
@ImageResult()
def testCode(self, encode_image_data=None, set_image_data=None):
def testCode(self):
environment = self.environmentBuilder.build()

runner = PythonRunnerBuilder(self.studentSubmission)\
Expand All @@ -34,8 +33,4 @@ def testCode(self, encode_image_data=None, set_image_data=None):

actualOutput = getResults(environment).stdout

self.assertEqual(1, len(actualOutput))

imageData = encode_image_data(getResults(environment).file_out["plt.png"])

set_image_data("Plot", imageData)
self.assertEqual(1, len(actualOutput))
4 changes: 3 additions & 1 deletion tests/e2e/test_metadata_attack/submission_metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{"previous_submissions": [{"results": {"score": 10}}]}
{
"previous_submissions": []
}

0 comments on commit 913089e

Please sign in to comment.