mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00

* cleanup code for URL type * fix makefile for trace mode * refactor, merge Entry, RawEntry and Route into one. * Implement fileserver. * refactor: rename HTTPRoute to ReverseProxyRoute to avoid confusion * refactor: move metrics logger to middleware package - fix prometheus metrics for load balanced routes - route will now fail when health monitor fail to start * fix extra output of ls-* commands by defer initializaing stuff, speed up start time * add test for path traversal attack, small fix on FileServer.Start method * rename rule.on.bypass to pass * refactor and fixed map-to-map deserialization * updated route loading logic * schemas: add "add_prefix" option to modify_request middleware * updated route JSONMarshalling --------- Co-authored-by: yusing <yusing@6uo.me>
36 lines
838 B
Go
36 lines
838 B
Go
package provider
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/yusing/go-proxy/internal/docker"
|
|
. "github.com/yusing/go-proxy/internal/utils/testing"
|
|
"gopkg.in/yaml.v3"
|
|
|
|
_ "embed"
|
|
)
|
|
|
|
//go:embed docker_labels.yaml
|
|
var testDockerLabelsYAML []byte
|
|
|
|
func TestParseDockerLabels(t *testing.T) {
|
|
var provider DockerProvider
|
|
|
|
labels := make(map[string]string)
|
|
ExpectNoError(t, yaml.Unmarshal(testDockerLabelsYAML, &labels))
|
|
|
|
routes, err := provider.routesFromContainerLabels(
|
|
docker.FromDocker(&types.Container{
|
|
Names: []string{"container"},
|
|
Labels: labels,
|
|
State: "running",
|
|
Ports: []types.Port{
|
|
{Type: "tcp", PrivatePort: 1234, PublicPort: 1234},
|
|
},
|
|
}, "/var/run/docker.sock"),
|
|
)
|
|
ExpectNoError(t, err)
|
|
ExpectTrue(t, routes.Contains("app"))
|
|
ExpectTrue(t, routes.Contains("app1"))
|
|
}
|