X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=security%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsecurity%2Fauthorization%2FTestUserAccessor.java;h=c4cadcc851236d27e779f3fa6ab55a6d5df1ee17;hb=17775e14ecfb286e59f67117e5cee7e21e95ab1f;hp=02e090206c87e7736ffee7555400030843c850a4;hpb=532f7219273021ef3652e0abe1326b7aeed1f30a;p=utils diff --git a/security/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java b/security/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java index 02e09020..c4cadcc8 100644 --- a/security/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java +++ b/security/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2005 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ * 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. - */ - + */ package org.wamblee.security.authorization; import junit.framework.TestCase; import org.wamblee.security.encryption.Md5HexMessageDigester; + import org.wamblee.usermgt.Group; import org.wamblee.usermgt.InMemoryGroupSet; import org.wamblee.usermgt.InMemoryUserSet; @@ -31,15 +31,15 @@ import org.wamblee.usermgt.UserMgtException; import org.wamblee.usermgt.UserMgtException.Reason; /** - * User access that always returns a user that belongs to - * a fixed group. - * + * User access that always returns a user that belongs to a fixed group. + * * @author Erik Brakkee */ public class TestUserAccessor implements UserAccessor { - - private static final String USER = "erik"; + private static final String USER = "erik"; + private static final String PASSWORD = "abc123"; + private static final String GROUP = "users"; /* @@ -49,18 +49,22 @@ public class TestUserAccessor implements UserAccessor { */ public User getCurrentUser() { UserAdministration admin = new UserAdministrationImpl( - new InMemoryUserSet( new RegexpNameValidator(RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD, "Password must contain at least 6 characters"), - new Md5HexMessageDigester()), new InMemoryGroupSet(), - new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, Reason.INVALID_USERNAME, "Invalid user"), - new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, Reason.INVALID_GROUPNAME, "Invalid group") - ); + new InMemoryUserSet(new RegexpNameValidator( + RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD, + "Password must contain at least 6 characters"), + new Md5HexMessageDigester()), new InMemoryGroupSet(), + new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, + Reason.INVALID_USERNAME, "Invalid user"), + new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, + Reason.INVALID_GROUPNAME, "Invalid group")); + try { Group group = admin.createGroup(GROUP); + return admin.createUser(USER, PASSWORD, group); } catch (UserMgtException e) { TestCase.fail(e.getMessage()); throw new RuntimeException(e); } } - }