Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f5617601
Commit
f5617601
authored
Jul 24, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Register OAuth2AuthorizedClientRepository bean"
Closes gh-13870
parent
2dcf1993
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
24 deletions
+22
-24
OAuth2WebSecurityConfiguration.java
...oauth2/client/servlet/OAuth2WebSecurityConfiguration.java
+2
-1
OAuth2WebSecurityConfigurationTests.java
...2/client/servlet/OAuth2WebSecurityConfigurationTests.java
+20
-23
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfiguration.java
View file @
f5617601
...
...
@@ -50,7 +50,8 @@ class OAuth2WebSecurityConfiguration {
@ConditionalOnMissingBean
public
OAuth2AuthorizedClientRepository
authorizedClientRepository
(
OAuth2AuthorizedClientService
authorizedClientService
)
{
return
new
AuthenticatedPrincipalOAuth2AuthorizedClientRepository
(
authorizedClientService
);
return
new
AuthenticatedPrincipalOAuth2AuthorizedClientRepository
(
authorizedClientService
);
}
@Configuration
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfigurationTests.java
View file @
f5617601
...
...
@@ -24,7 +24,6 @@ import javax.servlet.Filter;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
;
...
...
@@ -94,16 +93,12 @@ public class OAuth2WebSecurityConfigurationTests {
}
@Test
public
void
configurationRegistersAuthorizedRepositoryServiceBean
()
{
this
.
contextRunner
.
withUserConfiguration
(
ClientRepositoryConfiguration
.
class
,
OAuth2WebSecurityConfiguration
.
class
).
run
((
context
)
->
{
OAuth2AuthorizedClientRepository
bean
=
context
.
getBean
(
OAuth2AuthorizedClientRepository
.
class
);
OAuth2AuthorizedClientRepository
authorizedClientService
=
(
OAuth2AuthorizedClientRepository
)
ReflectionTestUtils
.
getField
(
getAuthCodeFilters
(
context
).
get
(
0
),
"authorizedClientRepository"
);
assertThat
(
authorizedClientService
).
isEqualTo
(
bean
);
});
public
void
configurationRegistersAuthorizedClientRepositoryBean
()
{
this
.
contextRunner
.
withUserConfiguration
(
ClientRepositoryConfiguration
.
class
,
OAuth2WebSecurityConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
OAuth2AuthorizedClientRepository
.
class
));
}
@Test
...
...
@@ -130,16 +125,12 @@ public class OAuth2WebSecurityConfigurationTests {
@Test
public
void
authorizedClientRepositoryBeanIsConditionalOnMissingBean
()
{
this
.
contextRunner
.
withUserConfiguration
(
OAuth2AuthorizedClientServiceConfiguration
.
class
,
OAuth2WebSecurityConfiguration
.
class
)
.
run
((
context
)
->
{
OAuth2AuthorizedClientRepository
bean
=
context
.
getBean
(
OAuth2AuthorizedClientRepository
.
class
);
OAuth2AuthorizedClientRepository
authorizedClientService
=
(
OAuth2AuthorizedClientRepository
)
ReflectionTestUtils
.
getField
(
getAuthCodeFilters
(
context
).
get
(
0
),
"authorizedClientRepository"
);
assertThat
(
authorizedClientService
).
isEqualTo
(
bean
);
this
.
contextRunner
.
withUserConfiguration
(
OAuth2AuthorizedClientRepositoryConfiguration
.
class
,
OAuth2WebSecurityConfiguration
.
class
).
run
((
context
)
->
{
assertThat
(
context
)
.
hasSingleBean
(
OAuth2AuthorizedClientRepository
.
class
);
assertThat
(
context
).
hasBean
(
"testAuthorizedClientRepository"
);
});
}
...
...
@@ -241,11 +232,17 @@ public class OAuth2WebSecurityConfigurationTests {
clientRegistrationRepository
);
}
}
@Configuration
@Import
(
ClientRepositoryConfiguration
.
class
)
static
class
OAuth2AuthorizedClientRepositoryConfiguration
{
@Bean
@ConditionalOnMissingBean
public
OAuth2AuthorizedClientRepository
testAuthorizedClientRepository
(
OAuth2AuthorizedClientService
authorizedClientService
)
{
return
new
AuthenticatedPrincipalOAuth2AuthorizedClientRepository
(
authorizedClientService
);
return
new
AuthenticatedPrincipalOAuth2AuthorizedClientRepository
(
authorizedClientService
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment