-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
0ca151f
commit 7a1d45a
Showing
12 changed files
with
112 additions
and
24 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
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
46 changes: 46 additions & 0 deletions
46
...erver/src/test/kotlin/com/bestswlkh0310/graduating/graduatingserver/AuthControllerTest.kt
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.bestswlkh0310.graduating.graduatingserver | ||
|
||
import com.bestswlkh0310.graduating.graduatingserver.api.auth.res.TokenRes | ||
import com.bestswlkh0310.graduating.graduatingserver.core.user.PlatformType | ||
import com.bestswlkh0310.graduating.graduatingserver.core.user.User | ||
import com.bestswlkh0310.graduating.graduatingserver.core.user.UserRepository | ||
import com.bestswlkh0310.graduating.graduatingserver.infra.token.JwtClient | ||
import com.bestswlkh0310.graduating.graduatingserver.util.TestAnnotation | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.test.web.servlet.MockMvc | ||
|
||
@TestAnnotation | ||
class AuthControllerTest { | ||
|
||
@Autowired | ||
lateinit var userRepository: UserRepository | ||
@Autowired | ||
lateinit var jwtClient: JwtClient | ||
@Autowired | ||
lateinit var mvc: MockMvc | ||
|
||
private var token: TokenRes? = null | ||
|
||
@BeforeEach | ||
fun beforeEach() { | ||
val user = userRepository.save( | ||
User( | ||
id = 0, | ||
username = "hhhello0507@gmail.com", | ||
nickname = "testuser", | ||
platformType = PlatformType.GOOGLE | ||
) | ||
) | ||
token = jwtClient.generate(user) | ||
} | ||
|
||
@Test | ||
fun `sign up`() { | ||
// mvc.perform( | ||
// MockMvcRequestBuilders.post("/api/auth/signup") | ||
// ) | ||
println(token) | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
.../kotlin/com/bestswlkh0310/graduating/graduatingserver/GraduatingServerApplicationTests.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...rver/src/test/kotlin/com/bestswlkh0310/graduating/graduatingserver/util/TestAnnotation.kt
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bestswlkh0310.graduating.graduatingserver.util | ||
|
||
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.annotation.DirtiesContext | ||
import org.springframework.test.context.TestPropertySource | ||
|
||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@SpringBootTest | ||
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) // reset DB | ||
@AutoConfigureTestDatabase( | ||
connection = EmbeddedDatabaseConnection.H2, | ||
replace = AutoConfigureTestDatabase.Replace.ANY | ||
) | ||
@TestPropertySource("classpath:application-test.yml") | ||
@AutoConfigureMockMvc | ||
annotation class TestAnnotation |
16 changes: 16 additions & 0 deletions
16
...ating-Server/src/test/kotlin/com/bestswlkh0310/graduating/graduatingserver/util/toJson.kt
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.bestswlkh0310.graduating.graduatingserver.util | ||
|
||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.readValue | ||
|
||
fun Any.toJson(): String = try { | ||
jacksonObjectMapper().writeValueAsString(this) | ||
} catch (e: Exception) { | ||
throw RuntimeException(e) | ||
} | ||
|
||
inline fun <reified T> String.fromJson(): T = try { | ||
jacksonObjectMapper().readValue<T>(this) | ||
} catch (e: Exception) { | ||
throw RuntimeException(e) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
spring: | ||
datasource: | ||
url: jdbc:h2:mem:testdb | ||
# username: | ||
# password: | ||
driver-class-name: org.h2.Driver | ||
h2: | ||
console: | ||
enabled: true | ||
jpa: | ||
database-platform: org.hibernate.dialect.H2Dialect | ||
hibernate: | ||
ddl-auto: | ||
update | ||
show-sql: true |