MCPcopy Index your code
hub / github.com/coder/coder / TestGitSSHKey

Function TestGitSSHKey

coderd/gitsshkey_test.go:22–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestGitSSHKey(t *testing.T) {
23 t.Parallel()
24 t.Run("None", func(t *testing.T) {
25 t.Parallel()
26 client := coderdtest.New(t, nil)
27 res := coderdtest.CreateFirstUser(t, client)
28
29 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
30 defer cancel()
31
32 key, err := client.GitSSHKey(ctx, res.UserID.String())
33 require.NoError(t, err)
34 require.NotEmpty(t, key.PublicKey)
35 })
36 t.Run("Ed25519", func(t *testing.T) {
37 t.Parallel()
38 client := coderdtest.New(t, &coderdtest.Options{
39 SSHKeygenAlgorithm: gitsshkey.AlgorithmEd25519,
40 })
41 res := coderdtest.CreateFirstUser(t, client)
42
43 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
44 defer cancel()
45
46 key, err := client.GitSSHKey(ctx, res.UserID.String())
47 require.NoError(t, err)
48 require.NotEmpty(t, key.PublicKey)
49 })
50 t.Run("ECDSA", func(t *testing.T) {
51 t.Parallel()
52 client := coderdtest.New(t, &coderdtest.Options{
53 SSHKeygenAlgorithm: gitsshkey.AlgorithmECDSA,
54 })
55 res := coderdtest.CreateFirstUser(t, client)
56
57 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
58 defer cancel()
59
60 key, err := client.GitSSHKey(ctx, res.UserID.String())
61 require.NoError(t, err)
62 require.NotEmpty(t, key.PublicKey)
63 })
64 t.Run("RSA4096", func(t *testing.T) {
65 t.Parallel()
66 client := coderdtest.New(t, &coderdtest.Options{
67 SSHKeygenAlgorithm: gitsshkey.AlgorithmRSA4096,
68 })
69 res := coderdtest.CreateFirstUser(t, client)
70
71 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
72 defer cancel()
73
74 key, err := client.GitSSHKey(ctx, res.UserID.String())
75 require.NoError(t, err)
76 require.NotEmpty(t, key.PublicKey)
77 })
78 t.Run("Regenerate", func(t *testing.T) {
79 t.Parallel()

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
CreateFirstUserFunction · 0.92
NewMockFunction · 0.92
NotEmptyMethod · 0.80
RegenerateGitSSHKeyMethod · 0.80
RunMethod · 0.65
GitSSHKeyMethod · 0.45
StringMethod · 0.45
LenMethod · 0.45
AuditLogsMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected