MCPcopy Create free account
hub / github.com/Scalingo/cli / TestPrivateKey_IsEncrypted

Function TestPrivateKey_IsEncrypted

crypto/sshkeys/private_key_test.go:16–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14}
15
16func TestPrivateKey_IsEncrypted(t *testing.T) {
17 cases := []struct {
18 Name string
19 PrivateKey *PrivateKey
20 ExpectBoolean bool
21 }{
22 {
23 Name: "Unencrypted RSA Key",
24 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(unencryptedRSAKey)},
25 ExpectBoolean: false,
26 },
27 {
28 Name: "Encrypted AES RSA Key",
29 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(aesRSA)},
30 ExpectBoolean: true,
31 },
32 {
33 Name: "Encrypted AES RSA Key (Mac OS Maverick)",
34 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(aesRSAMacOSMaverick)},
35 ExpectBoolean: true,
36 },
37 {
38 Name: "Encrypted AES RSA Key (Mac OS Yosemite)",
39 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(aesRSAMacOSYosemite)},
40 ExpectBoolean: true,
41 },
42 {
43 Name: "Encrypted DES3 RSA Key",
44 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(des3RSA)},
45 ExpectBoolean: true,
46 },
47 {
48 Name: "Encrypted DES3 RSA Key with Long Passphrase",
49 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(des3RSALongPassphrase)},
50 ExpectBoolean: true,
51 },
52 {
53 Name: "Unencrypted OpenSSH RSA Key",
54 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(unencryptedOpenSSHRSA)},
55 ExpectBoolean: false,
56 },
57 {
58 Name: "Encrypted OpenSSH RSA Key",
59 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(openSSHRSA)},
60 ExpectBoolean: true,
61 },
62 {
63 Name: "Unencrypted OpenSSH ecdsa Key",
64 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(unencryptedOpenSSHecdsa)},
65 ExpectBoolean: false,
66 },
67 {
68 Name: "Encrypted OpenSSH ecdsa Key",
69 PrivateKey: &PrivateKey{Path: "n/a", Block: pemDecode(openSSHecdsa)},
70 ExpectBoolean: true,
71 },
72 {
73 Name: "Unencrypted OpenSSH ed25519 Key",

Callers

nothing calls this directly

Calls 2

pemDecodeFunction · 0.85
isEncryptedMethod · 0.80

Tested by

no test coverage detected