feat(live): 인증 헤더 헬퍼를 추가한다

This commit is contained in:
2026-06-26 23:42:41 +09:00
parent 0943237b5f
commit e13da00215
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
package kr.co.vividnext.sodalive.v2.live.onair.model
fun homeOnAirLiveAuthHeader(token: String): String? = token
.trim()
.takeIf { it.isNotEmpty() }
?.let { "Bearer $it" }

View File

@@ -0,0 +1,25 @@
package kr.co.vividnext.sodalive.v2.live.onair
import kr.co.vividnext.sodalive.v2.live.onair.model.homeOnAirLiveAuthHeader
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class HomeOnAirLiveAuthHeaderTest {
@Test
fun `blank token은 null을 반환한다`() {
assertNull(homeOnAirLiveAuthHeader(""))
assertNull(homeOnAirLiveAuthHeader(" "))
}
@Test
fun `non blank token은 Bearer header를 반환한다`() {
assertEquals("Bearer token-1", homeOnAirLiveAuthHeader("token-1"))
}
@Test
fun `token 앞뒤 공백은 trim 후 Bearer header를 반환한다`() {
assertEquals("Bearer token-1", homeOnAirLiveAuthHeader(" token-1 "))
}
}