Skip to content

Commit af04047

Browse files
Example test showing the minimalist response to an empty Authorization header
1 parent 3dd3c18 commit af04047

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java

+13
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ public void getWhenExpiredThenReturnsInvalidToken() {
178178
// @formatter:on
179179
}
180180

181+
@Test
182+
public void getWhenBearerMissingInvalidToken() {
183+
this.spring.register(PublicKeyConfig.class).autowire();
184+
// @formatter:off
185+
this.client.get()
186+
.headers((headers) -> headers
187+
.set("Authorization", ""))
188+
.exchange()
189+
.expectStatus().isUnauthorized()
190+
.expectHeader().value(HttpHeaders.WWW_AUTHENTICATE, startsWith("Bearer error=\"missing_token\""));
191+
// @formatter:on
192+
}
193+
181194
@Test
182195
public void getWhenUnsignedThenReturnsInvalidToken() {
183196
this.spring.register(PublicKeyConfig.class).autowire();

0 commit comments

Comments
 (0)