-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests for CryptoKey #88988
Add unit tests for CryptoKey #88988
Conversation
78193af
to
54eee89
Compare
My apologies, there was a careless error in 78193af , involving a file being compared to itself. |
Sorry - I have managed to lock myself out of the original account 😓 This is it's successor, on the same email address as before. If that's too complex, please close this PR, and I will gladly open another in the new account's name. EDIT - this will likely be necessary, I can't push to this branch anymore. |
Since CryptoKey is implemented by the mbedTLS module (core come with the interface, but no implementation), we might want to move the tests there, since they would all fail when |
crypto_key->save(priv_out_path); | ||
const String priv_path = TestUtils::get_data_path("crypto/in.key"); | ||
Ref<FileAccess> f_priv_out = FileAccess::open(priv_out_path, FileAccess::READ); | ||
REQUIRE(!f_priv_out.is_null()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REQUIRE(!f_priv_out.is_null()); | |
REQUIRE(f_priv_out.is_valid()); |
crypto_key->save(pub_out_path, true); | ||
const String pub_path = TestUtils::get_data_path("crypto/in.pub"); | ||
Ref<FileAccess> f_pub_out = FileAccess::open(pub_out_path, FileAccess::READ); | ||
REQUIRE(!f_pub_out.is_null()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REQUIRE(!f_pub_out.is_null()); | |
REQUIRE(f_pub_out.is_valid()); |
REQUIRE(!f_pub_out.is_null()); | ||
String s_pub_out = f_pub_out->get_as_utf8_string(); | ||
Ref<FileAccess> f_pub_in = FileAccess::open(pub_path, FileAccess::READ); | ||
String s_pub_in = f_pub_in->get_as_utf8_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String s_pub_in = f_pub_in->get_as_utf8_string(); | |
REQUIRE(f_pub_in.is_valid()); | |
String s_pub_in = f_pub_in->get_as_utf8_string(); |
REQUIRE(!f_priv_out.is_null()); | ||
String s_priv_out = f_priv_out->get_as_utf8_string(); | ||
Ref<FileAccess> f_priv_in = FileAccess::open(priv_path, FileAccess::READ); | ||
String s_priv_in = f_priv_in->get_as_utf8_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String s_priv_in = f_priv_in->get_as_utf8_string(); | |
REQUIRE(f_priv_in.is_valid()); | |
String s_priv_in = f_priv_in->get_as_utf8_string(); |
@Calinou please could you close this PR? I can't do it myself, because it was created by my irrecoverable account, nor can I implement the suggestions. I will open a duplicated one at the weekend, in this new accounts name, and link it to this one. @AThousandShips @Faless - sorry, you both gave really helpful comments - they won't be in vain! |
Further to #43440, this Pull Request adds three unit tests for
CryptoKey
.These concern a
CryptoKey
instance that has loaded in the attached private key, namelytests/data/crypto/in.key
:load()
a private key implies notis_public_only()
save()
leads to identical file contents astests/data/crypto/in.key
, since they are the same private keysave()
withpublic_only
set totrue
leads to identical contents as the separately prepared public key, namelytests/data/crypto/in.pub