@@ -0,0 +1,1758 @@
+package ca.uhnresearch.pughlab.tracker.security;%0A%0Aimport static org.easymock.EasyMock.createMock;%0Aimport static org.easymock.EasyMock.expect;%0Aimport static org.easymock.EasyMock.replay;%0Aimport static org.easymock.EasyMock.verify;%0Aimport junit.framework.Assert;%0A%0Aimport org.apache.shiro.authc.credential.CredentialsMatcher;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.apache.shiro.authc.AuthenticationInfo;%0Aimport org.apache.shiro.authc.UsernamePasswordToken;%0A%0Apublic class BcryptPasswordMatcherTest %7B%0A%09%0A%09private CredentialsMatcher matcher;%0A%09%0A%09private UsernamePasswordToken token;%0A%09%0A%09@Before%0A%09public void initialize() %7B%0A%09%09matcher = new BcryptPasswordMatcher();%0A%0A%09%09token = createMock(UsernamePasswordToken.class);%0A%09%09String password = %22archaeopteryx%22;%0A%09%09char passwordArray%5B%5D = password.toCharArray();%0A%09%09expect(token.getPassword()).andStubReturn(passwordArray);%0A%09%09replay(token);%0A%7D%0A%0A%09@Test%0A%09public void testSuccess() %7B%0A%09%09String credentials = %22$2y$11$mCd3GelBmDBE8M4vk1buyeMc1Jq8n8pEJb.Wo20T0G7o/XySvmT4.%22;%0A%09%09char credentialsArray%5B%5D = credentials.toCharArray();%0A%0A%09%09AuthenticationInfo info = createMock(AuthenticationInfo.class);%0A%09%09expect(info.getCredentials()).andStubReturn(credentialsArray);%0A%09%09replay(info);%0A%09%09%0A%09%09Assert.assertTrue(matcher.doCredentialsMatch(token,  info));%0A%09%09verify(token);%0A%09%09verify(info);%0A%09%7D%0A%0A%09@Test%0A%09public void testFailure() %7B%0A%09%09%0A%09%09String credentials = %22$2y$11$mCd3GelBmDBE8M4vk1buyeMc1Jq8n8pEJb.Wo20T0G7o/XySvmT3.%22;%0A%09%09char credentialsArray%5B%5D = credentials.toCharArray();%0A%0A%09%09AuthenticationInfo info = createMock(AuthenticationInfo.class);%0A%09%09expect(info.getCredentials()).andStubReturn(credentialsArray);%0A%09%09replay(info);%0A%09%09%0A%09%09Assert.assertFalse(matcher.doCredentialsMatch(token,  info));%09%09%0A%09%09verify(token);%0A%09%09verify(info);%0A%09%7D%0A%7D%0A

Test password matching