-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
66 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ class UserIntegrationTest | |
fun `회원가입시에 유저 아이디, 비밀번호, 닉네임, 이메일 중 한 가지라도 정해진 규칙에 맞지 않는 경우 Bad Request 응답을 내려준다`() { | ||
// 잘못된 userId (너무 짧은 경우) | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -42,7 +42,7 @@ class UserIntegrationTest | |
|
||
// 잘못된 password (너무 짧은 경우) | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -60,7 +60,7 @@ class UserIntegrationTest | |
|
||
// 잘못된 nickname (너무 긴 경우) | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -78,7 +78,7 @@ class UserIntegrationTest | |
|
||
// 잘못된 email 형식 (이메일 형식에 맞지 않는 경우) | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -96,7 +96,7 @@ class UserIntegrationTest | |
|
||
// 회원가입 성공 계정 1 | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -116,7 +116,7 @@ class UserIntegrationTest | |
fun `회원가입시에 이미 해당 유저 아이디나 닉네임이 존재하면 Conflict 응답을 내려준다`() { | ||
// 회원가입 성공 계정 2 | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -133,7 +133,7 @@ class UserIntegrationTest | |
|
||
// 유저 아이디가 존재하는 경우 | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -151,7 +151,7 @@ class UserIntegrationTest | |
|
||
// 유저 닉네임이 존재하는 경우 | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -172,7 +172,7 @@ class UserIntegrationTest | |
fun `로그인 정보가 정확하지 않으면 Unauthorized 응답을 내려준다`() { | ||
// 회원가입 성공 계정 3 | ||
mvc.perform( | ||
post("/auth/register") | ||
post("/auth/sign/up") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -189,7 +189,7 @@ class UserIntegrationTest | |
|
||
// 유저 아이디가 존재하지 않는 경우 | ||
mvc.perform( | ||
post("/auth/login") | ||
post("/auth/sign/in") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -205,7 +205,7 @@ class UserIntegrationTest | |
|
||
// 유저 아이디가 존재하지만 비밀번호가 틀렸을 경우 | ||
mvc.perform( | ||
post("/auth/login") | ||
post("/auth/sign/in") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -221,7 +221,7 @@ class UserIntegrationTest | |
|
||
// 계정 3에 로그인 성공 | ||
mvc.perform( | ||
post("/auth/login") | ||
post("/auth/sign/in") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
|
@@ -235,57 +235,57 @@ class UserIntegrationTest | |
.andExpect(status().isOk) | ||
} | ||
|
||
@Test | ||
fun `잘못된 인증 토큰으로 인증시 Unauthorized 응답을 내려준다`() { | ||
// 회원가입 성공 계정 4 | ||
val (userId, password, nickname) = Triple("Karrot4", "KarrotMarket4", "모두!!얼음!!!") | ||
mvc.perform( | ||
post("/auth/register") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
"userId" to userId, | ||
"password" to password, | ||
"nickname" to nickname, | ||
"email" to "[email protected]", | ||
), | ||
), | ||
) | ||
.contentType(MediaType.APPLICATION_JSON), | ||
) | ||
.andExpect(status().isOk) | ||
|
||
val accessToken = | ||
mvc.perform( | ||
post("/auth/login") | ||
.content( | ||
mapper.writeValueAsString( | ||
mapOf( | ||
"userId" to userId, | ||
"password" to password, | ||
), | ||
), | ||
) | ||
.contentType(MediaType.APPLICATION_JSON), | ||
) | ||
.andExpect(status().isOk) | ||
.andReturn() | ||
.response.getContentAsString(Charsets.UTF_8) | ||
.let { mapper.readTree(it).get("accessToken").asText() } | ||
|
||
mvc.perform( | ||
get("/auth/me") | ||
.header("Authorization", "Bearer Bad"), | ||
) | ||
.andExpect(status().isUnauthorized) | ||
.andExpect(jsonPath("$.error").value("Authenticate failed")) | ||
|
||
mvc.perform( | ||
get("/auth/me") | ||
.header("Authorization", "Bearer $accessToken"), | ||
) | ||
.andExpect(status().isOk) | ||
.andExpect(jsonPath("$.userId").value(userId)) | ||
.andExpect(jsonPath("$.nickname").value(nickname)) | ||
} | ||
// @Test | ||
// fun `잘못된 인증 토큰으로 인증시 Unauthorized 응답을 내려준다`() { | ||
// // 회원가입 성공 계정 4 | ||
// val (userId, password, nickname) = Triple("Karrot4", "KarrotMarket4", "모두!!얼음!!!") | ||
// mvc.perform( | ||
// post("/auth/sign/up") | ||
// .content( | ||
// mapper.writeValueAsString( | ||
// mapOf( | ||
// "userId" to userId, | ||
// "password" to password, | ||
// "nickname" to nickname, | ||
// "email" to "[email protected]", | ||
// ), | ||
// ), | ||
// ) | ||
// .contentType(MediaType.APPLICATION_JSON), | ||
// ) | ||
// .andExpect(status().isOk) | ||
// | ||
// val accessToken = | ||
// mvc.perform( | ||
// post("/auth/sign/in") | ||
// .content( | ||
// mapper.writeValueAsString( | ||
// mapOf( | ||
// "userId" to userId, | ||
// "password" to password, | ||
// ), | ||
// ), | ||
// ) | ||
// .contentType(MediaType.APPLICATION_JSON), | ||
// ) | ||
// .andExpect(status().isOk) | ||
// .andReturn() | ||
// .response.getContentAsString(Charsets.UTF_8) | ||
// .let { mapper.readTree(it).get("accessToken").asText() } | ||
// | ||
// mvc.perform( | ||
// get("/auth/me") | ||
// .header("Authorization", "Bearer Bad"), | ||
// ) | ||
// .andExpect(status().isUnauthorized) | ||
// .andExpect(jsonPath("$.error").value("Authenticate failed")) | ||
// | ||
// mvc.perform( | ||
// get("/auth/me") | ||
// .header("Authorization", "Bearer $accessToken"), | ||
// ) | ||
// .andExpect(status().isOk) | ||
// .andExpect(jsonPath("$.id").value(userId)) | ||
// .andExpect(jsonPath("$.nickname").value(nickname)) | ||
// } | ||
} |