Jos*_*shG 6 scala www-authenticate akka-http
在我的akka-http应用程序中,我从另一个响应WWW-Authenticate头部的安全服务返回响应:当akka-http解析此头部然后将WWW-Authenticate值呈现为字符串时,其中一个参数的引号丢失.我在渲染中遗漏了什么,或者这是一个akka-http错误?
这是一个测试用例:
import akka.http.scaladsl.model.HttpHeader
import akka.http.scaladsl.model.HttpHeader.ParsingResult
import akka.http.scaladsl.model.headers.{`WWW-Authenticate`, HttpChallenge}
import org.scalatest.{Matchers, WordSpec}
class wwwAuthenticateParserTest extends WordSpec with Matchers {
"WWW-Authenticate header" should {
"have correctly-quoted strings" in {
val rawHeader = HttpHeader.parse("WWW-Authenticate",
"Bearer error=\"invalid_request\", error_description=\"Access token is not found\"")
val expectedHeader = `WWW-Authenticate`(HttpChallenge("Bearer",
"",
Map("error" -> "invalid_request", "error_description" -> "Access token is not found")))
rawHeader match {
case ParsingResult.Ok(`WWW-Authenticate`(challenges), _) =>
challenges.head should be(expectedHeader.challenges.head)
challenges.head.params("error") should be("invalid_request")
challenges.head.toString should be("Bearer realm=\"\",error=\"invalid_request\",error_description=\"Access token is not found\"")
case _ => ???
}
}
Run Code Online (Sandbox Code Playgroud)
第三个断言失败,引号周围invalid_request缺失.akka-http应用程序发送的响应标头中也缺少引号.
| 归档时间: |
|
| 查看次数: |
256 次 |
| 最近记录: |