Initial commit (code only without large binaries)
This commit is contained in:
33
EdgeNode/internal/js/lib_crypto_hmac_test.go
Normal file
33
EdgeNode/internal/js/lib_crypto_hmac_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
//go:build script
|
||||
// +build script
|
||||
|
||||
package js_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/js"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestJSHMACCryptoLibrary_NewHMAC(t *testing.T) {
|
||||
isolate, err := js.NewIsolate()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, err := isolate.GetContext()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer ctx.Done()
|
||||
|
||||
v, err := ctx.Run(`
|
||||
let h = new gojs.crypto.HMAC("sha1", "")
|
||||
h.update("123456")
|
||||
h.sum()
|
||||
`, "hmac.js")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(v)
|
||||
}
|
||||
Reference in New Issue
Block a user