Rebase against upstream
This commit is contained in:
parent
a675b5faae
commit
4cd89a9113
|
@ -380,68 +380,3 @@ func TestAgent_ConsulService(t *testing.T) {
|
||||||
t.Fatalf("%s service should be in sync", consul.ConsulServiceID)
|
t.Fatalf("%s service should be in sync", consul.ConsulServiceID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgent_LoadKeyrings(t *testing.T) {
|
|
||||||
key := "tbLJg26ZJyJ9pK3qhc9jig=="
|
|
||||||
|
|
||||||
// Should be no configured keyring file by default
|
|
||||||
conf1 := nextConfig()
|
|
||||||
dir1, agent1 := makeAgent(t, conf1)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
defer agent1.Shutdown()
|
|
||||||
|
|
||||||
c := agent1.config.ConsulConfig
|
|
||||||
if c.SerfLANConfig.KeyringFile != "" {
|
|
||||||
t.Fatalf("bad: %#v", c.SerfLANConfig.KeyringFile)
|
|
||||||
}
|
|
||||||
if c.SerfLANConfig.MemberlistConfig.Keyring != nil {
|
|
||||||
t.Fatalf("keyring should not be loaded")
|
|
||||||
}
|
|
||||||
if c.SerfWANConfig.KeyringFile != "" {
|
|
||||||
t.Fatalf("bad: %#v", c.SerfLANConfig.KeyringFile)
|
|
||||||
}
|
|
||||||
if c.SerfWANConfig.MemberlistConfig.Keyring != nil {
|
|
||||||
t.Fatalf("keyring should not be loaded")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Server should auto-load LAN and WAN keyring files
|
|
||||||
conf2 := nextConfig()
|
|
||||||
dir2, agent2 := makeAgentKeyring(t, conf2, key)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
defer agent2.Shutdown()
|
|
||||||
|
|
||||||
c = agent2.config.ConsulConfig
|
|
||||||
if c.SerfLANConfig.KeyringFile == "" {
|
|
||||||
t.Fatalf("should have keyring file")
|
|
||||||
}
|
|
||||||
if c.SerfLANConfig.MemberlistConfig.Keyring == nil {
|
|
||||||
t.Fatalf("keyring should be loaded")
|
|
||||||
}
|
|
||||||
if c.SerfWANConfig.KeyringFile == "" {
|
|
||||||
t.Fatalf("should have keyring file")
|
|
||||||
}
|
|
||||||
if c.SerfWANConfig.MemberlistConfig.Keyring == nil {
|
|
||||||
t.Fatalf("keyring should be loaded")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client should auto-load only the LAN keyring file
|
|
||||||
conf3 := nextConfig()
|
|
||||||
conf3.Server = false
|
|
||||||
dir3, agent3 := makeAgentKeyring(t, conf3, key)
|
|
||||||
defer os.RemoveAll(dir3)
|
|
||||||
defer agent3.Shutdown()
|
|
||||||
|
|
||||||
c = agent3.config.ConsulConfig
|
|
||||||
if c.SerfLANConfig.KeyringFile == "" {
|
|
||||||
t.Fatalf("should have keyring file")
|
|
||||||
}
|
|
||||||
if c.SerfLANConfig.MemberlistConfig.Keyring == nil {
|
|
||||||
t.Fatalf("keyring should be loaded")
|
|
||||||
}
|
|
||||||
if c.SerfWANConfig.KeyringFile != "" {
|
|
||||||
t.Fatalf("bad: %#v", c.SerfLANConfig.KeyringFile)
|
|
||||||
}
|
|
||||||
if c.SerfWANConfig.MemberlistConfig.Keyring != nil {
|
|
||||||
t.Fatalf("keyring should not be loaded")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
<<<<<<< HEAD
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
=======
|
|
||||||
"github.com/mitchellh/cli"
|
|
||||||
>>>>>>> agent: -encrypt appends to keyring if one exists
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/testutil"
|
"github.com/hashicorp/consul/testutil"
|
||||||
|
@ -169,32 +163,3 @@ func TestRetryJoinWanFail(t *testing.T) {
|
||||||
t.Fatalf("bad: %d", code)
|
t.Fatalf("bad: %d", code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestArgConflict(t *testing.T) {
|
|
||||||
ui := new(cli.MockUi)
|
|
||||||
c := &Command{Ui: ui}
|
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "agent")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
key := "HS5lJ+XuTlYKWaeGYyG+/A=="
|
|
||||||
|
|
||||||
fileLAN := filepath.Join(dir, SerfLANKeyring)
|
|
||||||
if err := testutil.InitKeyring(fileLAN, key); err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
args := []string{
|
|
||||||
"-encrypt=" + key,
|
|
||||||
"-data-dir=" + dir,
|
|
||||||
}
|
|
||||||
code := c.Run(args)
|
|
||||||
if code != 1 {
|
|
||||||
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
|
|
||||||
}
|
|
||||||
if !strings.Contains(ui.ErrorWriter.String(), "keyring files exist") {
|
|
||||||
t.Fatalf("bad: %#v", ui.ErrorWriter.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -206,6 +206,11 @@ func (c *Client) UserEvent(name string, payload []byte) error {
|
||||||
return c.serf.UserEvent(userEventName(name), payload, false)
|
return c.serf.UserEvent(userEventName(name), payload, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KeyManagerLAN returns the LAN Serf keyring manager
|
||||||
|
func (c *Client) KeyManagerLAN() *serf.KeyManager {
|
||||||
|
return c.serf.KeyManager()
|
||||||
|
}
|
||||||
|
|
||||||
// Encrypted determines if gossip is encrypted
|
// Encrypted determines if gossip is encrypted
|
||||||
func (c *Client) Encrypted() bool {
|
func (c *Client) Encrypted() bool {
|
||||||
return c.serf.EncryptionEnabled()
|
return c.serf.EncryptionEnabled()
|
||||||
|
|
Loading…
Reference in New Issue