Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow invalid uaids in autoconnect #464

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions autoconnect/autoconnect-ws/autoconnect-ws-sm/src/unidentified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ impl UnidentifiedClient {
uaid
);

let uaid = uaid
.as_deref()
.map(Uuid::try_parse)
.transpose()
.map_err(|_| SMError::invalid_message("Invalid uaid".to_owned()))?;
// Ignore invalid uaids (treat as None) so they'll be issued a new one
let uaid = uaid.as_deref().and_then(|uaid| Uuid::try_parse(uaid).ok());

let GetOrCreateUser {
user,
Expand Down Expand Up @@ -262,6 +259,30 @@ mod tests {
client.on_client_msg(msg).await.expect("Hello failed");
}

#[tokio::test]
async fn hello_empty_uaid() {
let client = uclient(Default::default());
let msg = ClientMessage::Hello {
uaid: Some("".to_owned()),
channel_ids: None,
use_webpush: Some(true),
broadcasts: None,
};
client.on_client_msg(msg).await.expect("Hello failed");
}

#[tokio::test]
async fn hello_invalid_uaid() {
let client = uclient(Default::default());
let msg = ClientMessage::Hello {
uaid: Some("invalid".to_owned()),
channel_ids: None,
use_webpush: Some(true),
broadcasts: None,
};
client.on_client_msg(msg).await.expect("Hello failed");
}

#[tokio::test]
async fn hello_bad_user() {}
}