Skip to content

Commit

Permalink
upgrade jwt-scala (#257)
Browse files Browse the repository at this point in the history
* upgrade jwt-scala

Update Dependencies.scala

* compile problem

* Update Dependencies.scala

* Update Dependencies.scala

* compile issues

* Update SqsAckSpec.scala
  • Loading branch information
pjfanning authored Jan 27, 2024
1 parent 838dcca commit 7475bc2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private[auth] object GoogleOAuth2 {
.expiresIn(3600)
.issuedNow

JwtSprayJson.encode(claim, privateKey, RS256)
JwtSprayJson(clock).encode(claim, privateKey, RS256)
}

final case class JwtClaimContent(scope: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ private[google] trait JwtSprayJsonParser[H, C] extends JwtJsonCommon[JsObject, H
}

@InternalApi
private[google] object JwtSprayJson extends JwtSprayJsonParser[JwtHeader, JwtClaim] {
import DefaultJsonProtocol._

private[google] object JwtSprayJson {
def apply(clock: Clock): JwtSprayJson = new JwtSprayJson(clock)
}

@InternalApi
private[google] class JwtSprayJson private (defaultClock: Clock)
extends JwtSprayJsonParser[JwtHeader, JwtClaim] {
import DefaultJsonProtocol._
implicit val clock: Clock = defaultClock

override def parseHeader(header: String): JwtHeader = {
val jsObj = parse(header)
Expand Down Expand Up @@ -75,10 +80,3 @@ private[google] object JwtSprayJson extends JwtSprayJsonParser[JwtHeader, JwtCla
private[this] def safeGetField[A: JsonReader](js: JsObject, name: String) =
js.fields.get(name).flatMap(safeRead[A])
}

@InternalApi
private[google] class JwtSprayJson private (override val clock: Clock)
extends JwtSprayJsonParser[JwtHeader, JwtClaim] {
override def parseHeader(header: String): JwtHeader = JwtSprayJson.parseHeader(header)
override def parseClaim(header: String): JwtClaim = JwtSprayJson.parseClaim(header)
}
14 changes: 7 additions & 7 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ object Dependencies {
val PekkoGrpcBinaryVersion = "1.0"
val PekkoHttpVersion = PekkoHttpDependency.version
val PekkoHttpBinaryVersion = "1.0"
val ScalaTestVersion = "3.2.14"
val ScalaTestVersion = "3.2.17"
val TestContainersScalaTestVersion = "0.41.0"
val mockitoVersion = "4.2.0" // check even https://github.com/scalatest/scalatestplus-mockito/releases
val mockitoVersion = "4.11.0" // check even https://github.com/scalatest/scalatestplus-mockito/releases
val protobufJavaVersion = "3.21.12"
val hoverflyVersion = "0.14.1"
val scalaCheckVersion = "1.16.0"
val scalaCheckVersion = "1.17.0"

val LogbackForSlf4j1Version = "1.2.13"
val LogbackForSlf4j2Version = "1.3.14"
Expand All @@ -60,7 +60,7 @@ object Dependencies {
val CouchbaseVersionForDocs = "2.7"

val GoogleAuthVersion = "1.20.0"
val JwtCoreVersion = "3.0.1"
val JwtScalaVersion = "9.4.4"

val log4jOverSlf4jVersion = "1.7.36"
val jclOverSlf4jVersion = "1.7.36"
Expand All @@ -85,7 +85,7 @@ object Dependencies {
val Mockito = Seq(
"org.mockito" % "mockito-core" % mockitoVersion % Test,
// https://github.com/scalatest/scalatestplus-mockito/releases
"org.scalatestplus" %% "mockito-4-6" % (ScalaTestVersion + ".0") % Test)
"org.scalatestplus" %% "mockito-4-11" % (ScalaTestVersion + ".0") % Test)

// Releases https://github.com/FasterXML/jackson-databind/releases
// CVE issues https://github.com/FasterXML/jackson-databind/issues?utf8=%E2%9C%93&q=+label%3ACVE
Expand Down Expand Up @@ -204,7 +204,7 @@ object Dependencies {
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-http" % PekkoHttpVersion,
"org.apache.pekko" %% "pekko-http-spray-json" % PekkoHttpVersion,
"com.github.jwt-scala" %% "jwt-json-common" % "7.1.5",
"com.github.jwt-scala" %% "jwt-json-common" % JwtScalaVersion,
"com.google.auth" % "google-auth-library-credentials" % GoogleAuthVersion,
"io.specto" % "hoverfly-java" % hoverflyVersion % Test) ++ Mockito)

Expand Down Expand Up @@ -295,7 +295,7 @@ object Dependencies {
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-http" % PekkoHttpVersion,
"org.apache.pekko" %% "pekko-http-spray-json" % PekkoHttpVersion,
"com.github.jwt-scala" %% "jwt-json-common" % "7.1.5") ++ Mockito)
"com.github.jwt-scala" %% "jwt-json-common" % JwtScalaVersion) ++ Mockito)

val InfluxDB = Seq(
libraryDependencies ++= Seq(
Expand Down
12 changes: 9 additions & 3 deletions sqs/src/test/scala/docs/scaladsl/SqsAckSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package docs.scaladsl

import java.util.concurrent.{ CompletableFuture, TimeUnit }
import java.util.function.Supplier

import org.apache.pekko
import pekko.Done
import pekko.stream.connectors.sqs.scaladsl._
Expand All @@ -25,8 +24,9 @@ import pekko.stream.connectors.sqs.SqsAckResultEntry._
import pekko.stream.connectors.testkit.scaladsl.LogCapturing
import pekko.stream.scaladsl.{ Sink, Source }
import pekko.util.ccompat.JavaConverters._
import org.mockito.{ Answers, Mockito }
import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito.{ spy, times, verify, when }
import org.mockito.Mockito.{ times, verify, when, withSettings }
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.mockito.MockitoSugar.mock
Expand All @@ -39,7 +39,13 @@ class SqsAckSpec extends AnyFlatSpec with Matchers with DefaultTestContext with

trait IntegrationFixture {
val queueUrl: String = randomQueueUrl()
implicit val awsSqsClient: SqsAsyncClient = spy(sqsClient)
implicit val awsSqsClient: SqsAsyncClient = spyInternal(sqsClient)

// spyInternal was created due to compile problems using Mockito 4.11 in Scala 2.12
private def spyInternal[T](t: T): T =
Mockito.mock(t.getClass.asInstanceOf[Class[T]],
withSettings.spiedInstance(t)
.defaultAnswer(Answers.CALLS_REAL_METHODS))

def sendMessage(message: String): Unit = {
def request =
Expand Down
2 changes: 1 addition & 1 deletion sqs/src/test/scala/docs/scaladsl/SqsSourceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SqsSourceSpec extends AnyFlatSpec with ScalaFutures with Matchers with Def

import SqsSourceSpec._

implicit override val patienceConfig = PatienceConfig(timeout = 10.seconds, interval = 100.millis)
implicit override val patienceConfig: PatienceConfig = PatienceConfig(timeout = 10.seconds, interval = 100.millis)

trait IntegrationFixture {
val queueUrl: String = randomQueueUrl()
Expand Down

0 comments on commit 7475bc2

Please sign in to comment.