Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Remove unnecessary build plan information from the exam conduction payload #8059

Merged
merged 8 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ public void filterSensitiveInformation() {
setTestRepositoryUri(null);
setTemplateBuildPlanId(null);
setSolutionBuildPlanId(null);
setBuildPlanConfiguration(null);
setBuildScript(null);
super.filterSensitiveInformation();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,11 @@ private void prepareStudentExamForConduction(HttpServletRequest request, User cu
}
}

// remove build script and config information from the student exam
for (var programmingExercise : programmingExercises) {
programmingExercise.filterSensitiveInformation();
}

// Load quizzes from database, because they include lazy relationships
examService.loadQuizExercisesForStudentExam(studentExam);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ void initTestCase() throws Exception {
exam1 = examRepository.save(exam1);

exam2 = examUtilService.addExam(course1);
exam2 = examUtilService.addTextModelingProgrammingExercisesToExam(exam2, true, false);

studentExam1 = examUtilService.addStudentExam(exam1);
studentExam1.setWorkingTime(7200);
Expand Down Expand Up @@ -485,6 +486,10 @@ void testGetStudentExamForConduction() throws Exception {
assertThat(exercise.getExerciseGroup()).isNotNull();
assertThat(exercise.getExerciseGroup().getExercises()).isEmpty();
assertThat(exercise.getExerciseGroup().getExam()).isNull();
if (exercise instanceof ProgrammingExercise) {
assertThat(((ProgrammingExercise) exercise).getBuildScript()).isNull();
assertThat(((ProgrammingExercise) exercise).getBuildPlanConfiguration()).isNull();
}
}
assertThat(studentExamRepository.findById(studentExam.getId()).orElseThrow().isStarted()).isTrue();
assertParticipationAndSubmissions(response, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ private static void populateUnreleasedProgrammingExercise(ProgrammingExercise pr
programmingExercise.setTestwiseCoverageEnabled(false);
programmingExercise.setAssessmentType(AssessmentType.SEMI_AUTOMATIC);
programmingExercise.setProgrammingLanguage(programmingLanguage);
programmingExercise.setBuildScript("Some script");
programmingExercise.setBuildPlanConfiguration("{\"api\":\"v0.0.1\",\"metadata\":{},\"actions\":[]}");
laurenzfb marked this conversation as resolved.
Show resolved Hide resolved
if (programmingLanguage == ProgrammingLanguage.JAVA) {
programmingExercise.setProjectType(ProjectType.PLAIN_MAVEN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import de.tum.in.www1.artemis.AbstractSpringIntegrationJenkinsGitlabTest;
import de.tum.in.www1.artemis.domain.enumeration.AeolusTarget;
import de.tum.in.www1.artemis.domain.enumeration.ExerciseMode;
import de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage;
import de.tum.in.www1.artemis.domain.enumeration.SubmissionType;
Expand All @@ -49,26 +50,30 @@ void setup() throws Exception {
programmingExerciseTestService.setup(this, versionControlService, continuousIntegrationService);
jenkinsRequestMockProvider.enableMockingOfRequests(jenkinsServer);
gitlabRequestMockProvider.enableMockingOfRequests();
aeolusRequestMockProvider.enableMockingOfRequests();
laurenzfb marked this conversation as resolved.
Show resolved Hide resolved
}

@AfterEach
void tearDown() throws Exception {
programmingExerciseTestService.tearDown();
gitlabRequestMockProvider.reset();
jenkinsRequestMockProvider.reset();
aeolusRequestMockProvider.reset();
}

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(value = ProgrammingLanguage.class, names = { "JAVA", "KOTLIN" }, mode = EnumSource.Mode.INCLUDE)
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_sequential_validExercise_created(ProgrammingLanguage programmingLanguage) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_sequential_validExercise_created(programmingLanguage);
}

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(ExerciseMode.class)
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_validExercise_created(ExerciseMode mode) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_mode_validExercise_created(mode);
}

Expand All @@ -77,6 +82,7 @@ void createProgrammingExercise_validExercise_created(ExerciseMode mode) throws E
@EnumSource(value = ProgrammingLanguage.class, names = { "VHDL", "ASSEMBLER", "OCAML" }, mode = EnumSource.Mode.EXCLUDE)
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_programmingLanguage_validExercise_created(ProgrammingLanguage language) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_programmingLanguage_validExercise_created(language,
programmingLanguageFeatureService.getProgrammingLanguageFeatures(language));
}
Expand All @@ -98,20 +104,23 @@ void createProgrammingExercise_failed_custom_build_plan_validExercise_created(Pr
@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_validExercise_bonusPointsIsNull() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_validExercise_bonusPointsIsNull();
}

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(value = ProgrammingLanguage.class, names = { "JAVA", "SWIFT" })
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_validExercise_withStaticCodeAnalysis(ProgrammingLanguage language) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_validExercise_withStaticCodeAnalysis(language,
programmingLanguageFeatureService.getProgrammingLanguageFeatures(language));
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExerciseForExam_validExercise_created() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExerciseForExam_validExercise_created();
}

Expand Down Expand Up @@ -146,6 +155,7 @@ void importExercise_created(ProgrammingLanguage programmingLanguage, boolean rec
@ValueSource(booleans = { true, false })
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createAndImportJavaProgrammingExercise(boolean staticCodeAnalysisEnabled) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createAndImportJavaProgrammingExercise(staticCodeAnalysisEnabled);
}

Expand Down Expand Up @@ -188,12 +198,14 @@ void importExerciseNoneSubmissionPolicy() throws Exception {
@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_validExercise_structureOracle() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_validExercise_structureOracle();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_noTutors_created() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_noTutors_created();
}

Expand Down Expand Up @@ -233,25 +245,29 @@ void importExerciseFromFileMissingRepository_badRequest() throws Exception {
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
void importExerciseFromFile_valid_Java_Exercise_importSuccessful(boolean scaEnabled) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.importFromFile_validJavaExercise_isSuccessfullyImported(scaEnabled);
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void importExerciseFromFile_embeddedFiles_filesCopied() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.importFromFile_embeddedFiles_embeddedFilesCopied();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void importExerciseFromFile_buildPlanPresent_buildPlanSet() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.importFromFile_buildPlanPresent_buildPlanUsed();
}

@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(value = ProgrammingLanguage.class, names = { "HASKELL", "PYTHON" }, mode = EnumSource.Mode.INCLUDE)
void importExerciseFromFile_valid_Exercise_importSuccessful(ProgrammingLanguage language) throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.importFromFile_validExercise_isSuccessfullyImported(language);
}

Expand Down Expand Up @@ -514,6 +530,7 @@ void createProgrammingExercise_setInvalidExampleSolutionPublicationDate_badReque
@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void createProgrammingExercise_setValidExampleSolutionPublicationDate() throws Exception {
forceDefaultBuildPlanCreation();
programmingExerciseTestService.createProgrammingExercise_setValidExampleSolutionPublicationDate();
}

Expand Down Expand Up @@ -572,4 +589,9 @@ void testBuildLogStatistics() throws Exception {
void testUpdateBuildPlanURL() throws Exception {
programmingExerciseTestService.updateBuildPlanURL();
}

private void forceDefaultBuildPlanCreation() {
aeolusRequestMockProvider.mockFailedPublishBuildPlan(AeolusTarget.JENKINS);
aeolusRequestMockProvider.mockFailedPublishBuildPlan(AeolusTarget.JENKINS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import de.tum.in.www1.artemis.course.CourseUtilService;
import de.tum.in.www1.artemis.domain.Course;
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.enumeration.AeolusTarget;
import de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage;
import de.tum.in.www1.artemis.domain.enumeration.ProjectType;
import de.tum.in.www1.artemis.service.programming.ProgrammingLanguageFeatureService;
Expand Down Expand Up @@ -188,13 +189,15 @@ private Stream<Arguments> languageTypeBuilder() {
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
@MethodSource("languageTypeBuilder")
void test_template_exercise(ProgrammingLanguage language, ProjectType projectType, boolean testwiseCoverageAnalysis) throws Exception {
forceDefaultBuildPlanCreation();
runTests(language, projectType, exerciseRepo, TestResult.FAILED, testwiseCoverageAnalysis);
}

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
@MethodSource("languageTypeBuilder")
void test_template_solution(ProgrammingLanguage language, ProjectType projectType, boolean testwiseCoverageAnalysis) throws Exception {
forceDefaultBuildPlanCreation();
runTests(language, projectType, solutionRepo, TestResult.SUCCESSFUL, testwiseCoverageAnalysis);
}

Expand Down Expand Up @@ -302,4 +305,9 @@ static TestResult of(ReportTestCase testCase) {
return TestResult.SUCCESSFUL;
}
}

private void forceDefaultBuildPlanCreation() {
aeolusRequestMockProvider.mockFailedPublishBuildPlan(AeolusTarget.JENKINS);
aeolusRequestMockProvider.mockFailedPublishBuildPlan(AeolusTarget.JENKINS);
}
laurenzfb marked this conversation as resolved.
Show resolved Hide resolved
}
Loading