fixed discovery API

This commit is contained in:
anhefti 2019-09-05 15:18:22 +02:00
parent e1ff871693
commit 9bf6033fbd
2 changed files with 37 additions and 1 deletions

View file

@ -73,7 +73,7 @@ public class ExamAPIDiscoveryController {
this.examAPI_V1_Endpoint + API.EXAM_API_PING_ENDPOINT,
"Bearer"),
new ExamAPIDiscovery.Endpoint(
"seb-ping-endpoint",
"seb-log-endpoint",
"endpoint to send log events to while running exam",
this.examAPI_V1_Endpoint + API.EXAM_API_EVENT_ENDPOINT,
"Bearer")))));

View file

@ -16,6 +16,8 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import com.fasterxml.jackson.databind.ObjectWriter;
import ch.ethz.seb.sebserver.gbl.api.ExamAPIDiscovery;
import ch.ethz.seb.sebserver.gbl.api.ExamAPIDiscovery.ExamAPIVersion;
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
@ -35,6 +37,8 @@ public class ExamDiscoveryEndpointTest extends ExamAPIIntegrationTester {
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString();
final ObjectWriter writer = this.jsonMapper.writerWithDefaultPrettyPrinter();
final ExamAPIDiscovery examAPIDiscovery = this.jsonMapper.readValue(contentAsString, ExamAPIDiscovery.class);
assertNotNull(examAPIDiscovery);
assertEquals("Safe Exam Browser Server / Exam API Description", examAPIDiscovery.title);
@ -43,6 +47,38 @@ public class ExamDiscoveryEndpointTest extends ExamAPIIntegrationTester {
final ExamAPIVersion version1 = examAPIDiscovery.versions.iterator().next();
assertEquals("v1", version1.name);
assertTrue(!version1.endpoints.isEmpty());
assertEquals(
"{\r\n" +
" \"name\" : \"v1\",\r\n" +
" \"endpoints\" : [ {\r\n" +
" \"name\" : \"access-token-endpoint\",\r\n" +
" \"description\" : \"request OAuth2 access token with client credentials grant\",\r\n" +
" \"location\" : \"/oauth/token\",\r\n" +
" \"authorization\" : \"Basic\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-handshake-endpoint\",\r\n" +
" \"description\" : \"endpoint to establish SEB - SEB Server connection\",\r\n" +
" \"location\" : \"/exam-api/v1/handshake\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-configuration-endpoint\",\r\n" +
" \"description\" : \"endpoint to get SEB exam configuration in exchange of connection-token and exam identifier\",\r\n"
+
" \"location\" : \"/exam-api/v1/examconfig\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-ping-endpoint\",\r\n" +
" \"description\" : \"endpoint to send pings to while running exam\",\r\n" +
" \"location\" : \"/exam-api/v1/sebping\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-log-endpoint\",\r\n" +
" \"description\" : \"endpoint to send log events to while running exam\",\r\n" +
" \"location\" : \"/exam-api/v1/seblog\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" } ]\r\n" +
"}",
writer.writeValueAsString(version1));
}
}