RC-2 passing all tests in js too
This commit is contained in:
parent
3a65080db3
commit
d6d479f853
@ -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
8
src/commonMain/kotlin/net.sergeych.superlogin/init.kt
Normal file
8
src/commonMain/kotlin/net.sergeych.superlogin/init.kt
Normal 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()
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package net.sergeych.superlogin
|
||||
|
||||
actual suspend fun initOperations() {
|
||||
// Java version currently does not need initialization
|
||||
}
|
@ -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>>()
|
@ -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")
|
||||
|
4
webpack.config.d/patch.js
Normal file
4
webpack.config.d/patch.js
Normal file
@ -0,0 +1,4 @@
|
||||
config.resolve.alias = {
|
||||
"crypto": false,
|
||||
"path": false,
|
||||
}
|
Loading…
Reference in New Issue
Block a user