-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
136 changed files
with
4,051 additions
and
4,576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,41 +19,40 @@ | |
@Import(WebSecurityConfig.class) | ||
class GreetingControllerTest { | ||
|
||
@Autowired | ||
MockMvcSupport api; | ||
|
||
@Test | ||
@OpenId(authorities = { | ||
"AUTHOR" }, claims = @OpenIdClaims(usernameClaim = StandardClaimNames.PREFERRED_USERNAME, preferredUsername = "Tonton Pirate", email = "[email protected]")) | ||
void givenUserIsAuthenticated_whenGreet_thenOk() throws Exception { | ||
api.get("/greet").andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.body").value( | ||
"Hi Tonton Pirate! You are granted with: [AUTHOR] and your email is [email protected].")); | ||
} | ||
|
||
@Test | ||
void givenRequestIsAnonymous_whenGreet_thenUnauthorized() throws Exception { | ||
api.get("/greet").andExpect(status().isUnauthorized()); | ||
} | ||
|
||
@Test | ||
@OpenId(authorities = { "NICE", | ||
"AUTHOR" }, claims = @OpenIdClaims(usernameClaim = StandardClaimNames.PREFERRED_USERNAME, preferredUsername = "Tonton Pirate", email = "[email protected]")) | ||
void givenUserIsGrantedWithNice_whenGetNice_thenOk() throws Exception { | ||
api.get("/nice").andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.body").value( | ||
"Dear Tonton Pirate! You are granted with: [NICE, AUTHOR].")); | ||
} | ||
|
||
@Test | ||
@OpenId(authorities = { "AUTHOR" }, claims = @OpenIdClaims(preferredUsername = "Tonton Pirate")) | ||
void givenUserIsNotGrantedWithNice_whenGetNice_thenForbidden() throws Exception { | ||
api.get("/nice").andExpect(status().isForbidden()); | ||
} | ||
|
||
@Test | ||
void givenRequestIsAnonymous_whenGetNice_thenUnauthorized() throws Exception { | ||
api.get("/nice").andExpect(status().isUnauthorized()); | ||
} | ||
@Autowired | ||
MockMvcSupport api; | ||
|
||
@Test | ||
@OpenId( | ||
authorities = { "AUTHOR" }, | ||
claims = @OpenIdClaims(usernameClaim = StandardClaimNames.PREFERRED_USERNAME, preferredUsername = "Tonton Pirate", email = "[email protected]")) | ||
void givenUserIsAuthenticated_whenGreet_thenOk() throws Exception { | ||
api.get("/greet").andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.body").value("Hi Tonton Pirate! You are granted with: [AUTHOR] and your email is [email protected].")); | ||
} | ||
|
||
@Test | ||
void givenRequestIsAnonymous_whenGreet_thenUnauthorized() throws Exception { | ||
api.get("/greet").andExpect(status().isUnauthorized()); | ||
} | ||
|
||
@Test | ||
@OpenId( | ||
authorities = { "NICE", "AUTHOR" }, | ||
claims = @OpenIdClaims(usernameClaim = StandardClaimNames.PREFERRED_USERNAME, preferredUsername = "Tonton Pirate", email = "[email protected]")) | ||
void givenUserIsGrantedWithNice_whenGetNice_thenOk() throws Exception { | ||
api.get("/nice").andExpect(status().isOk()).andExpect(jsonPath("$.body").value("Dear Tonton Pirate! You are granted with: [NICE, AUTHOR].")); | ||
} | ||
|
||
@Test | ||
@OpenId(authorities = { "AUTHOR" }, claims = @OpenIdClaims(preferredUsername = "Tonton Pirate")) | ||
void givenUserIsNotGrantedWithNice_whenGetNice_thenForbidden() throws Exception { | ||
api.get("/nice").andExpect(status().isForbidden()); | ||
} | ||
|
||
@Test | ||
void givenRequestIsAnonymous_whenGetNice_thenUnauthorized() throws Exception { | ||
api.get("/nice").andExpect(status().isUnauthorized()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.