MCPcopy Create free account
hub / github.com/github/gh-aw / TestEncryptWithPublicKeyEmptyPlaintext

Function TestEncryptWithPublicKeyEmptyPlaintext

pkg/cli/secret_set_command_test.go:122–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestEncryptWithPublicKeyEmptyPlaintext(t *testing.T) {
123 validKey := "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUY="
124 encrypted, err := encryptWithPublicKey(validKey, "")
125 if err != nil {
126 t.Fatalf("encryptWithPublicKey() error = %v, expected no error", err)
127 }
128 if encrypted == "" {
129 t.Error("expected non-empty ciphertext even for empty plaintext")
130 }
131 minBase64CiphertextLen := base64.StdEncoding.EncodedLen(box.AnonymousOverhead)
132 if len(encrypted) < minBase64CiphertextLen {
133 t.Errorf("encrypted length = %d, expected at least %d", len(encrypted), minBase64CiphertextLen)
134 }
135}
136
137func TestEncryptDecryptRoundTrip(t *testing.T) {
138 // Generate a real key pair for testing

Callers

nothing calls this directly

Calls 3

encryptWithPublicKeyFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected