use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class RemoteAuthenticationManagerImplTests method testSuccessfulAuthentication.
@Test
public void testSuccessfulAuthentication() {
RemoteAuthenticationManagerImpl manager = new RemoteAuthenticationManagerImpl();
AuthenticationManager am = mock(AuthenticationManager.class);
when(am.authenticate(any(Authentication.class))).thenReturn(new TestingAuthenticationToken("u", "p", "A"));
manager.setAuthenticationManager(am);
manager.attemptAuthentication("rod", "password");
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class RememberMeAuthenticationProviderTests method testIgnoresClassesItDoesNotSupport.
@Test
public void testIgnoresClassesItDoesNotSupport() throws Exception {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");
TestingAuthenticationToken token = new TestingAuthenticationToken("user", "password", "ROLE_A");
assertThat(aap.supports(TestingAuthenticationToken.class)).isFalse();
// Try it anyway
assertThat(aap.authenticate(token)).isNull();
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class DefaultWebInvocationPrivilegeEvaluatorTests method allowsAccessIfAccessDecisionManagerDoes.
@Test
public void allowsAccessIfAccessDecisionManagerDoes() throws Exception {
Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX");
DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(interceptor);
assertThat(wipe.isAllowed("/foo/index.jsp", token)).isTrue();
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security-oauth by spring-projects.
the class RefreshTokenGrantTests method setup.
@Before
public void setup() {
resource = new ResourceOwnerPasswordResourceDetails();
resource.setAccessTokenUri(serverRunning.getUrl("/sparklr2/oauth/token"));
resource.setClientId("my-trusted-client");
resource.setId("sparklr");
resource.setScope(Arrays.asList("trust"));
resource.setUsername("marissa");
resource.setPassword("koala");
OAuth2RestTemplate template = new OAuth2RestTemplate(resource);
existingToken = template.getAccessToken();
((DefaultOAuth2AccessToken) existingToken).setExpiration(new Date(0L));
SecurityContextImpl securityContext = new SecurityContextImpl();
securityContext.setAuthentication(new TestingAuthenticationToken("marissa", "koala", "ROLE_USER"));
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security-oauth by spring-projects.
the class RedisTokenStoreMockTests method setUp.
@Before
public void setUp() throws Exception {
connectionFactory = mock(JedisConnectionFactory.class);
connection = mock(JedisConnection.class);
when(connectionFactory.getConnection()).thenReturn(connection);
tokenStore = new RedisTokenStore(connectionFactory);
Set<String> scope = new LinkedHashSet<String>(Arrays.asList("read", "write", "read-write"));
request = RequestTokenFactory.createOAuth2Request("clientId", false, scope);
authentication = new TestingAuthenticationToken("user", "password");
}
Aggregations