- Introduced test files for the blossom and database packages to improve test coverage and ensure functionality. - Updated logging practices by suppressing unnecessary log outputs during tests to enhance clarity and focus on relevant information. - Refactored error handling in the `handle-message` and `handle-req` functions to avoid logging expected context cancellation errors during shutdown. - Bumped version to v0.25.2 to reflect these updates.
34 lines
662 B
Go
34 lines
662 B
Go
package auth
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"lol.mleku.dev/chk"
|
|
"next.orly.dev/pkg/interfaces/signer/p8k"
|
|
)
|
|
|
|
func TestCreateUnsigned(t *testing.T) {
|
|
var err error
|
|
signer := p8k.MustNew()
|
|
if err = signer.Generate(); chk.E(err) {
|
|
t.Fatal(err)
|
|
}
|
|
var ok bool
|
|
const relayURL = "wss://example.com"
|
|
for range 100 {
|
|
challenge := GenerateChallenge()
|
|
ev := CreateUnsigned(signer.Pub(), challenge, relayURL)
|
|
if err = ev.Sign(signer); chk.E(err) {
|
|
t.Fatal(err)
|
|
}
|
|
// log.I.S(ev)
|
|
if ok, err = Validate(ev, challenge, relayURL); chk.E(err) {
|
|
t.Fatal(err)
|
|
}
|
|
if !ok {
|
|
bb := ev.Marshal(nil)
|
|
t.Fatalf("failed to validate auth event\n%s", bb)
|
|
}
|
|
}
|
|
}
|