Akka-Http WWW-Authenticate渲染没有引号

时间:2016-04-05 16:31:35

标签: scala akka-http www-authenticate

在我的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 _ => ???
      }
    }

第三个断言失败,invalid_request周围的引号丢失。

0 个答案:

没有答案