static META: Metadata<'static>
diff --git a/relay/setup/static.META.html b/relay/setup/static.META.html index 95fe5e3a18..d16de853a6 100644 --- a/relay/setup/static.META.html +++ b/relay/setup/static.META.html @@ -1 +1 @@ -
use std::collections::HashMap;
use std::ffi::OsStr;
use std::path::Path;
@@ -357,9 +392,11 @@
}
}
- let arc = Arc::new(sanitized);
- for key in &arc.public_keys {
- states.insert(key.public_key, arc.clone());
+ // Keep a separate project state per key.
+ let keys = std::mem::take(&mut sanitized.public_keys);
+ for key in keys {
+ sanitized.public_keys = smallvec::smallvec![key.clone()];
+ states.insert(key.public_key, Arc::new(sanitized.clone()));
}
}
@@ -497,5 +534,38 @@
project_key,
)
}
+
+ #[tokio::test]
+ async fn test_multi_pub_static_config() {
+ let temp = tempfile::tempdir().unwrap();
+
+ let tmp_project_file = "111111.json";
+ let project_key1 = ProjectKey::parse("55f6b2d962564e99832a39890ee4573e").unwrap();
+ let project_key2 = ProjectKey::parse("55bbb2d96256bb9983bb39890bb457bb").unwrap();
+
+ let mut tmp_project_state = ProjectState::allowed();
+ tmp_project_state.public_keys.extend(vec![
+ PublicKeyConfig {
+ public_key: project_key1,
+ numeric_id: None,
+ },
+ PublicKeyConfig {
+ public_key: project_key2,
+ numeric_id: None,
+ },
+ ]);
+
+ // create the project file
+ let project_state = serde_json::to_string(&tmp_project_state).unwrap();
+ tokio::fs::write(temp.path().join(tmp_project_file), project_state.as_bytes())
+ .await
+ .unwrap();
+
+ let extracted_project_state = load_local_states(temp.path()).await.unwrap();
+
+ assert_eq!(extracted_project_state.len(), 2);
+ assert!(extracted_project_state.get(&project_key1).is_some());
+ assert!(extracted_project_state.get(&project_key2).is_some());
+ }
}