@Before public void setUp() throws Exception { user = createUser( TEST_VISTA_ID, TEST_DIVISION, TEST_DUZ, TEST_REMOTE_HOSTNAME + "(" + TEST_REMOTE_ADDRESS + ")" + TEST_ACCESS + ";" + TEST_VERIFY, true, true, true, true, new SimpleGrantedAuthority("ROLE_ONE"), new SimpleGrantedAuthority("ROLE_TWO")); mockUserDetailService = mock(VistaUserDetailsService.class); provider = new VistaAuthenticationProvider(); provider.setUserDetailsService(mockUserDetailService); mockCache = new MockUserCache(); provider.setUserCache(mockCache); provider.afterPropertiesSet(); }
@Test public void testStartupSuccess() throws Exception { VistaAuthenticationProvider provider = new VistaAuthenticationProvider(); provider.setUserDetailsService(mockUserDetailService); provider.setUserCache(new MockUserCache()); assertSame(mockUserDetailService, provider.getUserDetailsService()); provider.afterPropertiesSet(); }
@Test public void testStartupFailsIfNoVistaUserDetailsService() throws Exception { VistaAuthenticationProvider provider = new VistaAuthenticationProvider(); try { provider.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { assertTrue(true); } }
@Test public void testStartupFailsIfNoUserCacheSet() throws Exception { VistaAuthenticationProvider provider = new VistaAuthenticationProvider(); provider.setUserDetailsService(mockUserDetailService); assertEquals(NullUserCache.class, provider.getUserCache().getClass()); provider.setUserCache(null); try { provider.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { assertTrue(true); } }