CCM NG: Reverted changes from r4350: Interfaces and Annotations don't work together but we need the annotations...
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4351 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
1ebbe0e59d
commit
b674042e34
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.librecms;
|
|
||||||
|
|
||||||
import org.libreccm.security.Privilege;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public enum CmsPrivileges implements Privilege {
|
|
||||||
|
|
||||||
ADMINISTER_CATEGORIES,
|
|
||||||
ADMINISTER_CONTENT_TYPES,
|
|
||||||
ADMINISTER_LIFECYLES,
|
|
||||||
ADMINISTER_ROLES,
|
|
||||||
ADMINISTER_WORKFLOW,
|
|
||||||
ITEMS_APPROVE,
|
|
||||||
ITEMS_PUBLISH,
|
|
||||||
ITEMS_CATEGORIZE,
|
|
||||||
ITEMS_CREATE_NEW,
|
|
||||||
ITEMS_DELETE,
|
|
||||||
ITEMS_EDIT,
|
|
||||||
ITEMS_PREVIEW,
|
|
||||||
ITEMS_VIEW_PUBLISHED,
|
|
||||||
APPLY_ALTERNATE_WORKFLOW;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBundle() {
|
|
||||||
return CmsConstants.CMS_BUNDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrefix() {
|
|
||||||
return "privileges";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.libreccm.categorization;
|
|
||||||
|
|
||||||
import org.libreccm.security.Privilege;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public enum Privileges implements Privilege {
|
|
||||||
|
|
||||||
MANAGAE_CATEGORIES,
|
|
||||||
MANAGE_CATEGORY_OBJECTS,
|
|
||||||
MANAGE_DOMAINS;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBundle() {
|
|
||||||
return "org.libreccm.categorization.PrivilegesBundle";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrefix() {
|
|
||||||
return "categorization.privileges";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.libreccm.core;
|
|
||||||
|
|
||||||
import org.libreccm.security.Privilege;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public enum Privileges implements Privilege {
|
|
||||||
|
|
||||||
ADMIN,
|
|
||||||
SYSTEM;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBundle() {
|
|
||||||
return "org.libreccm.core.PrivilegesBundle";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrefix() {
|
|
||||||
return "core.privileges";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.libreccm.security;
|
|
||||||
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface to extend by privilege enums of the various modules.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public interface Privilege {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return to non localised key for the privilege. The default implementation
|
|
||||||
* uses the {@code toString} method.
|
|
||||||
*
|
|
||||||
* @return The non localised identifier of the privilege.
|
|
||||||
*/
|
|
||||||
default String getKey() {
|
|
||||||
return toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An optional prefix for the key to be used to retrieve the localised
|
|
||||||
* label. The default implementation returns an empty string.
|
|
||||||
*
|
|
||||||
* @return An optional prefix for the key.
|
|
||||||
*/
|
|
||||||
default String getPrefix() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the localised label for the role. Primarily for use in the user
|
|
||||||
* interface. The default implementation the return value
|
|
||||||
* {@link #getBundle()} to get the fully qualified name of the bundle to
|
|
||||||
* use. The key is generated by joining the return value from {@link #getPrefix()}
|
|
||||||
* (if not an empty string) and the return value from {@link #getKey()}.
|
|
||||||
* The separator between prefix and key is a dot.
|
|
||||||
*
|
|
||||||
* @return The localised label for the privilege.
|
|
||||||
*/
|
|
||||||
default GlobalizedMessage getLabel() {
|
|
||||||
final String prefix = getPrefix();
|
|
||||||
final String key;
|
|
||||||
if (prefix != null && !prefix.isEmpty()) {
|
|
||||||
key = String.join(".", getPrefix(), getKey());
|
|
||||||
} else {
|
|
||||||
key = getKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GlobalizedMessage(key, getBundle());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the bundle containing the localised labels for the privileges.
|
|
||||||
*
|
|
||||||
* @return The fully qualified name of the resource bundle which provides
|
|
||||||
* the localised labels for the privileges.
|
|
||||||
*/
|
|
||||||
String getBundle();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
categorization.privileges.MANAGE_CATEGORIES=Manage categories
|
|
||||||
categorization.privileges.MANAGE_CATEGORY_OBJECTS=Manage categorized objects
|
|
||||||
categorization.privileges.MANAGE_DOMAINS=Manage domains
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
categorization.privileges.MANAGE_CATEGORIES=Kategorien verwalten
|
|
||||||
categorization.privileges.MANAGE_CATEGORY_OBJECTS=Kategorisierte Objekte verwalten
|
|
||||||
categorization.privileges.MANAGE_DOMAINS=Domains verwalten
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
core.privileges.ADMIN=admin
|
|
||||||
core.privileges.SYSTEM=system
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
core.privileges.ADMIN=admin
|
|
||||||
core.privileges.SYSTEM=system
|
|
||||||
|
|
@ -47,14 +47,13 @@ import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.jpa.EntityManagerProducer;
|
import org.libreccm.jpa.EntityManagerProducer;
|
||||||
import org.libreccm.jpa.utils.UriConverter;
|
import org.libreccm.jpa.utils.UriConverter;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
import org.libreccm.web.ApplicationRepository;
|
import org.libreccm.web.ApplicationRepository;
|
||||||
import org.libreccm.workflow.Workflow;
|
import org.libreccm.workflow.Workflow;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.libreccm.security.Privilege;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
|
@ -90,7 +89,7 @@ public class SecurityConfigTest {
|
||||||
"LibreCCM-com.arsdigita.kernel.security.SecurityConfigTest.war")
|
"LibreCCM-com.arsdigita.kernel.security.SecurityConfigTest.war")
|
||||||
.addPackage(CcmObject.class.getPackage())
|
.addPackage(CcmObject.class.getPackage())
|
||||||
.addPackage(Categorization.class.getPackage())
|
.addPackage(Categorization.class.getPackage())
|
||||||
.addPackage(Privilege.class.getPackage())
|
.addPackage(PermissionChecker.class.getPackage())
|
||||||
.addPackage(LocalizedString.class.getPackage())
|
.addPackage(LocalizedString.class.getPackage())
|
||||||
.addPackage(Workflow.class.getPackage())
|
.addPackage(Workflow.class.getPackage())
|
||||||
.addPackage(UriConverter.class.getPackage())
|
.addPackage(UriConverter.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,8 @@ public class CategoryManagerTest {
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
||||||
.addPackage(org.libreccm.security.Privilege.class.getPackage())
|
.addPackage(org.libreccm.security.PermissionChecker.class
|
||||||
|
.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
|
|
@ -185,7 +186,7 @@ public class CategoryManagerTest {
|
||||||
assertThat(shiro.getSecurityManager(), is(not(nullValue())));
|
assertThat(shiro.getSecurityManager(), is(not(nullValue())));
|
||||||
assertThat(shiro.getSystemUser(), is(not(nullValue())));
|
assertThat(shiro.getSystemUser(), is(not(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/categorization/CategoryManagerTest/data.yml")
|
"datasets/org/libreccm/categorization/CategoryManagerTest/data.yml")
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import org.apache.shiro.authc.UsernamePasswordToken;
|
||||||
import org.apache.shiro.authz.UnauthorizedException;
|
import org.apache.shiro.authz.UnauthorizedException;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
|
@ -68,10 +67,10 @@ public class CategoryRepositoryTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DomainRepository domainRepo;
|
private DomainRepository domainRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Shiro shiro;
|
private Shiro shiro;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Subject subject;
|
private Subject subject;
|
||||||
|
|
||||||
|
|
@ -112,7 +111,8 @@ public class CategoryRepositoryTest {
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
||||||
.addPackage(org.libreccm.security.Privilege.class.getPackage())
|
.addPackage(org.libreccm.security.PermissionChecker.class
|
||||||
|
.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
|
|
@ -267,14 +267,14 @@ public class CategoryRepositoryTest {
|
||||||
"john.doe@example.org", "foo123");
|
"john.doe@example.org", "foo123");
|
||||||
token.setRememberMe(true);
|
token.setRememberMe(true);
|
||||||
subject.login(token);
|
subject.login(token);
|
||||||
|
|
||||||
final Category category = new Category();
|
final Category category = new Category();
|
||||||
category.setDisplayName("new-category");
|
category.setDisplayName("new-category");
|
||||||
category.setName("new-category");
|
category.setName("new-category");
|
||||||
category.setUniqueId("new0001");
|
category.setUniqueId("new0001");
|
||||||
|
|
||||||
categoryRepo.save(category);
|
categoryRepo.save(category);
|
||||||
|
|
||||||
subject.logout();
|
subject.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ public class ConfigurationManagerTest {
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.security.Privilege.class.getPackage())
|
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,8 @@ public class CcmObjectRepositoryTest {
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
||||||
.addPackage(org.libreccm.security.Privilege.class.getPackage())
|
.addPackage(org.libreccm.security.PermissionChecker.class
|
||||||
|
.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage())
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
|
||||||
Group.class,
|
Group.class,
|
||||||
GroupMembership.class,
|
GroupMembership.class,
|
||||||
Party.class,
|
Party.class,
|
||||||
Privilege.class,
|
|
||||||
OneTimeAuthToken.class,
|
OneTimeAuthToken.class,
|
||||||
Role.class,
|
Role.class,
|
||||||
RoleMembership.class,
|
RoleMembership.class,
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.libreccm.security;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public enum ExamplePrivileges implements Privilege {
|
|
||||||
|
|
||||||
ADMIN_EXAMPLES,
|
|
||||||
CREATE_EXAMPLES,
|
|
||||||
EDIT_EXAMPLES,
|
|
||||||
PREVIEW_EXAMPLES,
|
|
||||||
VIEW_EXAMPLES,
|
|
||||||
PUBLISH_EXAMPLES;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBundle() {
|
|
||||||
return "org.libreccm.security.ExamplePrivilegesBundle";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrefix() {
|
|
||||||
return "example.privileges";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,128 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.libreccm.security;
|
|
||||||
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.oro.text.GlobCompiler;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.libreccm.tests.categories.UnitTest;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A test for verifying that the default implementations of the methods of the
|
|
||||||
* {@link Privilege} interface work as expected.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@org.junit.experimental.categories.Category(UnitTest.class)
|
|
||||||
public class PrivilegeTest {
|
|
||||||
|
|
||||||
public PrivilegeTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void tearDownClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void verifyKeys() {
|
|
||||||
assertThat(ExamplePrivileges.ADMIN_EXAMPLES.getKey(),
|
|
||||||
is(equalTo("ADMIN_EXAMPLES")));
|
|
||||||
assertThat(ExamplePrivileges.CREATE_EXAMPLES.getKey(),
|
|
||||||
is(equalTo("CREATE_EXAMPLES")));
|
|
||||||
assertThat(ExamplePrivileges.EDIT_EXAMPLES.getKey(),
|
|
||||||
is(equalTo("EDIT_EXAMPLES")));
|
|
||||||
assertThat(ExamplePrivileges.PREVIEW_EXAMPLES.getKey(),
|
|
||||||
is(equalTo("PREVIEW_EXAMPLES")));
|
|
||||||
assertThat(ExamplePrivileges.PUBLISH_EXAMPLES.getKey(),
|
|
||||||
is(equalTo("PUBLISH_EXAMPLES")));
|
|
||||||
assertThat(ExamplePrivileges.VIEW_EXAMPLES.getKey(),
|
|
||||||
is(equalTo("VIEW_EXAMPLES")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void verifyLabels() {
|
|
||||||
final GlobalizedMessage adminLabel = ExamplePrivileges.ADMIN_EXAMPLES
|
|
||||||
.getLabel();
|
|
||||||
final GlobalizedMessage createLabel = ExamplePrivileges.CREATE_EXAMPLES
|
|
||||||
.getLabel();
|
|
||||||
final GlobalizedMessage editLabel = ExamplePrivileges.EDIT_EXAMPLES
|
|
||||||
.getLabel();
|
|
||||||
final GlobalizedMessage previewLabel
|
|
||||||
= ExamplePrivileges.PREVIEW_EXAMPLES
|
|
||||||
.getLabel();
|
|
||||||
final GlobalizedMessage publishLabel
|
|
||||||
= ExamplePrivileges.PUBLISH_EXAMPLES
|
|
||||||
.getLabel();
|
|
||||||
final GlobalizedMessage viewLabel = ExamplePrivileges.VIEW_EXAMPLES
|
|
||||||
.getLabel();
|
|
||||||
|
|
||||||
assertThat(adminLabel.localize(Locale.ENGLISH),
|
|
||||||
is(equalTo("Administer examples")));
|
|
||||||
assertThat(adminLabel.localize(Locale.GERMAN),
|
|
||||||
is(equalTo("Beispiele verwalten")));
|
|
||||||
|
|
||||||
assertThat(createLabel.localize(Locale.ENGLISH),
|
|
||||||
is(equalTo("Create new examples")));
|
|
||||||
assertThat(createLabel.localize(Locale.GERMAN),
|
|
||||||
is(equalTo("Neue Beispiele anlegen")));
|
|
||||||
|
|
||||||
assertThat(editLabel.localize(Locale.ENGLISH),
|
|
||||||
is(equalTo("Edit examples")));
|
|
||||||
assertThat(editLabel.localize(Locale.GERMAN),
|
|
||||||
is(equalTo("Beispiele bearbeiten")));
|
|
||||||
|
|
||||||
assertThat(previewLabel.localize(Locale.ENGLISH),
|
|
||||||
is(equalTo("Preview examples")));
|
|
||||||
assertThat(previewLabel.localize(Locale.GERMAN),
|
|
||||||
is(equalTo("Vorschau ansehen")));
|
|
||||||
|
|
||||||
assertThat(publishLabel.localize(Locale.ENGLISH),
|
|
||||||
is(equalTo("Publish examples")));
|
|
||||||
assertThat(publishLabel.localize(Locale.GERMAN),
|
|
||||||
is(equalTo("Beispiele veröffentlichen")));
|
|
||||||
|
|
||||||
assertThat(viewLabel.localize(Locale.ENGLISH),
|
|
||||||
is(equalTo("View examples")));
|
|
||||||
assertThat(viewLabel.localize(Locale.GERMAN),
|
|
||||||
is(equalTo("Beispiele ansehen")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class ToStringTest extends ToStringVerifier {
|
||||||
GroupMembership.class,
|
GroupMembership.class,
|
||||||
Party.class,
|
Party.class,
|
||||||
OneTimeAuthToken.class,
|
OneTimeAuthToken.class,
|
||||||
Privilege.class,
|
|
||||||
Role.class,
|
Role.class,
|
||||||
RoleMembership.class,
|
RoleMembership.class,
|
||||||
User.class
|
User.class
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
example.privileges.ADMIN_EXAMPLES=Administer examples
|
|
||||||
example.privileges.CREATE_EXAMPLES=Create new examples
|
|
||||||
example.privileges.EDIT_EXAMPLES=Edit examples
|
|
||||||
example.privileges.PREVIEW_EXAMPLES=Preview examples
|
|
||||||
example.privileges.VIEW_EXAMPLES=View examples
|
|
||||||
example.privileges.PUBLISH_EXAMPLES=Publish examples
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
example.privileges.ADMIN_EXAMPLES=Beispiele verwalten
|
|
||||||
example.privileges.CREATE_EXAMPLES=Neue Beispiele anlegen
|
|
||||||
example.privileges.EDIT_EXAMPLES=Beispiele bearbeiten
|
|
||||||
example.privileges.PREVIEW_EXAMPLES=Vorschau ansehen
|
|
||||||
example.privileges.VIEW_EXAMPLES=Beispiele ansehen
|
|
||||||
example.privileges.PUBLISH_EXAMPLES=Beispiele ver\u00f6ffentlichen
|
|
||||||
Loading…
Reference in New Issue