Update the Rust test to reflect the new Debug
Debug implementation was changed in https://android-review.googlesource.com/c/platform/frameworks/native/+/2239178.
This changes how enums made with declare_binder_enum are displayed by default. The updated strings print the Debug
implementation for the enum and check the values against that.
Test: Tested using `atest keystore2_test`
Bug: 252968848
Change-Id: I86a124432f83116b87c9b40c023851fac4030fb8
diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs
index 5cdfbe9..0f96d5c 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -3518,15 +3518,15 @@
// Test that we must pass in a valid Domain.
check_result_is_error_containing_string(
db.create_key_entry(&Domain::GRANT, &102, KeyType::Client, &KEYSTORE_UUID),
- "Domain Domain(1) must be either App or SELinux.",
+ &format!("Domain {:?} must be either App or SELinux.", Domain::GRANT),
);
check_result_is_error_containing_string(
db.create_key_entry(&Domain::BLOB, &103, KeyType::Client, &KEYSTORE_UUID),
- "Domain Domain(3) must be either App or SELinux.",
+ &format!("Domain {:?} must be either App or SELinux.", Domain::BLOB),
);
check_result_is_error_containing_string(
db.create_key_entry(&Domain::KEY_ID, &104, KeyType::Client, &KEYSTORE_UUID),
- "Domain Domain(4) must be either App or SELinux.",
+ &format!("Domain {:?} must be either App or SELinux.", Domain::KEY_ID),
);
Ok(())
@@ -3825,15 +3825,15 @@
// Test that we must pass in a valid Domain.
check_result_is_error_containing_string(
rebind_alias(&mut db, &KEY_ID_LOCK.get(0), "foo", Domain::GRANT, 42),
- "Domain Domain(1) must be either App or SELinux.",
+ &format!("Domain {:?} must be either App or SELinux.", Domain::GRANT),
);
check_result_is_error_containing_string(
rebind_alias(&mut db, &KEY_ID_LOCK.get(0), "foo", Domain::BLOB, 42),
- "Domain Domain(3) must be either App or SELinux.",
+ &format!("Domain {:?} must be either App or SELinux.", Domain::BLOB),
);
check_result_is_error_containing_string(
rebind_alias(&mut db, &KEY_ID_LOCK.get(0), "foo", Domain::KEY_ID, 42),
- "Domain Domain(4) must be either App or SELinux.",
+ &format!("Domain {:?} must be either App or SELinux.", Domain::KEY_ID),
);
// Test that we correctly handle setting an alias for something that does not exist.