diff --git a/src/main/java/ch/ethz/seb/sebserver/WebSecurityConfig.java b/src/main/java/ch/ethz/seb/sebserver/WebSecurityConfig.java index f34dd2d5..9c595304 100644 --- a/src/main/java/ch/ethz/seb/sebserver/WebSecurityConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/WebSecurityConfig.java @@ -133,6 +133,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter implements E log.info("Initialize with insecure ClientHttpRequestFactory for development"); final DevClientHttpRequestFactory devClientHttpRequestFactory = new DevClientHttpRequestFactory(); + devClientHttpRequestFactory.setOutputStreaming(false); return devClientHttpRequestFactory; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java index a814bdb5..67db3257 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java @@ -62,7 +62,7 @@ public class RAPSpringConfig { final ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource = new ReloadableResourceBundleMessageSource(); - log.info(" +++ Register external messages resources form: {}", this.externalMessagesPath); + log.info(" +++ Register external messages resources from: {}", this.externalMessagesPath); reloadableResourceBundleMessageSource.setBasenames( this.externalMessagesPath, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/OAuth2AuthorizationContextHolder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/OAuth2AuthorizationContextHolder.java index 13bc3f81..cf6cd646 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/OAuth2AuthorizationContextHolder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/OAuth2AuthorizationContextHolder.java @@ -300,8 +300,13 @@ public class OAuth2AuthorizationContextHolder implements AuthorizationContextHol @Override public boolean hasError(final ClientHttpResponse response) throws IOException { - final HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); - return (statusCode != null && statusCode.series().equals(HttpStatus.Series.SERVER_ERROR)); + try { + final HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); + return (statusCode != null && statusCode.series().equals(HttpStatus.Series.SERVER_ERROR)); + } catch (final Exception e) { + log.error("Unexpected: ", e); + return super.hasError(response); + } } } 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 5eb52e21..7be79ed6 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 @@ -54,28 +54,28 @@ public class ExamAPIDiscoveryController { new ExamAPIDiscovery.Endpoint( "access-token-endpoint", "request OAuth2 access token with client credentials grant", - serverURL + API.OAUTH_TOKEN_ENDPOINT, + API.OAUTH_TOKEN_ENDPOINT, "Basic"), new ExamAPIDiscovery.Endpoint( "seb-handshake-endpoint", "endpoint to establish SEB - SEB Server connection", - serverURL + this.examAPI_V1_Endpoint + API.EXAM_API_HANDSHAKE_ENDPOINT, + this.examAPI_V1_Endpoint + API.EXAM_API_HANDSHAKE_ENDPOINT, "Bearer"), new ExamAPIDiscovery.Endpoint( "seb-configuration-endpoint", "endpoint to get SEB exam configuration in exchange of connection-token and exam identifier", - serverURL + this.examAPI_V1_Endpoint + this.examAPI_V1_Endpoint + API.EXAM_API_CONFIGURATION_REQUEST_ENDPOINT, "Bearer"), new ExamAPIDiscovery.Endpoint( "seb-ping-endpoint", "endpoint to send pings to while running exam", - serverURL + this.examAPI_V1_Endpoint + API.EXAM_API_PING_ENDPOINT, + this.examAPI_V1_Endpoint + API.EXAM_API_PING_ENDPOINT, "Bearer"), new ExamAPIDiscovery.Endpoint( "seb-ping-endpoint", "endpoint to send log events to while running exam", - serverURL + this.examAPI_V1_Endpoint + API.EXAM_API_EVENT_ENDPOINT, + this.examAPI_V1_Endpoint + API.EXAM_API_EVENT_ENDPOINT, "Bearer"))))); } diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index 2d77cd15..e2fce5b9 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -150,6 +150,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertFalse(result.hasError()); UserInfo userInfo = result.get(); assertNotNull(userInfo); + assertEquals(instId, String.valueOf(userInfo.institutionId)); assertEquals("TestInstAdmin", userInfo.name); assertEquals("TestInstAdmin", userInfo.username); assertEquals("test@test.ch", userInfo.email); @@ -292,18 +293,15 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // ************************************* // Use Case 4: // - login as TestInstAdmin - // - create a new user-account (examAdmin1) with Exam Administrator role + // - create a new user-account (examAdmin2) with Exam Administrator role // - create a new user-account (examSupport1) with Exam Supporter role // - create a new user-account (examSupport2) with Exam Administrator and Exam Supporter role public void testUsecase4() { final RestServiceImpl restService = createRestServiceForUser( "TestInstAdmin", - "12345678", + "987654321", new GetInstitutionNames(), - new SaveUserAccount(), - new ChangePassword(), - new GetUserAccount(), - new GetUserAccountNames()); + new NewUserAccount()); final String instId = restService.getBuilder(GetInstitutionNames.class) .call() @@ -315,17 +313,51 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertNotNull(instId); - final Result result = restService.getBuilder(NewUserAccount.class) + Result result = restService.getBuilder(NewUserAccount.class) .withFormParam(Domain.USER.ATTR_INSTITUTION_ID, instId) - .withFormParam(Domain.USER.ATTR_NAME, "TestInstAdmin") - .withFormParam(Domain.USER.ATTR_USERNAME, "TestInstAdmin") + .withFormParam(Domain.USER.ATTR_NAME, "examAdmin2") + .withFormParam(Domain.USER.ATTR_USERNAME, "examAdmin2") .withFormParam(Domain.USER.ATTR_EMAIL, "test@test.ch") - .withFormParam(Domain.USER_ROLE.REFERENCE_NAME, UserRole.INSTITUTIONAL_ADMIN.name()) - .withFormParam(PasswordChange.ATTR_NAME_NEW_PASSWORD, "12345678") - .withFormParam(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD, "12345678") + .withFormParam(Domain.USER_ROLE.REFERENCE_NAME, UserRole.EXAM_ADMIN.name()) + .withFormParam(PasswordChange.ATTR_NAME_NEW_PASSWORD, "examAdmin2") + .withFormParam(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD, "examAdmin2") .withFormParam(Domain.USER.ATTR_LANGUAGE, Locale.ENGLISH.getLanguage()) .withFormParam(Domain.USER.ATTR_TIMEZONE, DateTimeZone.UTC.getID()) .call(); + + assertNotNull(result); + assertFalse(result.hasError()); + + result = restService.getBuilder(NewUserAccount.class) + .withFormParam(Domain.USER.ATTR_INSTITUTION_ID, instId) + .withFormParam(Domain.USER.ATTR_NAME, "examSupport2") + .withFormParam(Domain.USER.ATTR_USERNAME, "examSupport2") + .withFormParam(Domain.USER.ATTR_EMAIL, "test@test.ch") + .withFormParam(Domain.USER_ROLE.REFERENCE_NAME, UserRole.EXAM_SUPPORTER.name()) + .withFormParam(PasswordChange.ATTR_NAME_NEW_PASSWORD, "examSupport2") + .withFormParam(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD, "examSupport2") + .withFormParam(Domain.USER.ATTR_LANGUAGE, Locale.ENGLISH.getLanguage()) + .withFormParam(Domain.USER.ATTR_TIMEZONE, DateTimeZone.UTC.getID()) + .call(); + + assertNotNull(result); + assertFalse(result.hasError()); + + result = restService.getBuilder(NewUserAccount.class) + .withFormParam(Domain.USER.ATTR_INSTITUTION_ID, instId) + .withFormParam(Domain.USER.ATTR_NAME, "examSupport1") + .withFormParam(Domain.USER.ATTR_USERNAME, "examSupport1") + .withFormParam(Domain.USER.ATTR_EMAIL, "test@test.ch") + .withFormParam(Domain.USER_ROLE.REFERENCE_NAME, UserRole.EXAM_SUPPORTER.name()) + .withFormParam(PasswordChange.ATTR_NAME_NEW_PASSWORD, "examSupport1") + .withFormParam(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD, "examSupport1") + .withFormParam(Domain.USER.ATTR_LANGUAGE, Locale.ENGLISH.getLanguage()) + .withFormParam(Domain.USER.ATTR_TIMEZONE, DateTimeZone.UTC.getID()) + .call(); + + assertNotNull(result); + assertFalse(result.hasError()); + } @Test