|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2021 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
37 | 37 | import org.springframework.web.util.UriComponents;
|
38 | 38 |
|
39 | 39 | import static org.assertj.core.api.Assertions.assertThat;
|
| 40 | +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
40 | 41 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
41 | 42 | import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
42 | 43 |
|
43 | 44 | /**
|
44 | 45 | * @author Rob Winch
|
45 | 46 | * @author Rafiullah Hamedy
|
| 47 | + * @author Evgeniy Cheban |
46 | 48 | * @since 5.1
|
47 | 49 | */
|
48 | 50 | public class ClientRegistrationsTests {
|
@@ -581,6 +583,27 @@ public void oidcWhenHostContainsUnderscoreThenRetains() {
|
581 | 583 | assertThat(oidcRfc8414.getHost()).isEqualTo("elated_sutherland");
|
582 | 584 | }
|
583 | 585 |
|
| 586 | + @Test |
| 587 | + public void issuerWhenAllEndpointsFailedThenExceptionIncludesFailureInformation() { |
| 588 | + this.issuer = createIssuerFromServer("issuer1"); |
| 589 | + this.server.setDispatcher(new Dispatcher() { |
| 590 | + @Override |
| 591 | + public MockResponse dispatch(RecordedRequest request) { |
| 592 | + int responseCode = switch (request.getPath()) { |
| 593 | + case "/issuer1/.well-known/openid-configuration" -> 405; |
| 594 | + case "/.well-known/openid-configuration/issuer1" -> 400; |
| 595 | + default -> 404; |
| 596 | + }; |
| 597 | + return new MockResponse().setResponseCode(responseCode); |
| 598 | + } |
| 599 | + }); |
| 600 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 601 | + .isThrownBy(() -> ClientRegistrations.fromIssuerLocation(this.issuer).build()) |
| 602 | + .withMessageContaining("405") |
| 603 | + .withMessageContaining("400") |
| 604 | + .withMessageContaining("404"); |
| 605 | + } |
| 606 | + |
584 | 607 | private ClientRegistration.Builder registration(String path) throws Exception {
|
585 | 608 | this.issuer = createIssuerFromServer(path);
|
586 | 609 | this.response.put("issuer", this.issuer);
|
|
0 commit comments