use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class ResourceServerTokenServicesConfigurationTests method userInfoWithClient.
@Test
public void userInfoWithClient() {
EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.client.client-id=acme", "security.oauth2.resource.userInfoUri:http://example.com", "server.port=-1", "debug=true");
this.context = new SpringApplicationBuilder(ResourceNoClientConfiguration.class).environment(this.environment).web(WebApplicationType.SERVLET).run();
BeanDefinition bean = ((BeanDefinitionRegistry) this.context).getBeanDefinition("scopedTarget.oauth2ClientContext");
assertThat(bean.getScope()).isEqualTo("request");
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class ResourceServerTokenServicesConfigurationTests method springSocialUserInfo.
@Test
public void springSocialUserInfo() {
EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.resource.userInfoUri:http://example.com", "spring.social.facebook.app-id=foo", "spring.social.facebook.app-secret=bar");
this.context = new SpringApplicationBuilder(SocialResourceConfiguration.class).environment(this.environment).web(WebApplicationType.SERVLET).run();
ConnectionFactoryLocator connectionFactory = this.context.getBean(ConnectionFactoryLocator.class);
assertThat(connectionFactory).isNotNull();
SpringSocialTokenServices services = this.context.getBean(SpringSocialTokenServices.class);
assertThat(services).isNotNull();
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class ResourceServerTokenServicesConfigurationTests method jwkConfiguration.
@Test
public void jwkConfiguration() throws Exception {
EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys");
this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment).web(false).run();
DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
assertThat(services).isNotNull();
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(RemoteTokenServices.class);
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class ResourceServerTokenServicesConfigurationTests method switchToJwt.
@Test
public void switchToJwt() {
EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.resource.jwt.keyValue=FOOBAR");
this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment).web(WebApplicationType.NONE).run();
DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
assertThat(services).isNotNull();
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(RemoteTokenServices.class);
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class SpringApplicationAdminJmxAutoConfigurationTests method onlyRegisteredOnceWhenThereIsAChildContext.
@Test
public void onlyRegisteredOnceWhenThereIsAChildContext() throws Exception {
SpringApplicationBuilder parentBuilder = new SpringApplicationBuilder().web(WebApplicationType.NONE).sources(JmxAutoConfiguration.class, SpringApplicationAdminJmxAutoConfiguration.class);
SpringApplicationBuilder childBuilder = parentBuilder.child(JmxAutoConfiguration.class, SpringApplicationAdminJmxAutoConfiguration.class).web(WebApplicationType.NONE);
ConfigurableApplicationContext parent = null;
ConfigurableApplicationContext child = null;
try {
parent = parentBuilder.run("--" + ENABLE_ADMIN_PROP);
child = childBuilder.run("--" + ENABLE_ADMIN_PROP);
BeanFactoryUtils.beanOfType(parent.getBeanFactory(), SpringApplicationAdminMXBeanRegistrar.class);
this.thrown.expect(NoSuchBeanDefinitionException.class);
BeanFactoryUtils.beanOfType(child.getBeanFactory(), SpringApplicationAdminMXBeanRegistrar.class);
} finally {
if (parent != null) {
parent.close();
}
if (child != null) {
child.close();
}
}
}
Aggregations