You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2021/08/03 14:53:31 UTC
[turbine-archetypes] branch master updated (8936b5e -> b5688e5)
This is an automated email from the ASF dual-hosted git repository.
gk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git.
from 8936b5e fix mark up urls, formatting, readd deleted development section
new fcda132 cherry picked fro mbranch docker5x commit with junit 5 changes, merging docs/DOCKER-README.
new c538566 removing provived pre-generated peer classes now generated with interfaces in torique-schema/toque-securitx-schema.xml
new a039857 update docs
new fa6024a use log4j2, update junit (may be removed as already in fulcrum testcontainer), and update to Fulcrum Security v.2.0.1-SNAPSHOT
new 6cc40e1 fix and extend tests and test configurations
new b5688e5 formatting, update namespace
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../META-INF/maven/archetype-metadata.xml | 10 +-
.../archetype-resources/docs/DOCKER-README.md | 150 ++++++----
.../resources/archetype-resources/docs/README.md | 6 +-
src/main/resources/archetype-resources/pom.xml | 14 +-
.../src/main/docker-resources/docker-compose.yml | 6 +-
.../src/main/java/om/TurbineGroupPeer.java | 21 --
.../src/main/java/om/TurbineGroupPeerImpl.java | 25 --
.../src/main/java/om/TurbineUserPeer.java | 22 --
.../src/main/java/om/TurbineUserPeerImpl.java | 25 --
.../webapp/WEB-INF/conf/componentConfiguration.xml | 4 +-
.../main/webapp/templates/app/layouts/Default.vm | 116 ++++----
.../src/main/webapp/templates/app/screens/Index.vm | 91 ++++---
.../conf/torque/fulcrumComponentConfiguration.xml | 8 +-
.../turbine/CompleteTurbineResources.properties | 17 ++
.../torque/turbine/turbine-classic-pipeline.xml | 1 +
.../AbstractFulcrumTorqueModelManagerTest.java | 18 +-
.../FulcrumTorqueDefaultModelManagerTest.java | 13 +-
.../security/TurbineSecurityServiceTest.java | 303 +++++++++++++++++----
18 files changed, 516 insertions(+), 334 deletions(-)
delete mode 100644 src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeer.java
delete mode 100644 src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeerImpl.java
delete mode 100644 src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeer.java
delete mode 100644 src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeerImpl.java
[turbine-archetypes] 04/06: use log4j2,
update junit (may be removed as already in fulcrum testcontainer),
and update to Fulcrum Security v.2.0.1-SNAPSHOT
Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
commit fa6024aed3870e8cc26d43efed15d7957c3ef334
Author: gemkall <ge...@fu-berlin.de>
AuthorDate: Tue Aug 3 16:49:53 2021 +0200
use log4j2, update junit (may be removed as already in fulcrum testcontainer), and update to Fulcrum Security v.2.0.1-SNAPSHOT
---
src/main/resources/archetype-resources/pom.xml | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index 5fc4b71..8716d20 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -286,6 +286,11 @@ under the License.
<artifactId>log4j-web</artifactId>
<version>#var("log4j2.version")</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j2.version}</version>
+ </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
@@ -375,7 +380,7 @@ under the License.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.13</version>
+ <version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -394,7 +399,7 @@ under the License.
<mysql.version>8.0.25</mysql.version>
<fulcrum.json>2.0.1</fulcrum.json>
<fulcrum.intake>2.0.0</fulcrum.intake>
- <fulcrum.security>2.0.0</fulcrum.security>
+ <fulcrum.security>2.0.1-SNAPSHOT</fulcrum.security>
<fulcrum.yaafi>1.0.8</fulcrum.yaafi>
<fulcrum.cache>2.0.0</fulcrum.cache>
<fulcrum.testcontainer>1.0.9</fulcrum.testcontainer>
[turbine-archetypes] 02/06: removing provived pre-generated peer
classes now generated with interfaces in
torique-schema/toque-securitx-schema.xml
Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
commit c538566fa6ad2d087366a43040e0a427425a9966
Author: gemkall <ge...@fu-berlin.de>
AuthorDate: Tue Aug 3 16:47:55 2021 +0200
removing provived pre-generated peer classes now generated with interfaces in torique-schema/toque-securitx-schema.xml
---
.../src/main/java/om/TurbineGroupPeer.java | 21 ------------------
.../src/main/java/om/TurbineGroupPeerImpl.java | 25 ----------------------
.../src/main/java/om/TurbineUserPeer.java | 22 -------------------
.../src/main/java/om/TurbineUserPeerImpl.java | 25 ----------------------
4 files changed, 93 deletions(-)
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeer.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeer.java
deleted file mode 100644
index d54dcf1..0000000
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package ${package}.om;
-
-/**
- * The skeleton for this class was autogenerated by Torque on:
- *
- * [Tue Oct 25 15:50:37 CEST 2016]
- *
- * This class provides static wrappers for the peer implementation classes.
- * This class will only be generated as long as it does not already exist
- * in the output directory.
- */
-/**
- * Added Interface
- * @author gk
- *
- */
-public class TurbineGroupPeer
- extends ${package}.om.BaseTurbineGroupPeer implements org.apache.fulcrum.security.torque.peer.Peer
-{
-
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeerImpl.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeerImpl.java
deleted file mode 100644
index 94c681d..0000000
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeerImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package ${package}.om;
-
-/**
- * The skeleton for this class was autogenerated by Torque on:
- *
- * [Tue Oct 25 15:50:38 CEST 2016]
- *
- * You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
- * long as it does not already exist in the output directory.
- */
-/**
- * Added Interface
- * @author gk
- *
- */
-public class TurbineGroupPeerImpl
- extends ${package}.om.BaseTurbineGroupPeerImpl implements org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer<TurbineGroup>
-{
- /** Serial version */
- private static final long serialVersionUID = 1477403438057L;
-
-
-
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeer.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeer.java
deleted file mode 100644
index 4c330e2..0000000
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ${package}.om;
-
-/**
- * The skeleton for this class was autogenerated by Torque on:
- *
- * [Tue Oct 25 15:50:37 CEST 2016]
- *
- * This class provides static wrappers for the peer implementation classes.
- * This class will only be generated as long as it does not already exist
- * in the output directory.
- */
-/**
- * Added Interface
- * @author gk
- *
- */
-
-public class TurbineUserPeer
- extends ${package}.om.BaseTurbineUserPeer implements org.apache.fulcrum.security.torque.peer.Peer
-{
-
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeerImpl.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeerImpl.java
deleted file mode 100644
index 38d7984..0000000
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeerImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package ${package}.om;
-
-
-/**
- * The skeleton for this class was autogenerated by Torque on:
- *
- * [Tue Oct 25 15:50:38 CEST 2016]
- *
- * You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
- * long as it does not already exist in the output directory.
- */
-
-/**
- * Added Interface
- * @author gk
- *
- */
-public class TurbineUserPeerImpl
- extends ${package}.om.BaseTurbineUserPeerImpl implements org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer<TurbineUser>
-{
- /** Serial version */
- private static final long serialVersionUID = 1477403438057L;
-
-}
[turbine-archetypes] 05/06: fix and extend tests and test
configurations
Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
commit 6cc40e143d637116edc1410016cb30a5a0213bfc
Author: gemkall <ge...@fu-berlin.de>
AuthorDate: Tue Aug 3 16:51:42 2021 +0200
fix and extend tests and test configurations
---
.../conf/torque/fulcrumComponentConfiguration.xml | 8 +-
.../turbine/CompleteTurbineResources.properties | 17 ++
.../torque/turbine/turbine-classic-pipeline.xml | 1 +
.../security/TurbineSecurityServiceTest.java | 280 ++++++++++++++++++---
4 files changed, 264 insertions(+), 42 deletions(-)
diff --git a/src/main/resources/archetype-resources/src/test/conf/torque/fulcrumComponentConfiguration.xml b/src/main/resources/archetype-resources/src/test/conf/torque/fulcrumComponentConfiguration.xml
index 612e0a8..a24baad 100644
--- a/src/main/resources/archetype-resources/src/test/conf/torque/fulcrumComponentConfiguration.xml
+++ b/src/main/resources/archetype-resources/src/test/conf/torque/fulcrumComponentConfiguration.xml
@@ -51,9 +51,13 @@
<modelManager/>
<aclFactory/>
- <userManager>
- <className>${package}.om.TurbineUser</className>
+ <userManager class="${package}">
+ <className>${package}.om.TurbineUser</className>
<peerClassName>${package}.om.TurbineUserPeerImpl</peerClassName>
+ <userGroupRoleManager>
+ <!--className${package}.om.TurbineUserGroupRole</className-->
+ <peerClassName>${package}.om.TurbineUserGroupRolePeerImpl</peerClassName>
+ </userGroupRoleManager>
</userManager>
<groupManager>
<className>${package}.om.TurbineGroup</className>
diff --git a/src/main/resources/archetype-resources/src/test/conf/torque/turbine/CompleteTurbineResources.properties b/src/main/resources/archetype-resources/src/test/conf/torque/turbine/CompleteTurbineResources.properties
index 4c213d3..b14974a 100644
--- a/src/main/resources/archetype-resources/src/test/conf/torque/turbine/CompleteTurbineResources.properties
+++ b/src/main/resources/archetype-resources/src/test/conf/torque/turbine/CompleteTurbineResources.properties
@@ -637,3 +637,20 @@ services.SessionService.earlyInit=true
#
# Default: none
# -------------------------------------------------------------------
+
+# -------------------------------------------------------------------
+#
+# U R L M A P P E R S E R V I C E
+#
+# - the valve org.apache.turbine.services.urlmapper.URLMapperValve is activated in classic-pipeline.xml
+# - service, optional pull tool and read configuration
+# - configure turbine-url-mapping in xml, json or yaml
+# -------------------------------------------------------------------
+
+#services.URLMapperService.classname=org.apache.turbine.services.urlmapper.TurbineURLMapperService
+
+# new mapper in pull tooll data service
+#tool.request.mlink=org.apache.turbine.services.urlmapper.MappedTemplateLink
+
+#services.URLMapperService.configFile = /src/test/conf/turbine-url-mapping.xml
+
diff --git a/src/main/resources/archetype-resources/src/test/conf/torque/turbine/turbine-classic-pipeline.xml b/src/main/resources/archetype-resources/src/test/conf/torque/turbine/turbine-classic-pipeline.xml
index f8457b0..a670a1b 100644
--- a/src/main/resources/archetype-resources/src/test/conf/torque/turbine/turbine-classic-pipeline.xml
+++ b/src/main/resources/archetype-resources/src/test/conf/torque/turbine/turbine-classic-pipeline.xml
@@ -25,6 +25,7 @@
<valve>org.apache.turbine.pipeline.DefaultLoginValve</valve>
<valve>org.apache.turbine.pipeline.DefaultSessionValidationValve</valve>
<valve>org.apache.turbine.pipeline.DefaultACLCreationValve</valve>
+ <!-- <valve>org.apache.turbine.services.urlmapper.URLMapperValve</valve> -->
<valve>org.apache.turbine.pipeline.ExecutePageValve</valve>
<valve>org.apache.turbine.pipeline.CleanUpValve</valve>
<valve>org.apache.turbine.pipeline.DetermineRedirectRequestedValve</valve>
diff --git a/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java b/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java
index 7a48dae..592d71a 100644
--- a/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java
+++ b/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java
@@ -20,7 +20,9 @@ package ${package}.services.security;
*/
import static org.junit.jupiter.api.Assertions.*;
+import org.apache.fulcrum.security.GroupManager;
import org.apache.fulcrum.security.ModelManager;
+import org.apache.fulcrum.security.RoleManager;
import org.apache.fulcrum.security.entity.ExtendedUser;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Permission;
@@ -31,8 +33,12 @@ import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.GroupSet;
+import org.apache.fulcrum.security.util.RoleSet;
import org.apache.fulcrum.security.util.UnknownEntityException;
import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.torque.ConstraintViolationException;
import org.apache.turbine.annotation.AnnotationProcessor;
import org.apache.turbine.annotation.TurbineService;
@@ -47,14 +53,12 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Test that the SecurityService works properly by comparing behaviour of Turbine and Fulcrum security services using
* Torque and Turbine user manager. Requires MySQL
*
- * @author gkallidis
+ * @author <a href="mailto:gk@apache.org">Georg Kallidis</a>
* @version $Id$
*/
@@ -62,6 +66,10 @@ public class TurbineSecurityServiceTest
extends BaseUnit5Test
{
+ private static final String TEST_GROUP = "TEST_GROUP";
+
+ private static final String TEST_ROLE = "TEST_Role";
+
org.apache.fulcrum.security.SecurityService fulcrumSecurityService;
@TurbineService
@@ -73,12 +81,10 @@ public class TurbineSecurityServiceTest
boolean onDeleteCascade = true;
- // By default org.slf4j.LoggerFactory is optional in 4.0, but included in webapp
- Logger log = LoggerFactory.getLogger( getClass().getName() );
+ Logger log = LogManager.getLogger( getClass().getName() );
@BeforeAll
public static void init()
- throws Exception
{
tc = new TurbineConfig( ".", "src/test/conf/torque/turbine/CompleteTurbineResources.properties" );
tc.initialize();
@@ -169,62 +175,165 @@ public class TurbineSecurityServiceTest
}
/**
- * Tests Turbine and Fulcrum.
+ * Tests Turbine Security Manager User / Group / Role
*
* @throws Exception
*/
@Test
- // @Ignore(value="Turbine security service supported requires Turbine 4.0.1")
public void testGrantUserGroupRole()
- throws Exception
{
Group group = null;
Role role = null;
User user = null;
- TurbineUser fulcrumUser = null;
try
- {
- group = turbineSecurityService.getGroupInstance( "TEST_GROUP" );
- group = turbineSecurityService.addGroup( group ); // assign here to delete later as
- role = turbineSecurityService.getRoleInstance( "TEST_Role" );
- role = turbineSecurityService.addRole( role );
+ {
// Turbine security service returns a wrapped instance: org.apache.turbine.om.security.DefaultUserImpl
// which implements org.apache.turbine.om.security.User
user = turbineSecurityService.getUserInstance( "Clint" );
- // required not null constraint
- ( (ExtendedUser) user ).setFirstName( user.getName() );
- ( (ExtendedUser) user ).setLastName( user.getName() );
+
+ if (turbineSecurityService.accountExists( user ) ) {
+ // only now the user object is updated with id
+ user = turbineSecurityService.getUser( "Clint" );
+ turbineSecurityService.revokeAll( user );
+ } else {
+ // required not null constraint;
+ ( (ExtendedUser) user ).setFirstName( user.getName() );
+ ( (ExtendedUser) user ).setLastName( user.getName() );
+ turbineSecurityService.addUser( user, "clint" );
+ user = turbineSecurityService.getUser( "Clint" );
+ }
+
+ role = addNewTestRole(turbineSecurityService);
+ group = addNewTestGroup(turbineSecurityService);
- turbineSecurityService.addUser( user, "clint" );
turbineSecurityService.grant( user, group, role );
-
+
+ TurbineAccessControlList tacl = turbineSecurityService.<TurbineAccessControlList>getACL( user );
+
+ for (Group aclgroup : tacl.getAllGroups())
+ {
+ log.info( "acl group class:" + aclgroup.getClass() );
+ log.info( "acl group class:" + aclgroup );
+ }
+
+ for (TurbineUserGroupRole userGroupRoleSet : user.getUserGroupRoleSet())
+ {
+ log.info( "First Group class:" + userGroupRoleSet.getGroup().getClass() );
+ log.info( "First UserGroupRoleSet:" + userGroupRoleSet );
+ }
+ assertTrue(tacl.hasRole( role, group ) );
+
// existing role
- Group existingGroup = turbineSecurityService.getGroupByName( "global" );
- Role existingRole = turbineSecurityService.getRoleByName( "turbineuser" );
- turbineSecurityService.grant( user, existingGroup, existingRole );
- assertTrue( user.getUserGroupRoleSet().size() == 2 );
+ // special global group
+ Group globalGroup = turbineSecurityService.getGlobalGroup();
+ Role turbineuserRole = turbineSecurityService.getRoleByName( "turbineuser" );
+ turbineSecurityService.grant( user, globalGroup, turbineuserRole );
+ assertEquals(2, user.getUserGroupRoleSet().size());
+ turbineSecurityService.saveUser( user );
+
// get fresh db user
user = turbineSecurityService.getUser( "Clint" );
- existingGroup = turbineSecurityService.getGroupByName( "turbine" );
- existingRole = turbineSecurityService.getRoleByName( "turbineadmin" );
+ for (TurbineUserGroupRole userGroupRoleSet : user.getUserGroupRoleSet())
+ {
+ log.info( "Second (with turbineuser Group class:" + userGroupRoleSet.getGroup().getClass() );
+ log.info( "UserGroupRoleSet:" + userGroupRoleSet );
+ }
+
+ Group existingGroup = turbineSecurityService.getGroupByName( "turbine" );
+ Role existingRole = turbineSecurityService.getRoleByName( "turbineadmin" );
turbineSecurityService.grant( user, existingGroup, existingRole );
- assertTrue( user.getUserGroupRoleSet().size() == 3 );
+
+ for (TurbineUserGroupRole userGroupRoleSet : user.getUserGroupRoleSet())
+ {
+ log.info( "Third with turbineadmin Group class:" + userGroupRoleSet.getGroup().getClass() );
+ log.info( "UserGroupRoleSet:" + userGroupRoleSet );
+ }
+ assertEquals(3, user.getUserGroupRoleSet().size());
- TurbineAccessControlList tacl = turbineSecurityService.<TurbineAccessControlList>getACL( user );
+ user = turbineSecurityService.getUser( "Clint" );
+ tacl = turbineSecurityService.<TurbineAccessControlList>getACL( user );
- assertTrue(tacl.hasRole( existingRole, existingGroup ) );
- assertTrue(tacl.hasRole( "turbineuser" ));
+ GroupSet aclgroupset = tacl.getGroupSet();
+ for (Group aclgroup : aclgroupset )
+ {
+ log.info( "last acl group class:" + aclgroup.getClass() );
+ log.info( "acl group class:" + aclgroup );
+ RoleSet roles = tacl.getRoles( aclgroup );
+ if (roles == null) {
+ log.info( "No roles for group " + aclgroup );
+ } else {
+ for (Role aclrole : roles ) {
+ log.info( "last acl aclrole class:" + aclrole.getClass() );
+ log.info( "acl aclrole class:" + aclrole );
+ }
+ }
+ }
+
+ assertTrue(tacl.hasRole( role, group ),
+ "acl has not role " + role + ", group: " + group );
+ assertTrue(tacl.hasRole( existingRole, existingGroup ),
+ "acl has not role " + existingRole + ", group: " + existingGroup );
+
+ log.info( "tacl.hasRole( \"turbineuser\" ):" + tacl.hasRole( "turbineuser" ) );
+ //assertTrue(tacl.hasRole( "turbineuser" ), "acl " + tacl + " of user " + user + " has not expected role turbineuser: " + tacl.getRoles() + " in default group global");
+ //assertTrue(tacl.hasRole( "turbineuser" ), "acl " + tacl + " of user " + user + " has not expected role turbineuser: " + tacl.getRoles());
turbineSecurityService.revoke( user, existingGroup, existingRole );
//user = turbineSecurityService.getUser( "Clint" );
assertTrue( user.getUserGroupRoleSet().size() == 2 );
userGroupRoleCheck( group, role, user.getUserDelegate() );
+
+ tacl = turbineSecurityService.getACL( user );
+ // revoked
+ assertFalse(tacl.hasRole( existingRole, existingGroup ) );
+
+
+ } catch (EntityExistsException e) {
+ // cft. finally
+ fail(e);
+ } catch (Exception e) {
+ log.error( "error" , e);
+ fail(e);
+ }
+ finally
+ {
+ if ( user != null )
+ deleteUser( user );
+ // not needed as user remove revokes all :
+ // if (group != null && role != null && user != null) turbineSecurityService.revoke(user, group, role);
+ if ( group != null )
+ deleteGroup( group );
+ if ( role != null )
+ deleteRole( role );
+ }
+ }
+
+ /**
+ * Test Fulcrum Turbine Security Manager User / Group / Role
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGrantUserGroupRoleAlternative()
+ {
+ Group group = null;
+ Role role = null;
+ TurbineUser fulcrumUser = null;
+ try
+ {
+ role = addNewTestRole(fulcrumSecurityService.getRoleManager());
+ group = addNewTestGroup(fulcrumSecurityService.getGroupManager());
+
// compare
// Fulcrum security service returns a raw
// org.apache.fulcrum.security.model.turbine.entity.impl.TurbineUserImpl,
org.apache.fulcrum.security.UserManager userManager = fulcrumSecurityService.getUserManager();
fulcrumUser = userManager.getUserInstance( "Clint2" );
+ // clean up
+ if (userManager.checkExists( fulcrumUser )) {
+ ( (TurbineModelManager) fulcrumSecurityService.getModelManager() ).revokeAll( fulcrumUser );
+ }
// required not null constraint
( (ExtendedUser) fulcrumUser ).setFirstName( fulcrumUser.getName() );
( (ExtendedUser) fulcrumUser ).setLastName( fulcrumUser.getName() );
@@ -232,27 +341,38 @@ public class TurbineSecurityServiceTest
( (TurbineModelManager) fulcrumSecurityService.getModelManager() ).grant( fulcrumUser, group, role );
userGroupRoleCheck( group, role, fulcrumUser );
- tacl = turbineSecurityService.getACL( user );
- // revoked
+ TurbineAccessControlList tacl = fulcrumSecurityService.getUserManager().getACL( fulcrumUser );
+
+ Group existingGroup = fulcrumSecurityService.getGroupManager().getGroupByName( "turbine" );
+ Role existingRole = fulcrumSecurityService.getRoleManager().getRoleByName( "turbineadmin" );
+
assertFalse(tacl.hasRole( existingRole, existingGroup ) );
-;
+ fulcrumSecurityService.<TurbineModelManager> getModelManager().grant( fulcrumUser, existingGroup, existingRole );
+
+ tacl = fulcrumSecurityService.getUserManager().getACL( fulcrumUser );
+ assertTrue(tacl.hasRole( existingRole, existingGroup ) );
+
+ Role turbineuserRole = fulcrumSecurityService.getRoleManager().getRoleByName( "turbineuser" );
+ Group globalGroup = fulcrumSecurityService.<TurbineModelManager> getModelManager().getGlobalGroup();
+ fulcrumSecurityService.<TurbineModelManager> getModelManager().grant( fulcrumUser, globalGroup, turbineuserRole );
+
+ tacl = fulcrumSecurityService.getUserManager().getACL( fulcrumUser );
+ assertTrue(tacl.hasRole( turbineuserRole, globalGroup ) );
+ // global role
+ assertTrue(tacl.hasRole( turbineuserRole ) );
} catch (EntityExistsException e) {
// cft. finally
- fail();
+ fail(e);
} catch (Exception e) {
log.error( "error" , e);
- fail();
+ fail(e);
}
finally
{
if ( fulcrumUser != null )
deleteUser( new DefaultUserImpl( fulcrumUser ) );
- if ( user != null )
- deleteUser( user );
- // not needed as user remove revokes all :
- // if (group != null && role != null && user != null) turbineSecurityService.revoke(user, group, role);
if ( group != null )
deleteGroup( group );
if ( role != null )
@@ -264,7 +384,87 @@ public class TurbineSecurityServiceTest
{
}
+
+ /**
+ *
+ * @param securityService
+ * @return
+ * @throws UnknownEntityException
+ * @throws DataBackendException
+ * @throws EntityExistsException
+ */
+ private Group addNewTestGroup(SecurityService securityService) throws UnknownEntityException, DataBackendException, EntityExistsException
+ {
+ Group group = null;
+ group = securityService.getGroupInstance( TEST_GROUP );
+
+ GroupSet groups = securityService.getAllGroups();
+ for (Group delGroup : groups)
+ {
+ if (delGroup.getName().toLowerCase().contains( "test" )) {
+ log.warn( "deleting all group: "+ delGroup );
+ securityService.removeGroup( delGroup );
+ }
+ }
+ // assign here to delete later as
+ group = securityService.addGroup( group );
+ return group;
+ }
+ private Role addNewTestRole(SecurityService securityService) throws DataBackendException, UnknownEntityException, EntityExistsException
+ {
+ Role role = null;
+ RoleSet roles = securityService.getAllRoles();
+ for (Role delRole : roles)
+ {
+ if (delRole.getName().toLowerCase().contains( "test" )) {
+ log.warn( "deleting all user,groups for role: "+ delRole );
+ securityService.revokeAll( delRole, true );
+ securityService.removeRole( delRole );
+ }
+ }
+ role = securityService.getRoleInstance( TEST_ROLE );
+ // assign here to delete later as
+ role = securityService.addRole( role );
+ return role;
+ }
+
+
+ private Group addNewTestGroup(GroupManager groupManager) throws UnknownEntityException, DataBackendException, EntityExistsException
+ {
+ Group group = null;
+ group = groupManager.getGroupInstance( TEST_GROUP );
+
+ GroupSet groups = groupManager.getAllGroups();
+ for (Group delGroup : groups)
+ {
+ if (delGroup.getName().toLowerCase().contains( "test" )) {
+ log.warn( "deleting all group: "+ delGroup );
+ groupManager.removeGroup( delGroup );
+ }
+ }
+ // assign here to delete later as
+ group = groupManager.addGroup( group );
+ return group;
+ }
+
+ private Role addNewTestRole(RoleManager roleManager) throws DataBackendException, UnknownEntityException, EntityExistsException
+ {
+ Role role = null;
+ RoleSet roles = roleManager.getAllRoles();
+ for (Role delRole : roles)
+ {
+ if (delRole.getName().toLowerCase().contains( "test" )) {
+ log.warn( "deleting all user,groups for role could not be done with fulcrum security service! " );
+ roleManager.removeRole( delRole );
+ }
+ }
+ role = roleManager.getRoleInstance( TEST_ROLE );
+ // assign here to delete later as
+ role = roleManager.addRole( role );
+ return role;
+ }
+
/**
* Fulcrum contract check
@@ -290,7 +490,7 @@ public class TurbineSecurityServiceTest
break;
}
}
- assertTrue( ugrFound );
+ assertTrue( ugrFound, "Not found user" + user + " with role " + role + " in group " + group);
assertTrue( ugrTest.getGroup().equals( group ) );
assertTrue( ugrTest.getUser().equals( user ) );
}
[turbine-archetypes] 01/06: cherry picked fro mbranch docker5x
commit with junit 5 changes, merging docs/DOCKER-README.
Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
commit fcda132f6fca20eae40fa8ce4c23e3b68b9be5fd
Author: Georg Kallidis <gk...@apache.org>
AuthorDate: Thu Jul 22 16:54:57 2021 +0200
cherry picked fro mbranch docker5x commit with junit 5 changes, merging docs/DOCKER-README.
---
.../archetype-resources/docs/DOCKER-README.md | 92 ++++++++--------
src/main/resources/archetype-resources/pom.xml | 5 +-
.../src/main/docker-resources/docker-compose.yml | 2 +-
.../main/webapp/templates/app/layouts/Default.vm | 116 ++++++++++-----------
.../src/main/webapp/templates/app/screens/Index.vm | 91 ++++++++--------
.../AbstractFulcrumTorqueModelManagerTest.java | 18 ++--
.../FulcrumTorqueDefaultModelManagerTest.java | 13 +--
.../security/TurbineSecurityServiceTest.java | 23 ++--
8 files changed, 182 insertions(+), 178 deletions(-)
diff --git a/src/main/resources/archetype-resources/docs/DOCKER-README.md b/src/main/resources/archetype-resources/docs/DOCKER-README.md
index 4e121a8..8c67a37 100644
--- a/src/main/resources/archetype-resources/docs/DOCKER-README.md
+++ b/src/main/resources/archetype-resources/docs/DOCKER-README.md
@@ -44,24 +44,63 @@ First time building might take a couple of minutes.
N.B. You may use the command *docker compose* or *docker-compose*, but will slightly different results.
-- Check database service call in ** target/<projectname>/WEB-INF/jetty-env.xml**. It should reference the service name (db), not localhost - as it is also set in maven docker profile.
+
+- Double check database service call in ** target/<projectname>/WEB-INF/jetty-env.xml**. It should reference the service name (db), not localhost - this was set when using the maven docker profile.
```xml
<Set name="url">jdbc:mysql://db:3306/turbine</Set>
```
-- To change velocity templates check webapp in ** src/main/webapp**. Ohter resources might depend on https://www.eclipse.org/jetty/documentation/jetty-9/index.html#jars-scanned-for-annotations.
+### Build Services
+
+The app service uses later a volume, which maps to the local maven repository, which you may need/not need.
+The db service uses mysql-latest (currently 8.x), you may replace it with a fixed release tag.
+
+If previously build, you may want to delete all volumes (this will delete all tables in /var/lib/mysql) and containers
+
+ docker-compose down -v
+
+- Build it
+
+ docker-compose build --no-cache
+
+ .. optionally build it separately
+ docker-compose build --no-cache --build-arg DB_CONTEXT=./docker-resources/db db
+
+ .. building app service first/only requires removing the dependency in docker-compose.yml(comment depends_on: db)
+ docker-compose build --no-cache app
+
+DB_CONTEXT is set to allow starting the db container standalone (in folder db, e.g. with docker build --tag my-db .)
+to test it. CAVEAT: The db service is build and populated until now with hard coded data.
+It is a dependency for the service app (see app/Dockerfile).
+
+
+### Starting Services
+
+Start both services in one step
+
+ docker-compose up
+
+.. or doing it in background, requires second start command
+
+ docker-compose -d up
+ docker-compose start
+
+This will start first the db service, then the app service. Jetty is run exposing the webapp to **http://localhost:8081/app**.
+By default remote debugging is activated (port 9000), which could be removed/commented in docker-compose.yml.
+You could follow the logs with docker-compose logs -f app or docker-compose logs -f db.
+
+
+- To change velocity templates check webapp in ** src/main/webapp** and run in another window *mvn package*. Jetty should restart automatically. Other resources might depend on https://www.eclipse.org/jetty/documentation/jetty-9/index.html#jars-scanned-for-annotations.
-## Start, cleanup or restart
+### Cleanup or restart (optional)
-- Optionally check system or cleanup, e.g. with docker-compose down, docker-compose down -v or docker sytem prune (removes any container on system).
+- Optionally Check system or cleanup, e.g. with docker-compose down, docker-compose down -v or docker sytem prune (removes any container on system).
- If services are already installed, activate/start by
docker-compose up
-You might do it separately for the db and the app service. The latter will start a maven build process finally starting the jetty server. Maven depends on the Maven settings, which are set in docker-resources/app/settings.xml. The local maven repository is mapped in the docker-compose.yml final to the host's local repository settings.localRepository during the first build, which reads the host's environment. Be sure to check this, if compilation errors occur as the host's maven executabl [...]
-
Example Logs:
[Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.25-1debian10 started.
@@ -90,52 +129,13 @@ You might do it separately for the db and the app service. The latter will start
[INFO] --- torque-maven-plugin:5.1-SNAPSHOT:generate (torque-om) @ integrationtest ---
[main] INFO | org.apache.torque.generator.control.Controller - readConfiguration() : Starting to read configuration files
-- Starting the app service will build the app and start jetty with Maven on port 8081 by default.
+- Starting the app service will build the app and start jetty with Maven on port 8081.
This command is set as a **command** in the app service in docker compose.
Currently the docker-compose is generated once more, if starting the containers, this will overwrite m2repo and may result in errors.
If not yet done, build on the host with mvn clean install -f ../pom.xml -Pdocker.
-### Build Services
-
-The app service uses later a volume, which maps to the local maven repository, which you may need/not need.
-The db service uses mysql-latest (currently 8.x), you may replace it with a fixed release tag.
-
-If previously build, you may want to delete all volumes (this will delete all tables in /var/lib/mysql) and containers
-
- docker-compose down -v
-
-- Build it
-
- docker-compose build --no-cache
-
- .. optionally build it separately
- docker-compose build --no-cache --build-arg DB_CONTEXT=./docker-resources/db db
-
- .. building app service first/only requires removing the dependency in docker-compose.yml(comment depends_on: db)
- docker-compose build --no-cache app
-
-DB_CONTEXT is set to allow starting the db container standalone (in folder db, e.g. with docker build --tag my-db .)
-to test it. CAVEAT: The db service is build and populated until now with hard coded data.
-It is a dependency for the service app (see app/Dockerfile).
-
-
-### Starting Services
-
-Start both services in one step
-
- docker-compose up
-
-.. or doing it in background, requires second start command
-
- docker-compose -d up
- docker-compose start
-
-This will start first the db service, then the app service. Jetty is run exposing the webapp to **http://localhost:8081/app**.
-By default remote debugging is activated (port 9000), which could be removed/commented in docker-compose.yml.
-You could follow the logs with docker-compose logs -f app or docker-compose logs -f db.
-
#### Lifecycle (developers only)
- If you generate the archetype itself, you might have to stop the services before cleaning up (docker-compose stop).
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index 0e2d8d5..5fc4b71 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -101,7 +101,7 @@ under the License.
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.0</version>
+ <version>3.8.1</version>
<configuration>
<source>#var("maven.compile.source")</source>
<target>#var("maven.compile.target")</target>
@@ -437,7 +437,8 @@ under the License.
</webApp>
</configuration>
</plugin>
- <!-- aswe call this profile in docker-resources/docker-compose.yml for app, which will replace /m2repo,
+ <!-- we call this profile in docker-resources/docker-compose.yml for app,
+ which should not replace /m2repo,
we want to avoid a second parsing from inside the container -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml b/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml
index 026a5de..868ad52 100644
--- a/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml
+++ b/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml
@@ -12,7 +12,7 @@ services:
- MAVEN_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9000
# this runs the app server in the container, be sure not to filter resources once again!
- command: mvn -Pjetty
+ command: mvn -Pjetty,docker
ports:
- "8081:8081"
# remote debugging port, uncomment if not needed
diff --git a/src/main/resources/archetype-resources/src/main/webapp/templates/app/layouts/Default.vm b/src/main/resources/archetype-resources/src/main/webapp/templates/app/layouts/Default.vm
index 798ecba..7a5befc 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/templates/app/layouts/Default.vm
+++ b/src/main/resources/archetype-resources/src/main/webapp/templates/app/layouts/Default.vm
@@ -1,58 +1,58 @@
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements. See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership. The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied. See the License for the
-## specific language governing permissions and limitations
-## under the License.
-
-$page.addStyleSheet("http://www.w3schools.com/lib/w3.css")
-$page.addStyleSheet("http://www.w3schools.com/lib/w3-theme-blue-grey.css")
-$page.setTitle("Sample Apache Turbine Application")
-$page.addScript($ui.getScript("page.js"))
-<html>
-
-#TurbineHtmlHead()
-
-<link href="$ui.getStylecss()" rel="stylesheet" type="text/css" />
-
-<body #TurbineHtmlBodyAttributes() class="w3-theme-l4">
-
- <div class="w3-wrapper">
-
- <!-- Header -->
- <header class="w3-container w3-center w3-padding-32 w3-theme">
- <img class="w3-right" src="$ui.image('turbine4-project.png')" />
- #if ( $data.getUser().hasLoggedIn() )
- #set ( $u = $data.getUser() )
- <div class="w3-right">
- <h5>Hello $!u.FirstName</h5>
- </div>
- #end
- </header>
-
- <!-- Default Menu -->
- $navigation.setTemplate("/Menu.vm")
-
- <!-- Content -->
- <div class="w3-left w3-padding" id="content">
- $screen_placeholder
- </div>
-
- <!-- Footer -->
- <footer class="w3-bottom">
- <p>Powered by <img src="$ui.image('pb-turbine100px.png')"/></p>
- </footer>
- </div>
-
-</body>
-</html>
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+
+$page.addStyleSheet("http://www.w3schools.com/lib/w3.css")
+$page.addStyleSheet("http://www.w3schools.com/lib/w3-theme-blue-grey.css")
+$page.setTitle("Sample Apache Turbine Application")
+$page.addScript($ui.getScript("page.js"))
+<html>
+
+#TurbineHtmlHead()
+
+<link href="$ui.getStylecss()" rel="stylesheet" type="text/css" />
+
+<body #TurbineHtmlBodyAttributes() class="w3-theme-l4">
+
+ <div class="w3-wrapper">
+
+ <!-- Header -->
+ <header class="w3-container w3-center w3-padding-32 w3-theme">
+ <img class="w3-right" src="$ui.image('turbine4-project.png')" />
+ #if ( $data.getUser().hasLoggedIn() )
+ #set ( $u = $data.getUser() )
+ <div class="w3-right">
+ <h5>Hello $!u.FirstName</h5>
+ </div>
+ #end
+ </header>
+
+ <!-- Default Menu -->
+ $navigation.setTemplate("/Menu.vm")
+
+ <!-- Content -->
+ <div class="w3-left w3-padding" id="content">
+ $screen_placeholder
+ </div>
+
+ <!-- Footer -->
+ <footer class="w3-bottom">
+ <p>Powered by <img src="$ui.image('pb-turbine100px.png')"/></p>
+ </footer>
+ </div>
+
+</body>
+</html>
diff --git a/src/main/resources/archetype-resources/src/main/webapp/templates/app/screens/Index.vm b/src/main/resources/archetype-resources/src/main/webapp/templates/app/screens/Index.vm
index 578e66f..04926f4 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/templates/app/screens/Index.vm
+++ b/src/main/resources/archetype-resources/src/main/webapp/templates/app/screens/Index.vm
@@ -1,45 +1,46 @@
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements. See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership. The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied. See the License for the
-## specific language governing permissions and limitations
-## under the License.
-
-
-
-#if ( $data.getMessage() )
- #info( $data.getMessage() )
-#end
-
-#if ($!success) <div align="center"><h1>$success</h1></div>
- <p>
- You're now successfully running a <a href="http://turbine.apache.org/">Turbine</a> based
- application, deployed to <font color="red">$data.ServerData.ContextPath</a></font> on
- your web container.
- </p>
-
- <p>
- You can (and should!) change or remove this page at any time. It is
- intended to give you immediate feedback if you just deployed an newly
- setup Turbine application.
- </p>
-#end
-
- ## including a secured does not trigger the security check, as it is just handled by velocity, not turbine
- #parse("/screens/TestSecure.vm")
-
- ## trigger the security check, but without all context
- ## <a href="$link.setPage("TestSecure.vm")">Test a secure access without context</a>
- ## trigger the security check
- <a href="$link.setPage("TestSecure.vm").addPathInfo("action","SecureAction")">Test a secure access with context</a>
-
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+
+
+
+#if ( $data.getMessage() )
+ #info( $data.getMessage() )
+#end
+
+#if ($!success) <div align="center"><h1>$success</h1></div>
+ <p>
+ You're now successfully running a <a href="http://turbine.apache.org/">Turbine</a> based
+ application, deployed to <font color="red">$data.ServerData.ContextPath</a></font> on
+ your web container.
+ </p>
+
+ <p>
+ You can (and should!) change or remove this page at any time. It is
+ intended to give you immediate feedback if you just deployed an newly
+ setup Turbine application.
+ </p>
+
+#end
+
+ ## including a secured does not trigger the security check, as it is just handled by velocity, not turbine
+ #parse("/screens/TestSecure.vm")
+
+ ## trigger the security check, but without all context
+ ## <a href="$link.setPage("TestSecure.vm")">Test a secure access without context</a>
+ ## trigger the security check
+ <a href="$link.setPage("TestSecure.vm").addPathInfo("action","SecureAction")">Test a secure access with context</a>
+
diff --git a/src/main/resources/archetype-resources/src/test/java/services/security/AbstractFulcrumTorqueModelManagerTest.java b/src/main/resources/archetype-resources/src/test/java/services/security/AbstractFulcrumTorqueModelManagerTest.java
index 2ffc5de..e31ffe9 100644
--- a/src/main/resources/archetype-resources/src/test/java/services/security/AbstractFulcrumTorqueModelManagerTest.java
+++ b/src/main/resources/archetype-resources/src/test/java/services/security/AbstractFulcrumTorqueModelManagerTest.java
@@ -18,7 +18,7 @@ package ${package}.services.security;
* specific language governing permissions and limitations
* under the License.
*/
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.Set;
@@ -41,11 +41,13 @@ import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.EntityExistsException;
import org.apache.fulcrum.security.util.PermissionSet;
import org.apache.fulcrum.security.util.UnknownEntityException;
-import org.apache.fulcrum.testcontainer.BaseUnit4Test;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
import org.apache.torque.ConstraintViolationException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +58,7 @@ import org.slf4j.LoggerFactory;
* @version $Id$
*
*/
-public abstract class AbstractFulcrumTorqueModelManagerTest extends BaseUnit4Test
+public abstract class AbstractFulcrumTorqueModelManagerTest extends BaseUnit5Test
{
protected Role role;
@@ -77,7 +79,7 @@ public abstract class AbstractFulcrumTorqueModelManagerTest extends BaseUnit4Tes
// By default org.slf4j.LoggerFactory is optional in 4.0, but included in webapp
Logger log = LoggerFactory.getLogger( getClass().getName() );
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
securityService = (SecurityService) lookup(SecurityService.ROLE);
@@ -89,7 +91,7 @@ public abstract class AbstractFulcrumTorqueModelManagerTest extends BaseUnit4Tes
}
@Override
- @After
+ @AfterEach
public void tearDown()
{
modelManager = null;
diff --git a/src/main/resources/archetype-resources/src/test/java/services/security/FulcrumTorqueDefaultModelManagerTest.java b/src/main/resources/archetype-resources/src/test/java/services/security/FulcrumTorqueDefaultModelManagerTest.java
index 67f5781..c57a51d 100644
--- a/src/main/resources/archetype-resources/src/test/java/services/security/FulcrumTorqueDefaultModelManagerTest.java
+++ b/src/main/resources/archetype-resources/src/test/java/services/security/FulcrumTorqueDefaultModelManagerTest.java
@@ -18,12 +18,13 @@ package ${package}.services.security;
* under the License.
*/
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Ignore;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
* Test Fulcrum Integration.
@@ -38,7 +39,7 @@ public class FulcrumTorqueDefaultModelManagerTest
{
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
try
diff --git a/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java b/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java
index aa38651..7a48dae 100644
--- a/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java
+++ b/src/main/resources/archetype-resources/src/test/java/services/security/TurbineSecurityServiceTest.java
@@ -18,9 +18,7 @@ package ${package}.services.security;
* specific language governing permissions and limitations
* under the License.
*/
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import org.apache.fulcrum.security.ModelManager;
import org.apache.fulcrum.security.entity.ExtendedUser;
@@ -34,7 +32,7 @@ import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.EntityExistsException;
import org.apache.fulcrum.security.util.UnknownEntityException;
-import org.apache.fulcrum.testcontainer.BaseUnit4Test;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
import org.apache.torque.ConstraintViolationException;
import org.apache.turbine.annotation.AnnotationProcessor;
import org.apache.turbine.annotation.TurbineService;
@@ -44,10 +42,11 @@ import org.apache.turbine.services.ServiceManager;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.security.SecurityService;
import org.apache.turbine.util.TurbineConfig;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +59,7 @@ import org.slf4j.LoggerFactory;
*/
public class TurbineSecurityServiceTest
- extends BaseUnit4Test
+ extends BaseUnit5Test
{
org.apache.fulcrum.security.SecurityService fulcrumSecurityService;
@@ -77,7 +76,7 @@ public class TurbineSecurityServiceTest
// By default org.slf4j.LoggerFactory is optional in 4.0, but included in webapp
Logger log = LoggerFactory.getLogger( getClass().getName() );
- @BeforeClass
+ @BeforeAll
public static void init()
throws Exception
{
@@ -85,7 +84,7 @@ public class TurbineSecurityServiceTest
tc.initialize();
}
- @Before
+ @BeforeEach
public void setUpBefore()
throws Exception
{
@@ -296,7 +295,7 @@ public class TurbineSecurityServiceTest
assertTrue( ugrTest.getUser().equals( user ) );
}
- @AfterClass
+ @AfterAll
public static void setupAfter()
{
ServiceManager serviceManager = TurbineServices.getInstance();
[turbine-archetypes] 03/06: update docs
Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
commit a039857d9926c768d1076cba2a9a1dcfd1212fb5
Author: gemkall <ge...@fu-berlin.de>
AuthorDate: Tue Aug 3 16:48:45 2021 +0200
update docs
---
.../archetype-resources/docs/DOCKER-README.md | 60 +++++++++++++++++++---
.../resources/archetype-resources/docs/README.md | 6 +--
2 files changed, 55 insertions(+), 11 deletions(-)
diff --git a/src/main/resources/archetype-resources/docs/DOCKER-README.md b/src/main/resources/archetype-resources/docs/DOCKER-README.md
index 8c67a37..dba2129 100644
--- a/src/main/resources/archetype-resources/docs/DOCKER-README.md
+++ b/src/main/resources/archetype-resources/docs/DOCKER-README.md
@@ -143,9 +143,10 @@ If not yet done, build on the host with mvn clean install -f ../pom.xml -Pdocker
## Debugging Services: Db, App
### Db Service
-```
-docker-compose run --rm db /bin/sh
-```
+
+
+ docker-compose run --rm db /bin/sh
+
Extract data in db service
mysql -u root -h db -P 3306 -p
@@ -157,19 +158,59 @@ Extract data in db service
### App Service
-This will start app and db (as it depends on app):
+This will start app (and db as app depends on db):
docker-compose run --rm app /bin/sh
In the container, check:
ls -la /myapp // should list pom.xml ...
+
+## Tests
+
+The security test is skipped by default as it requires a running mysql. It tests many of the Fulcrum Torque Turbine security aspects,
+you may activate it by calling in the root of the container in the shell (e.g. with docker-compose run --rm app /bin/sh):
+
+ mvn test -DskipTests=false
+
+- You may reset MAVEN_OPTS, which is by default set in settings.xml
+
+ export MAVEN_OPTS=
+
+
+### Prerequisites
+
+- a running docker service db
+
+- proper settings of Db connection URL. Check/update
+ <project-path>/src/test/conf/torque/TorqueTest.properties
+
+ If you have not initialized docker, when creating the archetype instance,
+ you may have to edit TorqueTest.properties and adapt the url from localhost to db.
+
+ That is, if running tests inside container, set in TorqueTest.properties should be:
+
+ torque.dsfactory.turbine.connection.url =
+ jdbc:mysql://db:3306/turbine?serverTimeZone=UTC
+
+ On the other side, if running the tests outside the container
+ the setting should be :
+
+ torque.dsfactory.turbine.connection.url =
+ jdbc:mysql://localhost:13306/turbine?serverTimeZone=UTC
+
+ This depends of course on the db ports settings in docker-compose.yml.
+
# System Specific Informations
## Windows
+- Start Docker Desktop, you might not get an error immediately if not, but only when shared volumes are created (like
+
+ Error response from daemon: error while creating mount source path '/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/..': mkdir /run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/.. file exists
+
### Powershell
- You may have to replace in volume mapping for host repo path (maven localRepository) backslashes with slashes "/" in docker-compose.yml.
@@ -179,9 +220,10 @@ In the container, check:
- If a image download fails, try Docker->Network->Update DNS to 8.8.8.8
- ERROR, when starting docker-compose up/start:
- "for db Cannot start service db: driver failed programming external connectivity on endpoint docker-resources_db_1 or
-ERROR: for docker-resources_db_1 Cannot start service db: driver failed programming external connectivity on endpoint docker-resources_db_1 ...
-Error starting userland proxy: mkdir /port/tcp:0.0.0.0:13306:tcp:...:3306: input/output error"
+
+ for db Cannot start service db: driver failed programming external connectivity on endpoint docker-resources_db_1 or
+ ERROR: for docker-resources_db_1 Cannot start service db: driver failed programming external connectivity on endpoint docker-resources_db_1 ...
+ Error starting userland proxy: mkdir /port/tcp:0.0.0.0:13306:tcp:...:3306: input/output error"
- Check if containers not already running.
- Remove containers (if any): docker rm $(docker ps -a -q)
@@ -191,7 +233,9 @@ Error starting userland proxy: mkdir /port/tcp:0.0.0.0:13306:tcp:...:3306: input
- Check file permissions of archetype generated files (chmod -R a+rw docker-resources, chmod -R a+rw src .
-- https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
+- If you generated the project with windows shell, but run the docker form wsl you have to regenerate docker-compose.yml with unix pathes running this command again
+
+ mvn install -Pdocker
### More Internals, Helpful Docker commands
diff --git a/src/main/resources/archetype-resources/docs/README.md b/src/main/resources/archetype-resources/docs/README.md
index d215d6e..c982b92 100644
--- a/src/main/resources/archetype-resources/docs/README.md
+++ b/src/main/resources/archetype-resources/docs/README.md
@@ -75,7 +75,7 @@ N.B. Set docker variable to true to enable Docker setup in building the artifact
-Ddocker=true
-to immediately enable docker setup, when generating the archetype.
+to immediately enable docker setup, when generating the archetype. If
Currently only port 3306 is supported, if you do not want ot change the port seetings for the db container in docker-compose.yml
@@ -161,7 +161,7 @@ action.login=LoginUser in TurbineResources.properties and changing Login.vm appr
Prerequisites
- ignored tests require at least Turbine version 4.0.1
- database was build successfully e.g. with archetype.
-- running mysql
+- running mysql or docker service db
If running from integration test, check/update
- in pom.xml turbine.core property,
@@ -175,7 +175,7 @@ mvn test -DskipTests=false
```
CAVEAT: If initialization fails, double check your database credentials! If invalid the error might be somewhat hidden behind a
- Torque exception!
+ Torque exception! Docker: If you have not initialized docker when creating the archetype instance, you have to edit TorqueTest.properties and adapt the url from localhost to db. You may then run the tests from inside the container service app.
## IDE Integration, Eclipse
[turbine-archetypes] 06/06: formatting, update namespace
Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
commit b5688e5f3dc98bfcb39ae31ebc8e5dc2eba20e1b
Author: gemkall <ge...@fu-berlin.de>
AuthorDate: Tue Aug 3 16:52:36 2021 +0200
formatting, update namespace
---
src/main/resources/META-INF/maven/archetype-metadata.xml | 10 +++++-----
.../src/main/docker-resources/docker-compose.yml | 8 ++++----
.../src/main/webapp/WEB-INF/conf/componentConfiguration.xml | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml
index 749675b..0158c60 100644
--- a/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -21,7 +21,7 @@
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
- name="turbine-5.0-webapp">
+ name="turbine-5.1-webapp">
<requiredProperties>
<requiredProperty key="turbine_app_name">
@@ -54,12 +54,12 @@
<requiredProperty key="turbine_database_password">
<defaultValue>db_password</defaultValue>
</requiredProperty>
- <requiredProperty key="app_volume_local_repo">
+ <requiredProperty key="app_volume_local_repo">
<defaultValue>${settings.localRepository}</defaultValue>
- </requiredProperty>
- <requiredProperty key="docker">
+ </requiredProperty>
+ <requiredProperty key="docker">
<defaultValue>${docker}</defaultValue>
- </requiredProperty>
+ </requiredProperty>
</requiredProperties>
<fileSets>
<fileSet filtered="true" packaged="true">
diff --git a/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml b/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml
index 868ad52..f438d83 100644
--- a/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml
+++ b/src/main/resources/archetype-resources/src/main/docker-resources/docker-compose.yml
@@ -9,10 +9,10 @@ services:
dockerfile: ./docker-resources/app/Dockerfile
# uncomment, if no remote debugging app is required
environment:
- - MAVEN_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9000
+ - MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=y
# this runs the app server in the container, be sure not to filter resources once again!
- command: mvn -Pjetty,docker
+ command: mvn -Pjetty
ports:
- "8081:8081"
# remote debugging port, uncomment if not needed
@@ -26,9 +26,9 @@ services:
# - "3000"
volumes:
- # project root wtih pom.xml and src folder
+ # project root with pom.xml and src folder
- ../../:/myapp
- # or use local sapp/ettings.xml
+ # or use local app/settings.xml
- '#var("app_volume_local_repo"):/m2repo'
db:
diff --git a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
index 06d1032..31bbc44 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
+++ b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
@@ -129,10 +129,10 @@
- requires attribute peerClass in fulcrum-turbine-schema.xml table elements set to org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer
-->
- <userManager>
+ <userManager>
<className>${package}.om.TurbineUser</className>
<peerClassName>${package}.om.TurbineUserPeerImpl</peerClassName>
- <userGroupRoleManager><!-- using custom peers requires now since fulcrum security 1.1.2 this element -->
+ <userGroupRoleManager><!-- using custom peers requires now this element -->
<!-- className>org.apache.fulcrum.security.torque.om.TurbineUserGroupRole</className-->
<peerClassName>${package}.om.TurbineUserGroupRolePeerImpl</peerClassName>
</userGroupRoleManager>