From 5d389d953da2bc50e78ac1c2fb3bf1e031e7810f Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Mon, 13 Jul 2009 23:11:15 +0000 Subject: [PATCH] RoleVoter test class. --- .../security/access/vote/RoleVoterTests.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java diff --git a/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java b/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java new file mode 100644 index 0000000000..e82e96af35 --- /dev/null +++ b/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java @@ -0,0 +1,26 @@ +package org.springframework.security.access.vote; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.springframework.security.access.AccessDecisionVoter; +import org.springframework.security.access.SecurityConfig; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; + +/** + * + * @author Luke Taylor + * @version $Id$ + */ +public class RoleVoterTests { + + // Vote on attribute list that has two attributes A and C (i.e. one matching) + @Test + public void oneMatchingAttributeGrantsAccess() { + RoleVoter voter = new RoleVoter(); + voter.setRolePrefix(""); + Authentication userAB = new TestingAuthenticationToken("user","pass", "A", "B"); + assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(userAB, this, SecurityConfig.createList("A","C"))); + } +}