feat: add client self-service purchases and integration kit
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
@@ -56,6 +56,20 @@ func TestIntegrationInputs(t *testing.T) {
|
||||
if spec["openapi"] != "3.0.3" {
|
||||
t.Fatal("invalid OpenAPI")
|
||||
}
|
||||
paths := spec["paths"].(map[string]any)
|
||||
kit := buildIntegrationKit("nodejs", "desktop")
|
||||
for _, path := range []string{"/api/v1/client/plans", "/api/v1/client/purchases", "/api/v1/client/purchases/status", "/api/v1/client/purchases/claim"} {
|
||||
found := false
|
||||
for _, endpoint := range kit.Endpoints {
|
||||
found = found || endpoint.Path == path
|
||||
}
|
||||
if paths[path] == nil || !found {
|
||||
t.Fatalf("missing purchase contract: %s", path)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(kit.Prompt, "installation_id") || !strings.Contains(kit.Prompt, "claim 返回") {
|
||||
t.Fatal("missing purchase instructions")
|
||||
}
|
||||
}
|
||||
func TestIntegrationArchiveAndSignatures(t *testing.T) {
|
||||
const public = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESr8/VFFwt70o7fwa8HiRNyxWtZEu\nUqzCBfYRG72DazEgeOaSVAdlTv49OujtggXSJzFLOluMENJzaRmp9+iJ0Q==\n-----END PUBLIC KEY-----\n"
|
||||
@@ -78,7 +92,7 @@ func TestIntegrationArchiveAndSignatures(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(archive.File) != 12 {
|
||||
if len(archive.File) != 17 {
|
||||
t.Fatal("missing files")
|
||||
}
|
||||
for _, file := range archive.File {
|
||||
@@ -106,7 +120,13 @@ func TestIntegrationArchiveAndSignatures(t *testing.T) {
|
||||
if file.Name == "client/update-sdk.mjs" && !strings.Contains(string(content), "verifyCheck") {
|
||||
t.Fatal("missing Node SDK")
|
||||
}
|
||||
if strings.HasSuffix(file.Name, ".md") && (strings.Contains(string(content), "verify.mjs") || strings.Contains(string(content), `"arch":"amd64"`)) {
|
||||
if file.Name == "client/purchase-sdk.mjs" && !strings.Contains(string(content), "class PurchaseClient") {
|
||||
t.Fatal("missing purchase SDK")
|
||||
}
|
||||
if file.Name == "purchase.md" && !strings.Contains(string(content), "/api/v1/client/purchases/claim") {
|
||||
t.Fatal("missing purchase protocol")
|
||||
}
|
||||
if strings.HasSuffix(file.Name, ".md") && strings.Contains(string(content), `"arch":"amd64"`) {
|
||||
t.Fatal("invalid reference or architecture")
|
||||
}
|
||||
if file.Name == "README.md" && (!strings.Contains(string(content), "requirements.txt") || !strings.Contains(string(content), "不支持 Range")) {
|
||||
@@ -147,7 +167,7 @@ func TestIntegrationArchiveAndSignatures(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIntegrationSDKCopies(t *testing.T) {
|
||||
for _, name := range []string{"update_sdk.py", "update-sdk.mjs", "test_update_sdk.py", "test-update-sdk.mjs", "requirements.txt"} {
|
||||
for _, name := range []string{"update_sdk.py", "update-sdk.mjs", "test_update_sdk.py", "test-update-sdk.mjs", "requirements.txt", "purchase-sdk.mjs", "verify.mjs", "test-purchase-sdk.mjs", "purchase-sdk.md"} {
|
||||
source, err := os.ReadFile("../../../client/" + name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user