@@ -0,0 +1,2043 @@
+package edu.northwestern.bioinformatics.studycalendar.security;%0A%0Aimport edu.northwestern.bioinformatics.studycalendar.testing.StudyCalendarTestCase;%0Aimport edu.northwestern.bioinformatics.studycalendar.domain.Role;%0Aimport org.acegisecurity.userdetails.UserDetailsService;%0Aimport org.acegisecurity.userdetails.User;%0Aimport org.acegisecurity.userdetails.UserDetails;%0Aimport org.easymock.classextension.EasyMock;%0Aimport static org.easymock.classextension.EasyMock.*;%0A%0A/**%0A * @author Rhett Sutphin%0A */%0Apublic class WebSSOAuthoritiesPopulatorTest extends StudyCalendarTestCase %7B%0A    private WebSSOAuthoritiesPopulator populator;%0A    private UserDetailsService userDetailsService;%0A%0A    @Override%0A    protected void setUp() throws Exception %7B%0A        super.setUp();%0A        userDetailsService = registerMockFor(UserDetailsService.class);%0A        populator = new WebSSOAuthoritiesPopulator();%0A        populator.setUserDetailsService(userDetailsService);%0A    %7D%0A%0A    public void testPopulation() throws Exception %7B%0A        String expectedSsoUserId = %22CAGRID_SSO_EMAIL_ID%5Ejo@org.org$CAGRID_SSO_FIRST_NAME%5EJosephine$CAGRID_SSO_LAST_NAME%5EMiller$CAGRID_SSO_GRID_IDENTITY%5Eablablab%22;%0A        String expectedAddress = %22jo@org.org%22;%0A        expect(userDetailsService.loadUserByUsername(expectedAddress)).andReturn(%0A            new User(expectedAddress, %22ignored%22, true, true, true, true, new Role%5B%5D %7B Role.STUDY_ADMIN %7D));%0A        replayMocks();%0A%0A        UserDetails details = populator.getUserDetails(expectedSsoUserId);%0A        assertTrue(%22Returned details not an instance of WebSSOUser%22, details instanceof WebSSOUser);%0A        WebSSOUser ssoDetails = (WebSSOUser) details;%0A        assertEquals(%22First name not preserved%22, %22Josephine%22, ssoDetails.getFirstName());%0A        assertEquals(%22Last name not preserved%22, %22Miller%22, ssoDetails.getLastName());%0A        assertEquals(%22User has wrong number of authorities%22, 1, ssoDetails.getAuthorities().length);%0A        assertEquals(%22User has wrong authority%22, Role.STUDY_ADMIN, ssoDetails.getAuthorities()%5B0%5D);%0A    %7D%0A%7D%0A

Add test for WebSSO "username" parser