use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class AuthenticationTagTests method testOperationWhenPrincipalIsNull.
@Test
public void testOperationWhenPrincipalIsNull() throws JspException {
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(null, "koala", AuthorityUtils.NO_AUTHORITIES));
authenticationTag.setProperty("principal");
assertThat(authenticationTag.doStartTag()).isEqualTo(Tag.SKIP_BODY);
assertThat(authenticationTag.doEndTag()).isEqualTo(Tag.EVAL_PAGE);
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class JaasApiIntegrationFilterTests method obtainSubjectNonJaasAuthentication.
@Test
public void obtainSubjectNonJaasAuthentication() {
Authentication authentication = new TestingAuthenticationToken("un", "pwd");
authentication.setAuthenticated(true);
SecurityContextHolder.getContext().setAuthentication(authentication);
assertNullSubject(filter.obtainSubject(request));
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class GrantedAuthorityDefaultsJcTests method setup.
private void setup(String role) {
TestingAuthenticationToken user = new TestingAuthenticationToken("user", "password", role);
SecurityContextHolder.getContext().setAuthentication(user);
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class GrantedAuthorityDefaultsXmlTests method setup.
private void setup(String role) {
TestingAuthenticationToken user = new TestingAuthenticationToken("user", "password", role);
SecurityContextHolder.getContext().setAuthentication(user);
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project spring-security by spring-projects.
the class WebMvcSecurityConfigurationTests method setup.
@Before
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
authentication = new TestingAuthenticationToken("user", "password", AuthorityUtils.createAuthorityList("ROLE_USER"));
SecurityContextHolder.getContext().setAuthentication(authentication);
}
Aggregations