Skip to content
Open
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
29 changes: 28 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#[cfg(target_arch = "wasm32")]
async fn read_clipboard_web() -> Option<String> {
use wasm_bindgen::prelude::*;

Check warning on line 31 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

unused import: `wasm_bindgen::prelude::*`
use wasm_bindgen_futures::JsFuture;

let window = web_sys::window()?;
Expand Down Expand Up @@ -213,7 +213,7 @@
}

impl InviteCodeManager {
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {

Check warning on line 216 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

associated function `new` is never used
egui_extras::install_image_loaders(&cc.egui_ctx);
styles::setup_fonts(&cc.egui_ctx);
styles::apply_global_style(&cc.egui_ctx);
Expand Down Expand Up @@ -761,7 +761,7 @@
let parts = js_sys::Array::new();
parts.push(&wasm_bindgen::JsValue::from_str(&export_text));

let mut blob_props = web_sys::BlobPropertyBag::new();

Check warning on line 764 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

variable does not need to be mutable
blob_props.set_type("text/plain");

if let Ok(blob) =
Expand Down Expand Up @@ -960,7 +960,7 @@
30,
Secret::Encoded(res.0).to_bytes().unwrap(),
Some("Northsky".to_string()),
"Northsky".to_string(),
self.username.clone(),
)
.unwrap();
let qr_code = totp.get_qr_png().unwrap();
Expand Down Expand Up @@ -1334,3 +1334,30 @@
pub username: String,
pub password: String,
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_totp_uses_username_as_account_name() {
let test_username = "testuser@example.com";
let test_secret = "JBSWY3DPEHPK3PXP";

let totp = TOTP::new(
Algorithm::SHA1,
6,
1,
30,
Secret::Raw(test_secret.as_bytes().to_vec())
.to_bytes()
.unwrap(),
Some("Northsky".to_string()),
test_username.to_string(),
)
.unwrap();

assert_eq!(totp.account_name, test_username);
assert_eq!(totp.issuer, Some("Northsky".to_string()));
}
}
Loading