@@ -0,0 +1,2657 @@
+/*%0A * Copyright 2013 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except in compliance with%0A * the License. You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on%0A * an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations under the License.%0A */%0A%0Apackage org.springframework.security.oauth2.provider.client;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport org.junit.Test;%0Aimport org.mockito.Mockito;%0Aimport org.springframework.mock.web.MockHttpServletRequest;%0Aimport org.springframework.mock.web.MockHttpServletResponse;%0Aimport org.springframework.security.authentication.AuthenticationManager;%0Aimport org.springframework.security.authentication.BadCredentialsException;%0Aimport org.springframework.security.authentication.UsernamePasswordAuthenticationToken;%0Aimport org.springframework.security.core.Authentication;%0Aimport org.springframework.security.core.authority.AuthorityUtils;%0A%0A/**%0A * @author Dave Syer%0A * %0A */%0Apublic class TestClientCredentialsTokenEndpointFilter %7B%0A%0A%09private ClientCredentialsTokenEndpointFilter filter = new ClientCredentialsTokenEndpointFilter();%0A%09private AuthenticationManager authenticationManager = Mockito%0A%09%09%09.mock(AuthenticationManager.class);%0A%0A%09@Test(expected=IllegalArgumentException.class)%0A%09public void testAuthenticationManagerNeeded() %7B%0A%09%09new ClientCredentialsTokenEndpointFilter().afterPropertiesSet();%0A%09%7D%0A%0A%09@Test(expected = BadCredentialsException.class)%0A%09public void testFailedAuthentication() throws Exception %7B%0A%09%09filter.setAuthenticationManager(authenticationManager);%0A%09%09filter.afterPropertiesSet();%0A%09%09filter.attemptAuthentication(new MockHttpServletRequest(),%0A%09%09%09%09new MockHttpServletResponse());%0A%09%7D%0A%0A%09@Test%0A%09public void testAuthentication() throws Exception %7B%0A%09%09MockHttpServletRequest request = new MockHttpServletRequest();%0A%09%09request.addParameter(%22client_id%22, %22foo%22);%0A%09%09filter.setAuthenticationManager(authenticationManager);%0A%09%09filter.afterPropertiesSet();%0A%09%09Authentication authentication = new UsernamePasswordAuthenticationToken(%0A%09%09%09%09%22foo%22, %22%22,%0A%09%09%09%09AuthorityUtils.commaSeparatedStringToAuthorityList(%22CLIENT%22));%0A%09%09Mockito.when(%0A%09%09%09%09authenticationManager.authenticate(Mockito%0A%09%09%09%09%09%09.any(Authentication.class))).thenReturn(authentication);%0A%09%09assertEquals(authentication, filter.attemptAuthentication(request,%0A%09%09%09%09new MockHttpServletResponse()));%0A%09%7D%0A%0A%7D%0A

Add test case for CCTF