Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

test(plugins): make unloadable-package tests use a mismatched slug

Gabe Kangas60d8cd5848e3
diff --git a/pluginhost/registry_test.go b/pluginhost/registry_test.go
index 89289870de..5d27a6954e 100644
--- a/pluginhost/registry_test.go
+++ b/pluginhost/registry_test.go
@@ -286,9 +286,13 @@ func TestHandleRegistryInstall_Success(t *testing.T) {
func TestHandleRegistryInstall_RejectsUnloadablePackage(t *testing.T) {
wasmPath := findExampleWasm(t)
wasmBytes, _ := os.ReadFile(wasmPath)
+ // Package the hello-world wasm under a slug it does NOT bake into its
+ // register() output, so the manifest/runtime agreement check fails (the
+ // wasm reports slug "hello-world"; the package claims "ghost-plugin").
pkg := buildPackageBytes(t, []byte(`{
"api": "1",
- "name": "hello-world",
+ "name": "Ghost Plugin",
+ "slug": "ghost-plugin",
"version": "9.9.9",
"description": "mismatched manifest/runtime for registry install",
"permissions": []
@@ -296,13 +300,13 @@ func TestHandleRegistryInstall_RejectsUnloadablePackage(t *testing.T) {
sum := sha256.Sum256(pkg)
sha := hex.EncodeToString(sum[:])
- upstream := newRegistryStub(t, "hello-world", "9.9.9", pkg, sha)
+ upstream := newRegistryStub(t, "ghost-plugin", "9.9.9", pkg, sha)
withRegistryEnv(t, upstream.URL)
host := newTestHost(t)
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodPost, "/api/admin/plugin-registry/install",
- strings.NewReader(`{"slug":"hello-world","version":"9.9.9"}`))
+ strings.NewReader(`{"slug":"ghost-plugin","version":"9.9.9"}`))
host.handleRegistryInstall(rec, req)
if rec.Code != http.StatusBadRequest {
diff --git a/services/plugins/hostfns.go b/services/plugins/hostfns.go
index 4523d76322..78db16d8ae 100644
--- a/services/plugins/hostfns.go
+++ b/services/plugins/hostfns.go
@@ -540,8 +540,8 @@ func hostTimerSet(env *HostEnv, pluginName string) extism.HostFunction {
stack[0] = 0
}
},
- []extism.ValueType{extism.ValueTypeI64, extism.ValueTypeI64, extism.ValueTypeI32},
- []extism.ValueType{extism.ValueTypeI32},
+ []extism.ValueType{extism.ValueTypeI64, extism.ValueTypeI64, extism.ValueTypeI64},
+ []extism.ValueType{extism.ValueTypeI64},
)
fn.SetNamespace("extism:host/user")
return fn
@@ -713,7 +713,7 @@ func hostUserSetEnabled(env *HostEnv, pluginName string) extism.HostFunction {
env.SetUserEnabled(pluginName, id, enabled, reason)
}
},
- []extism.ValueType{extism.ValueTypePTR, extism.ValueTypeI32, extism.ValueTypePTR},
+ []extism.ValueType{extism.ValueTypePTR, extism.ValueTypeI64, extism.ValueTypePTR},
[]extism.ValueType{},
)
fn.SetNamespace("extism:host/user")
@@ -1175,7 +1175,7 @@ func hostFSExists(env *HostEnv, pluginName string) extism.HostFunction {
}
},
[]extism.ValueType{extism.ValueTypePTR},
- []extism.ValueType{extism.ValueTypeI32},
+ []extism.ValueType{extism.ValueTypeI64},
)
fn.SetNamespace("extism:host/user")
return fn
@@ -1287,7 +1287,7 @@ func hostChatHistory(env *HostEnv) extism.HostFunction {
}
stack[0] = offset
},
- []extism.ValueType{extism.ValueTypeI32},
+ []extism.ValueType{extism.ValueTypeI64},
[]extism.ValueType{extism.ValueTypePTR},
)
fn.SetNamespace("extism:host/user")
diff --git a/services/plugins/manager_test.go b/services/plugins/manager_test.go
index 24f31b6725..2e7238a1d1 100644
--- a/services/plugins/manager_test.go
+++ b/services/plugins/manager_test.go
@@ -524,9 +524,12 @@ func TestManager_Install_RejectsUnloadablePackage(t *testing.T) {
wasmBytes, _ := os.ReadFile(wasmPath)
mgr := NewManager(t.TempDir(), &HostEnv{})
+ // Package the wasm under a slug it does not bake into register() so the
+ // manifest/runtime agreement check fails (the wasm reports "hello-world").
pkg := buildPackageBytes(t, []byte(`{
"api": "1",
- "name": "hello-world",
+ "name": "Ghost Plugin",
+ "slug": "ghost-plugin",
"version": "9.9.9",
"description": "mismatched manifest/runtime for install preflight",
"permissions": []