Merge branch 'master' into BAEL-1525
This commit is contained in:
commit
f7023fb616
2
pom.xml
2
pom.xml
|
@ -49,7 +49,9 @@
|
|||
<module>core-java</module>
|
||||
<module>core-java-io</module>
|
||||
<module>core-java-8</module>
|
||||
<!--
|
||||
<module>core-java-concurrency</module>
|
||||
-->
|
||||
<module>couchbase</module>
|
||||
|
||||
<module>deltaspike</module>
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
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>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>oauth2client</artifactId>
|
||||
<artifactId>auth-client</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>oauth2client</name>
|
||||
<name>auth-client</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
|
@ -4,11 +4,11 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>personresource</artifactId>
|
||||
<artifactId>auth-resource</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>personresource</name>
|
||||
<name>auth-resource</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>authserver</artifactId>
|
||||
<artifactId>auth-server</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
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.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
|
@ -21,6 +24,9 @@ import com.baeldung.si.security.SecurityConfig;
|
|||
@ContextConfiguration(classes = { SecurityConfig.class, SecuredDirectChannel.class, MessageConsumer.class })
|
||||
public class TestSpringIntegrationSecurity {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Autowired
|
||||
SubscribableChannel startDirectChannel;
|
||||
|
||||
|
@ -34,34 +40,28 @@ public class TestSpringIntegrationSecurity {
|
|||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
@Test
|
||||
@WithMockUser(username = "jane", roles = { "LOGGER" })
|
||||
public void givenRoleLogger_whenSendMessageToDirectChannel_thenAccessDenied() throws Throwable {
|
||||
try {
|
||||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
} catch (Exception e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
public void givenRoleLogger_whenSendMessageToDirectChannel_thenAccessDenied() {
|
||||
expectedException.expectCause(IsInstanceOf.<Throwable> instanceOf(AccessDeniedException.class));
|
||||
|
||||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
@Test
|
||||
@WithMockUser(username = "jane")
|
||||
public void givenJane_whenSendMessageToDirectChannel_thenAccessDenied() throws Throwable {
|
||||
try {
|
||||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
} catch (Exception e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
public void givenJane_whenSendMessageToDirectChannel_thenAccessDenied() {
|
||||
expectedException.expectCause(IsInstanceOf.<Throwable> instanceOf(AccessDeniedException.class));
|
||||
|
||||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
@Test
|
||||
@WithMockUser(roles = { "VIEWER" })
|
||||
public void givenRoleViewer_whenSendToDirectChannel_thenAccessDenied() throws Throwable {
|
||||
try {
|
||||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
} catch (Exception e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
public void givenRoleViewer_whenSendToDirectChannel_thenAccessDenied() {
|
||||
expectedException.expectCause(IsInstanceOf.<Throwable> instanceOf(AccessDeniedException.class));
|
||||
|
||||
startDirectChannel.send(new GenericMessage<String>(DIRECT_CHANNEL_MESSAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -78,4 +78,4 @@ public class TestSpringIntegrationSecurity {
|
|||
assertEquals(DIRECT_CHANNEL_MESSAGE, messageConsumer.getMessageContent());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue