Skip to content

Commit f3ce7e6

Browse files
authored
애플 Public Key 통신 후 응답 구조 수정한다. (#66)
fix: apple public key response model
1 parent 25a8141 commit f3ce7e6

File tree

7 files changed

+18
-8
lines changed

7 files changed

+18
-8
lines changed

api/src/main/kotlin/com/gotchai/api/presentation/v1/exam/ExamController.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ExamController(
3131
@AuthenticationPrincipal
3232
userId: Long
3333
): ExamListResponse =
34-
examQueryUseCase.getExamsByUserId(userId)
34+
examQueryUseCase
35+
.getExamsByUserId(userId)
3536
.let { ExamListResponse.from(it) }
3637
}

api/src/test/kotlin/com/gotchai/api/presentation/v1/exam/ExamControllerTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class ExamControllerTest : ControllerTest() {
7373
}
7474

7575
it("상태 코드 200과 ExamListResponse를 반환한다.") {
76-
webClient.get()
76+
webClient
77+
.get()
7778
.uri("/api/v1/users/me/exam/solved")
7879
.exchange()
7980
.expectStatus()

domain/src/testFixtures/kotlin/com/gotchai/domain/fixture/ExamFixture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fun createGetExamResult(
5454
iconImage: String = ICON_IMAGE,
5555
theme: String = THEME,
5656
quizIds: List<Long> = listOf(ID),
57-
createdAt: LocalDateTime = CREATED_AT,
57+
createdAt: LocalDateTime = CREATED_AT
5858
): GetExamResult =
5959
GetExamResult(
6060
id = id,

infrastructure/oauth/src/main/kotlin/com/gotchai/infrastructure/oauth/client/AppleClient.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.gotchai.infrastructure.oauth.client
33
import com.fasterxml.jackson.databind.ObjectMapper
44
import com.gotchai.domain.auth.exception.InvalidOAuthTokenException
55
import com.gotchai.infrastructure.oauth.config.AppleProperties
6-
import com.gotchai.infrastructure.oauth.dto.ApplePublicKey
6+
import com.gotchai.infrastructure.oauth.dto.ApplePublicKeyResponse
77
import com.gotchai.infrastructure.oauth.dto.AppleUser
88
import com.nimbusds.jose.crypto.RSASSAVerifier
99
import com.nimbusds.jose.jwk.JWK
@@ -52,17 +52,18 @@ class AppleClient(
5252

5353
private fun isSignatureValid(signedJWT: SignedJWT): Boolean =
5454
getPublicKeys()
55+
.keys
5556
.map {
5657
val rsaKey = JWK.parse(objectMapper.writeValueAsString(it)) as RSAKey
5758
val publicKey = rsaKey.toRSAPublicKey()
5859

5960
RSASSAVerifier(publicKey)
6061
}.any { signedJWT.verify(it) }
6162

62-
private fun getPublicKeys(): List<ApplePublicKey> =
63+
private fun getPublicKeys(): ApplePublicKeyResponse =
6364
restClient
6465
.get()
6566
.uri("$APPLE_URI/auth/keys")
6667
.retrieve()
67-
.requiredBody<List<ApplePublicKey>>()
68+
.requiredBody<ApplePublicKeyResponse>()
6869
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.gotchai.infrastructure.oauth.dto
2+
3+
data class ApplePublicKeyResponse(
4+
val keys: List<ApplePublicKey>
5+
)

storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/exam/adapter/out/ExamQueryAdapter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ExamQueryAdapter(
1919

2020
@ReadOnlyTransactional
2121
override fun getExamsByInIn(ids: Collection<Long>): List<Exam> =
22-
examJpaRepository.findByIdIn(ids)
22+
examJpaRepository
23+
.findByIdIn(ids)
2324
.map { it.toExam() }
2425
}

storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/exam/adapter/out/ExamResultQueryAdapter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ExamResultQueryAdapter(
1010
private val examResultJpaRepository: ExamResultJpaRepository
1111
) : ExamResultQueryPort {
1212
override fun getExamResultsByUserId(userId: Long): List<ExamResult> =
13-
examResultJpaRepository.findExamResultsByUserId(userId)
13+
examResultJpaRepository
14+
.findExamResultsByUserId(userId)
1415
.map { it.toExamResult() }
1516
}

0 commit comments

Comments
 (0)