Skip to content

Commit 45f4bad

Browse files
committed
Test that FidoMetadataDownloader does not write cache file if not necessary
1 parent 5e75688 commit 45f4bad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

webauthn-server-attestation/src/test/scala/com/yubico/fido/metadata/FidoMetadataDownloaderSpec.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class FidoMetadataDownloaderSpec
410410
}
411411

412412
it(
413-
"The trust root is not downloaded if there's a valid one in file cache."
413+
"The trust root is not downloaded and not written to cache if there's a valid one in file cache."
414414
) {
415415
val random = new SecureRandom()
416416
val trustRootDistinguishedName =
@@ -438,6 +438,10 @@ class FidoMetadataDownloaderSpec
438438
f.write(trustRootCert.getEncoded)
439439
f.close()
440440
cacheFile.deleteOnExit()
441+
cacheFile.setLastModified(
442+
cacheFile.lastModified() - 1000
443+
) // Set mtime in the past to ensure any write will change it
444+
val initialModTime = cacheFile.lastModified
441445

442446
val blob = load(
443447
FidoMetadataDownloader
@@ -456,6 +460,7 @@ class FidoMetadataDownloaderSpec
456460
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
457461
trustRootDistinguishedName
458462
)
463+
cacheFile.lastModified should equal(initialModTime)
459464
}
460465

461466
it(

0 commit comments

Comments
 (0)