Skip to content

Commit

Permalink
Wrap password options in a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Mors committed Mar 9, 2023
1 parent 73c8075 commit 601e14d
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 165 deletions.
24 changes: 12 additions & 12 deletions iostest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn test_round_trip_empty_generic_password() {
println!("test_round_trip_empty_generic_password: start");
let name = "test_empty_generic_password_input";
let in_pass = "".as_bytes();
set_generic_password(name, name, in_pass, None).unwrap();
set_generic_password(name, name, in_pass).unwrap();
let out_pass = get_generic_password(name, name).unwrap();
assert_eq!(in_pass, out_pass);
delete_generic_password(name, name).unwrap();
Expand All @@ -73,7 +73,7 @@ fn test_round_trip_ascii_generic_password() {
println!("test_round_trip_ascii_generic_password: start");
let name = "test_round_trip_ascii_generic_password";
let password = "test ascii password".as_bytes();
set_generic_password(name, name, password, None).unwrap();
set_generic_password(name, name, password).unwrap();
let stored_password = get_generic_password(name, name).unwrap();
assert_eq!(stored_password, password);
delete_generic_password(name, name).unwrap();
Expand All @@ -84,7 +84,7 @@ fn test_round_trip_non_ascii_generic_password() {
println!("test_round_trip_non_ascii_generic_password: start");
let name = "test_round_trip_non_ascii_generic_password";
let password = "このきれいな花は桜です".as_bytes();
set_generic_password(name, name, password, None).unwrap();
set_generic_password(name, name, password).unwrap();
let stored_password = get_generic_password(name, name).unwrap();
assert_eq!(stored_password, password);
delete_generic_password(name, name).unwrap();
Expand All @@ -95,7 +95,7 @@ fn test_round_trip_non_utf8_generic_password() {
println!("test_round_trip_non_utf8_generic_password: start");
let name = "test_round_trip_non_utf8_generic_password";
let password: [u8; 10] = [0, 121, 122, 123, 40, 50, 126, 127, 8, 9];
set_generic_password(name, name, &password, None).unwrap();
set_generic_password(name, name, &password).unwrap();
let stored_password = get_generic_password(name, name).unwrap();
assert_eq!(stored_password, password);
delete_generic_password(name, name).unwrap();
Expand All @@ -106,11 +106,11 @@ fn test_update_generic_password() {
println!("test_update_generic_password: start");
let name = "test_update_generic_password";
let password = "test ascii password".as_bytes();
set_generic_password(name, name, password, None).unwrap();
set_generic_password(name, name, password).unwrap();
let stored_password = get_generic_password(name, name).unwrap();
assert_eq!(stored_password, password);
let password = "このきれいな花は桜です".as_bytes();
set_generic_password(name, name, password, None).unwrap();
set_generic_password(name, name, password).unwrap();
let stored_password = get_generic_password(name, name).unwrap();
assert_eq!(stored_password, password);
delete_generic_password(name, name).unwrap();
Expand Down Expand Up @@ -145,7 +145,7 @@ fn test_round_trip_empty_internet_password() {
println!("test_round_trip_empty_internet_password: start");
let name = "test_empty_internet_password_input";
let in_pass = "".as_bytes();
set_internet_password(name, None, name, "/test", None, HTTP, Any, in_pass, None).unwrap();
set_internet_password(name, None, name, "/test", None, HTTP, Any, in_pass).unwrap();
let out_pass = get_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
assert_eq!(in_pass, out_pass);
delete_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
Expand All @@ -156,7 +156,7 @@ fn test_round_trip_ascii_internet_password() {
println!("test_round_trip_ascii_internet_password: start");
let name = "test_round_trip_ascii_internet_password";
let password = "test ascii password".as_bytes();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password, None).unwrap();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password).unwrap();
let stored_password = get_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
assert_eq!(stored_password, password);
delete_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
Expand All @@ -167,7 +167,7 @@ fn test_round_trip_non_ascii_internet_password() {
println!("test_round_trip_non_ascii_internet_password: start");
let name = "test_round_trip_non_ascii_internet_password";
let password = "このきれいな花は桜です".as_bytes();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password, None).unwrap();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password).unwrap();
let stored_password = get_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
assert_eq!(stored_password, password);
delete_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
Expand All @@ -178,7 +178,7 @@ fn test_round_trip_non_utf8_internet_password() {
println!("test_round_trip_non_utf8_internet_password: start");
let name = "test_round_trip_non_utf8_internet_password";
let password: [u8; 10] = [0, 121, 122, 123, 40, 50, 126, 127, 8, 9];
set_internet_password(name, None, name, "/test", None, HTTP, Any, &password, None).unwrap();
set_internet_password(name, None, name, "/test", None, HTTP, Any, &password).unwrap();
let stored_password = get_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
assert_eq!(stored_password, password);
delete_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
Expand All @@ -189,11 +189,11 @@ fn test_update_internet_password() {
println!("test_update_internet_password: start");
let name = "test_update_internet_password";
let password = "test ascii password".as_bytes();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password, None).unwrap();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password).unwrap();
let stored_password = get_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
assert_eq!(stored_password, password);
let password = "このきれいな花は桜です".as_bytes();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password, None).unwrap();
set_internet_password(name, None, name, "/test", None, HTTP, Any, password).unwrap();
let stored_password = get_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
assert_eq!(stored_password, password);
delete_internet_password(name, None, name, "/test", None, HTTP, Any).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions iostest/tests/ios_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn insert_then_find_generic() {
let mut names = vec![];
for _ in 0..4 {
let name = generate_random_string();
set_generic_password(&name, &name, name.as_bytes(), None).unwrap();
set_generic_password(&name, &name, name.as_bytes()).unwrap();
names.push(name);
}
let results = ItemSearchOptions::new()
Expand Down Expand Up @@ -78,7 +78,7 @@ fn insert_then_find_generic_legacy() {
let mut modern_names = vec![];
for _ in 0..4 {
let name = generate_random_string();
set_generic_password(&name, &name, name.as_bytes(), None).unwrap();
set_generic_password(&name, &name, name.as_bytes()).unwrap();
modern_names.push(name);
}
// first check to see that the legacy passwords are found by the modern search
Expand Down
1 change: 1 addition & 0 deletions security-framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub mod item;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod key;
pub mod os;
pub mod passwords_options;
pub mod passwords;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod policy;
Expand Down
Loading

0 comments on commit 601e14d

Please sign in to comment.