You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2022/09/13 08:08:48 UTC
[isis] branch master updated: ISIS-3209: migrate core-security
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 3f755d2699 ISIS-3209: migrate core-security
3f755d2699 is described below
commit 3f755d26993dacbc9b2eacb32469771ee4438e95
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Sep 13 10:08:41 2022 +0200
ISIS-3209: migrate core-security
---
core/security/pom.xml | 23 ++++----------------
.../isis/security/EncodabilityContractTest.java | 8 +++----
.../AuthenticationManager_authenticators_Test.java | 25 +++++++++++++---------
.../SimpleSessionEncodabilityNoRolesTest.java | 2 +-
.../SimpleSessionEncodabilityTestAbstract.java | 2 +-
.../SimpleSessionEncodabilityWithRolesTest.java | 2 +-
...rdAuthenticationManager_AuthenticationTest.java | 8 +++----
7 files changed, 30 insertions(+), 40 deletions(-)
diff --git a/core/security/pom.xml b/core/security/pom.xml
index b358545aec..79e7c99b9d 100644
--- a/core/security/pom.xml
+++ b/core/security/pom.xml
@@ -44,26 +44,11 @@
<artifactId>isis-core-config</artifactId>
</dependency>
- <!-- TEST DEPENDENCIES -->
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <scope>test</scope>
- </dependency>
+ <!-- TESTING -->
+
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-internaltestsupport</artifactId>
<scope>test</scope>
</dependency>
diff --git a/core/security/src/test/java/org/apache/isis/security/EncodabilityContractTest.java b/core/security/src/test/java/org/apache/isis/security/EncodabilityContractTest.java
index 2670a9a8eb..8efcaa4c1f 100644
--- a/core/security/src/test/java/org/apache/isis/security/EncodabilityContractTest.java
+++ b/core/security/src/test/java/org/apache/isis/security/EncodabilityContractTest.java
@@ -25,8 +25,8 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
@@ -48,7 +48,7 @@ public abstract class EncodabilityContractTest {
super();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
serializable = createEncodable();
authContext = InteractionContext.ofUserWithSystemDefaults(
@@ -73,7 +73,7 @@ public abstract class EncodabilityContractTest {
}
@SneakyThrows
- private static <T extends Serializable> T doRoundTrip(T serializable) {
+ private static <T extends Serializable> T doRoundTrip(final T serializable) {
val buffer = new ByteArrayOutputStream();
diff --git a/core/security/src/test/java/org/apache/isis/security/authentication/standard/AuthenticationManager_authenticators_Test.java b/core/security/src/test/java/org/apache/isis/security/authentication/standard/AuthenticationManager_authenticators_Test.java
index 4df586d23c..149a312181 100644
--- a/core/security/src/test/java/org/apache/isis/security/authentication/standard/AuthenticationManager_authenticators_Test.java
+++ b/core/security/src/test/java/org/apache/isis/security/authentication/standard/AuthenticationManager_authenticators_Test.java
@@ -21,11 +21,12 @@ package org.apache.isis.security.authentication.standard;
import java.util.Collections;
import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.isis.applib.exceptions.unrecoverable.NoAuthenticatorException;
import org.apache.isis.core.security._testing.InteractionService_forTesting;
@@ -36,20 +37,24 @@ import org.apache.isis.security.AuthenticatorsForTesting;
import lombok.val;
-public class AuthenticationManager_authenticators_Test {
+class AuthenticationManager_authenticators_Test {
private AuthenticationManager authenticationManager;
- @Test(expected = NoAuthenticatorException.class)
+ @Test
public void shouldNotBeAbleToAuthenticateWithNoAuthenticators() throws Exception {
- authenticationManager = new AuthenticationManager(
- Collections.emptyList(),
- new InteractionService_forTesting(),
- new RandomCodeGeneratorDefault(),
- Optional.empty(),
- Collections.emptyList());
- authenticationManager.authenticate(new AuthenticationRequestPassword("foo", "bar"));
+ assertThrows(NoAuthenticatorException.class, ()->{
+
+ authenticationManager = new AuthenticationManager(
+ Collections.emptyList(),
+ new InteractionService_forTesting(),
+ new RandomCodeGeneratorDefault(),
+ Optional.empty(),
+ Collections.emptyList());
+ authenticationManager.authenticate(new AuthenticationRequestPassword("foo", "bar"));
+
+ });
}
@Test
diff --git a/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java b/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java
index 13ed095b8d..c5a3218153 100644
--- a/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java
+++ b/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java
@@ -23,7 +23,7 @@ import java.io.Serializable;
import org.apache.isis.applib.services.iactnlayer.InteractionContext;
import org.apache.isis.applib.services.user.UserMemento;
-public class SimpleSessionEncodabilityNoRolesTest
+class SimpleSessionEncodabilityNoRolesTest
extends SimpleSessionEncodabilityTestAbstract {
@Override
diff --git a/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityTestAbstract.java b/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityTestAbstract.java
index 73eea8c1b8..2212796c14 100644
--- a/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityTestAbstract.java
+++ b/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityTestAbstract.java
@@ -25,7 +25,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import org.apache.isis.applib.services.iactnlayer.InteractionContext;
import org.apache.isis.security.EncodabilityContractTest;
-public abstract class SimpleSessionEncodabilityTestAbstract
+abstract class SimpleSessionEncodabilityTestAbstract
extends EncodabilityContractTest {
@Override
diff --git a/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java b/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java
index e121ea8273..80a3c84c59 100644
--- a/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java
+++ b/core/security/src/test/java/org/apache/isis/security/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java
@@ -23,7 +23,7 @@ import java.io.Serializable;
import org.apache.isis.applib.services.iactnlayer.InteractionContext;
import org.apache.isis.applib.services.user.UserMemento;
-public class SimpleSessionEncodabilityWithRolesTest
+class SimpleSessionEncodabilityWithRolesTest
extends SimpleSessionEncodabilityTestAbstract {
@Override
diff --git a/core/security/src/test/java/org/apache/isis/security/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java b/core/security/src/test/java/org/apache/isis/security/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java
index b643e5260b..6db8b98cba 100644
--- a/core/security/src/test/java/org/apache/isis/security/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java
+++ b/core/security/src/test/java/org/apache/isis/security/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java
@@ -21,8 +21,8 @@ package org.apache.isis.security.authentication.standard;
import java.util.Collections;
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,11 +34,11 @@ import org.apache.isis.core.security.authentication.manager.AuthenticationManage
import org.apache.isis.core.security.authentication.standard.RandomCodeGeneratorDefault;
import org.apache.isis.security.AuthenticatorsForTesting;
-public class StandardAuthenticationManager_AuthenticationTest {
+class StandardAuthenticationManager_AuthenticationTest {
private AuthenticationManager authenticationManager;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
authenticationManager = new AuthenticationManager(