收紧 SSH 命令护栏、权限校验与远程执行会话,并同步主流大模型供应商列表。 Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
567 B
Go
26 lines
567 B
Go
package tools
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestBoundedSSHTimeout(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
in time.Duration
|
|
want time.Duration
|
|
}{
|
|
{name: "non-positive", in: 0, want: time.Second},
|
|
{name: "normal", in: 60 * time.Second, want: 60 * time.Second},
|
|
{name: "too-large", in: 24 * time.Hour, want: 300 * time.Second},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := boundedSSHTimeout(tc.in); got != tc.want {
|
|
t.Fatalf("boundedSSHTimeout(%v)=%v, want %v", tc.in, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|