Files
wanderer/db/util/network_test.go
slothful-vassal 485ec53f6d feat: add plugin system (#1034)
* feat: add plugin system

* fix db docker build

* fix hammerhead readme, add strava subscription news to docs

* fixes and sdk improvements

* fix: reduce Meilisearch load, debounce federation sync (#1012)

* optimize meili trail index

* several fixes

---------

Co-authored-by: Flomp <Flomp@users.noreply.github.com>

* Bump svelte from 5.55.5 to 5.56.0 in /docs (#1032)

Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 5.55.5 to 5.56.0.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/main/packages/svelte/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@5.56.0/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-version: 5.56.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Flomp <Flomp@users.noreply.github.com>

* Release v0.19.2 (#1035)

* chore: release v0.19.2

* add changelog

---------

Co-authored-by: Flomp <26000991+Flomp@users.noreply.github.com>
Co-authored-by: Christian Beutel <>

* speed up plugin sync and several small fixes

* concepts for security improvements and process stability

* improve concept

* security concept implemented

* remove insecure TLS

* worker concept implemented

* fixes and cleanup

* fixes

* docu

* mermaid, namings

* WASM plugin host improvements, plugin logging

* fix db migration

* Improve plugin config and category mapping UI

* fixes

* further fixes

* remove manual test sync

* fix db migration and strava mapping

* type added, UI improvements

* fix plugin card toggle clickable area

* optimize synch status card layout

* plugin type 'trails' instead of 'integration'

* session auth validation in UI

* fix komoot date and waypoints

* improve category mapping

* fix send to hammerhead: trail name

* plugin setup error handling improved

* fix review findings

* re-mapping added

* rename remote_category

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Flomp <Flomp@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Flomp <26000991+Flomp@users.noreply.github.com>
2026-06-22 15:00:44 +02:00

69 lines
1.9 KiB
Go

package util
import (
"bytes"
"context"
"net"
"testing"
)
func TestFetchPublicURLRejectsUnsafeInputs(t *testing.T) {
tests := []string{
"ftp://example.com/file.jpg",
"http://user:pass@example.com/file.jpg",
"http://127.0.0.1/file.jpg",
"http://localhost/file.jpg",
"http://10.0.0.1/file.jpg",
"http://169.254.169.254/latest/meta-data",
"http://[::1]/file.jpg",
"http://[fc00::1]/file.jpg",
"http://example.com:8080/file.jpg",
}
for _, rawURL := range tests {
t.Run(rawURL, func(t *testing.T) {
if _, err := FetchPublicURL(context.Background(), rawURL, 1024); err == nil {
t.Fatal("expected error")
}
})
}
}
func TestReadBoundedForPlugin(t *testing.T) {
if _, err := ReadBoundedForPlugin(bytes.NewReader([]byte("1234")), 4); err != nil {
t.Fatalf("unexpected exact-limit error: %v", err)
}
if _, err := ReadBoundedForPlugin(bytes.NewReader([]byte("12345")), 4); err == nil {
t.Fatal("expected oversized response error")
}
}
func TestConnectorTLSConfigRejectsInsecureMode(t *testing.T) {
if _, err := connectorTLSConfig("insecure", nil); err == nil {
t.Fatal("expected insecure TLS mode to be rejected")
}
}
func TestConnectorIPAllowed(t *testing.T) {
tests := []struct {
ip string
allowPrivate bool
want bool
}{
{ip: "8.8.8.8", want: true},
{ip: "10.0.0.1", want: false},
{ip: "10.0.0.1", allowPrivate: true, want: true},
{ip: "fc00::1", allowPrivate: true, want: true},
{ip: "127.0.0.1", allowPrivate: true, want: false},
{ip: "169.254.1.1", allowPrivate: true, want: false},
{ip: "100.64.0.1", allowPrivate: true, want: false},
{ip: "192.0.2.1", allowPrivate: true, want: false},
}
for _, test := range tests {
t.Run(test.ip, func(t *testing.T) {
if got := connectorIPAllowed(net.ParseIP(test.ip), test.allowPrivate); got != test.want {
t.Fatalf("got %v, want %v", got, test.want)
}
})
}
}