institutional logo

This commit is contained in:
anhefti 2019-02-10 21:07:15 +01:00
parent c0ba128bc7
commit 5a9b85ccde
29 changed files with 316 additions and 219 deletions

View file

@ -40,6 +40,7 @@ import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.profile.DevGuiProfile;
import ch.ethz.seb.sebserver.gbl.profile.DevWebServiceProfile;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
@ -80,7 +81,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter implements E
public void configure(final WebSecurity web) {
web
.ignoring()
.antMatchers("/error");
.antMatchers("/error")
.antMatchers(API.LOGO_ENDPOINT + "/*");
}
@RequestMapping("/error")

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package ch.ethz.seb.sebserver.gbl.api;
public class API {
public static final String LOGO_ENDPOINT = "/logo";
public static final String LOGO_PATH_CODE = "/logo/{institutionId}";
public static final String INSTITUTION_ENDPOINT = "/institution";
public static final String LMS_SETUP_ENDPOINT = "/lms_setup";
public static final String USER_ACCOUNT_ENDPOINT = "/useraccount";
public static final String QUIZ_IMPORT_ENDPOINT = "/quiz";
public static final String EXAM_ADMINISTRATION_ENDPOINT = "/exam";
public static final String USER_ACTIVITY_LOG_ENDPOINT = "/useractivity";
public static final String NAMES_SUFFIX = "/names";
public static final String LIST_SUFFIX = "/list";
public static final String ACTIVE_SUFFIX = "/active";
public static final String INACTIVE_SUFFIX = "/inactive";
}

View file

@ -1,33 +0,0 @@
/*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package ch.ethz.seb.sebserver.gbl.api;
public class SEBServerRestEndpoints {
public static final String ENDPOINT_INSTITUTION = "/institution";
public static final String ENDPOINT_LMS_SETUP = "/lms_setup";
public static final String ENDPOINT_USER_ACCOUNT = "/useraccount";
public static final String ENDPOINT_QUIZ_IMPORT = "/quiz";
public static final String ENDPOINT_EXAM_ADMINISTRATION = "/exam";
public static final String ENDPOINT_USER_ACTIVITY_LOG = "/useractivity";
public static final String NAMES_ENDPOINT_SUFFIX = "/names";
public static final String LIST_ENDPOINT_SUFFIX = "/list";
public static final String ENDPOINT_ACTIVE = "/active";
public static final String ENDPOINT_INACTIVE = "/inactive";
}

View file

@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.SEBServerAuthorizationContext;
@ -106,11 +106,11 @@ public class RAPConfiguration implements ApplicationConfiguration {
// some restriction to search the user. This is especially useful if the user is external registered and verified
// with LDAP or AAI SAML
final StartupParameters reqParams = RWT.getClient().getService(StartupParameters.class);
final String institutionId = reqParams.getParameter(Entity.FILTER_ATTR_INSTITUTION);
final String institutionId = reqParams.getParameter(Domain.ATTR_INSTITUTION_ID);
if (StringUtils.isNotBlank(institutionId)) {
httpSession.setAttribute(Entity.FILTER_ATTR_INSTITUTION, institutionId);
httpSession.setAttribute(Domain.ATTR_INSTITUTION_ID, institutionId);
} else {
httpSession.removeAttribute(Entity.FILTER_ATTR_INSTITUTION);
httpSession.removeAttribute(Domain.ATTR_INSTITUTION_ID);
}
final AuthorizationContextHolder authorizationContextHolder = webApplicationContext

View file

@ -31,12 +31,14 @@ public interface PageContext {
public interface AttributeKeys {
public static final String ATTR_PAGE_TEMPLATE_COMPOSER_NAME = "ATTR_PAGE_TEMPLATE_COMPOSER_NAME";
public static final String PAGE_TEMPLATE_COMPOSER_NAME = "ATTR_PAGE_TEMPLATE_COMPOSER_NAME";
public static final String ATTR_ENTITY_ID = "ENTITY_ID";
public static final String ATTR_PARENT_ENTITY_ID = "PARENT_ENTITY_ID";
public static final String ATTR_ENTITY_TYPE = "ENTITY_TYPE";
public static final String ATTR_PARENT_ENTITY_TYPE = "PARENT_ENTITY_TYPE";
public static final String INSTITUTION_ID = "INSTITUTION_ID";
public static final String ENTITY_ID = "ENTITY_ID";
public static final String PARENT_ENTITY_ID = "PARENT_ENTITY_ID";
public static final String ENTITY_TYPE = "ENTITY_TYPE";
public static final String PARENT_ENTITY_TYPE = "PARENT_ENTITY_TYPE";
// public static final String USER_NAME = "USER_NAME";
// public static final String PASSWORD = "PASSWORD";

View file

@ -97,8 +97,8 @@ public class ActivitySelection {
public ActivitySelection withEntity(final EntityKey entityKey) {
if (entityKey != null) {
this.attributes.put(AttributeKeys.ATTR_ENTITY_ID, entityKey.modelId);
this.attributes.put(AttributeKeys.ATTR_ENTITY_TYPE, entityKey.entityType.name());
this.attributes.put(AttributeKeys.ENTITY_ID, entityKey.modelId);
this.attributes.put(AttributeKeys.ENTITY_TYPE, entityKey.entityType.name());
}
return this;
@ -107,8 +107,8 @@ public class ActivitySelection {
public ActivitySelection withParentEntity(final EntityKey parentEntityKey) {
if (parentEntityKey != null) {
this.attributes.put(AttributeKeys.ATTR_PARENT_ENTITY_ID, parentEntityKey.modelId);
this.attributes.put(AttributeKeys.ATTR_PARENT_ENTITY_TYPE, parentEntityKey.entityType.name());
this.attributes.put(AttributeKeys.PARENT_ENTITY_ID, parentEntityKey.modelId);
this.attributes.put(AttributeKeys.PARENT_ENTITY_TYPE, parentEntityKey.entityType.name());
}
return this;
@ -131,7 +131,7 @@ public class ActivitySelection {
}
public String getEntityId() {
return this.attributes.get(AttributeKeys.ATTR_ENTITY_ID);
return this.attributes.get(AttributeKeys.ENTITY_ID);
}
public static ActivitySelection get(final TreeItem item) {

View file

@ -30,7 +30,7 @@ public class DefaultLoginPage implements PageDefinition {
@Override
public PageContext applyPageContext(final PageContext pageContext) {
return pageContext.withAttr(
AttributeKeys.ATTR_PAGE_TEMPLATE_COMPOSER_NAME,
AttributeKeys.PAGE_TEMPLATE_COMPOSER_NAME,
SEBLogin.class.getName());
}

View file

@ -30,7 +30,7 @@ public class DefaultMainPage implements PageDefinition {
@Override
public PageContext applyPageContext(final PageContext pageContext) {
return pageContext.withAttr(
AttributeKeys.ATTR_PAGE_TEMPLATE_COMPOSER_NAME,
AttributeKeys.PAGE_TEMPLATE_COMPOSER_NAME,
SEBMainPage.class.getName());
}

View file

@ -8,24 +8,35 @@
package ch.ethz.seb.sebserver.gui.service.page.impl;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64InputStream;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys;
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.WebserviceURIService;
import ch.ethz.seb.sebserver.gui.service.widget.WidgetFactory;
import ch.ethz.seb.sebserver.gui.service.widget.WidgetFactory.CustomVariant;
@ -33,17 +44,22 @@ import ch.ethz.seb.sebserver.gui.service.widget.WidgetFactory.CustomVariant;
@Component
public class DefaultPageLayout implements TemplateComposer {
private static final Logger log = LoggerFactory.getLogger(DefaultPageLayout.class);
private final WebserviceURIService webserviceURIService;
private final WidgetFactory widgetFactory;
private final PolyglotPageService polyglotPageService;
private final AuthorizationContextHolder authorizationContextHolder;
private final String sebServerVersion;
public DefaultPageLayout(
final WebserviceURIService webserviceURIService,
final WidgetFactory widgetFactory,
final PolyglotPageService polyglotPageService,
final AuthorizationContextHolder authorizationContextHolder,
@Value("${sebserver.version}") final String sebServerVersion) {
this.webserviceURIService = webserviceURIService;
this.widgetFactory = widgetFactory;
this.polyglotPageService = polyglotPageService;
this.authorizationContextHolder = authorizationContextHolder;
@ -52,7 +68,7 @@ public class DefaultPageLayout implements TemplateComposer {
@Override
public boolean validate(final PageContext pageContext) {
return pageContext.hasAttribute(AttributeKeys.ATTR_PAGE_TEMPLATE_COMPOSER_NAME);
return pageContext.hasAttribute(AttributeKeys.PAGE_TEMPLATE_COMPOSER_NAME);
}
@Override
@ -147,7 +163,30 @@ public class DefaultPageLayout implements TemplateComposer {
logoCell.minimumWidth = 400;
logoCell.horizontalIndent = 50;
logo.setLayoutData(logoCell);
logo.setData(RWT.CUSTOM_VARIANT, "bgLogo");
// try to get institutional logo first. If no success, use default logo
try {
final String institutionId = (String) RWT.getUISession()
.getHttpSession()
.getAttribute(Domain.ATTR_INSTITUTION_ID);
final String logoBase64 = new RestTemplate()
.getForObject(
this.webserviceURIService.getWebserviceServerAddress() + API.LOGO_PATH_CODE,
String.class,
institutionId);
final Base64InputStream input = new Base64InputStream(
new ByteArrayInputStream(logoBase64.getBytes(StandardCharsets.UTF_8)),
false);
logo.setData(RWT.CUSTOM_VARIANT, "bgLogoNoImage");
logo.setBackgroundImage(new Image(pageContext.getShell().getDisplay(), input));
} catch (final Exception e) {
log.warn("Get institutional logo failed: ", e);
logo.setData(RWT.CUSTOM_VARIANT, "bgLogo");
}
final Composite langSupport = new Composite(logoBar, SWT.NONE);
final GridData langSupportCell = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
@ -199,7 +238,7 @@ public class DefaultPageLayout implements TemplateComposer {
contentInner.setLayout(gridLayout);
final String contentComposerName = pageContext.getAttribute(
AttributeKeys.ATTR_PAGE_TEMPLATE_COMPOSER_NAME);
AttributeKeys.PAGE_TEMPLATE_COMPOSER_NAME);
pageContext.composerService().compose(
contentComposerName,
pageContext.copyOf(contentInner));

View file

@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@ -31,7 +31,7 @@ public class GetInstitution extends RestCall<Institution> {
},
HttpMethod.GET,
MediaType.APPLICATION_FORM_URLENCODED,
SEBServerRestEndpoints.ENDPOINT_INSTITUTION);
API.INSTITUTION_ENDPOINT);
}
}

View file

@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.EntityName;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@ -33,7 +33,7 @@ public class GetInstitutionNames extends RestCall<List<EntityName>> {
},
HttpMethod.GET,
MediaType.APPLICATION_FORM_URLENCODED,
SEBServerRestEndpoints.ENDPOINT_INSTITUTION + SEBServerRestEndpoints.NAMES_ENDPOINT_SUFFIX);
API.INSTITUTION_ENDPOINT + API.NAMES_SUFFIX);
}
@Override

View file

@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Page;
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
@ -32,7 +32,7 @@ public class GetInstitutions extends RestCall<Page<Institution>> {
},
HttpMethod.GET,
MediaType.APPLICATION_FORM_URLENCODED,
SEBServerRestEndpoints.ENDPOINT_INSTITUTION);
API.INSTITUTION_ENDPOINT);
}
}

View file

@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@ -31,7 +31,7 @@ public class NewInstitution extends RestCall<Institution> {
},
HttpMethod.POST,
MediaType.APPLICATION_FORM_URLENCODED,
SEBServerRestEndpoints.ENDPOINT_INSTITUTION);
API.INSTITUTION_ENDPOINT);
}
}

View file

@ -12,7 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
@Component
@ -21,7 +21,7 @@ public class WebserviceURIService {
private static final String OAUTH_TOKEN_URI_PATH = "oauth/token"; // TODO to config properties?
private static final String OAUTH_REVOKE_TOKEN_URI_PATH = "/oauth/revoke-token"; // TODO to config properties?
private static final String CURRENT_USER_URI_PATH = SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me";
private static final String CURRENT_USER_URI_PATH = API.USER_ACCOUNT_ENDPOINT + "/me";
private final String webserviceServerAddress;
private final UriComponentsBuilder webserviceURIBuilder;
@ -39,6 +39,10 @@ public class WebserviceURIService {
.path(webserviceAPIPath);
}
public String getWebserviceServerAddress() {
return this.webserviceServerAddress;
}
public UriComponentsBuilder getBuilder() {
return this.webserviceURIBuilder.cloneBuilder();
}

View file

@ -40,15 +40,15 @@ public class EntityTable<ROW extends Entity> extends Composite {
public static final String TABLE_ROW_DATA = "TABLE_ROW_DATA";
private final WidgetFactory widgetFactory;
private transient final WidgetFactory widgetFactory;
private final RestCall<Page<ROW>> restCall;
private final List<ColumnDefinition<ROW>> columns;
private final List<TableRowAction> actions;
private transient final RestCall<Page<ROW>> restCall;
private transient final List<ColumnDefinition<ROW>> columns;
private transient final List<TableRowAction> actions;
private final TableFilter<ROW> filter;
private final Table table;
private final TableNavigator navigator;
private transient final TableFilter<ROW> filter;
private transient final Table table;
private transient final TableNavigator navigator;
private int pageNumber = 1;
private int pageSize;

View file

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
@ -57,7 +57,7 @@ public abstract class ActivatableEntityController<T extends GrantEntity, M exten
}
@RequestMapping(
path = SEBServerRestEndpoints.ENDPOINT_ACTIVE,
path = API.ACTIVE_SUFFIX,
method = RequestMethod.GET,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ -80,7 +80,7 @@ public abstract class ActivatableEntityController<T extends GrantEntity, M exten
}
@RequestMapping(
path = SEBServerRestEndpoints.ENDPOINT_INACTIVE,
path = API.INACTIVE_SUFFIX,
method = RequestMethod.GET,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ -103,7 +103,7 @@ public abstract class ActivatableEntityController<T extends GrantEntity, M exten
}
@RequestMapping(
path = "/{modelId}" + SEBServerRestEndpoints.ENDPOINT_ACTIVE,
path = "/{modelId}" + API.ACTIVE_SUFFIX,
method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ -113,7 +113,7 @@ public abstract class ActivatableEntityController<T extends GrantEntity, M exten
}
@RequestMapping(
value = "/{modelId}" + SEBServerRestEndpoints.ENDPOINT_INACTIVE,
value = "/{modelId}" + API.INACTIVE_SUFFIX,
method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)

View file

@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
@ -121,7 +121,7 @@ public abstract class EntityController<T extends GrantEntity, M extends GrantEnt
// ******************
@RequestMapping(
path = SEBServerRestEndpoints.NAMES_ENDPOINT_SUFFIX,
path = API.NAMES_SUFFIX,
method = RequestMethod.GET,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ -169,7 +169,7 @@ public abstract class EntityController<T extends GrantEntity, M extends GrantEnt
// ******************
@RequestMapping(
path = SEBServerRestEndpoints.LIST_ENDPOINT_SUFFIX,
path = API.LIST_SUFFIX,
method = RequestMethod.GET,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)

View file

@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
@ -59,7 +59,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationSe
@WebServiceProfile
@RestController
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + SEBServerRestEndpoints.ENDPOINT_EXAM_ADMINISTRATION)
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + API.EXAM_ADMINISTRATION_ENDPOINT)
public class ExamAdministrationController extends ActivatableEntityController<Exam, Exam> {
private final ExamDAO examDAO;

View file

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.InstitutionRecordDynamicSqlSupport;
@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationSe
@WebServiceProfile
@RestController
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + API.INSTITUTION_ENDPOINT)
public class InstitutionController extends ActivatableEntityController<Institution, Institution> {
private final InstitutionDAO institutionDAO;

View file

@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.EntityType;
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
@ -39,7 +39,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationSe
@WebServiceProfile
@RestController
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + API.LMS_SETUP_ENDPOINT)
public class LmsSetupController extends ActivatableEntityController<LmsSetup, LmsSetup> {
private final LmsAPIService lmsAPIService;

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package ch.ethz.seb.sebserver.webservice.weblayer.api;
import java.io.IOException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.InstitutionDAO;
@WebServiceProfile
@RestController
public class LogoController {
private final InstitutionDAO institutionDAO;
protected LogoController(final InstitutionDAO institutionDAO) {
this.institutionDAO = institutionDAO;
}
@RequestMapping(API.LOGO_ENDPOINT + "/{institutionId}")
public String logo(@PathVariable final String institutionId) throws IOException {
return this.institutionDAO
.byModelId(institutionId)
.getOrThrow().logoImage;
}
}

View file

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import ch.ethz.seb.sebserver.gbl.model.EntityType;
@ -30,7 +30,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplate;
@WebServiceProfile
@RestController
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + SEBServerRestEndpoints.ENDPOINT_QUIZ_IMPORT)
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + API.QUIZ_IMPORT_ENDPOINT)
public class QuizImportController {
private final int defaultPageSize;

View file

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
import ch.ethz.seb.sebserver.gbl.model.user.UserMod;
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
@ -31,7 +31,7 @@ import ch.ethz.seb.sebserver.webservice.weblayer.oauth.RevokeTokenEndpoint;
@WebServiceProfile
@RestController
@RequestMapping("${sebserver.webservice.api.admin.endpoint}" + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
@RequestMapping("${sebserver.webservice.api.admin.endpoint}" + API.USER_ACCOUNT_ENDPOINT)
public class UserAccountController extends ActivatableEntityController<UserInfo, UserMod> {
private final ApplicationEventPublisher applicationEventPublisher;

View file

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.EntityType;
import ch.ethz.seb.sebserver.gbl.model.Page;
import ch.ethz.seb.sebserver.gbl.model.user.UserActivityLog;
@ -33,7 +33,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO;
@WebServiceProfile
@RestController
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG)
@RequestMapping("/${sebserver.webservice.api.admin.endpoint}" + API.USER_ACTIVITY_LOG_ENDPOINT)
public class UserActivityLogController {
private final UserActivityLogDAO userActivityLogDAO;

View file

@ -88,6 +88,14 @@ Composite.bgLogo {
background-position: left center;
}
Composite.bgLogoNoImage {
background-color: transparent;
background-repeat: no-repeat;
background-position: left center;
}
Composite.bgContent {
background-color: #EAECEE;
background-image: url(static/images/blueBackground.png);

View file

@ -24,7 +24,7 @@ import org.springframework.test.context.jdbc.Sql;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.EntityName;
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
import ch.ethz.seb.sebserver.gbl.model.Page;
@ -37,7 +37,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
public void getInstitutions() throws Exception {
Page<Institution> institutions = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Page<Institution>>() {
});
@ -49,7 +49,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
institutions = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withAttribute("active", "true")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Page<Institution>>() {
@ -62,7 +62,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
institutions = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withAttribute("active", "false")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Page<Institution>>() {
@ -75,7 +75,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// institutional admin sees only his institution
institutions = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Page<Institution>>() {
});
@ -87,7 +87,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// Institutional admin tries to get data from other institution
final List<APIMessage> errorMessage = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withAttribute("institutionId", "2") // try to hack
.withExpectedStatus(HttpStatus.FORBIDDEN)
.getAsObject(new TypeReference<List<APIMessage>>() {
@ -100,7 +100,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// get own institution
final Institution own = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION + "/self")
.withPath(API.INSTITUTION_ENDPOINT + "/self")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Institution>() {
});
@ -113,7 +113,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
public void getInstitutionById() throws Exception {
Institution institution = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION + "/1")
.withPath(API.INSTITUTION_ENDPOINT + "/1")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Institution>() {
});
@ -124,7 +124,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// a seb-admin is also able to get an institution that is not the one he self belongs to
institution = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION + "/2")
.withPath(API.INSTITUTION_ENDPOINT + "/2")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Institution>() {
});
@ -135,7 +135,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// but a institutional-admin is not able to get an institution that is not the one he self belongs to
new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION + "/2")
.withPath(API.INSTITUTION_ENDPOINT + "/2")
.withExpectedStatus(HttpStatus.FORBIDDEN)
.getAsString();
}
@ -145,7 +145,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// create new institution with seb-admin
Institution institution = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new institution")
.withAttribute("urlSuffix", "new_inst")
@ -161,7 +161,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// an institutional admin should not be allowed to create a new institution
List<APIMessage> errorMessage = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new institution")
.withAttribute("urlSuffix", "new_inst")
@ -173,7 +173,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// and name for institution must be unique
errorMessage = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new institution")
.withAttribute("urlSuffix", "new_inst")
@ -189,7 +189,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// and predefined id should be ignored
institution = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("id", "123")
.withAttribute("name", "newer institution")
@ -209,7 +209,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
final String sebAdminAccess = getSebAdminAccess();
Institution institution = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "testInstitution")
.withExpectedStatus(HttpStatus.OK)
@ -223,7 +223,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// get
institution = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION).withPath("/")
.withPath(API.INSTITUTION_ENDPOINT).withPath("/")
.withPath(String.valueOf(institution.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.OK)
@ -238,7 +238,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// modify
institution = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION).withPath("/")
.withPath(API.INSTITUTION_ENDPOINT).withPath("/")
.withPath(String.valueOf(institution.id))
.withMethod(HttpMethod.PUT)
.withBodyJson(new Institution(null, "testInstitution", "testSuffix", null, null))
@ -254,7 +254,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// activate
EntityProcessingReport report = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withPath("/").withPath(String.valueOf(institution.id)).withPath("/active")
.withMethod(HttpMethod.POST)
.withExpectedStatus(HttpStatus.OK)
@ -270,7 +270,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// get
institution = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION).withPath("/")
.withPath(API.INSTITUTION_ENDPOINT).withPath("/")
.withPath(String.valueOf(institution.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.OK)
@ -283,7 +283,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// deactivate
report = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withPath("/").withPath(String.valueOf(institution.id)).withPath("/inactive")
.withMethod(HttpMethod.POST)
.withExpectedStatus(HttpStatus.OK)
@ -299,7 +299,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// get
institution = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION).withPath("/")
.withPath(API.INSTITUTION_ENDPOINT).withPath("/")
.withPath(String.valueOf(institution.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.OK)
@ -312,7 +312,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// delete
report = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(API.INSTITUTION_ENDPOINT)
.withPath("/").withPath(String.valueOf(institution.id))
.withMethod(HttpMethod.DELETE)
.withExpectedStatus(HttpStatus.OK)
@ -329,7 +329,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// get
final List<APIMessage> error = new RestAPITestHelper()
.withAccessToken(sebAdminAccess)
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION).withPath("/")
.withPath(API.INSTITUTION_ENDPOINT).withPath("/")
.withPath(String.valueOf(institution.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.NOT_FOUND)
@ -345,8 +345,8 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
public void getForIds() throws Exception {
final Collection<Institution> institutions = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(SEBServerRestEndpoints.LIST_ENDPOINT_SUFFIX)
.withPath(API.INSTITUTION_ENDPOINT)
.withPath(API.LIST_SUFFIX)
.withAttribute("ids", "1,2,3")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Collection<Institution>>() {
@ -360,8 +360,8 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
public void getNames() throws Exception {
final Collection<EntityName> institutions = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_INSTITUTION)
.withPath(SEBServerRestEndpoints.NAMES_ENDPOINT_SUFFIX)
.withPath(API.INSTITUTION_ENDPOINT)
.withPath(API.NAMES_SUFFIX)
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Collection<EntityName>>() {
});
@ -375,7 +375,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
final String sebAdminToken = getSebAdminAccess();
Page<Institution> institutions = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_INSTITUTION + "/active")
this.mockMvc.perform(get(this.endpoint + API.INSTITUTION_ENDPOINT + "/active")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -388,7 +388,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester {
// all inactive of the own institution
institutions = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/inactive")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/inactive")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())

View file

@ -21,7 +21,7 @@ import org.springframework.test.context.jdbc.Sql;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.EntityName;
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
@ -36,7 +36,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// create new LmsSetup with seb-admin
LmsSetup lmsSetup = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 1")
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
@ -68,7 +68,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
lmsSetup = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP + "/" + lmsSetup.id)
.withPath(API.LMS_SETUP_ENDPOINT + "/" + lmsSetup.id)
.withMethod(HttpMethod.PUT)
.withBodyJson(modified)
.withExpectedStatus(HttpStatus.OK)
@ -90,7 +90,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// activate
EntityProcessingReport report = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath("/").withPath(String.valueOf(lmsSetup.id)).withPath("/active")
.withMethod(HttpMethod.POST)
.withExpectedStatus(HttpStatus.OK)
@ -107,7 +107,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// get
lmsSetup = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP).withPath("/")
.withPath(API.LMS_SETUP_ENDPOINT).withPath("/")
.withPath(String.valueOf(lmsSetup.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.OK)
@ -120,7 +120,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// deactivate
report = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath("/").withPath(String.valueOf(lmsSetup.id)).withPath("/inactive")
.withMethod(HttpMethod.POST)
.withExpectedStatus(HttpStatus.OK)
@ -136,7 +136,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
lmsSetup = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP).withPath("/")
.withPath(API.LMS_SETUP_ENDPOINT).withPath("/")
.withPath(String.valueOf(lmsSetup.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.OK)
@ -149,7 +149,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// delete
report = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath("/").withPath(String.valueOf(lmsSetup.id))
.withMethod(HttpMethod.DELETE)
.withExpectedStatus(HttpStatus.OK)
@ -166,7 +166,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// get
final List<APIMessage> error = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP).withPath("/")
.withPath(API.LMS_SETUP_ENDPOINT).withPath("/")
.withPath(String.valueOf(lmsSetup.id))
.withMethod(HttpMethod.GET)
.withExpectedStatus(HttpStatus.NOT_FOUND)
@ -183,7 +183,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// create new institution with seb-admin
final List<APIMessage> errors = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 1")
.withAttribute("active", "false")
@ -201,7 +201,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// create some new LmsSetup with seb-admin
final LmsSetup lmsSetup1 = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 1")
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
@ -211,7 +211,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
});
final LmsSetup lmsSetup2 = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 2")
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
@ -222,8 +222,8 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
final Collection<LmsSetup> lmsSetups = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(SEBServerRestEndpoints.LIST_ENDPOINT_SUFFIX)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath(API.LIST_SUFFIX)
.withAttribute("ids", lmsSetup1.id + "," + lmsSetup2.id)
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Collection<LmsSetup>>() {
@ -238,7 +238,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// create some new LmsSetup with seb-admin
new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 1")
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
@ -248,7 +248,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
});
new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 2")
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
@ -259,8 +259,8 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
final Collection<EntityName> lmsSetupNames = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(SEBServerRestEndpoints.NAMES_ENDPOINT_SUFFIX)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath(API.NAMES_SUFFIX)
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Collection<EntityName>>() {
});
@ -273,7 +273,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
public void getById() throws Exception {
final Long id1 = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 1")
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
@ -284,7 +284,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
final Long id2 = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withMethod(HttpMethod.POST)
.withAttribute("name", "new LmsSetup 2")
.withAttribute(Domain.LMS_SETUP.ATTR_INSTITUTION_ID, "2")
@ -296,7 +296,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
LmsSetup lmsSetup = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath(String.valueOf(id1))
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<LmsSetup>() {
@ -308,7 +308,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// a seb-admin is also able to get an institution that is not the one he self belongs to
lmsSetup = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath(String.valueOf(id2))
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<LmsSetup>() {
@ -320,7 +320,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
// but a institutional-admin is not able to get an institution that is not the one he self belongs to
new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_LMS_SETUP)
.withPath(API.LMS_SETUP_ENDPOINT)
.withPath(String.valueOf(id2))
.withExpectedStatus(HttpStatus.FORBIDDEN)
.getAsString();

View file

@ -32,7 +32,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
@ -52,7 +52,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void getMyUserInfo() throws Exception {
String contentAsString = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me")
.withPath(API.USER_ACCOUNT_ENDPOINT + "/me")
.withExpectedStatus(HttpStatus.OK)
.getAsString();
@ -70,7 +70,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
contentAsString = new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me")
.withPath(API.USER_ACCOUNT_ENDPOINT + "/me")
.withExpectedStatus(HttpStatus.OK)
.getAsString();
@ -91,7 +91,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void getUserInfoWithUUID() throws Exception {
final String sebAdminAccessToken = getSebAdminAccess();
String contentAsString = this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user2")
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminAccessToken))
.andExpect(status().isOk())
@ -111,7 +111,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String adminInstitution2AccessToken = getAdminInstitution2Access();
contentAsString = this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user1")
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user1")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + adminInstitution2AccessToken))
.andExpect(status().isForbidden())
@ -129,7 +129,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void institutionalAdminNotAllowedToSeeUsersOfOtherInstitution() throws Exception {
new RestAPITestHelper()
.withAccessToken(getAdminInstitution1Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "?institutionId=2")
.withPath(API.USER_ACCOUNT_ENDPOINT + "?institutionId=2")
.withExpectedStatus(HttpStatus.FORBIDDEN)
.getAsString();
}
@ -138,7 +138,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void getAllUserInfoNoFilter() throws Exception {
Page<UserInfo> userInfos = new RestAPITestHelper()
.withAccessToken(getSebAdminAccess())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
.withPath(API.USER_ACCOUNT_ENDPOINT)
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Page<UserInfo>>() {
});
@ -152,7 +152,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
userInfos = new RestAPITestHelper()
.withAccessToken(getAdminInstitution2Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
.withPath(API.USER_ACCOUNT_ENDPOINT)
.withAttribute("institutionId", "2")
.withExpectedStatus(HttpStatus.OK)
.getAsObject(new TypeReference<Page<UserInfo>>() {
@ -169,7 +169,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
//.. and without inactive, if active flag is set to true
userInfos = new RestAPITestHelper()
.withAccessToken(getAdminInstitution2Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
.withPath(API.USER_ACCOUNT_ENDPOINT)
.withAttribute(Entity.FILTER_ATTR_INSTITUTION, "2")
.withAttribute(Entity.FILTER_ATTR_ACTIVE, "true")
.withExpectedStatus(HttpStatus.OK)
@ -185,7 +185,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
//.. and only inactive, if active flag is set to false
userInfos = new RestAPITestHelper()
.withAccessToken(getAdminInstitution2Access())
.withPath(SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
.withPath(API.USER_ACCOUNT_ENDPOINT)
.withAttribute(Entity.FILTER_ATTR_INSTITUTION, "2")
.withAttribute(Entity.FILTER_ATTR_ACTIVE, "false")
.withExpectedStatus(HttpStatus.OK)
@ -205,7 +205,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String token = getSebAdminAccess();
final Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -228,7 +228,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String token = getSebAdminAccess();
final Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "?institutionId=2")
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "?institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -247,7 +247,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void getPageNoFilterNoPageAttributesDescendingOrder() throws Exception {
final String token = getSebAdminAccess();
final Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "?sort=-")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "?sort=-")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -269,7 +269,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// first page default sort order
Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "?page_number=1&page_size=3&institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -287,7 +287,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// second page default sort order
userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "?page_number=2&page_size=3&institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -306,7 +306,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// invalid page number should refer to last page
userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "?page_number=3&page_size=3&institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -325,7 +325,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// first page descending sort order
userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "?page_number=1&page_size=3&sort=-&institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -345,7 +345,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void getAllUserInfo() throws Exception {
final String token = getSebAdminAccess();
final Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -362,7 +362,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String token = getSebAdminAccess();
final Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "?active=true&institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -382,7 +382,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// expecting none for SEBAdmins institution
final String token = getSebAdminAccess();
Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "?active=false")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "?active=false")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -396,7 +396,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// expecting one for institution 2
userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "?active=false&institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -415,7 +415,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String token = getSebAdminAccess();
final Page<UserInfo> userInfos = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "?username=exam")
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "?username=exam")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -431,7 +431,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
@Test
public void testOwnerGet() throws Exception {
final String examAdminToken1 = getExamAdmin1();
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/me")
.header("Authorization", "Bearer " + examAdminToken1))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString();
@ -441,7 +441,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void createUserTest() throws Exception {
final String token = getSebAdminAccess();
final UserInfo createdUser = this.jsonMapper.readValue(
this.mockMvc.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
this.mockMvc.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT)
.header("Authorization", "Bearer " + token)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param(Domain.USER.ATTR_NAME, "NewTestUser")
@ -461,7 +461,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// get newly created user and check equality
final UserInfo createdUserGet = this.jsonMapper.readValue(
this.mockMvc.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + createdUser.uuid)
get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + createdUser.uuid)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -477,7 +477,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "?user=user1&activity_types=CREATE")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -557,7 +557,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void modifyUserWithPUTMethod() throws Exception {
final String token = getSebAdminAccess();
final UserInfo user = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user7")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user7")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -588,7 +588,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
UserInfo modifiedUserResult = this.jsonMapper.readValue(
this.mockMvc
.perform(
put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + user.getUuid())
put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + user.getUuid())
.header("Authorization", "Bearer " + token)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(modifyUserJson))
@ -607,7 +607,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// double check by getting the user by UUID
modifiedUserResult = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/"
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/"
+ modifiedUserResult.uuid)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + token))
@ -661,7 +661,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void testOwnerModifyPossibleForExamAdmin() throws Exception {
final String examAdminToken1 = getExamAdmin1();
final UserInfo examAdmin = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/me")
.header("Authorization", "Bearer " + examAdminToken1))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -671,7 +671,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final UserMod modifiedUser = new UserMod(examAdmin, null, null);
final String modifiedUserJson = this.jsonMapper.writeValueAsString(modifiedUser);
this.mockMvc.perform(put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + modifiedUser.uuid)
this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + modifiedUser.uuid)
.header("Authorization", "Bearer " + examAdminToken1)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(modifiedUserJson))
@ -683,7 +683,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void institutionalAdminTryToCreateOrModifyUserForOtherInstituionNotPossible() throws Exception {
final String token = getAdminInstitution1Access();
this.mockMvc.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
this.mockMvc.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT)
.header("Authorization", "Bearer " + token)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param(Domain.USER.ATTR_INSTITUTION_ID, "2")
@ -699,7 +699,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
new HashSet<>(Arrays.asList(UserRole.EXAM_ADMIN.name())));
final UserMod newUser = new UserMod(userInfo, "12345678", "12345678");
final String newUserJson = this.jsonMapper.writeValueAsString(newUser);
this.mockMvc.perform(put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/NewTestUser")
this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/NewTestUser")
.header("Authorization", "Bearer " + token)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(newUserJson))
@ -711,7 +711,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void unauthorizedAdminTryToCreateUserNotPossible() throws Exception {
final String token = getExamAdmin1();
this.mockMvc.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT)
this.mockMvc.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT)
.header("Authorization", "Bearer " + token)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param(Domain.USER.ATTR_INSTITUTION_ID, "2")
@ -727,7 +727,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
new HashSet<>(Arrays.asList(UserRole.EXAM_ADMIN.name())));
final UserMod newUser = new UserMod(userInfo, "12345678", "12345678");
final String newUserJson = this.jsonMapper.writeValueAsString(newUser);
this.mockMvc.perform(put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/NewTestUser")
this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/NewTestUser")
.header("Authorization", "Bearer " + token)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(newUserJson))
@ -743,7 +743,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// a SEB Server Admin now changes the password of ExamAdmin1
final String sebAdminToken = getSebAdminAccess();
final UserInfo examAdmin1 = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user4")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user4")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -757,7 +757,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
"newPassword");
final String modifiedUserJson = this.jsonMapper.writeValueAsString(modifiedUser);
this.mockMvc.perform(put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + modifiedUser.uuid)
this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + modifiedUser.uuid)
.header("Authorization", "Bearer " + sebAdminToken)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(modifiedUserJson))
@ -773,14 +773,14 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
}
// it should also not be possible to use an old token again after password change
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/me")
.header("Authorization", "Bearer " + examAdminToken1))
.andExpect(status().isUnauthorized())
.andReturn().getResponse().getContentAsString();
// but it should be possible to get a new access token and request again
final String examAdminToken2 = obtainAccessToken("examAdmin1", "newPassword");
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/me")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/me")
.header("Authorization", "Bearer " + examAdminToken2))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString();
@ -790,7 +790,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
public void modifyUserPasswordInvalidPasswords() throws Exception {
final String sebAdminToken = getSebAdminAccess();
final UserInfo examAdmin1 = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user4")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user4")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -807,7 +807,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
List<APIMessage> messages = this.jsonMapper.readValue(
this.mockMvc.perform(
put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + modifiedUser.uuid)
put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + modifiedUser.uuid)
.header("Authorization", "Bearer " + sebAdminToken)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(modifiedUserJson))
@ -830,7 +830,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
messages = this.jsonMapper.readValue(
this.mockMvc.perform(
put(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + modifiedUser.uuid)
put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + modifiedUser.uuid)
.header("Authorization", "Bearer " + sebAdminToken)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(modifiedUserJson))
@ -849,7 +849,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String timeNow = DateTime.now(DateTimeZone.UTC).toString(Constants.DATE_TIME_PATTERN_UTC_NO_MILLIS);
// only a SEB Administrator or an Institutional administrator should be able to deactivate a user-account
final String examAdminToken = getExamAdmin1();
this.mockMvc.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user4/inactive")
this.mockMvc.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user4/inactive")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + examAdminToken))
.andExpect(status().isForbidden());
@ -858,7 +858,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String sebAdminToken = getSebAdminAccess();
final EntityProcessingReport report = this.jsonMapper.readValue(
this.mockMvc
.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user4/inactive")
.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user4/inactive")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -876,7 +876,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final EntityKey key = report.source.iterator().next();
final UserInfo user = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + key.modelId)
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + key.modelId)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -891,7 +891,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final Page<UserActivityLog> userLogs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "/?user=user1&from=" + timeNow)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
@ -912,7 +912,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String timeNow = DateTime.now(DateTimeZone.UTC).toString(Constants.DATE_TIME_PATTERN_UTC_NO_MILLIS);
// only a SEB Administrator or an Institutional administrator should be able to deactivate a user-account
final String examAdminToken = getExamAdmin1();
this.mockMvc.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user6/active")
this.mockMvc.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user6/active")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + examAdminToken))
.andExpect(status().isForbidden());
@ -921,7 +921,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String sebAdminToken = getSebAdminAccess();
final EntityProcessingReport report = this.jsonMapper.readValue(
this.mockMvc
.perform(post(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/user6/active")
.perform(post(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/user6/active")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -939,7 +939,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final EntityKey key = report.source.iterator().next();
final UserInfo user = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/" + key.modelId)
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/" + key.modelId)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -953,7 +953,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// check also user activity log
final Page<UserActivityLog> userLogs = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "?user=user1&from=" + timeNow)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -974,7 +974,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// all active for the own institution
Page<UserInfo> usersPage = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/active")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/active")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -988,7 +988,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// all inactive of the own institution
usersPage = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/inactive")
this.mockMvc.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/inactive")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -1003,7 +1003,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// all active of institution 2
usersPage = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "/active?institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
@ -1019,7 +1019,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// all inactive of institution 2
usersPage = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "/inactive?institutionId=2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
@ -1041,7 +1041,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
Collection<UserInfo> users = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "/list?ids=user1,user2,user6,user7")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
@ -1059,7 +1059,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
users = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT
get(this.endpoint + API.USER_ACCOUNT_ENDPOINT
+ "/list?ids=user1,user2,user6,user7")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + instAdminToken))
@ -1080,7 +1080,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
// for SEB Admin
Collection<EntityName> names = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/names")
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/names")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + sebAdminToken))
.andExpect(status().isOk())
@ -1098,7 +1098,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
final String instAdminToken = getAdminInstitution2Access();
names = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/names")
.perform(get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/names")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + instAdminToken))
.andExpect(status().isOk())
@ -1117,7 +1117,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
names = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACCOUNT + "/names?active=true")
get(this.endpoint + API.USER_ACCOUNT_ENDPOINT + "/names?active=true")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header("Authorization", "Bearer " + instAdminToken))
.andExpect(status().isOk())

View file

@ -19,7 +19,7 @@ import org.springframework.test.context.jdbc.Sql;
import com.fasterxml.jackson.core.type.TypeReference;
import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.api.SEBServerRestEndpoints;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Page;
import ch.ethz.seb.sebserver.gbl.model.user.UserActivityLog;
@ -30,7 +30,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
public void getAllAsSEBAdmin() throws Exception {
final String token = getSebAdminAccess();
final Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG)
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -47,7 +47,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
// for a user in another institution, the institution has to be defined
Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?user=user4&institutionId=2")
.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?user=user4&institutionId=2")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -59,7 +59,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
// for a user in the same institution no institution is needed
logs = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?user=user2")
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?user=user2")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -82,7 +82,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
final String token = getSebAdminAccess();
Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?institutionId=2&from=" + sec2)
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?institutionId=2&from=" + sec2)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -94,7 +94,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?institutionId=2&from="
.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?institutionId=2&from="
+ sec2 + "&to=" + sec4)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -108,7 +108,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?institutionId=2&from=" + sec2
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?institutionId=2&from=" + sec2
+ "&to=" + sec5)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -122,7 +122,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?institutionId=2&from=" + sec2
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?institutionId=2&from=" + sec2
+ "&to=" + sec6)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -138,7 +138,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
public void getAllAsSEBAdminForActivityType() throws Exception {
final String token = getSebAdminAccess();
Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?activity_types=CREATE")
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?activity_types=CREATE")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -151,7 +151,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "?activity_types=CREATE,MODIFY")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -166,7 +166,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "?institutionId=2&activity_types=CREATE,MODIFY")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -183,7 +183,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
final String token = getSebAdminAccess();
Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc
.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?entity_types=INSTITUTION")
.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?entity_types=INSTITUTION")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -196,7 +196,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "?entity_types=INSTITUTION,EXAM")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -210,7 +210,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
logs = this.jsonMapper.readValue(
this.mockMvc
.perform(
get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG
get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT
+ "?entity_types=INSTITUTION,EXAM&institutionId=2")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
@ -226,7 +226,7 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
public void getAllAsInstitutionalAdmin() throws Exception {
final String token = getAdminInstitution1Access();
final Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG)
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
@ -242,18 +242,18 @@ public class UserActivityLogAPITest extends AdministrationAPIIntegrationTester {
String token = getExamAdmin1();
// no privilege at all
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG)
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT)
.header("Authorization", "Bearer " + token))
.andExpect(status().isForbidden());
// no privilege at all
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?user=user4")
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?user=user4")
.header("Authorization", "Bearer " + token))
.andExpect(status().isForbidden());
// no privilege to query logs of users of other institution
token = getAdminInstitution1Access();
final Page<UserActivityLog> logs = this.jsonMapper.readValue(
this.mockMvc.perform(get(this.endpoint + SEBServerRestEndpoints.ENDPOINT_USER_ACTIVITY_LOG + "?user=user4")
this.mockMvc.perform(get(this.endpoint + API.USER_ACTIVITY_LOG_ENDPOINT + "?user=user4")
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),