11/*
2- * Copyright 2002-2018 the original author or authors.
2+ * Copyright 2002-2019 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
3737import org .springframework .security .oauth2 .client .registration .ClientRegistration ;
3838import org .springframework .security .oauth2 .client .registration .InMemoryReactiveClientRegistrationRepository ;
3939import org .springframework .security .oauth2 .client .userinfo .ReactiveOAuth2UserService ;
40+ import org .springframework .security .oauth2 .client .web .server .ServerOAuth2AuthorizationRequestResolver ;
4041import org .springframework .security .oauth2 .core .OAuth2AccessToken ;
4142import org .springframework .security .oauth2 .core .TestOAuth2AccessTokens ;
4243import org .springframework .security .oauth2 .core .endpoint .OAuth2AccessTokenResponse ;
5960import org .springframework .security .web .server .SecurityWebFilterChain ;
6061import org .springframework .security .web .server .WebFilterChainProxy ;
6162import org .springframework .security .web .server .authentication .ServerAuthenticationConverter ;
63+ import org .springframework .security .web .server .util .matcher .ServerWebExchangeMatcher ;
6264import org .springframework .test .web .reactive .server .WebTestClient ;
6365import org .springframework .web .server .ServerWebExchange ;
6466import org .springframework .web .server .WebFilter ;
@@ -100,7 +102,7 @@ public class OAuth2LoginTests {
100102
101103 @ Test
102104 public void defaultLoginPageWithMultipleClientRegistrationsThenLinks () {
103- this .spring .register (OAuth2LoginWithMulitpleClientRegistrations .class ).autowire ();
105+ this .spring .register (OAuth2LoginWithMultipleClientRegistrations .class ).autowire ();
104106
105107 WebTestClient webTestClient = WebTestClientBuilder
106108 .bindToWebFilters (this .springSecurity )
@@ -120,7 +122,7 @@ public void defaultLoginPageWithMultipleClientRegistrationsThenLinks() {
120122 }
121123
122124 @ EnableWebFluxSecurity
123- static class OAuth2LoginWithMulitpleClientRegistrations {
125+ static class OAuth2LoginWithMultipleClientRegistrations {
124126 @ Bean
125127 InMemoryReactiveClientRegistrationRepository clientRegistrationRepository () {
126128 return new InMemoryReactiveClientRegistrationRepository (github , google );
@@ -165,6 +167,8 @@ public void oauth2LoginWhenCustomObjectsThenUsed() {
165167 .getBean (OAuth2LoginMockAuthenticationManagerConfig .class );
166168 ServerAuthenticationConverter converter = config .authenticationConverter ;
167169 ReactiveAuthenticationManager manager = config .manager ;
170+ ServerWebExchangeMatcher matcher = config .matcher ;
171+ ServerOAuth2AuthorizationRequestResolver resolver = config .resolver ;
168172
169173 OAuth2AuthorizationExchange exchange = TestOAuth2AuthorizationExchanges .success ();
170174 OAuth2User user = TestOAuth2Users .create ();
@@ -174,6 +178,8 @@ public void oauth2LoginWhenCustomObjectsThenUsed() {
174178
175179 when (converter .convert (any ())).thenReturn (Mono .just (new TestingAuthenticationToken ("a" , "b" , "c" )));
176180 when (manager .authenticate (any ())).thenReturn (Mono .just (result ));
181+ when (matcher .matches (any ())).thenReturn (ServerWebExchangeMatcher .MatchResult .match ());
182+ when (resolver .resolve (any ())).thenReturn (Mono .empty ());
177183
178184 webTestClient .get ()
179185 .uri ("/login/oauth2/code/github" )
@@ -182,6 +188,8 @@ public void oauth2LoginWhenCustomObjectsThenUsed() {
182188
183189 verify (converter ).convert (any ());
184190 verify (manager ).authenticate (any ());
191+ verify (matcher ).matches (any ());
192+ verify (resolver ).resolve (any ());
185193 }
186194
187195 @ Configuration
@@ -190,6 +198,10 @@ static class OAuth2LoginMockAuthenticationManagerConfig {
190198
191199 ServerAuthenticationConverter authenticationConverter = mock (ServerAuthenticationConverter .class );
192200
201+ ServerWebExchangeMatcher matcher = mock (ServerWebExchangeMatcher .class );
202+
203+ ServerOAuth2AuthorizationRequestResolver resolver = mock (ServerOAuth2AuthorizationRequestResolver .class );
204+
193205 @ Bean
194206 public SecurityWebFilterChain springSecurityFilter (ServerHttpSecurity http ) {
195207 http
@@ -198,14 +210,16 @@ public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
198210 .and ()
199211 .oauth2Login ()
200212 .authenticationConverter (authenticationConverter )
201- .authenticationManager (manager );
213+ .authenticationManager (manager )
214+ .authenticationMatcher (matcher )
215+ .authorizationRequestResolver (resolver );
202216 return http .build ();
203217 }
204218 }
205219
206220 @ Test
207221 public void oauth2LoginWhenCustomJwtDecoderFactoryThenUsed () {
208- this .spring .register (OAuth2LoginWithMulitpleClientRegistrations .class ,
222+ this .spring .register (OAuth2LoginWithMultipleClientRegistrations .class ,
209223 OAuth2LoginWithJwtDecoderFactoryBeanConfig .class ).autowire ();
210224
211225 WebTestClient webTestClient = WebTestClientBuilder
0 commit comments