feat: import Sea vHost single-server testing release
This commit is contained in:
commit
248badd33e
441 files changed
+63221
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package panel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestManagedACMEIndexUsesNativePythonJSON(t *testing.T) {
|
||||
raw := `[{"type": "dns", "value": "a.example.com"}, {"type": "dns", "value": "b.example.com"}]`
|
||||
sum := md5.Sum([]byte(raw))
|
||||
if got := managedACMEIndex([]string{"a.example.com", "b.example.com"}); got != hex.EncodeToString(sum[:]) {
|
||||
t.Fatal("native order index mismatch", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearManagedCertificateOrderIsScopedAndIdempotent(t *testing.T) {
|
||||
calls := 0
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = r.ParseForm()
|
||||
calls++
|
||||
if r.URL.Path != "/acme" || r.Form.Get("action") != "remove_order" || r.Form.Get("index") != "owned-order" {
|
||||
t.Error("unexpected order mutation")
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"status":false,"msg":"指定订单不存在!"}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
c := NewClient(server.URL, "test-key", false, time.Second)
|
||||
if err := c.ClearManagedCertificateOrder(context.Background(), "../foreign"); err == nil || calls != 0 {
|
||||
t.Fatal("invalid index reached panel")
|
||||
}
|
||||
if err := c.ClearManagedCertificateOrder(context.Background(), "owned-order"); err != nil || calls != 1 {
|
||||
t.Fatal("missing owned order retry failed", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user