Import Anubis v1.28.2
Replace the tree with upstream TecharoHQ/anubis v1.28.2 (a1384fbf42e3). Masyunis customizations are re-applied in the following commits.
This commit is contained in:
1 parent
eb3e46d8d0
commit
e07de898cd
573 files changed
+35846
-6807
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
func TestHS512SecretMinimumLength(t *testing.T) {
|
||||
for _, size := range []int{0, 1, 32, 63, 64, 128} {
|
||||
t.Run(fmt.Sprint(size), func(t *testing.T) {
|
||||
secret := bytes.Repeat([]byte("x"), size)
|
||||
if size == 0 {
|
||||
secret = nil
|
||||
}
|
||||
srv, err := New(Options{Next: http.NewServeMux(), Policy: loadPolicies(t, "testdata/zero_difficulty.yaml", 0), HS512Secret: secret})
|
||||
if size > 0 && size < 64 {
|
||||
if err == nil {
|
||||
t.Errorf("accepted %d-byte HS512 key", size)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := srv.signJWT(jwt.MapClaims{}); err != nil {
|
||||
t.Fatalf("valid signing configuration failed: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user