Skip to content

Commit 0817223

Browse files
committed
Replace is_err with unwrap_err
The test should fail if it is a success. Other small fixes. Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
1 parent 3fb11fb commit 0817223

File tree

3 files changed

+9
-27
lines changed

3 files changed

+9
-27
lines changed

tests/per_provider/normal_tests/create_destroy_key.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ fn failed_created_key_should_be_removed() -> Result<()> {
143143
};
144144

145145
// Unsupported parameter, should fail
146-
if client.generate_key(key_name.clone(), attributes).is_err() {
147-
// The key should not exist anymore in the KIM
148-
client.generate_rsa_sign_key(key_name)?;
149-
}
146+
let _ = client
147+
.generate_key(key_name.clone(), attributes)
148+
.unwrap_err();
149+
// The key should not exist anymore in the KIM
150+
client.generate_rsa_sign_key(key_name)?;
150151

151152
Ok(())
152153
}

tests/per_provider/normal_tests/export_public_key.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,6 @@ fn check_public_rsa_export_format() -> Result<()> {
8585
Ok(())
8686
}
8787

88-
#[test]
89-
fn check_public_rsa_export_format2() -> Result<()> {
90-
// Same test but with a RsaPublicKey
91-
let mut client = TestClient::new();
92-
let key_name = String::from("check_public_rsa_export_format2");
93-
94-
client.generate_rsa_sign_key(key_name.clone())?;
95-
96-
let public_key = client.export_public_key(key_name)?;
97-
98-
// That should not fail if the bytes are in the expected format.
99-
let _public_key: RsaPublicKey = picky_asn1_der::from_bytes(&public_key).unwrap();
100-
Ok(())
101-
}
102-
10388
#[test]
10489
fn check_export_public_possible() -> Result<()> {
10590
// Exporting a public key is always permitted

tests/per_provider/normal_tests/import_key.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ fn check_format_import3() -> Result<()> {
198198

199199
#[test]
200200
fn failed_imported_key_should_be_removed() -> Result<()> {
201-
// If the key_bits field of the key attributes is zero, the operation should still work.
202-
// The size of the key is always taken from the data parameter.
203201
let mut client = TestClient::new();
204202
let key_name = String::from("failed_imported_key_should_be_removed");
205203

@@ -231,13 +229,11 @@ fn failed_imported_key_should_be_removed() -> Result<()> {
231229
},
232230
};
233231

234-
if client
232+
let _ = client
235233
.import_key(key_name.clone(), attributes, Vec::new())
236-
.is_err()
237-
{
238-
// Should succeed because key would have been destroyed.
239-
client.import_rsa_public_key(key_name, picky_asn1_der::to_vec(&public_key).unwrap())?;
240-
}
234+
.unwrap_err();
235+
// Should succeed because key would have been destroyed.
236+
client.import_rsa_public_key(key_name, picky_asn1_der::to_vec(&public_key).unwrap())?;
241237

242238
Ok(())
243239
}

0 commit comments

Comments
 (0)