|
3 | 3 | import org.cloudfoundry.identity.uaa.DefaultTestContext; |
4 | 4 | import org.cloudfoundry.identity.uaa.authentication.UaaAuthentication; |
5 | 5 | import org.cloudfoundry.identity.uaa.authentication.UaaPrincipal; |
| 6 | +import org.cloudfoundry.identity.uaa.client.UaaClientDetails; |
6 | 7 | import org.cloudfoundry.identity.uaa.mock.util.MockMvcUtils; |
| 8 | +import org.cloudfoundry.identity.uaa.mock.util.MockMvcUtils.ZoneResolutionMode; |
7 | 9 | import org.cloudfoundry.identity.uaa.scim.ScimUser; |
8 | 10 | import org.cloudfoundry.identity.uaa.test.ZoneSeeder; |
9 | 11 | import org.cloudfoundry.identity.uaa.test.ZoneSeederExtension; |
10 | 12 | import org.cloudfoundry.identity.uaa.user.UaaAuthority; |
| 13 | +import org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder; |
11 | 14 | import org.junit.jupiter.api.BeforeEach; |
12 | 15 | import org.junit.jupiter.api.Nested; |
13 | 16 | import org.junit.jupiter.api.Test; |
14 | 17 | import org.junit.jupiter.api.extension.ExtendWith; |
| 18 | +import org.junit.jupiter.params.ParameterizedTest; |
| 19 | +import org.junit.jupiter.params.provider.EnumSource; |
15 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | +import org.springframework.http.HttpMethod; |
16 | 22 | import org.springframework.mock.web.MockHttpSession; |
17 | 23 | import org.cloudfoundry.identity.uaa.oauth.common.exceptions.RedirectMismatchException; |
18 | 24 | import org.springframework.security.web.context.HttpSessionSecurityContextRepository; |
@@ -235,4 +241,33 @@ private MockHttpServletRequestBuilder authCodeAuthorizeRequest(String redirectUr |
235 | 241 | .param(REDIRECT_URI, redirectUri) |
236 | 242 | .session(session); |
237 | 243 | } |
| 244 | + |
| 245 | + @Nested |
| 246 | + @DefaultTestContext |
| 247 | + class ConfirmAccessAndErrorZonePathSupport { |
| 248 | + |
| 249 | + @ParameterizedTest |
| 250 | + @EnumSource(ZoneResolutionMode.class) |
| 251 | + void confirm_access_responds_for_zone_path(ZoneResolutionMode mode) throws Exception { |
| 252 | + String subdomain = "zone" + System.nanoTime(); |
| 253 | + UaaClientDetails client = new UaaClientDetails("client-id", "", "openid", "authorization_code", "", "http://redirect"); |
| 254 | + client.setClientSecret("secret"); |
| 255 | + MockMvcUtils.createOtherIdentityZoneAndReturnResult(subdomain, mockMvc, webApplicationContext, client, IdentityZoneHolder.getCurrentZoneId()); |
| 256 | + |
| 257 | + mockMvc.perform(mode.createRequestBuilder(subdomain, HttpMethod.GET, "/oauth/confirm_access")) |
| 258 | + .andExpect(status().is3xxRedirection()); |
| 259 | + } |
| 260 | + |
| 261 | + @ParameterizedTest |
| 262 | + @EnumSource(ZoneResolutionMode.class) |
| 263 | + void oauth_error_responds_for_zone_path(ZoneResolutionMode mode) throws Exception { |
| 264 | + String subdomain = "zone" + System.nanoTime(); |
| 265 | + UaaClientDetails client = new UaaClientDetails("client-id", "", "openid", "authorization_code", "", "http://redirect"); |
| 266 | + client.setClientSecret("secret"); |
| 267 | + MockMvcUtils.createOtherIdentityZoneAndReturnResult(subdomain, mockMvc, webApplicationContext, client, IdentityZoneHolder.getCurrentZoneId()); |
| 268 | + |
| 269 | + mockMvc.perform(mode.createRequestBuilder(subdomain, HttpMethod.GET, "/oauth/error")) |
| 270 | + .andExpect(status().is3xxRedirection()); |
| 271 | + } |
| 272 | + } |
238 | 273 | } |
0 commit comments