Skip to content

Commit

Permalink
fix: server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 2, 2023
1 parent 0ff2f2d commit 443e713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions server/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

func TestParseMultipleKeys(t *testing.T) {
is := is.New(t)
is.NoErr(os.Setenv("SOFT_SERVE_INITIAL_ADMIN_KEY", "testdata/k1.pub\ntestdata/k2.pub"))
t.Cleanup(func() { is.NoErr(os.Unsetenv("SOFT_SERVE_INITIAL_ADMIN_KEY")) })
is.NoErr(os.Setenv("SOFT_SERVE_INITIAL_ADMIN_KEYS", "testdata/k1.pub\ntestdata/k2.pub"))
t.Cleanup(func() { is.NoErr(os.Unsetenv("SOFT_SERVE_INITIAL_ADMIN_KEYS")) })
cfg := DefaultConfig()
is.Equal(cfg.InitialAdminKeys, []string{
"testdata/k1.pub",
Expand Down
7 changes: 3 additions & 4 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ func createKeyPair(tb testing.TB) (ssh.PublicKey, string) {
tb.Helper()
is := is.New(tb)
keyDir := tb.TempDir()
kp, err := keygen.NewWithWrite(filepath.Join(keyDir, "id"), nil, keygen.Ed25519)
fp := filepath.Join(keyDir, "id_ed25519")
kp, err := keygen.New(fp, keygen.WithKeyType(keygen.Ed25519), keygen.WithWrite())
is.NoErr(err)
pubkey, _, _, _, err := ssh.ParseAuthorizedKey(kp.PublicKey())
is.NoErr(err)
return pubkey, filepath.Join(keyDir, "id_ed25519")
return kp.PublicKey(), fp
}

func authorizedKey(pk ssh.PublicKey) string {
Expand Down

0 comments on commit 443e713

Please sign in to comment.