mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00
update docker test
This commit is contained in:
parent
c3b779a810
commit
1bac96dc2a
1 changed files with 64 additions and 62 deletions
|
@ -235,73 +235,75 @@ func TestExplicitExclude(t *testing.T) {
|
|||
ExpectFalse(t, ok)
|
||||
}
|
||||
|
||||
func TestImplicitExclude(t *testing.T) {
|
||||
var p DockerProvider
|
||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||
Names: dummyNames,
|
||||
Labels: map[string]string{
|
||||
D.LabelAliases: "a",
|
||||
"proxy.a.no_tls_verify": "true",
|
||||
},
|
||||
State: "running",
|
||||
}, ""))
|
||||
ExpectNoError(t, err.Error())
|
||||
//! Now nothing will be implicit excluded
|
||||
//
|
||||
// func TestImplicitExclude(t *testing.T) {
|
||||
// var p DockerProvider
|
||||
// entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||
// Names: dummyNames,
|
||||
// Labels: map[string]string{
|
||||
// D.LabelAliases: "a",
|
||||
// "proxy.a.no_tls_verify": "true",
|
||||
// },
|
||||
// State: "running",
|
||||
// }, ""))
|
||||
// ExpectNoError(t, err.Error())
|
||||
|
||||
_, ok := entries.Load("a")
|
||||
ExpectFalse(t, ok)
|
||||
}
|
||||
// _, ok := entries.Load("a")
|
||||
// ExpectFalse(t, ok)
|
||||
// }
|
||||
|
||||
func TestImplicitExcludeNoExposedPort(t *testing.T) {
|
||||
var p DockerProvider
|
||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||
Image: "redis",
|
||||
Names: []string{"redis"},
|
||||
Ports: []types.Port{
|
||||
{Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||
},
|
||||
State: "running",
|
||||
}, ""))
|
||||
ExpectNoError(t, err.Error())
|
||||
// func TestImplicitExcludeNoExposedPort(t *testing.T) {
|
||||
// var p DockerProvider
|
||||
// entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||
// Image: "redis",
|
||||
// Names: []string{"redis"},
|
||||
// Ports: []types.Port{
|
||||
// {Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||
// },
|
||||
// State: "running",
|
||||
// }, ""))
|
||||
// ExpectNoError(t, err.Error())
|
||||
|
||||
_, ok := entries.Load("redis")
|
||||
ExpectFalse(t, ok)
|
||||
}
|
||||
// _, ok := entries.Load("redis")
|
||||
// ExpectFalse(t, ok)
|
||||
// }
|
||||
|
||||
func TestNotExcludeSpecifiedPort(t *testing.T) {
|
||||
var p DockerProvider
|
||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||
Image: "redis",
|
||||
Names: []string{"redis"},
|
||||
Ports: []types.Port{
|
||||
{Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"proxy.redis.port": "6379:6379", // but specified in label
|
||||
},
|
||||
}, ""))
|
||||
ExpectNoError(t, err.Error())
|
||||
// func TestNotExcludeSpecifiedPort(t *testing.T) {
|
||||
// var p DockerProvider
|
||||
// entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||
// Image: "redis",
|
||||
// Names: []string{"redis"},
|
||||
// Ports: []types.Port{
|
||||
// {Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||
// },
|
||||
// Labels: map[string]string{
|
||||
// "proxy.redis.port": "6379:6379", // but specified in label
|
||||
// },
|
||||
// }, ""))
|
||||
// ExpectNoError(t, err.Error())
|
||||
|
||||
_, ok := entries.Load("redis")
|
||||
ExpectTrue(t, ok)
|
||||
}
|
||||
// _, ok := entries.Load("redis")
|
||||
// ExpectTrue(t, ok)
|
||||
// }
|
||||
|
||||
func TestNotExcludeNonExposedPortHostNetwork(t *testing.T) {
|
||||
var p DockerProvider
|
||||
cont := &types.Container{
|
||||
Image: "redis",
|
||||
Names: []string{"redis"},
|
||||
Ports: []types.Port{
|
||||
{Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"proxy.redis.port": "6379:6379",
|
||||
},
|
||||
}
|
||||
cont.HostConfig.NetworkMode = "host"
|
||||
// func TestNotExcludeNonExposedPortHostNetwork(t *testing.T) {
|
||||
// var p DockerProvider
|
||||
// cont := &types.Container{
|
||||
// Image: "redis",
|
||||
// Names: []string{"redis"},
|
||||
// Ports: []types.Port{
|
||||
// {Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||
// },
|
||||
// Labels: map[string]string{
|
||||
// "proxy.redis.port": "6379:6379",
|
||||
// },
|
||||
// }
|
||||
// cont.HostConfig.NetworkMode = "host"
|
||||
|
||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(cont, ""))
|
||||
ExpectNoError(t, err.Error())
|
||||
// entries, err := p.entriesFromContainerLabels(D.FromDocker(cont, ""))
|
||||
// ExpectNoError(t, err.Error())
|
||||
|
||||
_, ok := entries.Load("redis")
|
||||
ExpectTrue(t, ok)
|
||||
}
|
||||
// _, ok := entries.Load("redis")
|
||||
// ExpectTrue(t, ok)
|
||||
// }
|
||||
|
|
Loading…
Add table
Reference in a new issue