Skip to content

Commit

Permalink
Version two with snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Oct 9, 2023
1 parent cac3893 commit 9c518d2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion demo/src/main/kotlin/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ object Server : ServerPathGroup(ServerPath.root) {

val multiplex = path("multiplex").websocket(MultiplexWebSocketHandler(cache))

val meta = path("meta").metaEndpoints<Unit>()
val meta = path("meta").metaEndpoints()

val weirdAuth = path("weird-auth").get.typed(
summary = "Get weird auth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class AuthEndpointsForSubject<SUBJECT : HasId<ID>, ID : Comparable<ID>>(
errorCases = listOf(),
implementation = { futureSessionToken: String ->
val future = FutureSession.fromToken(futureSessionToken)
if(future.oauthClient != null) throw ForbiddenException("Please use the token endpoint for OAuth instead, so we can check your secret.")
val (s, secret) = newSessionPrivate(
label = future.label,
subjectId = future.subjectId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.lightningkite.lightningserver.auth.proof

import com.lightningkite.lightningserver.TestSettings
import com.lightningkite.lightningserver.email.Email
import com.lightningkite.lightningserver.email.EmailLabeledValue
import com.lightningkite.lightningserver.email.TestEmailClient
import com.lightningkite.lightningserver.serialization.Serialization
import io.ktor.http.*
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.encodeToString
import org.junit.Assert.*
import org.junit.Test
import java.util.Base64

class EmailProofEndpointsTest {
@Test fun test(): Unit = runBlocking {
TestSettings.proofEmail.send("[email protected]") { proof ->
Email(
to = listOf(EmailLabeledValue("[email protected]")),
subject = "Login",
plainText = """
|Test got proof
|${Serialization.json.encodeToString(proof).encodeURLQueryComponent()}
|${Serialization.json.encodeToString(proof).let{ Base64.getEncoder().encodeToString(it.toByteArray()) }}
|""".trimMargin()
)
}
assertNotNull(TestEmailClient.lastEmailSent)
TestEmailClient.lastEmailSent?.plainText?.let { println(it) }
}
}

0 comments on commit 9c518d2

Please sign in to comment.