agent: /v1/agent/services test with connect proxies (works w/ no change)
This commit is contained in:
parent
8777ff139c
commit
6cd9e0e37c
|
@ -23,6 +23,7 @@ import (
|
||||||
"github.com/hashicorp/consul/types"
|
"github.com/hashicorp/consul/types"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
"github.com/pascaldekloe/goe/verify"
|
"github.com/pascaldekloe/goe/verify"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeReadOnlyAgentACL(t *testing.T, srv *HTTPServer) string {
|
func makeReadOnlyAgentACL(t *testing.T, srv *HTTPServer) string {
|
||||||
|
@ -68,6 +69,32 @@ func TestAgent_Services(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAgent_Services_ConnectProxy(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
assert := assert.New(t)
|
||||||
|
a := NewTestAgent(t.Name(), "")
|
||||||
|
defer a.Shutdown()
|
||||||
|
|
||||||
|
srv1 := &structs.NodeService{
|
||||||
|
Kind: structs.ServiceKindConnectProxy,
|
||||||
|
ID: structs.ConnectProxyServiceName,
|
||||||
|
Service: structs.ConnectProxyServiceName,
|
||||||
|
Port: 5000,
|
||||||
|
ProxyDestination: "db",
|
||||||
|
}
|
||||||
|
a.State.AddService(srv1, "")
|
||||||
|
|
||||||
|
req, _ := http.NewRequest("GET", "/v1/agent/services", nil)
|
||||||
|
obj, err := a.srv.AgentServices(nil, req)
|
||||||
|
assert.Nil(err)
|
||||||
|
val := obj.(map[string]*structs.NodeService)
|
||||||
|
assert.Len(val, 1)
|
||||||
|
actual := val[structs.ConnectProxyServiceName]
|
||||||
|
assert.Equal(structs.ServiceKindConnectProxy, actual.Kind)
|
||||||
|
assert.Equal("db", actual.ProxyDestination)
|
||||||
|
}
|
||||||
|
|
||||||
func TestAgent_Services_ACLFilter(t *testing.T) {
|
func TestAgent_Services_ACLFilter(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
a := NewTestAgent(t.Name(), TestACLConfig())
|
a := NewTestAgent(t.Name(), TestACLConfig())
|
||||||
|
|
Loading…
Reference in New Issue