Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
if: matrix.msrv
run: |
cargo update -p idna_adapter --precise 1.1.0 # This has us use `unicode-normalization` which has a more conservative MSRV
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to note that it would be nice to drop this pin at some point, now that we don't depend on url anymore. However, we do still depend on it through mockito. Given we previously wondered how much benefit the mock testing gives us to begin with, we might at some point consider to drop that dev-dependency, too.

cargo update -p proptest --precise "1.8.0" --verbose # proptest 1.9.0 requires rustc 1.82.0
- name: Build on Rust ${{ matrix.toolchain }}
run: cargo build --verbose --color always
- name: Check formatting
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ reqwest = { version = "0.12", default-features = false, features = ["rustls-tls

[dev-dependencies]
mockito = "0.28.0"
proptest = "1.1.0"
tokio = { version = "1.22.0", features = ["macros"]}

[lints.rust.unexpected_cfgs]
Expand Down
19 changes: 15 additions & 4 deletions src/util/key_obfuscator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,22 @@ mod tests {
assert_eq!(deobfuscated_key, "my_storage_key_v031_compat");
}

use proptest::prelude::*;
#[test]
fn obfuscate_deobfuscate_randomized() {
use rand::Rng;

let charset =
b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_!@#,;:% *$^&()[]{}.\t\n\r";
let mut rng = rand::thread_rng();

for _ in 0..100 {
let mut obfuscation_master_key = [0u8; 32];
rng.fill(&mut obfuscation_master_key);

let key_len: usize = rng.gen_range(0..128);
let expected_key: String =
(0..key_len).map(|_| charset[rng.gen_range(0..charset.len())] as char).collect();

proptest! {
#[test]
fn obfuscate_deobfuscate_proptest(expected_key in "[a-zA-Z0-9_!@#,;:%\\s\\*\\$\\^&\\(\\)\\[\\]\\{\\}\\.]*", obfuscation_master_key in any::<[u8; 32]>()) {
let key_obfuscator = KeyObfuscator::new(obfuscation_master_key);
let obfuscated_key = key_obfuscator.obfuscate(&expected_key);
let actual_key = key_obfuscator.deobfuscate(obfuscated_key.as_str()).unwrap();
Expand Down