MCPcopy Create free account
hub / github.com/foxcpp/maddy / TestKeyLoad_existing_pkcs8

Function TestKeyLoad_existing_pkcs8

internal/modify/dkim/keys_test.go:79–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77const pubkeyEd25519 = `5TPcCxzVByMyRsMFs5Dx23pnxKilI+1UrGg0t+O2oZU=`
78
79func TestKeyLoad_existing_pkcs8(t *testing.T) {
80 m := Modifier{}
81 m.log = testutils.Logger(t, m.Name())
82
83 dir := t.TempDir()
84
85 if err := os.WriteFile(filepath.Join(dir, "testkey.key"), []byte(pkeyEd25519), 0o600); err != nil {
86 t.Fatal(err)
87 }
88
89 signer, newKey, err := m.loadOrGenerateKey(filepath.Join(dir, "testkey.key"), "ed25519")
90 if err != nil {
91 t.Fatal(err)
92 }
93 if newKey {
94 t.Fatal("newKey = true")
95 }
96
97 blob := signer.Public().(ed25519.PublicKey)
98 if signerKey := base64.StdEncoding.EncodeToString(blob); signerKey != pubkeyEd25519 {
99 t.Fatalf("wrong public key returned by loadOrGenerateKey, \nwant %s\ngot %s", pubkeyEd25519, signerKey)
100 }
101}
102
103const pkeyRSA = `-----BEGIN RSA PRIVATE KEY-----
104MIIEowIBAAKCAQEAuxWwDR9ADiuV2b9xF+btOIgwS5W0yJeS/Dht4HlUELrye2JZ

Callers

nothing calls this directly

Calls 3

NameMethod · 0.95
loadOrGenerateKeyMethod · 0.95
LoggerFunction · 0.92

Tested by

no test coverage detected