use of org.springframework.security.access.ConfigAttribute in project spring-security by spring-projects.
the class DefaultFilterInvocationSecurityMetadataSourceTests method lookupRequiringExactMatchWithAdditionalSlashesIsSuccessful.
@Test
public void lookupRequiringExactMatchWithAdditionalSlashesIsSuccessful() {
createFids("/someAdminPage.html**", null);
FilterInvocation fi = createFilterInvocation("/someAdminPage.html", null, "a=/test", null);
Collection<ConfigAttribute> response = this.fids.getAttributes(fi);
// see SEC-161 (it should truncate after ?
assertThat(response);
// sign).isEqualTo(def)
}
use of org.springframework.security.access.ConfigAttribute in project spring-security-oauth by spring-projects.
the class ClientScopeVoterTests method testAccessDeniedNoException.
@Test
public void testAccessDeniedNoException() {
voter.setThrowException(false);
client.setScope(Arrays.asList("none"));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(authentication, null, Arrays.<ConfigAttribute>asList(new SecurityConfig("CLIENT_HAS_SCOPE"))));
}
use of org.springframework.security.access.ConfigAttribute in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessGrantedIfScopesPresent.
@Test
public void testAccessGrantedIfScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_READ"))));
}
use of org.springframework.security.access.ConfigAttribute in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessGrantedIfScopesPresentWithPrefix.
@Test
public void testAccessGrantedIfScopesPresentWithPrefix() throws Exception {
voter.setScopePrefix("scope=");
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("scope=read"))));
}
use of org.springframework.security.access.ConfigAttribute in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testExceptionThrownIfWrongScopesPresent.
@Test(expected = AccessDeniedException.class)
public void testExceptionThrownIfWrongScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_WRITE"))));
}
Aggregations