resource bundle configuration and discovery bugfix

This commit is contained in:
anhefti 2019-09-05 08:37:18 +02:00
parent c4b6f85035
commit ec1d10b646
5 changed files with 58 additions and 20 deletions

View file

@ -133,6 +133,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter implements E
log.info("Initialize with insecure ClientHttpRequestFactory for development"); log.info("Initialize with insecure ClientHttpRequestFactory for development");
final DevClientHttpRequestFactory devClientHttpRequestFactory = new DevClientHttpRequestFactory(); final DevClientHttpRequestFactory devClientHttpRequestFactory = new DevClientHttpRequestFactory();
devClientHttpRequestFactory.setOutputStreaming(false);
return devClientHttpRequestFactory; return devClientHttpRequestFactory;
} }

View file

@ -62,7 +62,7 @@ public class RAPSpringConfig {
final ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource = final ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource =
new ReloadableResourceBundleMessageSource(); new ReloadableResourceBundleMessageSource();
log.info(" +++ Register external messages resources form: {}", this.externalMessagesPath); log.info(" +++ Register external messages resources from: {}", this.externalMessagesPath);
reloadableResourceBundleMessageSource.setBasenames( reloadableResourceBundleMessageSource.setBasenames(
this.externalMessagesPath, this.externalMessagesPath,

View file

@ -300,8 +300,13 @@ public class OAuth2AuthorizationContextHolder implements AuthorizationContextHol
@Override @Override
public boolean hasError(final ClientHttpResponse response) throws IOException { public boolean hasError(final ClientHttpResponse response) throws IOException {
final HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); try {
return (statusCode != null && statusCode.series().equals(HttpStatus.Series.SERVER_ERROR)); 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);
}
} }
} }

View file

@ -54,28 +54,28 @@ public class ExamAPIDiscoveryController {
new ExamAPIDiscovery.Endpoint( new ExamAPIDiscovery.Endpoint(
"access-token-endpoint", "access-token-endpoint",
"request OAuth2 access token with client credentials grant", "request OAuth2 access token with client credentials grant",
serverURL + API.OAUTH_TOKEN_ENDPOINT, API.OAUTH_TOKEN_ENDPOINT,
"Basic"), "Basic"),
new ExamAPIDiscovery.Endpoint( new ExamAPIDiscovery.Endpoint(
"seb-handshake-endpoint", "seb-handshake-endpoint",
"endpoint to establish SEB - SEB Server connection", "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"), "Bearer"),
new ExamAPIDiscovery.Endpoint( new ExamAPIDiscovery.Endpoint(
"seb-configuration-endpoint", "seb-configuration-endpoint",
"endpoint to get SEB exam configuration in exchange of connection-token and exam identifier", "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, + API.EXAM_API_CONFIGURATION_REQUEST_ENDPOINT,
"Bearer"), "Bearer"),
new ExamAPIDiscovery.Endpoint( new ExamAPIDiscovery.Endpoint(
"seb-ping-endpoint", "seb-ping-endpoint",
"endpoint to send pings to while running exam", "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"), "Bearer"),
new ExamAPIDiscovery.Endpoint( new ExamAPIDiscovery.Endpoint(
"seb-ping-endpoint", "seb-ping-endpoint",
"endpoint to send log events to while running exam", "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"))))); "Bearer")))));
} }

View file

@ -150,6 +150,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
assertFalse(result.hasError()); assertFalse(result.hasError());
UserInfo userInfo = result.get(); UserInfo userInfo = result.get();
assertNotNull(userInfo); assertNotNull(userInfo);
assertEquals(instId, String.valueOf(userInfo.institutionId));
assertEquals("TestInstAdmin", userInfo.name); assertEquals("TestInstAdmin", userInfo.name);
assertEquals("TestInstAdmin", userInfo.username); assertEquals("TestInstAdmin", userInfo.username);
assertEquals("test@test.ch", userInfo.email); assertEquals("test@test.ch", userInfo.email);
@ -292,18 +293,15 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
// ************************************* // *************************************
// Use Case 4: // Use Case 4:
// - login as TestInstAdmin // - 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 (examSupport1) with Exam Supporter role
// - create a new user-account (examSupport2) with Exam Administrator and Exam Supporter role // - create a new user-account (examSupport2) with Exam Administrator and Exam Supporter role
public void testUsecase4() { public void testUsecase4() {
final RestServiceImpl restService = createRestServiceForUser( final RestServiceImpl restService = createRestServiceForUser(
"TestInstAdmin", "TestInstAdmin",
"12345678", "987654321",
new GetInstitutionNames(), new GetInstitutionNames(),
new SaveUserAccount(), new NewUserAccount());
new ChangePassword(),
new GetUserAccount(),
new GetUserAccountNames());
final String instId = restService.getBuilder(GetInstitutionNames.class) final String instId = restService.getBuilder(GetInstitutionNames.class)
.call() .call()
@ -315,17 +313,51 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
assertNotNull(instId); assertNotNull(instId);
final Result<UserInfo> result = restService.getBuilder(NewUserAccount.class) Result<UserInfo> result = restService.getBuilder(NewUserAccount.class)
.withFormParam(Domain.USER.ATTR_INSTITUTION_ID, instId) .withFormParam(Domain.USER.ATTR_INSTITUTION_ID, instId)
.withFormParam(Domain.USER.ATTR_NAME, "TestInstAdmin") .withFormParam(Domain.USER.ATTR_NAME, "examAdmin2")
.withFormParam(Domain.USER.ATTR_USERNAME, "TestInstAdmin") .withFormParam(Domain.USER.ATTR_USERNAME, "examAdmin2")
.withFormParam(Domain.USER.ATTR_EMAIL, "test@test.ch") .withFormParam(Domain.USER.ATTR_EMAIL, "test@test.ch")
.withFormParam(Domain.USER_ROLE.REFERENCE_NAME, UserRole.INSTITUTIONAL_ADMIN.name()) .withFormParam(Domain.USER_ROLE.REFERENCE_NAME, UserRole.EXAM_ADMIN.name())
.withFormParam(PasswordChange.ATTR_NAME_NEW_PASSWORD, "12345678") .withFormParam(PasswordChange.ATTR_NAME_NEW_PASSWORD, "examAdmin2")
.withFormParam(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD, "12345678") .withFormParam(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD, "examAdmin2")
.withFormParam(Domain.USER.ATTR_LANGUAGE, Locale.ENGLISH.getLanguage()) .withFormParam(Domain.USER.ATTR_LANGUAGE, Locale.ENGLISH.getLanguage())
.withFormParam(Domain.USER.ATTR_TIMEZONE, DateTimeZone.UTC.getID()) .withFormParam(Domain.USER.ATTR_TIMEZONE, DateTimeZone.UTC.getID())
.call(); .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 @Test