@@ -9,6 +9,7 @@ import com.yubico.webauthn.TestAuthenticator
9
9
import com .yubico .webauthn .data .ByteArray
10
10
import com .yubico .webauthn .data .COSEAlgorithmIdentifier
11
11
import org .bouncycastle .asn1 .x500 .X500Name
12
+ import org .eclipse .jetty .http .HttpStatus
12
13
import org .eclipse .jetty .server .HttpConfiguration
13
14
import org .eclipse .jetty .server .HttpConnectionFactory
14
15
import org .eclipse .jetty .server .Request
@@ -198,14 +199,16 @@ class FidoMetadataDownloaderSpec
198
199
path : String ,
199
200
response : String ,
200
201
): (Server , String , X509Certificate ) =
201
- makeHttpServer(Map (path -> response.getBytes(StandardCharsets .UTF_8 )))
202
+ makeHttpServer(
203
+ Map (path -> (200 , response.getBytes(StandardCharsets .UTF_8 )))
204
+ )
202
205
private def makeHttpServer (
203
206
path : String ,
204
207
response : Array [Byte ],
205
208
): (Server , String , X509Certificate ) =
206
- makeHttpServer(Map (path -> response))
209
+ makeHttpServer(Map (path -> ( 200 , response) ))
207
210
private def makeHttpServer (
208
- responses : Map [String , Array [Byte ]]
211
+ responses : Map [String , ( Int , Array [Byte ]) ]
209
212
): (Server , String , X509Certificate ) = {
210
213
val tlsKey = TestAuthenticator .generateEcKeypair()
211
214
val tlsCert = TestAuthenticator .buildCertificate(
@@ -248,9 +251,9 @@ class FidoMetadataDownloaderSpec
248
251
response : HttpServletResponse ,
249
252
): Unit = {
250
253
responses.get(target) match {
251
- case Some (responseBody) => {
254
+ case Some ((status, responseBody) ) => {
252
255
response.getOutputStream.write(responseBody)
253
- response.setStatus(200 )
256
+ response.setStatus(status )
254
257
}
255
258
case None => response.setStatus(404 )
256
259
}
@@ -1062,7 +1065,7 @@ class FidoMetadataDownloaderSpec
1062
1065
blob.getNo should equal(blobNo)
1063
1066
}
1064
1067
1065
- it(" The BLOB is downloaded if the cached one is out of date ." ) {
1068
+ it(" The cache is used if the BLOB download fails ." ) {
1066
1069
val oldBlobNo = 1
1067
1070
val newBlobNo = 2
1068
1071
@@ -1093,7 +1096,12 @@ class FidoMetadataDownloaderSpec
1093
1096
)
1094
1097
1095
1098
val (server, serverUrl, httpsCert) =
1096
- makeHttpServer(" /blob.jwt" , newBlobJwt)
1099
+ makeHttpServer(
1100
+ Map (
1101
+ " /blob.jwt" -> (HttpStatus .TOO_MANY_REQUESTS_429 , newBlobJwt
1102
+ .getBytes(StandardCharsets .UTF_8 ))
1103
+ )
1104
+ )
1097
1105
startServer(server)
1098
1106
1099
1107
val blob = load(
@@ -1117,7 +1125,7 @@ class FidoMetadataDownloaderSpec
1117
1125
.build()
1118
1126
).getPayload
1119
1127
blob should not be null
1120
- blob.getNo should equal(newBlobNo )
1128
+ blob.getNo should equal(oldBlobNo )
1121
1129
}
1122
1130
}
1123
1131
@@ -1152,8 +1160,10 @@ class FidoMetadataDownloaderSpec
1152
1160
val (server, _, httpsCert) =
1153
1161
makeHttpServer(
1154
1162
Map (
1155
- " /chain.pem" -> certChainPem.getBytes(StandardCharsets .UTF_8 ),
1156
- " /blob.jwt" -> blobJwt.getBytes(StandardCharsets .UTF_8 ),
1163
+ " /chain.pem" -> (200 , certChainPem.getBytes(
1164
+ StandardCharsets .UTF_8
1165
+ )),
1166
+ " /blob.jwt" -> (200 , blobJwt.getBytes(StandardCharsets .UTF_8 )),
1157
1167
)
1158
1168
)
1159
1169
startServer(server)
0 commit comments