We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1bba9c commit bde153eCopy full SHA for bde153e
modules/ssh/ssh_test.go
@@ -0,0 +1,32 @@
1
+package ssh_test
2
+
3
+import (
4
+ "crypto/x509"
5
+ "encoding/pem"
6
+ "io"
7
+ "os"
8
+ "testing"
9
10
+ "code.gitea.io/gitea/modules/ssh"
11
+ "github.com/stretchr/testify/assert"
12
+ "github.com/stretchr/testify/require"
13
+)
14
15
+func TestGenKeyPair(t *testing.T) {
16
+ path := t.TempDir() + "/gitea.rsa"
17
+ ssh.GenKeyPair(path)
18
19
+ file, err := os.Open(path)
20
+ require.NoError(t, err)
21
22
+ bytes, err := io.ReadAll(file)
23
24
25
+ block, _ := pem.Decode(bytes)
26
+ require.NotNil(t, block)
27
+ assert.Equal(t, "RSA PRIVATE KEY", block.Type)
28
29
+ privateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
30
31
+ assert.NotNil(t, privateKey)
32
+}
0 commit comments