Commit ec2823f9 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza
Browse files

TokenController updates

Exclude MeController from component scan in the test configuration
parent 8411a21c
......@@ -122,8 +122,10 @@ public class OAuth2ServerConfig {
// cors
.and().cors()
// TODO 1.7 Delete "/token" URL
.and().requestMatchers().antMatchers("/api/**", "/google/verify-token", "/token")
// TODO 1.7 Delete "/token" URL
.and().authorizeRequests().antMatchers("/api/**", "/google/verify-token", "/token").authenticated()
.and().exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler());
......
......@@ -28,10 +28,12 @@ import org.genesys.catalog.service.filters.DescriptorListFilter;
import org.genesys.catalog.service.filters.PartnerFilter;
import org.genesys.common.model.Partner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -60,6 +62,16 @@ public class MeController {
@Autowired
private DescriptorListService descriptorListService;
@Autowired
@Qualifier("tokenServices")
private DefaultTokenServices defaultTokenServices;
@PostMapping(value = "/token", consumes = "text/plain")
public Object removeToken(@RequestBody final String token) {
defaultTokenServices.revokeToken(token);
return token;
}
@PostMapping(value = "/partners")
public Page<Partner> myPartners(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
......
......@@ -34,6 +34,10 @@ public class TokenController {
this.defaultTokenServices = defaultTokenServices;
}
/**
* @deprecated
*/
// TODO 1.7 Delete this
@RequestMapping(method = RequestMethod.DELETE)
public Object removeToken(@RequestParam("token") final String token) {
defaultTokenServices.revokeToken(token);
......
......@@ -23,6 +23,7 @@ import org.genesys.blocks.oauth.service.OAuthServiceImpl;
import org.genesys.catalog.server.config.SwaggerConfig;
import org.genesys.catalog.server.controller.DescriptorListExporter;
import org.genesys.catalog.server.controller.api.v0.ApiInfoController;
import org.genesys.catalog.server.controller.api.v0.me.MeController;
import org.genesys.catalog.server.service.FreemarkerTemplating;
import org.genesys.catalog.server.service.impl.FreemarkerTemplatingServiceImpl;
import org.genesys.catalog.server.tests.ServiceTest;
......@@ -31,6 +32,7 @@ import org.junit.runner.RunWith;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
......@@ -79,7 +81,7 @@ public abstract class AbstractRestTest extends ServiceTest {
@EnableWebMvc
@Import(SwaggerConfig.class)
// Only import controller.api package
@ComponentScan(basePackageClasses = { ApiInfoController.class })
@ComponentScan(basePackageClasses = { ApiInfoController.class}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = MeController.class))
@DirtiesContext(hierarchyMode = HierarchyMode.CURRENT_LEVEL, classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public static class Config extends WebMvcConfigurerAdapter {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment