Skip to content

Commit

Permalink
Addressed Pawel's review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-da committed Oct 14, 2021
1 parent 4026991 commit 15a619c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,22 @@ class AuthorizationInterceptorSpec
behavior of s"$className.interceptCall"

it should "close the ServerCall with a V1 status code on decoding failure" in {
testServerCloseError(usesSelfServiceErrorCodes = false) { case (status, metadata) =>
status.getCode shouldBe Status.Code.INTERNAL
status.getDescription shouldBe "Failed to get claims from request metadata"
metadata.keys() shouldBe empty
testServerCloseError(usesSelfServiceErrorCodes = false) { case (actualStatus, actualMetadata) =>
actualStatus.getCode shouldBe Status.Code.INTERNAL
actualStatus.getDescription shouldBe "Failed to get claims from request metadata"
actualMetadata.keys() shouldBe empty
}
}

it should "close the ServerCall with a V2 status code on decoding failure" in {
testServerCloseError(usesSelfServiceErrorCodes = true) {
case (actualStatus: Status, actualTrailers) =>
actualStatus.getCode shouldBe Status.Code.INTERNAL
actualStatus.getDescription shouldBe "An error occurred. Please contact the operator and inquire about the request <no-correlation-id>"
testServerCloseError(usesSelfServiceErrorCodes = true) { case (actualStatus, actualMetadata) =>
actualStatus.getCode shouldBe Status.Code.INTERNAL
actualStatus.getDescription shouldBe "An error occurred. Please contact the operator and inquire about the request <no-correlation-id>"

val actualRpcStatus = StatusProto.fromStatusAndTrailers(actualStatus, actualTrailers)
actualRpcStatus.getDetailsList.size() shouldBe 1
val errorInfo = actualRpcStatus.getDetailsList.get(0).unpack(classOf[ErrorInfo])
errorInfo.getReason shouldBe "INTERNAL_AUTHORIZATION_ERROR"
val actualRpcStatus = StatusProto.fromStatusAndTrailers(actualStatus, actualMetadata)
actualRpcStatus.getDetailsList.size() shouldBe 1
val errorInfo = actualRpcStatus.getDetailsList.get(0).unpack(classOf[ErrorInfo])
errorInfo.getReason shouldBe "INTERNAL_AUTHORIZATION_ERROR"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.util.{Failure, Success, Try}
class AuthorizerSpec extends AsyncFlatSpec with Matchers {
private val className = classOf[Authorizer].getSimpleName
private val dummyRequest = 1337L
private val expectedSuccessfulResponse = "leet"
private val expectedSuccessfulResponse = "expectedSuccessfulResponse"
private val dummyReqRes: Long => Future[String] =
Map(dummyRequest -> Future.successful(expectedSuccessfulResponse))
private val allAuthorized: ClaimSet.Claims => Either[AuthorizationError, Unit] = _ => Right(())
Expand Down

0 comments on commit 15a619c

Please sign in to comment.