Выпуск WDTT Plus v16
This commit is contained in:
1 parent
3038b8ddc0
commit
4be5f36c88
102 files changed
+21554
-1427
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -421,6 +422,43 @@ func TestClientPasswordValidation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadAdminPasswordLine(t *testing.T) {
|
||||
for _, input := range []string{"ABCDEFGHJKLMNPQR\n", "ABCDEFGHJKLMNPQR\r\n", "ABCDEFGHJKLMNPQR"} {
|
||||
value, err := readAdminPasswordLine(strings.NewReader(input))
|
||||
if err != nil {
|
||||
t.Fatalf("valid password input %q rejected: %v", input, err)
|
||||
}
|
||||
if value != "ABCDEFGHJKLMNPQR" {
|
||||
t.Fatalf("unexpected password value %q", value)
|
||||
}
|
||||
}
|
||||
for _, input := range []string{"", "\n", "first\nsecond\n", strings.Repeat("x", 258)} {
|
||||
if _, err := readAdminPasswordLine(strings.NewReader(input)); err == nil {
|
||||
t.Fatalf("invalid password input %q accepted", input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadAdminRequest(t *testing.T) {
|
||||
request, err := readAdminRequest(strings.NewReader(`{"main_password":"secret-value","args":["create","--days","30"]}`))
|
||||
if err != nil {
|
||||
t.Fatalf("valid request rejected: %v", err)
|
||||
}
|
||||
if request.MainPassword != "secret-value" || !reflect.DeepEqual(request.Args, []string{"create", "--days", "30"}) {
|
||||
t.Fatalf("unexpected request: %#v", request)
|
||||
}
|
||||
for _, input := range []string{
|
||||
`{}`,
|
||||
`{"main_password":"secret-value"}`,
|
||||
`{"args":["list"]}`,
|
||||
`not-json`,
|
||||
} {
|
||||
if _, err := readAdminRequest(strings.NewReader(input)); err == nil {
|
||||
t.Fatalf("invalid request %q accepted", input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminCreateRejectsPasswordConflicts(t *testing.T) {
|
||||
configDir := t.TempDir()
|
||||
loaded := &Database{
|
||||
|
||||
Reference in new issue
Block a user