mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-27 06:35:52 -05:00
ed4e19996b
* upgrade tailscale Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * make Node object use actualy tailscale key types This commit changes the Node struct to have both a field for strings to store the keys in the database and a dedicated Key for each type of key. The keys are populated and stored with Gorm hooks to ensure the data is stored in the db. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * use key types throughout the code Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * make sure machinekey is concistently used Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * use machine key in auth url Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * fix web register Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * use key type in notifier Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * fix relogin with webauth Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> --------- Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
61 lines
896 B
Go
61 lines
896 B
Go
package db
|
|
|
|
import (
|
|
"log"
|
|
"net/netip"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/juanfont/headscale/hscontrol/notifier"
|
|
"gopkg.in/check.v1"
|
|
)
|
|
|
|
func Test(t *testing.T) {
|
|
check.TestingT(t)
|
|
}
|
|
|
|
var _ = check.Suite(&Suite{})
|
|
|
|
type Suite struct{}
|
|
|
|
var (
|
|
tmpDir string
|
|
db *HSDatabase
|
|
)
|
|
|
|
func (s *Suite) SetUpTest(c *check.C) {
|
|
s.ResetDB(c)
|
|
}
|
|
|
|
func (s *Suite) TearDownTest(c *check.C) {
|
|
// os.RemoveAll(tmpDir)
|
|
}
|
|
|
|
func (s *Suite) ResetDB(c *check.C) {
|
|
// if len(tmpDir) != 0 {
|
|
// os.RemoveAll(tmpDir)
|
|
// }
|
|
|
|
var err error
|
|
tmpDir, err = os.MkdirTemp("", "headscale-db-test-*")
|
|
if err != nil {
|
|
c.Fatal(err)
|
|
}
|
|
|
|
log.Printf("database path: %s", tmpDir+"/headscale_test.db")
|
|
|
|
db, err = NewHeadscaleDatabase(
|
|
"sqlite3",
|
|
tmpDir+"/headscale_test.db",
|
|
false,
|
|
notifier.NewNotifier(),
|
|
[]netip.Prefix{
|
|
netip.MustParsePrefix("10.27.0.0/23"),
|
|
},
|
|
"",
|
|
)
|
|
if err != nil {
|
|
c.Fatal(err)
|
|
}
|
|
}
|