RC-2 passing all tests in js too

This commit is contained in:
Sergey Chernov 2022-12-02 21:32:58 +01:00
parent 3a65080db3
commit d6d479f853
10 changed files with 53 additions and 1439 deletions

View File

@ -37,6 +37,11 @@ kotlin {
commonWebpackConfig {
cssSupport.enabled = true
}
testTask {
useMocha {
timeout = "30000"
}
}
}
}
sourceSets {
@ -46,7 +51,8 @@ kotlin {
api("net.sergeych:unikrypto:1.2.2-SNAPSHOT")
api("net.sergeych:parsec3:0.3.3-SNAPSHOT")
api("net.sergeych:boss-serialization-mp:0.2.4-SNAPSHOT")
3 }
api("net.sergeych:unikrypto:1.2.2-SNAPSHOT")
}
}
val commonTest by getting {
dependencies {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
package net.sergeych.superlogin
/**
* Call it somewhere in th application before using any crypto-based methods.
* Currently, it is mandatory for JS and is not needed on JVM platform, but
* we recommend to call it anyway
*/
expect suspend fun initOperations()

View File

@ -2,6 +2,7 @@ package superlogin
import kotlinx.coroutines.test.runTest
import net.sergeych.superlogin.AccessControlObject
import net.sergeych.superlogin.initOperations
import net.sergeych.unikrypto.SymmetricKeys
import kotlin.test.Test
import kotlin.test.assertEquals
@ -12,6 +13,8 @@ internal class AccessControlObjectTest {
@Test
fun createRestoreTest() = runTest {
initOperations()
val pk1 = SymmetricKeys.random()
val pk2 = SymmetricKeys.random()
val (rk, packed1) = AccessControlObject.pack(pk1, 117)
@ -37,7 +40,6 @@ internal class AccessControlObjectTest {
assertEquals(121, ac21.payload)
packed3 = ac1.updatePasswordKey(pk2).packed
println("-------")
ac21 = AccessControlObject.unpackWithKey(packed3,pk2)
assertNotNull(ac21)
assertEquals(117, ac21.payload)

View File

@ -2,16 +2,18 @@ package superlogin
import kotlinx.coroutines.test.runTest
import net.sergeych.superlogin.RestoreKey
import kotlin.test.*
import net.sergeych.superlogin.initOperations
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertFails
internal class RestoreKeyTest {
@Test
fun checkRestoreKey() = runTest {
initOperations()
val rk = RestoreKey.generate()
println(rk.secret)
println(rk.restoreId)
println(rk.key)
val (id, k) = RestoreKey.parse(rk.secret)
assertContentEquals(rk.restoreId, id)

View File

@ -0,0 +1,9 @@
package net.sergeych.superlogin
import kotlinx.coroutines.await
import net.sergeych.unikrypto.Unicrypto
actual suspend fun initOperations() {
// library uses sync operations from unicrypto so:
Unicrypto.unicryptoReady.await()
}

View File

@ -0,0 +1,5 @@
package net.sergeych.superlogin
actual suspend fun initOperations() {
// Java version currently does not need initialization
}

View File

@ -1,8 +0,0 @@
package net.sergeych.superlogin.server
import net.sergeych.parsec3.CommandHost
/**
* Server-side API convenience base.
*/
open class SLServerApiBase<D>: CommandHost<SLServerSession<D>>()

View File

@ -183,7 +183,6 @@ internal class WsServerKtTest {
assertEquals("foo", slc.call(api.loginName))
slc.logout()
println(secret)
assertNull(slc.resetPasswordAndLogin("bad_secret", "newpass2"))
assertNull(slc.resetPasswordAndLogin("3PBpp-Aris5-ogdV7-Abz36-ggGH5", "newpass2"))
ar = slc.resetPasswordAndLogin(secret,"newpass2")

View File

@ -0,0 +1,4 @@
config.resolve.alias = {
"crypto": false,
"path": false,
}