@@ -262,7 +262,7 @@ fn list_netflix_names() {
262
262
263
263
expect_cert_dns_names (
264
264
ee,
265
- & [
265
+ [
266
266
"account.netflix.com" ,
267
267
"ca.netflix.com" ,
268
268
"netflix.ca" ,
@@ -288,7 +288,7 @@ fn invalid_subject_alt_names() {
288
288
289
289
expect_cert_dns_names (
290
290
data,
291
- & [
291
+ [
292
292
"account.netflix.com" ,
293
293
"ca.netflix.com" ,
294
294
"netflix.ca" ,
@@ -314,7 +314,7 @@ fn wildcard_subject_alternative_names() {
314
314
315
315
expect_cert_dns_names (
316
316
data,
317
- & [
317
+ [
318
318
"account.netflix.com" ,
319
319
"*.netflix.com" ,
320
320
"netflix.ca" ,
@@ -332,28 +332,21 @@ fn wildcard_subject_alternative_names() {
332
332
}
333
333
334
334
#[ cfg( feature = "alloc" ) ]
335
- fn expect_cert_dns_names ( cert_der : & [ u8 ] , expected_names : & [ & str ] ) {
336
- use std:: collections:: HashSet ;
335
+ fn expect_cert_dns_names < ' name > (
336
+ cert_der : & [ u8 ] ,
337
+ expected_names : impl IntoIterator < Item = & ' name str > ,
338
+ ) {
339
+ use webpki:: GeneralDnsNameRef ;
337
340
338
341
let der = CertificateDer :: from ( cert_der) ;
339
342
let cert = webpki:: EndEntityCert :: try_from ( & der)
340
343
. expect ( "should parse end entity certificate correctly" ) ;
341
344
342
- let expected_names: HashSet < _ > = expected_names. iter ( ) . cloned ( ) . collect ( ) ;
345
+ let expected_names = expected_names
346
+ . into_iter ( )
347
+ . map ( |name| GeneralDnsNameRef :: try_from_ascii_str ( name) . unwrap ( ) ) ;
343
348
344
- let mut actual_names = cert
345
- . dns_names ( )
346
- . expect ( "should get all DNS names correctly for end entity cert" )
347
- . collect :: < Vec < _ > > ( ) ;
348
-
349
- // Ensure that converting the list to a set doesn't throw away
350
- // any duplicates that aren't supposed to be there
351
- assert_eq ! ( actual_names. len( ) , expected_names. len( ) ) ;
352
-
353
- let actual_names: std:: collections:: HashSet < & str > =
354
- actual_names. drain ( ..) . map ( |name| name. into ( ) ) . collect ( ) ;
355
-
356
- assert_eq ! ( actual_names, expected_names) ;
349
+ assert ! ( cert. dns_names( ) . unwrap( ) . eq( expected_names) ) ;
357
350
}
358
351
359
352
#[ cfg( feature = "alloc" ) ]
0 commit comments