agent: /v1/agent/services test with connect proxies (works w/ no change)

This commit is contained in:
Mitchell Hashimoto 2018-03-08 10:54:05 -08:00
parent 8777ff139c
commit 6cd9e0e37c
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 27 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import (
"github.com/hashicorp/consul/types"
"github.com/hashicorp/serf/serf"
"github.com/pascaldekloe/goe/verify"
"github.com/stretchr/testify/assert"
)
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) {
t.Parallel()
a := NewTestAgent(t.Name(), TestACLConfig())