rpc: Add regression tests for encoding/decoding public keys (#15054)

This PR adds some tests to ensure we don't regress in our public key
encoding/decoding capabilities when making changes in this area.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-23 19:58:47 -04:00 committed by GitHub
parent 9d11a6ff78
commit 1307a80e07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -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 {

View file

@ -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