Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
rpc: Add regression tests for encoding/decoding public keys (#15054)
Marshall Bowers1307a80e0704
diff --git a/crates/rpc/src/auth.rs b/crates/rpc/src/auth.rsindex ac7bbcebecd..56525983fbc 100644--- a/crates/rpc/src/auth.rs+++ b/crates/rpc/src/auth.rs@@ -107,6 +107,20 @@ mod tests {assert_eq!(decrypted_token, token);}+ #[test]+ fn test_encode_and_decode_base64_public_key() {+ // A base64-encoded public key.+ //+ // We're using a literal string to ensure that encoding and decoding works across differences in implementations.+ let encoded_public_key = "MIGJAoGBAMPvufou8wOuUIF1Wlkbtn0ZMM9nC55QJ06nTZvgMfZv5esFVU9-cQO_JC1P9ZoEcMDJweFERnQuQLqzsrMDLFbkdgL128ZU43WOLiQraxaICFIZsPUeTtWMKp2D5bPWsNxs-lnCma7vCAry6fpXuj5AKQdk7cTZJNucgvZQ0uUfAgMBAAE=".to_string();++ // Make sure we can parse the public key.+ let public_key = PublicKey::try_from(encoded_public_key.clone()).unwrap();++ // Make sure we re-encode to the same format.+ assert_eq!(encoded_public_key, String::try_from(public_key).unwrap());+ }+#[test]fn test_tokens_are_always_url_safe() {for _ in 0..5 {diff --git a/typos.toml b/typos.tomlindex c52c9e9eae6..9e2763eac25 100644--- a/typos.toml+++ b/typos.toml@@ -15,6 +15,11 @@ extend-exclude = ["crates/editor/src/editor_tests.rs",# Clojure uses .edn filename extension, which is not a misspelling of "end""extensions/clojure/languages/clojure/config.toml",+ # There are some names in the test data that are incorrectly flagged as typos.+ "crates/git/test_data/blame_incremental_complex",+ "crates/git/test_data/golden/blame_incremental_complex.json",+ # We have some base64-encoded data that is incorrectly being flagged.+ "crates/rpc/src/auth.rs",# glsl isn't recognized by this tool"extensions/glsl/languages/glsl/",# Windows likes its abbreviations