From 9bf6033fbd2f6933776d46bc9814ec5b6503ea8c Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 5 Sep 2019 15:18:22 +0200 Subject: [PATCH] fixed discovery API --- .../api/ExamAPIDiscoveryController.java | 2 +- .../api/exam/ExamDiscoveryEndpointTest.java | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java index 7be79ed6..36afa01e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java @@ -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"))))); diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamDiscoveryEndpointTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamDiscoveryEndpointTest.java index 8b80d478..5aabb1c0 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamDiscoveryEndpointTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamDiscoveryEndpointTest.java @@ -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)); } }