Fix OAuth2 multitenancy sample
Allowing requests with valid tokens, and fixed documentation. Fixes: gh-6834
This commit is contained in:
committed by
Josh Cummings
parent
5aa50500cf
commit
c4b6cdea3f
@@ -62,6 +62,15 @@ public class OAuth2ResourceServerApplicationITests {
|
||||
.andExpect(content().string(containsString("Hello, subject for tenantOne!")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tenantOnePerformWhenValidBearerTokenWithServletPathThenAllows()
|
||||
throws Exception {
|
||||
|
||||
this.mvc.perform(get("/tenantOne").servletPath("/tenantOne").with(bearerToken(this.tenantOneNoScopesToken)))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("Hello, subject for tenantOne!")));
|
||||
}
|
||||
|
||||
// -- tests with scopes
|
||||
|
||||
@Test
|
||||
@@ -113,6 +122,13 @@ public class OAuth2ResourceServerApplicationITests {
|
||||
containsString("Bearer error=\"insufficient_scope\"")));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidTenantPerformWhenValidBearerTokenThenThrowsException()
|
||||
throws Exception {
|
||||
|
||||
this.mvc.perform(get("/tenantThree").with(bearerToken(this.tenantOneNoScopesToken)));
|
||||
}
|
||||
|
||||
private static class BearerTokenRequestPostProcessor implements RequestPostProcessor {
|
||||
private String token;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user