use of org.springframework.web.context.support.GenericWebApplicationContext in project spring-security by spring-projects.
the class OAuth2ResourceServerConfigurerTests method getJwtAuthenticationConverterWhenConverterBeanSpecified.
@Test
public void getJwtAuthenticationConverterWhenConverterBeanSpecified() {
JwtAuthenticationConverter converterBean = new JwtAuthenticationConverter();
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.registerBean(JwtAuthenticationConverter.class, () -> converterBean);
this.spring.context(context).autowire();
OAuth2ResourceServerConfigurer.JwtConfigurer jwtConfigurer = new OAuth2ResourceServerConfigurer(context).jwt();
assertThat(jwtConfigurer.getJwtAuthenticationConverter()).isEqualTo(converterBean);
}
use of org.springframework.web.context.support.GenericWebApplicationContext in project spring-security by spring-projects.
the class OAuth2ResourceServerConfigurerTests method getJwtAuthenticationConverterWhenConverterBeanAndAnotherOnTheDslThenTheDslOneIsUsed.
@Test
public void getJwtAuthenticationConverterWhenConverterBeanAndAnotherOnTheDslThenTheDslOneIsUsed() {
JwtAuthenticationConverter converter = new JwtAuthenticationConverter();
JwtAuthenticationConverter converterBean = new JwtAuthenticationConverter();
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.registerBean(JwtAuthenticationConverter.class, () -> converterBean);
this.spring.context(context).autowire();
OAuth2ResourceServerConfigurer.JwtConfigurer jwtConfigurer = new OAuth2ResourceServerConfigurer(context).jwt();
jwtConfigurer.jwtAuthenticationConverter(converter);
assertThat(jwtConfigurer.getJwtAuthenticationConverter()).isEqualTo(converter);
}
use of org.springframework.web.context.support.GenericWebApplicationContext in project spring-security by spring-projects.
the class OAuth2ResourceServerConfigurerTests method getJwtDecoderWhenTwoJwtDecoderBeansAndAnotherWiredOnDslThenDslWiredOneTakesPrecedence.
@Test
public void getJwtDecoderWhenTwoJwtDecoderBeansAndAnotherWiredOnDslThenDslWiredOneTakesPrecedence() {
JwtDecoder decoderBean = mock(JwtDecoder.class);
JwtDecoder decoder = mock(JwtDecoder.class);
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.registerBean("decoderOne", JwtDecoder.class, () -> decoderBean);
context.registerBean("decoderTwo", JwtDecoder.class, () -> decoderBean);
this.spring.context(context).autowire();
OAuth2ResourceServerConfigurer.JwtConfigurer jwtConfigurer = new OAuth2ResourceServerConfigurer(context).jwt();
jwtConfigurer.decoder(decoder);
assertThat(jwtConfigurer.getJwtDecoder()).isEqualTo(decoder);
}
use of org.springframework.web.context.support.GenericWebApplicationContext in project spring-security by spring-projects.
the class OAuth2ResourceServerConfigurerTests method getBearerTokenResolverWhenResolverBeanAndAnotherOnTheDslThenTheDslOneIsUsed.
@Test
public void getBearerTokenResolverWhenResolverBeanAndAnotherOnTheDslThenTheDslOneIsUsed() {
BearerTokenResolver resolver = mock(BearerTokenResolver.class);
BearerTokenResolver resolverBean = mock(BearerTokenResolver.class);
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.registerBean(BearerTokenResolver.class, () -> resolverBean);
this.spring.context(context).autowire();
OAuth2ResourceServerConfigurer oauth2 = new OAuth2ResourceServerConfigurer(context);
oauth2.bearerTokenResolver(resolver);
assertThat(oauth2.getBearerTokenResolver()).isEqualTo(resolver);
}
use of org.springframework.web.context.support.GenericWebApplicationContext in project spring-framework by spring-projects.
the class DelegatingWebMvcConfigurationIntegrationTests method load.
private void load(Consumer<GenericWebApplicationContext> context) {
GenericWebApplicationContext webContext = new GenericWebApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(webContext);
webContext.setServletContext(new MockServletContext());
context.accept(webContext);
webContext.registerBean(DelegatingWebMvcConfiguration.class);
webContext.refresh();
this.context = webContext;
}
Aggregations