When attempting to unshare a node from the primary namespace, return

errorMachineNotShared, not errorSameNamespace. Add test for same.
This commit is contained in:
Ward Vandewege 2021-10-24 17:00:51 -04:00
parent 6d162eeff9
commit c8e1afb14b
2 changed files with 5 additions and 1 deletions

View File

@ -43,7 +43,8 @@ func (h *Headscale) AddSharedMachineToNamespace(m *Machine, ns *Namespace) error
// RemoveSharedMachineFromNamespace removes a shared machine from a namespace
func (h *Headscale) RemoveSharedMachineFromNamespace(m *Machine, ns *Namespace) error {
if m.NamespaceID == ns.ID {
return errorSameNamespace
// Can't unshare from primary namespace
return errorMachineNotShared
}
sharedMachine := SharedMachine{}

View File

@ -86,6 +86,9 @@ func (s *Suite) TestUnshare(c *check.C) {
err = h.RemoveSharedMachineFromNamespace(m2, n1)
c.Assert(err, check.Equals, errorMachineNotShared)
err = h.RemoveSharedMachineFromNamespace(m1, n1)
c.Assert(err, check.Equals, errorMachineNotShared)
}
func (s *Suite) TestAlreadyShared(c *check.C) {