mirror of
https://github.com/tailscale/tailscale.git
synced 2026-03-25 09:42:39 -04:00
This makes tsnet apps not depend on x/crypto/ssh and locks that in with a test. It also paves the wave for tsnet apps to opt-in to SSH support via a blank feature import in the future. Updates #12614 Change-Id: Ica85628f89c8f015413b074f5001b82b27c953a9 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
40 lines
780 B
Go
40 lines
780 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build linux || (darwin && !ios)
|
|
|
|
package tailssh
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSSHKeyGen(t *testing.T) {
|
|
dir := t.TempDir()
|
|
keys, err := getTailscaleHostKeys(dir, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got := map[string]bool{}
|
|
for _, k := range keys {
|
|
got[k.PublicKey().Type()] = true
|
|
}
|
|
want := map[string]bool{
|
|
"ssh-rsa": true,
|
|
"ecdsa-sha2-nistp256": true,
|
|
"ssh-ed25519": true,
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("keys = %v; want %v", got, want)
|
|
}
|
|
|
|
keys2, err := getTailscaleHostKeys(dir, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !reflect.DeepEqual(keys, keys2) {
|
|
t.Errorf("got different keys on second call")
|
|
}
|
|
}
|