mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 20:26:47 +02:00
Updates #cleanup Change-Id: Id69d509f5e470fb5fb50b5c5c4ca61f000389c53 Signed-off-by: Alex Chan <alexc@tailscale.com>
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package tka
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGenerateDeeplink(t *testing.T) {
|
|
pub, _ := testingKey25519(t, 1)
|
|
key := Key{Kind: Key25519, Public: pub, Votes: 2}
|
|
c := newTestchain(t, `
|
|
G1 -> L1
|
|
|
|
G1.template = genesis
|
|
`, genesisTemplate(key),
|
|
)
|
|
a, _ := Open(c.Chonk())
|
|
|
|
nodeKey := "nodekey:1234567890"
|
|
tlPub := "tlpub:1234567890"
|
|
deviceName := "Example Device"
|
|
osName := "iOS"
|
|
loginName := "insecure@example.com"
|
|
|
|
deeplink, err := a.NewDeeplink(NewDeeplinkParams{
|
|
NodeKey: nodeKey,
|
|
TLPub: tlPub,
|
|
DeviceName: deviceName,
|
|
OSName: osName,
|
|
LoginName: loginName,
|
|
})
|
|
if err != nil {
|
|
t.Errorf("deeplink generation failed: %v", err)
|
|
}
|
|
|
|
res := a.ValidateDeeplink(deeplink)
|
|
if !res.IsValid {
|
|
t.Errorf("deeplink validation failed: %s", res.Error)
|
|
}
|
|
if res.NodeKey != nodeKey {
|
|
t.Errorf("node key mismatch: %s != %s", res.NodeKey, nodeKey)
|
|
}
|
|
if res.TLPub != tlPub {
|
|
t.Errorf("tlpub mismatch: %s != %s", res.TLPub, tlPub)
|
|
}
|
|
}
|