@@ -157,6 +157,32 @@ void main() {
157157 });
158158 });
159159
160+ group ('KeyPair Factory Tests' , () {
161+ test ('Generate a random RSA Keypair' , () {
162+ final keypair = RSAKeypairFactory ().fromRandom ();
163+ expect (keypair, isNot (isA <ECKeypair >()));
164+ expect (keypair, isA <RSAKeypair >());
165+ });
166+
167+ test ('Generate a random RSA Keypair asynchronously' , () async {
168+ final keypair = await RSAKeypairFactory ().fromRandomAsync ();
169+ expect (keypair, isNot (isA <ECKeypair >()));
170+ expect (keypair, isA <RSAKeypair >());
171+ });
172+
173+ test ('Generate a random EC Keypair' , () {
174+ final keypair = ECKeypairFactory ().fromRandom ();
175+ expect (keypair, isNot (isA <RSAKeypair >()));
176+ expect (keypair, isA <ECKeypair >());
177+ });
178+
179+ test ('Generate a random EC Keypair asynchronously' , () async {
180+ final keypair = await ECKeypairFactory ().fromRandomAsync ();
181+ expect (keypair, isNot (isA <RSAKeypair >()));
182+ expect (keypair, isA <ECKeypair >());
183+ });
184+ });
185+
160186 group ('Edge Cases' , () {
161187 late RSAKeypair rsaKeypair;
162188
@@ -183,19 +209,20 @@ void main() {
183209
184210 test (
185211 'Public key PEM-String is formatted and with a leading and trailing whitespace' ,
186- () {
187- var pemLeadingWhitespace = " \n ${rsaKeypair .privateKey .toFormattedPEM ()}" ;
188- var pemTrailingWhitespace = "${rsaKeypair .privateKey .toFormattedPEM ()}\n " ;
212+ () {
213+ var pemLeadingWhitespace = " \n ${rsaKeypair .privateKey .toFormattedPEM ()}" ;
214+ var pemTrailingWhitespace =
215+ "${rsaKeypair .privateKey .toFormattedPEM ()}\n " ;
189216
190- final publicKeyString = rsaKeypair.privateKey.toString ();
217+ final publicKeyString = rsaKeypair.privateKey.toString ();
191218
192- final publicKeyLeadingWhitespace =
219+ final publicKeyLeadingWhitespace =
193220 RSAPrivateKey .fromPEM (pemLeadingWhitespace);
194- expect (publicKeyLeadingWhitespace.toString (), publicKeyString);
221+ expect (publicKeyLeadingWhitespace.toString (), publicKeyString);
195222
196- final publicKeyTrailingWhitespace =
223+ final publicKeyTrailingWhitespace =
197224 RSAPrivateKey .fromPEM (pemTrailingWhitespace);
198- expect (publicKeyTrailingWhitespace.toString (), publicKeyString);
199- });
225+ expect (publicKeyTrailingWhitespace.toString (), publicKeyString);
226+ });
200227 });
201228}
0 commit comments