Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
This commit is contained in:
1 parent
288e6e94ac
commit
c1175d389f
699 files changed
+110197
-4117
No files matched your search
@@ -0,0 +1,72 @@
|
||||
package server
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateAdapterPlugin(t *testing.T) {
|
||||
plugin := adapterPlugin{
|
||||
ID: "Code.Server", Name: "code-server", Mode: "editor",
|
||||
URLTemplate: "https://code.example.test/open?ticket={ticket}&origin={origin}",
|
||||
Extensions: []string{"md", ".txt"},
|
||||
Enabled: true,
|
||||
}
|
||||
if err := validateAdapterPlugin(&plugin); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if plugin.ID != "code.server" || plugin.Extensions[0] != ".md" {
|
||||
t.Fatalf("normalized plugin = %#v", plugin)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkspaceFilenamePreservesHierarchyAndMarkdownExtension(t *testing.T) {
|
||||
if got := workspaceFilename("/guide/install", "/guide", "install.html", true); got != "install.md" {
|
||||
t.Fatalf("child workspace filename = %q", got)
|
||||
}
|
||||
if got := workspaceFilename("/guide/linux/setup", "/guide", "setup.py", false); got != "linux/setup.py" {
|
||||
t.Fatalf("nested workspace filename = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateAdapterPluginRejectsUnsafeOrUnboundTemplate(t *testing.T) {
|
||||
tests := []adapterPlugin{
|
||||
{ID: "bad.scheme", Name: "Bad", Mode: "viewer", URLTemplate: "javascript:{path}"},
|
||||
{ID: "native.todo", Name: "Vim", Mode: "native", URLTemplate: "vim:{path}"},
|
||||
{ID: "no.binding", Name: "Bad", Mode: "viewer", URLTemplate: "https://example.invalid/open"},
|
||||
{ID: "bad.mode", Name: "Bad", Mode: "execute", URLTemplate: "https://example.invalid/{url}"},
|
||||
{ID: "editor.raw", Name: "Bad", Mode: "editor", URLTemplate: "https://example.invalid/{url}"},
|
||||
}
|
||||
for _, plugin := range tests {
|
||||
if err := validateAdapterPlugin(&plugin); err == nil {
|
||||
t.Fatalf("plugin unexpectedly accepted: %#v", plugin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginMatchesMimeWildcardAndExtension(t *testing.T) {
|
||||
plugin := adapterPlugin{
|
||||
Enabled: true, MediaTypes: []string{"image/*"}, Extensions: []string{".drawio"},
|
||||
}
|
||||
if !pluginMatches(plugin, "image/png", "image.bin") {
|
||||
t.Fatal("MIME wildcard did not match")
|
||||
}
|
||||
if !pluginMatches(plugin, "application/xml", "diagram.drawio") {
|
||||
t.Fatal("extension did not match")
|
||||
}
|
||||
if pluginMatches(plugin, "text/plain", "notes.txt") {
|
||||
t.Fatal("unrelated document matched")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginMatchesNeverOffersLegacyNativeAdapter(t *testing.T) {
|
||||
plugin := adapterPlugin{Enabled: true, Mode: "native"}
|
||||
if pluginMatches(plugin, "text/plain", "notes.txt") {
|
||||
t.Fatal("legacy native adapter was offered as a runtime action")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateAdapterPluginRejectsLegacyEditorWithoutTicket(t *testing.T) {
|
||||
plugin := adapterPlugin{ID: "vscode", Name: "VS Code", Mode: "editor",
|
||||
URLTemplate: "vscode://file/{url}", Enabled: true}
|
||||
if err := validateAdapterPlugin(&plugin); err == nil {
|
||||
t.Fatal("legacy executable URL was accepted")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user