Commit 37011547 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Test requests with not acceptable accept headers

parent b73c463e
......@@ -29,7 +29,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${ldap.userSearchFilter}") private String ldapUserSearchFilter;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser(username)
.password(password).authorities("ADMIN");
......@@ -55,7 +55,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
}
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(final HttpSecurity http) throws Exception {
http.csrf().disable();
http.httpBasic();
}
......
......@@ -15,8 +15,11 @@ public class RepoPermissionEvaluator implements PermissionEvaluator {
private InternalUserService internalUserService;
@Override
public boolean hasPermission(final Authentication authentication,
final Object targetDomainObject, final Object permission) {
public boolean hasPermission(
final Authentication authentication,
final Object targetDomainObject,
final Object permission
) {
return false;
}
......@@ -25,9 +28,12 @@ public class RepoPermissionEvaluator implements PermissionEvaluator {
*
*/
@Override
public boolean hasPermission(final Authentication authentication,
final Serializable targetId, final String targetType,
final Object permission) {
public boolean hasPermission(
final Authentication authentication,
final Serializable targetId,
final String targetType,
final Object permission
) {
if (authentication.getPrincipal() instanceof String) {
return false;
}
......
......@@ -30,7 +30,7 @@ public class IliasConnectorDaoImpl implements UniRepDao {
public List<IliasCategoryNode> getTreeObjects(final int refId) {
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String typefilter = "";
String typefilter = null;
if (this.getClass().getAnnotation(UniRepDao.Filter.class) != null) {
switch (this.getClass().getAnnotation(UniRepDao.Filter.class).value()) {
......@@ -40,6 +40,9 @@ public class IliasConnectorDaoImpl implements UniRepDao {
case TEST:
typefilter = " AND type <> 'qpl'";
break;
default:
typefilter = "";
break;
}
}
......@@ -68,8 +71,8 @@ public class IliasConnectorDaoImpl implements UniRepDao {
questionCount.get(resultSet.getInt("child")) == null ? 0 :
questionCount.get(resultSet.getInt("child"))
);
if("tst".equals(node.getType())) {
if(randomQuestionAmount.get(node.getId()) == null) {
if ("tst".equals(node.getType())) {
if (randomQuestionAmount.get(node.getId()) == null) {
node.setIsRandomTest(false);
} else {
node.setIsRandomTest(true);
......
......@@ -155,8 +155,10 @@ public class UniRepServiceImpl implements UniRepService {
removeNotMarkedNodes(node.getChildren(), true);
} else {
removeNotMarkedNodes(node.getChildren(), false);
if (node.getChildren() == null
|| node.getChildren().size() == 0) {
if (
node.getChildren() == null
|| node.getChildren().size() == 0
) {
it.remove();
}
}
......
......@@ -129,4 +129,10 @@ public class WebDomainIntegrationTest {
.andExpect(status().isServiceUnavailable())
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
@Test
public void testShouldRejectRequestNotAcceptingJson() throws Exception {
mockMvc.perform(get("/test/membership/42").accept(MediaType.TEXT_PLAIN))
.andExpect(status().isNotAcceptable());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment