{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8329","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8329/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8329/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8329/events","html_url":"https://github.com/spring-projects/spring-boot/issues/8329","id":208710612,"number":8329,"title":"@AutoConfigureMockMvc with @EnableResourceServer seems to be broken","user":{"login":"dsyer","id":124075,"avatar_url":"https://avatars.githubusercontent.com/u/124075?v=3","gravatar_id":"","url":"https://api.github.com/users/dsyer","html_url":"https://github.com/dsyer","followers_url":"https://api.github.com/users/dsyer/followers","following_url":"https://api.github.com/users/dsyer/following{/other_user}","gists_url":"https://api.github.com/users/dsyer/gists{/gist_id}","starred_url":"https://api.github.com/users/dsyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsyer/subscriptions","organizations_url":"https://api.github.com/users/dsyer/orgs","repos_url":"https://api.github.com/users/dsyer/repos","events_url":"https://api.github.com/users/dsyer/events{/privacy}","received_events_url":"https://api.github.com/users/dsyer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-02-19T11:09:27Z","updated_at":"2017-02-21T11:40:28Z","closed_at":"2017-02-21T11:40:28Z","body":"The app starts up fine and works, but tests with `@AutoConfigureMockMvc` fail like this:\r\n\r\n```\r\nCaused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.security.oauth2.provider.token.ResourceServerTokenServices' available: expected single matching bean but found 3: remoteTokenServices,consumerTokenServices,defaultAuthorizationServerTokenServices\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1041) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:345) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]\r\n```\r\n\r\nA sample you can try this with: https://github.com/spring-guides/tut-spring-boot-oauth2/tree/master/auth-server. Here's the test that fails:\r\n\r\n```\r\n@RunWith(SpringJUnit4ClassRunner.class)\r\n@SpringBootTest\r\n@AutoConfigureMockMvc\r\npublic class SocialApplicationTests {\r\n\t\r\n\t@Test\r\n\tpublic void contextLoads() throws Exception {\r\n\t}\r\n\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/281319369","html_url":"https://github.com/spring-projects/spring-boot/issues/8329#issuecomment-281319369","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8329","id":281319369,"user":{"login":"wilkinsona","id":914682,"avatar_url":"https://avatars.githubusercontent.com/u/914682?v=3","gravatar_id":"","url":"https://api.github.com/users/wilkinsona","html_url":"https://github.com/wilkinsona","followers_url":"https://api.github.com/users/wilkinsona/followers","following_url":"https://api.github.com/users/wilkinsona/following{/other_user}","gists_url":"https://api.github.com/users/wilkinsona/gists{/gist_id}","starred_url":"https://api.github.com/users/wilkinsona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilkinsona/subscriptions","organizations_url":"https://api.github.com/users/wilkinsona/orgs","repos_url":"https://api.github.com/users/wilkinsona/repos","events_url":"https://api.github.com/users/wilkinsona/events{/privacy}","received_events_url":"https://api.github.com/users/wilkinsona/received_events","type":"User","site_admin":false},"created_at":"2017-02-21T11:40:28Z","updated_at":"2017-02-21T11:40:28Z","body":"You don't even need to register a singleton. This blows up too:\r\n\r\n```java\r\npackage com.example;\r\n\r\nimport org.springframework.context.annotation.AnnotationConfigApplicationContext;\r\nimport org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;\r\nimport org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;\r\nimport org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;\r\nimport org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;\r\n\r\n@EnableAuthorizationServer\r\n@EnableWebSecurity\r\npublic class BrokenOAuthApplication extends AuthorizationServerConfigurerAdapter {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tAnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BrokenOAuthApplication.class);\r\n\t\tcontext.getBean(ResourceServerTokenServices.class);\r\n\t\tcontext.close();\r\n\t}\r\n\r\n}\r\n```\r\n\r\nI've opened https://github.com/spring-projects/spring-security-oauth/issues/984."}}
{"actor":{"display_login":"wilkinsona"}}