2021-05-23 07:55:15 -06:00
|
|
|
package headscale
|
|
|
|
|
|
|
|
import (
|
2021-10-18 13:26:43 -06:00
|
|
|
"time"
|
|
|
|
|
2021-05-23 07:55:15 -06:00
|
|
|
"gopkg.in/check.v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Suite) TestRegisterMachine(c *check.C) {
|
|
|
|
n, err := h.CreateNamespace("test")
|
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
|
2021-10-18 13:26:43 -06:00
|
|
|
now := time.Now().UTC()
|
|
|
|
|
2021-05-23 07:55:15 -06:00
|
|
|
m := Machine{
|
2021-10-18 13:26:43 -06:00
|
|
|
ID: 0,
|
|
|
|
MachineKey: "8ce002a935f8c394e55e78fbbb410576575ff8ec5cfa2e627e4b807f1be15b0e",
|
|
|
|
NodeKey: "bar",
|
|
|
|
DiscoKey: "faa",
|
|
|
|
Name: "testmachine",
|
|
|
|
NamespaceID: n.ID,
|
|
|
|
IPAddress: "10.0.0.1",
|
|
|
|
Expiry: &now,
|
|
|
|
RequestedExpiry: &now,
|
2021-05-23 07:55:15 -06:00
|
|
|
}
|
2021-07-04 13:40:46 -06:00
|
|
|
h.db.Save(&m)
|
2021-05-23 07:55:15 -06:00
|
|
|
|
|
|
|
_, err = h.GetMachine("test", "testmachine")
|
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
|
2021-11-13 01:36:45 -07:00
|
|
|
m2, err := h.RegisterMachine(
|
|
|
|
"8ce002a935f8c394e55e78fbbb410576575ff8ec5cfa2e627e4b807f1be15b0e",
|
|
|
|
n.Name,
|
|
|
|
)
|
2021-05-23 07:55:15 -06:00
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
c.Assert(m2.Registered, check.Equals, true)
|
|
|
|
|
|
|
|
_, err = m2.GetHostInfo()
|
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
}
|