More test cleanup

This commit is contained in:
Paul Banks 2018-05-10 17:14:16 +01:00 committed by Mitchell Hashimoto
parent 834ed1d25f
commit cac32ba071
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 8 additions and 24 deletions

View File

@ -565,9 +565,6 @@ func (a *Agent) ForceLeave(node string) error {
// ConnectAuthorize is used to authorize an incoming connection
// to a natively integrated Connect service.
//
// TODO(mitchellh): we need to test this better once we have a way to
// configure CAs from the API package (when the CA work is done).
func (a *Agent) ConnectAuthorize(auth *AgentAuthorizeParams) (*AgentAuthorize, error) {
r := a.c.newRequest("POST", "/v1/agent/connect/authorize")
r.obj = auth
@ -585,9 +582,6 @@ func (a *Agent) ConnectAuthorize(auth *AgentAuthorizeParams) (*AgentAuthorize, e
}
// ConnectCARoots returns the list of roots.
//
// TODO(mitchellh): we need to test this better once we have a way to
// configure CAs from the API package (when the CA work is done).
func (a *Agent) ConnectCARoots(q *QueryOptions) (*CARootList, *QueryMeta, error) {
r := a.c.newRequest("GET", "/v1/agent/connect/ca/roots")
r.setQueryOptions(q)

View File

@ -1044,7 +1044,9 @@ func TestAPI_AgentConnectCARoots_empty(t *testing.T) {
t.Parallel()
require := require.New(t)
c, s := makeClient(t)
c, s := makeClientWithConfig(t, nil, func(c *testutil.TestServerConfig) {
c.Connect = nil // disable connect to prevent CA beening bootstrapped
})
defer s.Stop()
agent := c.Agent()
@ -1058,12 +1060,7 @@ func TestAPI_AgentConnectCARoots_list(t *testing.T) {
t.Parallel()
require := require.New(t)
c, s := makeClientWithConfig(t, nil, func(c *testutil.TestServerConfig) {
// Force auto port range to 1 port so we have deterministic response.
c.Connect = map[string]interface{}{
"enabled": true,
}
})
c, s := makeClient(t)
defer s.Stop()
agent := c.Agent()
@ -1077,12 +1074,7 @@ func TestAPI_AgentConnectCALeaf(t *testing.T) {
t.Parallel()
require := require.New(t)
c, s := makeClientWithConfig(t, nil, func(c *testutil.TestServerConfig) {
// Force auto port range to 1 port so we have deterministic response.
c.Connect = map[string]interface{}{
"enabled": true,
}
})
c, s := makeClient(t)
defer s.Stop()
agent := c.Agent()
@ -1109,9 +1101,6 @@ func TestAPI_AgentConnectCALeaf(t *testing.T) {
require.True(leaf.ValidBefore.After(time.Now()))
}
// TODO(banks): once we have CA stuff setup properly we can probably make this
// much more complete. This is just a sanity check that the agent code basically
// works.
func TestAPI_AgentConnectAuthorize(t *testing.T) {
t.Parallel()
require := require.New(t)
@ -1151,6 +1140,7 @@ func TestAPI_AgentConnectProxyConfig(t *testing.T) {
Port: 8000,
Connect: &AgentServiceConnect{
Proxy: &AgentServiceConnectProxy{
Command: []string{"consul connect proxy"},
Config: map[string]interface{}{
"foo": "bar",
},
@ -1167,7 +1157,7 @@ func TestAPI_AgentConnectProxyConfig(t *testing.T) {
ProxyServiceID: "foo-proxy",
TargetServiceID: "foo",
TargetServiceName: "foo",
ContentHash: "e662ea8600d84cf0",
ContentHash: "93baee1d838888ae",
ExecMode: "daemon",
Command: []string{"consul connect proxy"},
Config: map[string]interface{}{
@ -1178,5 +1168,5 @@ func TestAPI_AgentConnectProxyConfig(t *testing.T) {
},
}
require.Equal(t, expectConfig, config)
require.Equal(t, "e662ea8600d84cf0", qm.LastContentHash)
require.Equal(t, expectConfig.ContentHash, qm.LastContentHash)
}