Forces user-supplied node IDs to lower case for consistency.

This commit is contained in:
James Phillips 2017-03-13 19:51:56 -07:00
parent 99db8f2f2a
commit 9b43b31900
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
2 changed files with 4 additions and 2 deletions

View File

@ -646,6 +646,7 @@ func (a *Agent) setupNodeID(config *Config) error {
// If they've configured a node ID manually then just use that, as
// long as it's valid.
if config.NodeID != "" {
config.NodeID = types.NodeID(strings.ToLower(string(config.NodeID)))
if _, err := uuid.ParseUUID(string(config.NodeID)); err != nil {
return err
}
@ -674,6 +675,7 @@ func (a *Agent) setupNodeID(config *Config) error {
}
nodeID := strings.TrimSpace(string(rawID))
nodeID = strings.ToLower(nodeID)
if _, err := uuid.ParseUUID(nodeID); err != nil {
return err
}

View File

@ -341,7 +341,7 @@ func TestAgent_NodeID(t *testing.T) {
if err != nil {
t.Fatalf("err: %v", err)
}
c.NodeID = types.NodeID(newID)
c.NodeID = types.NodeID(strings.ToUpper(newID))
if err := agent.setupNodeID(c); err != nil {
t.Fatalf("err: %v", err)
}
@ -361,7 +361,7 @@ func TestAgent_NodeID(t *testing.T) {
}
// Set a valid ID via the file.
if err := ioutil.WriteFile(fileID, []byte("adf4238a-882b-9ddc-4a9d-5b6758e4159e"), 0600); err != nil {
if err := ioutil.WriteFile(fileID, []byte("ADF4238a-882b-9ddc-4a9d-5b6758e4159e"), 0600); err != nil {
t.Fatalf("err: %v", err)
}
c.NodeID = ""