Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Aug 8, 2024
1 parent 66962e3 commit cf67844
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions service/src/main/kotlin/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ internal fun Headers.getApiAndSecretKey(): Pair<String?, String?> {
return null to null
}
try {
val segmentedAuthValue = authHeaderValue
.substring("Basic ".length)
.decodeBase64String()
.split(":")
val segmentedAuthValue =
authHeaderValue
.substring("Basic ".length)
.decodeBase64String()
.split(":")
if (segmentedAuthValue.size < 2) {
return null to null
}
Expand Down
8 changes: 4 additions & 4 deletions service/src/test/kotlin/ServerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import kotlin.test.Test
import kotlin.test.assertEquals

class ServerTest {

@Test
fun `test get api and secret key`() {
val apiKey = "api"
val secretKey = "secret"
val headers = Headers.build {
set("Authorization", "Basic ${"$apiKey:$secretKey".encodeBase64()}")
}
val headers =
Headers.build {
set("Authorization", "Basic ${"$apiKey:$secretKey".encodeBase64()}")
}

val result = headers.getApiAndSecretKey()
assertEquals(apiKey, result.first)
Expand Down

0 comments on commit cf67844

Please sign in to comment.