mire integration tests / better logging
This commit is contained in:
parent
210f6db747
commit
5e5a8d054c
4 changed files with 99 additions and 5 deletions
|
@ -154,11 +154,18 @@ public class DistributedIndicatorValueService implements DisposableBean {
|
||||||
final Long recId = this.clientIndicatorValueMapper.indicatorRecordIdByConnectionId(
|
final Long recId = this.clientIndicatorValueMapper.indicatorRecordIdByConnectionId(
|
||||||
connectionId,
|
connectionId,
|
||||||
type);
|
type);
|
||||||
|
|
||||||
if (recId != null) {
|
if (recId != null) {
|
||||||
log.debug("Distributed indicator value cache already exists for: {}, {}", connectionId, type);
|
if (log.isTraceEnabled()) {
|
||||||
|
log.trace("Distributed indicator value cache already exists for: {}, {}", connectionId, type);
|
||||||
|
}
|
||||||
return recId;
|
return recId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.info("Missing distributed indicator value cache. Create for: {}, {}", connectionId, type);
|
||||||
|
}
|
||||||
|
|
||||||
// if not, create new one and return PK
|
// if not, create new one and return PK
|
||||||
final ClientIndicatorRecord clientEventRecord = new ClientIndicatorRecord(
|
final ClientIndicatorRecord clientEventRecord = new ClientIndicatorRecord(
|
||||||
null, connectionId, type.id, initValue);
|
null, connectionId, type.id, initValue);
|
||||||
|
|
|
@ -60,6 +60,7 @@ import ch.ethz.seb.sebserver.gbl.util.Cryptor;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamProctoringService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamProctoringService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
|
@ -107,19 +108,22 @@ public class JitsiProctoringService implements ExamProctoringService {
|
||||||
private final Cryptor cryptor;
|
private final Cryptor cryptor;
|
||||||
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;
|
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;
|
||||||
private final JSONMapper jsonMapper;
|
private final JSONMapper jsonMapper;
|
||||||
|
private final WebserviceInfo webserviceInfo;
|
||||||
|
|
||||||
protected JitsiProctoringService(
|
protected JitsiProctoringService(
|
||||||
final AuthorizationService authorizationService,
|
final AuthorizationService authorizationService,
|
||||||
final ExamSessionService examSessionService,
|
final ExamSessionService examSessionService,
|
||||||
final Cryptor cryptor,
|
final Cryptor cryptor,
|
||||||
final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
|
final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
|
||||||
final JSONMapper jsonMapper) {
|
final JSONMapper jsonMapper,
|
||||||
|
final WebserviceInfo webserviceInfo) {
|
||||||
|
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.examSessionService = examSessionService;
|
this.examSessionService = examSessionService;
|
||||||
this.cryptor = cryptor;
|
this.cryptor = cryptor;
|
||||||
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;
|
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;
|
||||||
this.jsonMapper = jsonMapper;
|
this.jsonMapper = jsonMapper;
|
||||||
|
this.webserviceInfo = webserviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,6 +145,11 @@ public class JitsiProctoringService implements ExamProctoringService {
|
||||||
"proctoringSettings:serverURL:invalidURL");
|
"proctoringSettings:serverURL:invalidURL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In testing we do not check the JITSI service on URL to be able to test without service
|
||||||
|
if (this.webserviceInfo != null && this.webserviceInfo.hasProfile("test")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final ClientHttpRequestFactory clientHttpRequestFactory = this.clientHttpRequestFactoryService
|
final ClientHttpRequestFactory clientHttpRequestFactory = this.clientHttpRequestFactoryService
|
||||||
.getClientHttpRequestFactory()
|
.getClientHttpRequestFactory()
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
|
@ -62,6 +62,7 @@ import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport.ErrorEntry;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Page;
|
import ch.ethz.seb.sebserver.gbl.model.Page;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
|
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.ExamTemplate;
|
import ch.ethz.seb.sebserver.gbl.model.exam.ExamTemplate;
|
||||||
|
@ -3457,4 +3458,81 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(27)
|
||||||
|
// *************************************
|
||||||
|
// Use Case 27: Login as admin and set exam proctoring settings for Jtisi
|
||||||
|
// - Get Exam (running)
|
||||||
|
// - Set Proctoring settings for exam
|
||||||
|
// - Check settings for exam
|
||||||
|
public void testUsecase27_SetProctoringSettingsJitsiForExam() throws IOException {
|
||||||
|
final RestServiceImpl restService = createRestServiceForUser(
|
||||||
|
"admin",
|
||||||
|
"admin",
|
||||||
|
new GetExamPage(),
|
||||||
|
new GetExamProctoringSettings(),
|
||||||
|
new SaveExamProctoringSettings());
|
||||||
|
|
||||||
|
// get exam
|
||||||
|
final Result<Page<Exam>> exams = restService
|
||||||
|
.getBuilder(GetExamPage.class)
|
||||||
|
.call();
|
||||||
|
|
||||||
|
assertNotNull(exams);
|
||||||
|
assertFalse(exams.hasError());
|
||||||
|
final Page<Exam> examPage = exams.get();
|
||||||
|
assertFalse(examPage.isEmpty());
|
||||||
|
|
||||||
|
final Exam runningExam = examPage.content
|
||||||
|
.stream()
|
||||||
|
.filter(exam -> exam.status == ExamStatus.RUNNING)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
assertNotNull(runningExam);
|
||||||
|
assertTrue(runningExam.status == ExamStatus.RUNNING);
|
||||||
|
|
||||||
|
final Result<ProctoringServiceSettings> pSettings = restService
|
||||||
|
.getBuilder(GetExamProctoringSettings.class)
|
||||||
|
.withURIVariable(API.PARAM_MODEL_ID, runningExam.getModelId())
|
||||||
|
.call();
|
||||||
|
|
||||||
|
assertNotNull(pSettings);
|
||||||
|
assertFalse(pSettings.hasError());
|
||||||
|
ProctoringServiceSettings proctoringServiceSettings = pSettings.get();
|
||||||
|
assertFalse(proctoringServiceSettings.enableProctoring);
|
||||||
|
assertNull(proctoringServiceSettings.serverURL);
|
||||||
|
|
||||||
|
// set proctoring settings
|
||||||
|
final ProctoringServiceSettings newProctoringServiceSettings = new ProctoringServiceSettings(
|
||||||
|
runningExam.id,
|
||||||
|
true,
|
||||||
|
ProctoringServerType.JITSI_MEET,
|
||||||
|
"https://test.proc/service",
|
||||||
|
2,
|
||||||
|
EnumSet.allOf(ProctoringFeature.class),
|
||||||
|
true,
|
||||||
|
"appKey", "appSecret",
|
||||||
|
"sdkKey", "sdkSecret",
|
||||||
|
false);
|
||||||
|
|
||||||
|
final Result<ProctoringServiceSettings> newProcSettings = restService
|
||||||
|
.getBuilder(SaveExamProctoringSettings.class)
|
||||||
|
.withURIVariable(API.PARAM_MODEL_ID, runningExam.getModelId())
|
||||||
|
.withBody(newProctoringServiceSettings)
|
||||||
|
.call();
|
||||||
|
|
||||||
|
assertNotNull(newProcSettings);
|
||||||
|
assertFalse(newProcSettings.hasError());
|
||||||
|
|
||||||
|
proctoringServiceSettings = restService
|
||||||
|
.getBuilder(GetExamProctoringSettings.class)
|
||||||
|
.withURIVariable(API.PARAM_MODEL_ID, runningExam.getModelId())
|
||||||
|
.call()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
assertTrue(proctoringServiceSettings.enableProctoring);
|
||||||
|
assertEquals("https://test.proc/service", proctoringServiceSettings.serverURL);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ExamJITSIProctoringServiceTest {
|
||||||
final Cryptor cryptorMock = Mockito.mock(Cryptor.class);
|
final Cryptor cryptorMock = Mockito.mock(Cryptor.class);
|
||||||
Mockito.when(cryptorMock.decrypt(Mockito.any())).thenReturn(Result.of("fbvgeghergrgrthrehreg123"));
|
Mockito.when(cryptorMock.decrypt(Mockito.any())).thenReturn(Result.of("fbvgeghergrgrthrehreg123"));
|
||||||
final JitsiProctoringService examJITSIProctoringService =
|
final JitsiProctoringService examJITSIProctoringService =
|
||||||
new JitsiProctoringService(null, null, cryptorMock, null, new JSONMapper());
|
new JitsiProctoringService(null, null, cryptorMock, null, new JSONMapper(), null);
|
||||||
|
|
||||||
String accessToken = examJITSIProctoringService.createPayload(
|
String accessToken = examJITSIProctoringService.createPayload(
|
||||||
"test-app",
|
"test-app",
|
||||||
|
@ -115,7 +115,7 @@ public class ExamJITSIProctoringServiceTest {
|
||||||
final Cryptor cryptorMock = Mockito.mock(Cryptor.class);
|
final Cryptor cryptorMock = Mockito.mock(Cryptor.class);
|
||||||
Mockito.when(cryptorMock.decrypt(Mockito.any())).thenReturn(Result.of("fbvgeghergrgrthrehreg123"));
|
Mockito.when(cryptorMock.decrypt(Mockito.any())).thenReturn(Result.of("fbvgeghergrgrthrehreg123"));
|
||||||
final JitsiProctoringService examJITSIProctoringService =
|
final JitsiProctoringService examJITSIProctoringService =
|
||||||
new JitsiProctoringService(null, null, cryptorMock, null, new JSONMapper());
|
new JitsiProctoringService(null, null, cryptorMock, null, new JSONMapper(), null);
|
||||||
final ProctoringRoomConnection data = examJITSIProctoringService.createProctoringConnection(
|
final ProctoringRoomConnection data = examJITSIProctoringService.createProctoringConnection(
|
||||||
"connectionToken",
|
"connectionToken",
|
||||||
"https://seb-jitsi.example.ch",
|
"https://seb-jitsi.example.ch",
|
||||||
|
@ -160,7 +160,7 @@ public class ExamJITSIProctoringServiceTest {
|
||||||
examSessionService,
|
examSessionService,
|
||||||
cryptor,
|
cryptor,
|
||||||
clientHttpRequestFactoryService,
|
clientHttpRequestFactoryService,
|
||||||
jsonMapper);
|
jsonMapper, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue