Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Upgraded to Scala 2.13.1 #243

Merged
merged 2 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
with:
java-version: adopt@1.11
- name: StaticAnalysis
run: sbt clean scalafmtCheck test:scalafmtCheck scalafmtSbtCheck scapegoat
run: sbt -Dsbt.color=always -Dsbt.supershell=false clean scalafmtCheck test:scalafmtCheck scalafmtSbtCheck scapegoat
- name: Tests
run: sbt clean coverage test coverageReport coverageAggregate
run: sbt -Dsbt.color=always -Dsbt.supershell=false clean coverage test coverageReport coverageAggregate
publish:
if: github.event_name == 'push'
runs-on: ubuntu-latest
Expand All @@ -40,10 +40,10 @@ jobs:
with:
java-version: adopt@1.11
- name: PublishToBintray
run: sbt releaseEarly
run: sbt -Dsbt.color=always -Dsbt.supershell=false releaseEarly
- name: PublishToDockerHub
run: |
sbt docker:publishLocal
sbt -Dsbt.color=always -Dsbt.supershell=false docker:publishLocal
echo ${{ secrets.DOCKER_PASS }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
docker push bluebrain/nexus-iam:latest
- name: TriggerIntegrationTests
Expand All @@ -63,7 +63,7 @@ jobs:
-o /dev/null \
${{ secrets.JOB_ADDRESS }}
- name: RecordCoverage
run: sbt clean coverage test coverageReport coverageAggregate
run: sbt -Dsbt.color=always -Dsbt.supershell=false clean coverage test coverageReport coverageAggregate
- name: PublishCoverage
uses: codecov/codecov-action@v1
with:
Expand All @@ -87,14 +87,14 @@ jobs:
- name: SetVersion
run: echo ::set-env name=VERSION::$(echo ${GITHUB_REF:11})
- name: PublishToBintray
run: sbt releaseEarly
run: sbt -Dsbt.color=always -Dsbt.supershell=false releaseEarly
- name: PublishToDockerHub
run: |
sbt ";set Docker/version := \"${{ env.VERSION }}\"; docker:publishLocal"
sbt -Dsbt.color=always -Dsbt.supershell=false ";set Docker/version := \"${{ env.VERSION }}\"; docker:publishLocal"
echo ${{ secrets.DOCKER_PASS }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
docker push bluebrain/nexus-iam:${{ env.VERSION }}
- name: RecordCoverage
run: sbt clean coverage test coverageReport coverageAggregate
run: sbt -Dsbt.color=always -Dsbt.supershell=false clean coverage test coverageReport coverageAggregate
- name: PublishCoverage
uses: codecov/codecov-action@v1
with:
Expand Down
72 changes: 36 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,55 @@ scalafmt: {

// Dependency versions
val alpakkaVersion = "1.1.2"
val commonsVersion = "0.19.1"
val sourcingVersion = "0.18.0"
val commonsVersion = "0.20.0"
val sourcingVersion = "0.19.0"
val akkaVersion = "2.6.0"
val akkaCorsVersion = "0.4.2"
val akkaHttpVersion = "10.1.10"
val akkaPersistenceCassVersion = "0.100"
val akkaPersistenceMemVersion = "2.5.15.2"
val catsVersion = "2.0.0"
val circeVersion = "0.12.3"
val journalVersion = "3.0.19"
val logbackVersion = "1.2.3"
val mockitoVersion = "1.7.1"
val monixVersion = "3.1.0"
val nimbusJoseJwtVersion = "8.2.1"
val pureconfigVersion = "0.12.1"
val scalaTestVersion = "3.0.8"
val scalaLoggingVersion = "3.9.2"
val scalaTestVersion = "3.1.0"
val kryoVersion = "1.1.0"

// Dependencies modules
lazy val sourcingCore = "ch.epfl.bluebrain.nexus" %% "sourcing-core" % sourcingVersion
lazy val sourcingProjections = "ch.epfl.bluebrain.nexus" %% "sourcing-projections" % sourcingVersion
lazy val commonsCore = "ch.epfl.bluebrain.nexus" %% "commons-core" % commonsVersion
lazy val commonsKamon = "ch.epfl.bluebrain.nexus" %% "commons-kamon" % commonsVersion
lazy val commonsTest = "ch.epfl.bluebrain.nexus" %% "commons-test" % commonsVersion
lazy val akkaDowning = "ch.epfl.bluebrain.nexus" %% "akka-downing" % commonsVersion
lazy val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % akkaVersion
lazy val akkaClusterSharding = "com.typesafe.akka" %% "akka-cluster-sharding" % akkaVersion
lazy val akkaHttp = "com.typesafe.akka" %% "akka-http" % akkaHttpVersion
lazy val akkaHttpCors = "ch.megard" %% "akka-http-cors" % akkaCorsVersion
lazy val akkaHttpTestKit = "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion
lazy val akkaPersistence = "com.typesafe.akka" %% "akka-persistence" % akkaVersion
lazy val akkaPersistenceCass = "com.typesafe.akka" %% "akka-persistence-cassandra" % akkaPersistenceCassVersion
lazy val akkaPersistenceMem = "com.github.dnvriend" %% "akka-persistence-inmemory" % akkaPersistenceMemVersion
lazy val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % akkaVersion
lazy val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion
lazy val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % akkaVersion
lazy val akkaStream = "com.typesafe.akka" %% "akka-stream" % akkaVersion
lazy val akkaStreamTestKit = "com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion
lazy val alpakkaSSE = "com.lightbend.akka" %% "akka-stream-alpakka-sse" % alpakkaVersion
lazy val catsCore = "org.typelevel" %% "cats-core" % catsVersion
lazy val circeCore = "io.circe" %% "circe-core" % circeVersion
lazy val journalCore = "io.verizon.journal" %% "core" % journalVersion
lazy val mockitoScala = "org.mockito" %% "mockito-scala" % mockitoVersion
lazy val monixEval = "io.monix" %% "monix-eval" % monixVersion
lazy val nimbusJoseJwt = "com.nimbusds" % "nimbus-jose-jwt" % nimbusJoseJwtVersion
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion
lazy val pureconfig = "com.github.pureconfig" %% "pureconfig" % pureconfigVersion
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
lazy val kryo = "io.altoo" %% "akka-kryo-serialization" % kryoVersion
lazy val sourcingCore = "ch.epfl.bluebrain.nexus" %% "sourcing-core" % sourcingVersion
lazy val sourcingProjections = "ch.epfl.bluebrain.nexus" %% "sourcing-projections" % sourcingVersion
lazy val commonsCore = "ch.epfl.bluebrain.nexus" %% "commons-core" % commonsVersion
lazy val commonsKamon = "ch.epfl.bluebrain.nexus" %% "commons-kamon" % commonsVersion
lazy val commonsTest = "ch.epfl.bluebrain.nexus" %% "commons-test" % commonsVersion
lazy val akkaDowning = "ch.epfl.bluebrain.nexus" %% "akka-downing" % commonsVersion
lazy val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % akkaVersion
lazy val akkaClusterSharding = "com.typesafe.akka" %% "akka-cluster-sharding" % akkaVersion
lazy val akkaHttp = "com.typesafe.akka" %% "akka-http" % akkaHttpVersion
lazy val akkaHttpCors = "ch.megard" %% "akka-http-cors" % akkaCorsVersion
lazy val akkaHttpTestKit = "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion
lazy val akkaPersistence = "com.typesafe.akka" %% "akka-persistence" % akkaVersion
lazy val akkaPersistenceCass = "com.typesafe.akka" %% "akka-persistence-cassandra" % akkaPersistenceCassVersion
lazy val akkaPersistenceMem = "com.github.dnvriend" %% "akka-persistence-inmemory" % akkaPersistenceMemVersion
lazy val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % akkaVersion
lazy val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion
lazy val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % akkaVersion
lazy val akkaStream = "com.typesafe.akka" %% "akka-stream" % akkaVersion
lazy val akkaStreamTestKit = "com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion
lazy val alpakkaSSE = "com.lightbend.akka" %% "akka-stream-alpakka-sse" % alpakkaVersion
lazy val catsCore = "org.typelevel" %% "cats-core" % catsVersion
lazy val circeCore = "io.circe" %% "circe-core" % circeVersion
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion
lazy val mockitoScala = "org.mockito" %% "mockito-scala" % mockitoVersion
lazy val monixEval = "io.monix" %% "monix-eval" % monixVersion
lazy val nimbusJoseJwt = "com.nimbusds" % "nimbus-jose-jwt" % nimbusJoseJwtVersion
lazy val pureconfig = "com.github.pureconfig" %% "pureconfig" % pureconfigVersion
lazy val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
lazy val kryo = "io.altoo" %% "akka-kryo-serialization" % kryoVersion

lazy val iam = project
.in(file("."))
Expand Down Expand Up @@ -103,12 +103,12 @@ lazy val iam = project
akkaClusterSharding,
catsCore,
circeCore,
journalCore,
kryo,
logbackClassic,
monixEval,
nimbusJoseJwt,
logbackClassic,
pureconfig,
scalaLogging,
akkaTestKit % Test,
akkaHttpTestKit % Test,
akkaStreamTestKit % Test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import ch.epfl.bluebrain.nexus.iam.client.config.IamClientConfig
import ch.epfl.bluebrain.nexus.iam.client.types.AuthToken
import ch.epfl.bluebrain.nexus.rdf.Iri.AbsoluteIri
import ch.epfl.bluebrain.nexus.commons.rdf.syntax._
import com.typesafe.scalalogging.Logger
import io.circe.Decoder
import io.circe.parser.decode
import journal.Logger

import scala.concurrent.{ExecutionContext, Future}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import ch.epfl.bluebrain.nexus.iam.client.types._
import ch.epfl.bluebrain.nexus.iam.client.types.events.Event
import ch.epfl.bluebrain.nexus.iam.client.types.events.Event.{AclEvent, PermissionsEvent, RealmEvent}
import ch.epfl.bluebrain.nexus.rdf.Iri.{AbsoluteIri, Path}
import com.typesafe.scalalogging.Logger
import io.circe.generic.auto._
import io.circe.syntax._
import io.circe.{DecodingFailure, Json, ParsingFailure}
import journal.Logger

import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future}
import scala.reflect.ClassTag
Expand Down Expand Up @@ -93,11 +93,12 @@ class IamClient[F[_]] private[client] (
def putAcls(path: Path, acl: AccessControlList, rev: Option[Long] = None)(
implicit credentials: Option[AuthToken]
): F[Unit] = {
implicit val _ = config
val endpoint = config.aclsIri + path
val entity = HttpEntity(ContentTypes.`application/json`, acl.asJson.noSpaces)
val query = rev.map(r => Query("rev" -> r.toString)).getOrElse(Query.Empty)
val request = Put(endpoint.toAkkaUri.withQuery(query), entity)
implicit val iamClientConfig: IamClientConfig = config

val endpoint = config.aclsIri + path
val entity = HttpEntity(ContentTypes.`application/json`, acl.asJson.noSpaces)
val query = rev.map(r => Query("rev" -> r.toString)).getOrElse(Query.Empty)
val request = Put(endpoint.toAkkaUri.withQuery(query), entity)
val requestWithCredentials =
credentials.map(token => request.addCredentials(OAuth2BearerToken(token.value))).getOrElse(request)
jsonClient(requestWithCredentials) *> F.unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ object Vocabulary {
* Nexus vocabulary.
*/
object nxv {
val base: Iri.AbsoluteIri = url"https://bluebrain.github.io/nexus/vocabulary/".value
private[Vocabulary] implicit val _ = IriNode(base)
val base: Iri.AbsoluteIri = url"https://bluebrain.github.io/nexus/vocabulary/".value
private[Vocabulary] implicit val iriNode: IriNode = IriNode(base)

/**
* @param suffix the segment to suffix to the base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ final case class AccessControlList(value: Map[Identity, Set[Permission]]) {
def ++(acl: AccessControlList): AccessControlList = {
val toAddKeys = acl.value.keySet -- value.keySet
val toMergeKeys = acl.value.keySet -- toAddKeys
val added = value ++ acl.value.filterKeys(toAddKeys.contains)
val merged = value.filterKeys(toMergeKeys.contains).map {
val added = value ++ acl.value.view.filterKeys(toAddKeys.contains)
val merged = value.view.filterKeys(toMergeKeys.contains).map {
case (ident, perms) => ident -> (perms ++ acl.value.getOrElse(ident, Set.empty))
}
AccessControlList(added ++ merged)
Expand All @@ -43,7 +43,7 @@ final case class AccessControlList(value: Map[Identity, Set[Permission]]) {
* @param identities the identities to be filtered
*/
def filter(identities: Set[Identity]): AccessControlList =
AccessControlList(value.filterKeys(identities.contains))
AccessControlList(value.view.filterKeys(identities.contains).toMap)
}

object AccessControlList {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.iam.client.types

import java.time.Instant

import cats.syntax.either._
import ch.epfl.bluebrain.nexus.iam.client.config.Contexts._
import ch.epfl.bluebrain.nexus.iam.client.config.IamClientConfig
import ch.epfl.bluebrain.nexus.iam.client.config.Vocabulary._
Expand Down Expand Up @@ -84,7 +83,7 @@ object ResourceAccessControlList {
} yield ResourceAccessControlList(id, rev, types, createdAt, createdBy, updatedAt, updatedBy, acl)
}

private implicit class AbsoluteIriSyntax(private val iri: AbsoluteIri) extends AnyVal {
private[ResourceAccessControlList] implicit class AbsoluteIriSyntax(private val iri: AbsoluteIri) extends AnyVal {
def lastSegment: Option[String] =
iri.path.head match {
case segment: String => Some(segment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ object Event {
subject: Subject
) extends RealmEvent

private implicit val config: Configuration = Configuration.default
private[events] implicit val config: Configuration = Configuration.default
.withDiscriminator("@type")
.copy(transformMemberNames = {
case "label" => "_label"
Expand All @@ -287,7 +287,7 @@ object Event {
case other => other
})

private implicit val subjectDecoder: Decoder[Subject] =
private[events] implicit val subjectDecoder: Decoder[Subject] =
Decoder.decodeString.flatMap { id =>
Iri.absolute(id) match {
case Left(_) => Decoder.failedWithMessage(s"Couldn't convert id '$id' to Absolute Iri")
Expand All @@ -305,7 +305,7 @@ object Event {
implicit val eventDecoder: Decoder[Event] =
deriveConfiguredDecoder[Event]

private implicit val aclDecoder: Decoder[AccessControlList] =
private[events] implicit val aclDecoder: Decoder[AccessControlList] =
Decoder.instance { hc =>
for {
arr <- hc.focus.flatMap(_.asArray).toRight(DecodingFailure("acl field not found", hc.history))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import cats.effect.IO
import cats.implicits._
import ch.epfl.bluebrain.nexus.commons.http.HttpClient
import ch.epfl.bluebrain.nexus.commons.test.Resources
import ch.epfl.bluebrain.nexus.commons.test.io.IOValues
import ch.epfl.bluebrain.nexus.commons.test.io.IOEitherValues
import ch.epfl.bluebrain.nexus.iam.client.IamClientError.{Forbidden, Unauthorized}
import ch.epfl.bluebrain.nexus.iam.client.config.IamClientConfig
import ch.epfl.bluebrain.nexus.iam.client.types.Identity.{Anonymous, User}
Expand All @@ -26,25 +26,26 @@ import ch.epfl.bluebrain.nexus.rdf.syntax.node.unsafe._
import io.circe.Json
import org.mockito.{ArgumentMatchersSugar, IdiomaticMockito, Mockito}
import org.scalatest.concurrent.Eventually
import org.scalatest.{BeforeAndAfter, EitherValues, Matchers, WordSpecLike}
import org.scalatest.wordspec.AnyWordSpecLike
import org.scalatest.BeforeAndAfter
import org.scalatest.matchers.should.Matchers

import scala.concurrent.duration._
import scala.util.Random

//noinspection ScalaUnnecessaryParentheses,TypeAnnotation,RedundantDefaultArgument
class IamClientSpec
extends TestKit(ActorSystem("IamClientSpec"))
with WordSpecLike
with AnyWordSpecLike
with Matchers
with BeforeAndAfter
with IdiomaticMockito
with ArgumentMatchersSugar
with IOValues
with EitherValues
with IOEitherValues
with Resources
with Eventually {

override implicit val patienceConfig: PatienceConfig = PatienceConfig(5 seconds, 15 milliseconds)
override implicit val patienceConfig: PatienceConfig = PatienceConfig(5.seconds, 15.milliseconds)

private val clock = Clock.fixed(Instant.ofEpochSecond(3600), ZoneId.systemDefault())
private val config =
Expand Down Expand Up @@ -300,7 +301,7 @@ class IamClientSpec
"/events/realm-deprecated.json"
)

val eventsSource = Source(Random.shuffle(resources).map(jsonContentOf(_).as[Event].right.value))
val eventsSource = Source(Random.shuffle(resources).map(jsonContentOf(_).as[Event].rightValue))
}

"apply function when new acl event is received" in new Ctx {
Expand All @@ -310,7 +311,7 @@ class IamClientSpec
case _: AclSubtracted => IO(count.addAndGet(3)) *> IO.unit
case _: AclDeleted => IO(count.addAndGet(4)) *> IO.unit
}
val eventsIri = Iri.url("http://internal.example.com/some/v1/acls/events").right.value
val eventsIri = Iri.url("http://internal.example.com/some/v1/acls/events").rightValue
source(eventsIri, None) shouldReturn eventsSource
client.aclEvents(f)
eventually(count.get() shouldEqual 10)
Expand All @@ -323,7 +324,7 @@ class IamClientSpec
case _: PermissionsSubtracted => IO(count.addAndGet(3)) *> IO.unit
case _: PermissionsDeleted => IO(count.addAndGet(4)) *> IO.unit
}
val eventsIri = Iri.url("http://internal.example.com/some/v1/permissions/events").right.value
val eventsIri = Iri.url("http://internal.example.com/some/v1/permissions/events").rightValue
source(eventsIri, None) shouldReturn eventsSource
client.permissionEvents(f)
eventually(count.get() shouldEqual 10)
Expand All @@ -335,7 +336,7 @@ class IamClientSpec
case _: RealmUpdated => IO(count.addAndGet(2)) *> IO.unit
case _: RealmDeprecated => IO(count.addAndGet(3)) *> IO.unit
}
val eventsIri = Iri.url("http://internal.example.com/some/v1/realms/events").right.value
val eventsIri = Iri.url("http://internal.example.com/some/v1/realms/events").rightValue
source(eventsIri, None) shouldReturn eventsSource
client.realmEvents(f)
eventually(count.get() shouldEqual 6)
Expand Down