Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3354189
D13807.id45456.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13807.id45456.diff
View Options
diff --git a/services/backup/src/http/handlers/backup.rs b/services/backup/src/http/handlers/backup.rs
--- a/services/backup/src/http/handlers/backup.rs
+++ b/services/backup/src/http/handlers/backup.rs
@@ -17,6 +17,7 @@
use tokio_stream::{wrappers::ReceiverStream, StreamExt};
use tracing::{info, instrument, trace, warn};
+use crate::identity::find_user_id;
use crate::{
database::{backup_item::BackupItem, DatabaseClient},
error::BackupError,
@@ -282,8 +283,7 @@
db_client: web::Data<DatabaseClient>,
) -> actix_web::Result<impl Responder> {
let username = path.into_inner();
- // Treat username as user_id in the initial version
- let user_id = username;
+ let user_id = find_user_id(&username).await?;
let Some(backup_item) = db_client
.find_last_backup_item(&user_id)
@@ -308,8 +308,7 @@
blob_client: Authenticated<BlobServiceClient>,
) -> actix_web::Result<HttpResponse> {
let username = path.into_inner();
- // Treat username as user_id in the initial version
- let user_id = username;
+ let user_id = find_user_id(&username).await?;
let Some(backup_item) = db_client
.find_last_backup_item(&user_id)
diff --git a/services/commtest/tests/backup_integration_test.rs b/services/commtest/tests/backup_integration_test.rs
--- a/services/commtest/tests/backup_integration_test.rs
+++ b/services/commtest/tests/backup_integration_test.rs
@@ -75,10 +75,30 @@
.await?;
assert_eq!(user_data, backup_data.user_data);
+ // Test latest backup lookup for not-existing user
+ let latest_backup_descriptor = BackupDescriptor::Latest {
+ username: "non_existing_user".to_string(),
+ };
+
+ let non_existing_user_response = backup_client
+ .download_backup_data(&latest_backup_descriptor, RequestedData::BackupID)
+ .await;
+
+ match non_existing_user_response {
+ Ok(_) => panic!("Expected error, but got success response"),
+ Err(BackupClientError::ReqwestError(error)) => {
+ assert_eq!(
+ error.status(),
+ Some(StatusCode::BAD_REQUEST),
+ "Expected bad request status"
+ );
+ }
+ Err(_) => panic!("Unexpected error type"),
+ }
+
// Test latest backup lookup
let latest_backup_descriptor = BackupDescriptor::Latest {
- // Initial version of the backup service uses `user_id` in place of a username
- username: device_info.user_id.to_string(),
+ username: device_info.username,
};
let backup_id_response = backup_client
diff --git a/services/commtest/tests/backup_performance_test.rs b/services/commtest/tests/backup_performance_test.rs
--- a/services/commtest/tests/backup_performance_test.rs
+++ b/services/commtest/tests/backup_performance_test.rs
@@ -81,9 +81,15 @@
let mut handlers = vec![];
for user in &user_identities {
let backup_client = backup_client.clone();
- let descriptor = BackupDescriptor::Latest {
- username: user.user_id.clone(),
+
+ let username = if user.user_id == device_info_1.user_id {
+ device_info_1.username.clone()
+ } else {
+ device_info_2.username.clone()
};
+
+ let descriptor = BackupDescriptor::Latest { username };
+
handlers.push(tokio::spawn(async move {
let response = backup_client
.download_backup_data(&descriptor, RequestedData::BackupID)
@@ -107,9 +113,14 @@
let mut handlers = vec![];
for user in &user_identities {
let backup_client = backup_client.clone();
- let descriptor = BackupDescriptor::Latest {
- username: user.user_id.clone(),
+ let username = if user.user_id == device_info_1.user_id {
+ device_info_1.username.clone()
+ } else {
+ device_info_2.username.clone()
};
+
+ let descriptor = BackupDescriptor::Latest { username };
+
handlers.push(tokio::spawn(async move {
backup_client
.download_backup_data(&descriptor, RequestedData::UserKeys)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 12:17 PM (17 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575529
Default Alt Text
D13807.id45456.diff (3 KB)
Attached To
Mode
D13807: [backup-service] use `username` instead of `userID` when downloading backup
Attached
Detach File
Event Timeline
Log In to Comment