Merge branch 'master' into BAEL-1525

This commit is contained in:
Loredana Crusoveanu 2018-02-10 21:04:33 +02:00
commit f7023fb616
28 changed files with 30 additions and 28 deletions

View File

@ -49,7 +49,9 @@
<module>core-java</module> <module>core-java</module>
<module>core-java-io</module> <module>core-java-io</module>
<module>core-java-8</module> <module>core-java-8</module>
<!--
<module>core-java-concurrency</module> <module>core-java-concurrency</module>
-->
<module>couchbase</module> <module>couchbase</module>
<module>deltaspike</module> <module>deltaspike</module>

View File

@ -3,11 +3,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>oauth2client</artifactId> <artifactId>auth-client</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>oauth2client</name> <name>auth-client</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<parent> <parent>

View File

@ -4,11 +4,11 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>personresource</artifactId> <artifactId>auth-resource</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>personresource</name> <name>auth-resource</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<parent> <parent>

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>authserver</artifactId> <artifactId>auth-server</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>

View File

@ -1,8 +1,11 @@
package com.baeldung.si; package com.baeldung.si;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.SubscribableChannel;
@ -21,6 +24,9 @@ import com.baeldung.si.security.SecurityConfig;
@ContextConfiguration(classes = { SecurityConfig.class, SecuredDirectChannel.class, MessageConsumer.class }) @ContextConfiguration(classes = { SecurityConfig.class, SecuredDirectChannel.class, MessageConsumer.class })
public class TestSpringIntegrationSecurity { public class TestSpringIntegrationSecurity {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Autowired @Autowired
SubscribableChannel startDirectChannel; SubscribableChannel startDirectChannel;
@ -34,34 +40,28 @@ public class TestSpringIntegrationSecurity {
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE)); startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
} }
@Test(expected = AccessDeniedException.class) @Test
@WithMockUser(username = "jane", roles = { "LOGGER" }) @WithMockUser(username = "jane", roles = { "LOGGER" })
public void givenRoleLogger_whenSendMessageToDirectChannel_thenAccessDenied() throws Throwable { public void givenRoleLogger_whenSendMessageToDirectChannel_thenAccessDenied() {
try { expectedException.expectCause(IsInstanceOf.<Throwable> instanceOf(AccessDeniedException.class));
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE)); startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
} catch (Exception e) {
throw e.getCause();
}
} }
@Test(expected = AccessDeniedException.class) @Test
@WithMockUser(username = "jane") @WithMockUser(username = "jane")
public void givenJane_whenSendMessageToDirectChannel_thenAccessDenied() throws Throwable { public void givenJane_whenSendMessageToDirectChannel_thenAccessDenied() {
try { expectedException.expectCause(IsInstanceOf.<Throwable> instanceOf(AccessDeniedException.class));
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE)); startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
} catch (Exception e) {
throw e.getCause();
}
} }
@Test(expected = AccessDeniedException.class) @Test
@WithMockUser(roles = { "VIEWER" }) @WithMockUser(roles = { "VIEWER" })
public void givenRoleViewer_whenSendToDirectChannel_thenAccessDenied() throws Throwable { public void givenRoleViewer_whenSendToDirectChannel_thenAccessDenied() {
try { expectedException.expectCause(IsInstanceOf.<Throwable> instanceOf(AccessDeniedException.class));
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE)); startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
} catch (Exception e) {
throw e.getCause();
}
} }
@Test @Test