diff --git a/build.sbt b/build.sbt index 7d22e32fa..74fa1a091 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,3 @@ -// shadow sbt-scalajs' crossProject and CrossType until Scala.js 1.0.0 is released -import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} - name := "wust" // docker versions do not allow '+' @@ -10,8 +7,8 @@ dynver in ThisBuild ~= (_.replace('+', '-')) // TODO: https://github.com/dwijnan import Def.{setting => dep} // -- common setting -- -crossScalaVersions in ThisBuild := Seq("2.12.12") -scalaVersion in ThisBuild := crossScalaVersions.value.last +scalaVersion in ThisBuild := "2.12.12" + Global / onChangedBuildSource := IgnoreSourceChanges // disabled, since it doesn't recover state of devserver @@ -31,6 +28,9 @@ lazy val commonSettings = Seq( Deps.sourcecode.value :: Deps.scalatest.value % Test :: Deps.mockito.value % Test :: + Deps.scalatestFreespec.value % Test :: + Deps.scalatestMustmatchers.value % Test :: + Deps.scalatestMockito.value % Test :: Nil, dependencyOverrides ++= List( Deps.circe.core.value, @@ -72,17 +72,12 @@ lazy val commonSettings = Seq( "-feature" :: "-language:_" :: "-Xfuture" :: - "-Yno-adapted-args" :: - "-Ywarn-infer-any" :: - "-Ywarn-nullary-override" :: - "-Ywarn-nullary-unit" :: // "-opt-warnings:at-inline-failed" :: "-Xlint:_" :: "-Ywarn-unused:-imports" :: // "-Ywarn-self-implicit" :: // "-Ywarn-dead-code" :: // does not work well with scalajs js.native in facades "-Ywarn-extra-implicit" :: - "-P:silencer:checkUnused" :: "-Ypatmat-exhaust-depth" :: "off" :: // needed for huge match in FeatureDetails Nil, @@ -115,11 +110,6 @@ lazy val commonSettings = Seq( // scalacOptions in Test ~= (_ filterNot (_ == "-Xplugin-require:scalaxy-streams")), // scalacOptions in Test += "-Xplugin-disable:scalaxy-streams", // addCompilerPlugin("com.github.fdietze" % "scalaxy-streams" % "2.12-819f13722a-1"), //TODO: https://github.com/nativelibs4java/scalaxy-streams/pull/13 - - libraryDependencies ++= Seq( - compilerPlugin("com.github.ghik" %% "silencer-plugin" % Deps.silencerVersion), - "com.github.ghik" %% "silencer-lib" % Deps.silencerVersion % Provided - ) ) lazy val commonWebSettings = Seq( diff --git a/core/src/main/scala/wust/core/Server.scala b/core/src/main/scala/wust/core/Server.scala index 5b3839857..7a326c813 100644 --- a/core/src/main/scala/wust/core/Server.scala +++ b/core/src/main/scala/wust/core/Server.scala @@ -4,6 +4,7 @@ import java.nio.ByteBuffer import akka.actor.ActorSystem import akka.util.ByteStringBuilder +import ch.megard.akka.http.cors.scaladsl.model.HttpOriginMatcher import akka.http.scaladsl.marshalling.{Marshaller, ToResponseMarshaller} import akka.http.scaladsl.model.headers.HttpOriginRange import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpResponse, StatusCodes} @@ -49,7 +50,7 @@ object Server { val route = createRoute(config) - Http().bindAndHandle(route, interface = "0.0.0.0", port = config.server.port).onComplete { + Http().newServerAt("0.0.0.0", config.server.port).bindFlow(route).onComplete { case Success(binding) => { val separator = "\n" + ("#" * 50) val readyMsg = s"\n##### Server online at ${binding.localAddress} #####" @@ -108,7 +109,7 @@ object Server { val (protocol,port) = if (config.server.host == "localhost") ("http://", ":12345") else ("https://", "") s"${protocol}${config.server.host}${port}" } - val corsSettings = CorsSettings.defaultSettings.withAllowedOrigins(HttpOriginRange(websiteOrigin)) + val corsSettings = CorsSettings.defaultSettings.withAllowedOrigins(HttpOriginMatcher(websiteOrigin)) implicit val jsonMarshaller: ToResponseMarshaller[String] = Marshaller.withFixedContentType(ContentTypes.`application/json`) { s => diff --git a/core/src/main/scala/wust/core/config/Config.scala b/core/src/main/scala/wust/core/config/Config.scala index b86327783..f9f7610e4 100644 --- a/core/src/main/scala/wust/core/config/Config.scala +++ b/core/src/main/scala/wust/core/config/Config.scala @@ -61,6 +61,7 @@ final case class Config( object Config { import pureconfig._ import wust.util.Config._ + import pureconfig.generic.auto._ def load = loadConfig[Config]("wust.core") } diff --git a/core/src/test/scala/wust/core/ApiImplSpec.scala b/core/src/test/scala/wust/core/ApiImplSpec.scala index cfb6874c6..f6d21a206 100644 --- a/core/src/test/scala/wust/core/ApiImplSpec.scala +++ b/core/src/test/scala/wust/core/ApiImplSpec.scala @@ -10,7 +10,7 @@ // import java.time.LocalDateTime // import scala.concurrent.duration._ -// class ApiImplSpec extends AsyncFreeSpec with MustMatchers with ApiTestKit { +// class ApiImplSpec extends AsyncFreeSpec with must.Matchers with ApiTestKit { // object User { // def apply(id: Long, name: String): User = new User(id, name, isImplicit = false, 0) diff --git a/core/src/test/scala/wust/core/AuthApiImplSpec.scala b/core/src/test/scala/wust/core/AuthApiImplSpec.scala index 9578033cc..df583cf7f 100644 --- a/core/src/test/scala/wust/core/AuthApiImplSpec.scala +++ b/core/src/test/scala/wust/core/AuthApiImplSpec.scala @@ -12,7 +12,7 @@ // import scala.concurrent.duration._ // import com.roundeights.hasher.Hasher -// class AuthApiImplSpec extends AsyncFreeSpec with MustMatchers with ApiTestKit { +// class AuthApiImplSpec extends AsyncFreeSpec with must.Matchers with ApiTestKit { // implicit def passwordToDigest(pw: String): Array[Byte] = Hasher(pw).bcrypt // // implicit class EqualityByteArray(val arr: Array[Byte]) { // // def mustEqualDigest(pw: String) = assert(passwordToDigest(pw) diff --git a/core/src/test/scala/wust/core/GuardDslSpec.scala b/core/src/test/scala/wust/core/GuardDslSpec.scala index a0423efa1..372ba5d59 100644 --- a/core/src/test/scala/wust/core/GuardDslSpec.scala +++ b/core/src/test/scala/wust/core/GuardDslSpec.scala @@ -12,7 +12,7 @@ // import scala.concurrent.Future // import scala.concurrent.duration._ -// class GuardDslSpec extends AsyncFreeSpec with MustMatchers with DbMocks { +// class GuardDslSpec extends AsyncFreeSpec with must.Matchers with DbMocks { // val implicitUserDb = Data.User(14, "implicit", isImplicit = true, 0) // val implicitUser = DbConversions.forClient(implicitUserDb) // val initialUser = User(11, "existing", isImplicit = false, 0) diff --git a/core/src/test/scala/wust/core/JWTSpec.scala b/core/src/test/scala/wust/core/JWTSpec.scala index 60ec8732e..deb346245 100644 --- a/core/src/test/scala/wust/core/JWTSpec.scala +++ b/core/src/test/scala/wust/core/JWTSpec.scala @@ -3,13 +3,15 @@ package wust.core import java.time.Instant import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec import wust.api.{AuthUser, Authentication} import wust.core.auth.JWT import wust.ids._ import scala.concurrent.duration._ -class JWTSpec extends FreeSpec with MustMatchers { +class JWTSpec extends AnyFreeSpec with must.Matchers { val jwt = new JWT("secret", 1 hours) def User(name: String): AuthUser.Persisted = new AuthUser.Real(UserId.fresh, name, 0, None) diff --git a/core/src/test/scala/wust/core/Mocks.scala b/core/src/test/scala/wust/core/Mocks.scala index b0950a655..8d05dd0fd 100644 --- a/core/src/test/scala/wust/core/Mocks.scala +++ b/core/src/test/scala/wust/core/Mocks.scala @@ -1,10 +1,10 @@ package wust.core import org.mockito.Mockito -import org.scalatest.mockito.MockitoSugar import wust.db.Db import scala.concurrent.Future +import org.scalatestplus.mockito.MockitoSugar trait SpecsLikeMockito extends MockitoSugar { class MockitoMock[T](method: T) { diff --git a/database/src/it/scala/wust/db/DbSpec.scala b/database/src/it/scala/wust/db/DbSpec.scala index aad1f8783..449ea0f88 100644 --- a/database/src/it/scala/wust/db/DbSpec.scala +++ b/database/src/it/scala/wust/db/DbSpec.scala @@ -25,7 +25,7 @@ // } //} -//class DbSpec extends DbIntegrationTestSpec with MustMatchers { +//class DbSpec extends DbIntegrationTestSpec with must.Matchers { // import DbSpec._ // implicit def passwordToDigest(pw: String): Array[Byte] = pw.map(_.toByte).toArray // implicit class EqualityByteArray(val arr: Array[Byte]) { diff --git a/graph/src/test/scala/wust/graph/GraphSpec.scala b/graph/src/test/scala/wust/graph/GraphSpec.scala index c702db5a1..170fbdf28 100644 --- a/graph/src/test/scala/wust/graph/GraphSpec.scala +++ b/graph/src/test/scala/wust/graph/GraphSpec.scala @@ -1,9 +1,11 @@ package wust.graph import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec import wust.ids._ -class GraphSpec extends FreeSpec with MustMatchers { +class GraphSpec extends AnyFreeSpec with must.Matchers { implicit def intToNodeId(id: Int): NodeId = NodeId(Cuid(id, 0)) implicit def idToNode(id: Int): Node = Node.Content(id = id, data = NodeData.PlainText("content"), role = NodeRole.default, meta = NodeMeta(NodeAccess.ReadWrite)) implicit def nodeListToMap(nodes: List[Int]): List[Node] = nodes.map(idToNode) diff --git a/ids/src/main/scala/wust/ids/package.scala b/ids/src/main/scala/wust/ids/package.scala index b218073f8..ea19e3e8c 100644 --- a/ids/src/main/scala/wust/ids/package.scala +++ b/ids/src/main/scala/wust/ids/package.scala @@ -3,7 +3,6 @@ package wust import java.util.Date import java.time.{LocalDateTime, ZonedDateTime, ZoneOffset, Instant} -import com.github.ghik.silencer.silent import supertagged._ import scala.util.Try @@ -83,7 +82,6 @@ package object ids { @inline def now: EpochMilli = localNow plus delta @inline def zero: EpochMilli = EpochMilli(0L) - @silent("deprecated") def parse(str: String) = Try(Date.parse(str)).toOption.map(EpochMilli(_)) def fromDate(d: Date): EpochMilli = EpochMilli(d.toInstant.toEpochMilli) @@ -108,7 +106,6 @@ package object ids { @inline def toLocalDateTime: LocalDateTime = toZonedDateTime.toLocalDateTime def toZonedDateTime: ZonedDateTime = Instant.ofEpochMilli(t).atZone(ZoneOffset.UTC) - @silent("deprecated") def humanReadable: String = { // java.util.Date is deprecated, but implemented in java and scalajs // and therefore a simple cross-compiling solution @@ -123,7 +120,6 @@ package object ids { f"$year%04d-$month%02d-$day%02d $hour%02d:$minute%02d:$second%02d" } - @silent("deprecated") def isoDate: String = { // java.util.Date is deprecated, but implemented in java and scalajs // and therefore a simple cross-compiling solution @@ -135,7 +131,6 @@ package object ids { f"$year%04d-$month%02d-$day%02d" } - @silent("deprecated") def isoDateAndTime: String = { // java.util.Date is deprecated, but implemented in java and scalajs // and therefore a simple cross-compiling solution diff --git a/ids/src/test/scala/wust/ids/CuidSpec.scala b/ids/src/test/scala/wust/ids/CuidSpec.scala index 4c90e7816..bd4dac201 100644 --- a/ids/src/test/scala/wust/ids/CuidSpec.scala +++ b/ids/src/test/scala/wust/ids/CuidSpec.scala @@ -3,8 +3,10 @@ package wust.ids import java.util.UUID import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec -class CuidSpec extends FreeSpec with MustMatchers { +class CuidSpec extends AnyFreeSpec with must.Matchers { "uuid" in { val original = new UUID(12, 25) val bag = Cuid.fromUuid(original) diff --git a/project/Deps.scala b/project/Deps.scala index 226db2482..40e3fa3b5 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -4,16 +4,17 @@ import sbt._ object Deps { import Def.{ setting => dep } - val silencerVersion = "1.4.2" - - val acyclicDef = "com.lihaoyi" %% "acyclic" % "0.1.9" + val acyclicDef = "com.lihaoyi" %% "acyclic" % "0.2.0" val acyclic = dep(acyclicDef % "provided") // testing val scalatest = dep("org.scalatest" %%% "scalatest" % "3.2.0") + val scalatestFreespec = dep("org.scalatest" %%% "scalatest-freespec" % "3.2.0") + val scalatestMustmatchers = dep("org.scalatest" %%% "scalatest-mustmatchers" % "3.2.0") + val scalatestMockito = dep("org.scalatestplus" %% "mockito-3-3" % "3.2.0.0") + val mockito = dep("org.mockito" % "mockito-core" % "2.28.2") val selenium = dep("org.seleniumhq.selenium" % "selenium-java" % "3.3.1") val specs2 = dep("org.specs2" %% "specs2-core" % "4.7.0") - val mockito = dep("org.mockito" % "mockito-core" % "2.28.2") // core libraries val cats = new { @@ -22,12 +23,12 @@ object Deps { } val akka = new { private val version = "2.6.6" - private val httpVersion = "10.1.12" + private val httpVersion = "10.2.0" val http = dep("com.typesafe.akka" %% "akka-http" % httpVersion) val httpCore = dep("com.typesafe.akka" %% "akka-http-core" % httpVersion) val httpCirce = dep("de.heikoseeberger" %% "akka-http-circe" % "1.30.0") val httpPlay = dep("de.heikoseeberger" %% "akka-http-play-json" % "1.30.0") - val httpCors = dep("ch.megard" %% "akka-http-cors" % "0.3.1") + val httpCors = dep("ch.megard" %% "akka-http-cors" % "1.1.0") val stream = dep("com.typesafe.akka" %% "akka-stream" % version) val actor = dep("com.typesafe.akka" %% "akka-actor" % version) val testkit = dep("com.typesafe.akka" %% "akka-testkit" % version) @@ -50,7 +51,7 @@ object Deps { val scalaJsDom = dep("org.scala-js" %%% "scalajs-dom" % "1.0.0") val d3v4 = dep("com.github.fdietze.scala-js-d3v4" %%% "scala-js-d3v4" % "809f086") // val d3v4 = dep("com.github.fdietze" %%% "scala-js-d3v4" % "master-SNAPSHOT") - val fontawesome = dep("com.github.fdietze" % "scala-js-fontawesome" % "308e305") + val fontawesome = dep("com.github.fdietze.scala-js-fontawesome" %%% "scala-js-fontawesome" % "559c7f7") val vectory = dep("com.github.fdietze.vectory" %%% "vectory" % "14bf5d2") val scalarx = dep("com.lihaoyi" %%% "scalarx" % "0.4.3") val outwatch = new { @@ -65,15 +66,14 @@ object Deps { val monix = dep("com.github.cornerman.colibri" %%% "colibri-monix" % version) val rx = dep("com.github.cornerman.colibri" %%% "colibri-rx" % version) } - val bench = dep("com.github.fdietze.bench" %%% "bench" % "e66a721") - // val bench = dep("com.github.fdietze" %%% "bench" % "master-SNAPSHOT") + val bench = dep("com.github.fdietze.bench" %%% "bench" % "087e511") // utility val scribe = new { // TODO: val perfolation = dep("com.github.fdietze.perfolation" %%% "perfolation" % "6854947") val core = dep("com.outr" %%% "scribe" % "2.7.12") } - val pureconfig = dep("com.github.pureconfig" %% "pureconfig" % "0.9.2") + val pureconfig = dep("com.github.pureconfig" %% "pureconfig" % "0.11.1") // https://github.com/pureconfig/pureconfig/blob/master/CHANGELOG.md val monocle = dep("com.github.julien-truffaut" %% "monocle-macro" % "2.0.0") val monocleCore = dep("com.github.julien-truffaut" %% "monocle-core" % "2.0.0") val sourcecode = dep("com.lihaoyi" %%% "sourcecode" % "0.2.1") @@ -81,7 +81,7 @@ object Deps { val base58s = dep("io.github.fdietze.base58s" %%% "base58s" % "43d5684") val monix = dep("io.monix" %%% "monix" % "3.2.2") // val taggedTypes = dep("org.rudogma" %%% "supertagged" % "2.0-RC1") - val taggedTypes = dep("com.github.lolgab" % "scala-supertagged" % "scalajs-1.0.0-RC2-SNAPSHOT") + val taggedTypes = dep("com.github.fdietze.scala-supertagged" %%% "supertagged" % "0157b28") // until https://github.com/rudogma/scala-supertagged/pull/2 is merged val colorado = dep("com.github.fdietze.colorado" %%% "colorado" % "d36c389") val scalacss = dep("com.github.japgolly.scalacss" %%% "core" % "0.6.1") val kantanRegex = new { @@ -109,16 +109,17 @@ object Deps { } // auth - val hasher = dep("com.roundeights" %% "hasher" % "1.2.0") + //val hasher = dep("com.roundeights" %% "hasher" % "1.2.0") //TODO: https://github.com/Nycto/Hasher/pull/28 + val hasher = dep("com.github.fdietze.hasher" %% "hasher" % "75be8ed") val jbcrypt = dep("org.mindrot" % "jbcrypt" % "0.4") val jwt = dep("com.pauldijou" %% "jwt-circe" % "4.2.0") val bouncyCastle = dep("org.bouncycastle" % "bcpkix-jdk15on" % "1.60") val oAuthServer = dep("com.nulab-inc" %% "scala-oauth2-core" % "1.3.0") val oAuthAkkaProvider = dep("com.nulab-inc" %% "akka-http-oauth2-provider" % "1.3.0") - val oAuthClient = dep("com.github.fdietze" % "akka-http-oauth2-client" % "cf77841") + val oAuthClient = dep("com.github.fdietze.akka-http-oauth2-client" %% "akka-http-oauth2-client" % "dd8e734") // database - val quill = dep("io.getquill" %% "quill-async-postgres" % "3.2.2") + val quill = dep("io.getquill" %% "quill-async-postgres" % "3.5.2") // interfaces //val github4s = dep("com.47deg" %% "github4s" % "0.17.0") // only temporarly here diff --git a/sdk/jvm/src/main/scala/wust/sdk/Config.scala b/sdk/jvm/src/main/scala/wust/sdk/Config.scala index 3a81e17ad..3f4bae32e 100644 --- a/sdk/jvm/src/main/scala/wust/sdk/Config.scala +++ b/sdk/jvm/src/main/scala/wust/sdk/Config.scala @@ -25,6 +25,7 @@ final case class DefaultConfig(appServer: ServerConfig, wustServer: WustConfig, object Config { import pureconfig._ + import pureconfig.generic.auto._ import pureconfig.error.ConfigReaderFailures import wust.util.Config._ diff --git a/sdk/jvm/src/main/scala/wust/sdk/OAuthClient.scala b/sdk/jvm/src/main/scala/wust/sdk/OAuthClient.scala index 2e18e6895..cd3f620c0 100644 --- a/sdk/jvm/src/main/scala/wust/sdk/OAuthClient.scala +++ b/sdk/jvm/src/main/scala/wust/sdk/OAuthClient.scala @@ -73,43 +73,43 @@ class OAuthClient(val oAuthConfig: OAuthConfig, appServerConfig: ServerConfig, w //val newAccessToken: Future[Either[Throwable, OAuthToken]] = // client.getAccessToken(GrantType.RefreshToken, Map("refresh_token" -> "zzzzzzzz")) - def route(tokenObserver: Observer[AuthenticationData]): Route = path(separateOnSlashes(oAuthPath)) { - get { - parameters(('code, 'state)) { (code: String, state: String) => - val confirmedRequest = confirmOAuthRequest(code, state) - if (confirmedRequest.isDefined) { - - val accessToken: Future[Either[Throwable, OAuthToken]] = authClient.getAccessToken( - grant = GrantType.AuthorizationCode, - params = Map( - "code" -> code, - "redirect_uri" -> redirectUri, - "state" -> state - ) - ) - - accessToken.foreach { - case Right(t) => - tokenObserver.onNext(AuthenticationData(confirmedRequest.get, t)) - oAuthRequests.remove(state) - case Left(ex: UnauthorizedException) => - scribe.error(s"unauthorized error receiving access token: $ex") - case ex => - scribe.error(s"unknown error receiving access token: $ex") - } - - } else { - scribe.error(s"Could not verify request(code, state): ($code, $state)") - } - - //TODO env varibles - val wustProtocol = if(wustServerConfig.port == 443) "https" else "http" - val wustPort = if(wustServerConfig.port != 443) ":12345" else "" - redirect(s"$wustProtocol://${wustServerConfig.host}$wustPort/#view=usersettings&page=default", StatusCodes.SeeOther) - } - // TODO: handle user aborts - } - } + //def route(tokenObserver: Observer[AuthenticationData]): Route = path(separateOnSlashes(oAuthPath)) { + // get { + // parameters(('code, 'state)) { (code: String, state: String) => + // val confirmedRequest = confirmOAuthRequest(code, state) + // if (confirmedRequest.isDefined) { + + // val accessToken: Future[Either[Throwable, OAuthToken]] = authClient.getAccessToken( + // grant = GrantType.AuthorizationCode, + // params = Map( + // "code" -> code, + // "redirect_uri" -> redirectUri, + // "state" -> state + // ) + // ) + + // accessToken.foreach { + // case Right(t) => + // tokenObserver.onNext(AuthenticationData(confirmedRequest.get, t)) + // oAuthRequests.remove(state) + // case Left(ex: UnauthorizedException) => + // scribe.error(s"unauthorized error receiving access token: $ex") + // case ex => + // scribe.error(s"unknown error receiving access token: $ex") + // } + + // } else { + // scribe.error(s"Could not verify request(code, state): ($code, $state)") + // } + + // //TODO env varibles + // val wustProtocol = if(wustServerConfig.port == 443) "https" else "http" + // val wustPort = if(wustServerConfig.port != 443) ":12345" else "" + // redirect(s"$wustProtocol://${wustServerConfig.host}$wustPort/#view=usersettings&page=default", StatusCodes.SeeOther) + // } + // // TODO: handle user aborts + // } + //} } object OAuthClient { diff --git a/sdk/jvm/src/test/scala/wust/sdk/OAuthClientSpec.scala b/sdk/jvm/src/test/scala/wust/sdk/OAuthClientSpec.scala index bacf50abe..fc9378180 100644 --- a/sdk/jvm/src/test/scala/wust/sdk/OAuthClientSpec.scala +++ b/sdk/jvm/src/test/scala/wust/sdk/OAuthClientSpec.scala @@ -5,10 +5,12 @@ import java.util.UUID import akka.http.scaladsl.testkit.ScalatestRouteTest import monix.reactive.subjects.PublishSubject import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec import wust.api.{AuthUser, Authentication} import wust.ids.UserId -class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers { +class OAuthClientBasicSpec extends AnyFreeSpec with EitherValues with must.Matchers { def getClient(path: String = "wust.test") = { Config.load(path).map(config => OAuthClient.apply(config.oAuth, config.appServer, config.wustServer)) @@ -16,13 +18,13 @@ class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers { "load config" in { val config = Config.load("wust.test") - config should be ('right) + config must be ('right) } "can instanziate client" in { val client = getClient() - client should be ('right) + client must be ('right) } "generate url" in { @@ -31,8 +33,8 @@ class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers { val randomState = UUID.randomUUID().toString val url = client.map(c => c.authorizeUrlWithState(Authentication.Verified(AuthUser.Real(UserId.fresh, UserId.fresh.toBase58, 0, None), 0, Authentication.Token("token")), List("read:org", "read:user", "repo" , "write:discussion"), randomState).map(_.toString)) - url should be ('right) - url shouldEqual Right(Some(s"http://localhost/wust/oauth/authorize?state=$randomState&scope=read:org,read:user,repo,write:discussion&redirect_uri=http://localhost:8080/oauth/auth&client_id=clientId&response_type=code")) + url must be ('right) + url mustEqual Right(Some(s"http://localhost/wust/oauth/authorize?state=$randomState&scope=read:org,read:user,repo,write:discussion&redirect_uri=http://localhost:8080/oauth/auth&client_id=clientId&response_type=code")) } @@ -42,34 +44,34 @@ class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers { val randomState = UUID.randomUUID().toString val url = client.map(c => c.authorizeUrlWithState(Authentication.Verified(AuthUser.Real(UserId.fresh, UserId.fresh.toBase58, 0, None), 0, Authentication.Token("token")), List("read:org", "read:user", "repo" , "write:discussion"), randomState).map(_.toString)) - url should be ('right) - url shouldEqual Right(Some(s"http://localhost/oauth/authorize?state=$randomState&scope=read:org,read:user,repo,write:discussion&redirect_uri=http://localhost:8080/oauth/auth&client_id=clientId&response_type=code")) + url must be ('right) + url mustEqual Right(Some(s"http://localhost/oauth/authorize?state=$randomState&scope=read:org,read:user,repo,write:discussion&redirect_uri=http://localhost:8080/oauth/auth&client_id=clientId&response_type=code")) } } -class OAuthClientRoutingSpec extends WordSpec with EitherValues with Matchers with ScalatestRouteTest { - - private val client = Config.load("wust.test").map(config => OAuthClient.apply(config.oAuth, config.appServer, config.wustServer)).toOption.get - private val tokenObserver = PublishSubject[AuthenticationData] - private val testRoute = client.route(tokenObserver) - - "oauth ignore empty routing" in { - Get() ~> testRoute ~> check { - handled shouldBe false - } - } - - "oauth ignore route without paramaters" in { - Get(client.oAuthConfig.authPath.getOrElse("oauth/auth")) ~> testRoute ~> check { - handled shouldBe false - } - } - - "oauth handles route with paramaters correctly" in { - val routePath = s"/${client.oAuthConfig.authPath.getOrElse("oauth/auth")}?code=blub&state=bla" - Get(routePath) ~> testRoute ~> check { - handled shouldBe true - } - } -} +// class OAuthClientRoutingSpec extends AnyFreeSpec with EitherValues with must.Matchers with ScalatestRouteTest { + +// private val client = Config.load("wust.test").map(config => OAuthClient.apply(config.oAuth, config.appServer, config.wustServer)).toOption.get +// private val tokenObserver = PublishSubject[AuthenticationData] +// private val testRoute = client.route(tokenObserver) + +// "oauth ignore empty routing" in { +// Get() ~> testRoute ~> check { +// handled mustBe false +// } +// } + +// "oauth ignore route without paramaters" in { +// Get(client.oAuthConfig.authPath.getOrElse("oauth/auth")) ~> testRoute ~> check { +// handled mustBe false +// } +// } + +// "oauth handles route with paramaters correctly" in { +// val routePath = s"/${client.oAuthConfig.authPath.getOrElse("oauth/auth")}?code=blub&state=bla" +// Get(routePath) ~> testRoute ~> check { +// handled mustBe true +// } +// } +// } diff --git a/slackApp/src/test/scala/wust/slack/WustEventMapperSpec.scala b/slackApp/src/test/scala/wust/slack/WustEventMapperSpec.scala index 028d6b299..86bce794a 100644 --- a/slackApp/src/test/scala/wust/slack/WustEventMapperSpec.scala +++ b/slackApp/src/test/scala/wust/slack/WustEventMapperSpec.scala @@ -71,7 +71,7 @@ object TestConstants { val userId: UserId = UserId.fromBase58String("5R5TZsZJeL3enTMmq8Jwmg").right.get } -class WustEventMapperSpec extends FreeSpec with EitherValues with Matchers { +class WustEventMapperSpec extends AnyFreeSpec with EitherValues with Matchers { implicit val system: ActorSystem = ActorSystem("slack-test-wust-event") import monix.execution.Scheduler.Implicits.global diff --git a/util/jvm/src/main/scala/wust/util/Config.scala b/util/jvm/src/main/scala/wust/util/Config.scala index 570dc334b..0c103e48f 100644 --- a/util/jvm/src/main/scala/wust/util/Config.scala +++ b/util/jvm/src/main/scala/wust/util/Config.scala @@ -2,6 +2,7 @@ package wust.util import pureconfig._ import pureconfig.error.{ConvertFailure, KeyNotFound} +import pureconfig.generic.ProductHint object Config { implicit def hint[T] = diff --git a/util/shared/src/test/scala/wust/util/AlgorithmsSpec.scala b/util/shared/src/test/scala/wust/util/AlgorithmsSpec.scala index 398cdea6c..f38548082 100644 --- a/util/shared/src/test/scala/wust/util/AlgorithmsSpec.scala +++ b/util/shared/src/test/scala/wust/util/AlgorithmsSpec.scala @@ -2,9 +2,11 @@ package wust.util import flatland._ import org.scalatest._ +import org.scalatest.matchers._ import wust.util.algorithm._ +import org.scalatest.freespec.AnyFreeSpec -class AlgorithmsSpec extends FreeSpec with MustMatchers { +class AlgorithmsSpec extends AnyFreeSpec with must.Matchers { "connected components" - { "one vertex" in { diff --git a/util/shared/src/test/scala/wust/util/CollectionSpec.scala b/util/shared/src/test/scala/wust/util/CollectionSpec.scala index ee88dff6a..f51864573 100644 --- a/util/shared/src/test/scala/wust/util/CollectionSpec.scala +++ b/util/shared/src/test/scala/wust/util/CollectionSpec.scala @@ -1,8 +1,10 @@ package wust.util import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec -class CollectionSpec extends FreeSpec with MustMatchers { +class CollectionSpec extends AnyFreeSpec with must.Matchers { import collection._ "RichCollection" - { diff --git a/util/shared/src/test/scala/wust/util/DepthFirstSearchSpec.scala b/util/shared/src/test/scala/wust/util/DepthFirstSearchSpec.scala index 1fedd4aa2..ef409eccf 100644 --- a/util/shared/src/test/scala/wust/util/DepthFirstSearchSpec.scala +++ b/util/shared/src/test/scala/wust/util/DepthFirstSearchSpec.scala @@ -2,11 +2,13 @@ package wust.util import flatland._ import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec import wust.util.algorithm._ import scala.collection.mutable -class DepthFirstSearchSpec extends FreeSpec with MustMatchers { +class DepthFirstSearchSpec extends AnyFreeSpec with must.Matchers { "depth-first-search" - { "one vertex" in { diff --git a/webApp/src/main/scala/wust/webApp/state/GlobalState.scala b/webApp/src/main/scala/wust/webApp/state/GlobalState.scala index 9efcfa9a3..2e579f978 100644 --- a/webApp/src/main/scala/wust/webApp/state/GlobalState.scala +++ b/webApp/src/main/scala/wust/webApp/state/GlobalState.scala @@ -1,7 +1,6 @@ package wust.webApp.state // import acyclic.file -import com.github.ghik.silencer.silent import org.scalajs.dom.experimental.permissions.PermissionState import org.scalajs.dom.window import outwatch.dsl.events @@ -100,7 +99,6 @@ object GlobalState { val uiModalConfig = Subject.publish[Ownable[ModalConfig]] val uiModalClose = Subject.publish[Unit] - @silent("deprecated") val rawGraph: Rx[Graph] = { val internalGraph = eventProcessor.graph.unsafeToRx(seed = Graph.empty) diff --git a/webApp/src/main/scala/wust/webApp/state/GraphChangesAutomation.scala b/webApp/src/main/scala/wust/webApp/state/GraphChangesAutomation.scala index 6568bf1ed..1f6e22e03 100644 --- a/webApp/src/main/scala/wust/webApp/state/GraphChangesAutomation.scala +++ b/webApp/src/main/scala/wust/webApp/state/GraphChangesAutomation.scala @@ -1,6 +1,5 @@ package wust.webApp.state -import com.github.ghik.silencer.silent import wust.facades.segment.Segment import org.scalajs.dom import rx.Var @@ -56,7 +55,6 @@ private object StringWalker { object GraphChangesAutomation { val templateVariableRegex = "\\$(@)?\\{woost((\\.[^\\.\\}]+)+)\\}".r - @silent("possible missing interpolator") def replaceVariableInText(userId: UserId, graph: Graph, node: Node, templateText: String, newEdges: mutable.HashMap[NodeId, mutable.ArrayBuffer[(Edge, Node)]], newEdgesReverse: mutable.HashMap[NodeId, mutable.ArrayBuffer[(Edge, Node)]]): (String, Array[Edge]) = try { val extraEdges = Array.newBuilder[Edge] diff --git a/webApp/src/main/scala/wust/webApp/views/GraphChangesAutomationUI.scala b/webApp/src/main/scala/wust/webApp/views/GraphChangesAutomationUI.scala index d006a9b34..f056a6c7e 100644 --- a/webApp/src/main/scala/wust/webApp/views/GraphChangesAutomationUI.scala +++ b/webApp/src/main/scala/wust/webApp/views/GraphChangesAutomationUI.scala @@ -1,7 +1,6 @@ package wust.webApp.views import wust.sdk.{BaseColors, NodeColor} -import com.github.ghik.silencer.silent import outwatch._ import outwatch.dsl._ import colibri.ext.rx._ @@ -27,7 +26,6 @@ import fontAwesome.freeSolid // Offers methods for rendering components for the GraphChangesAutomation. -@silent("possible missing interpolator") object GraphChangesAutomationUI { val createAutomationTemplateText = "Create Template" diff --git a/webApp/src/main/scala/wust/webApp/views/RightSidebar.scala b/webApp/src/main/scala/wust/webApp/views/RightSidebar.scala index 4c5390854..80a681dc7 100644 --- a/webApp/src/main/scala/wust/webApp/views/RightSidebar.scala +++ b/webApp/src/main/scala/wust/webApp/views/RightSidebar.scala @@ -1,7 +1,6 @@ package wust.webApp.views import acyclic.file -import com.github.ghik.silencer.silent import fontAwesome.freeSolid import outwatch._ import outwatch.dsl._ @@ -485,7 +484,7 @@ object RightSidebar { }, customOptions = Some(VDomModifier( UI.checkbox("Create a new node from the reference", isCreateReference), - UI.checkbox("Rename existing node (original content in `${woost.original}`)", isRenameReference): @silent("possible missing interpolator") + UI.checkbox("Rename existing node (original content in `${woost.original}`)", isRenameReference) )) ), ItemProperties.EdgeFactory.Plain(create), diff --git a/webApp/src/test/scala/wust/webApp/parsers/UrlConfigParsingSpec.scala b/webApp/src/test/scala/wust/webApp/parsers/UrlConfigParsingSpec.scala index 94f279d1b..693247d44 100644 --- a/webApp/src/test/scala/wust/webApp/parsers/UrlConfigParsingSpec.scala +++ b/webApp/src/test/scala/wust/webApp/parsers/UrlConfigParsingSpec.scala @@ -2,11 +2,13 @@ package wust.webApp.parsers import cats.data.NonEmptyList import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec import wust.graph.Page import wust.ids.{Cuid, NodeId, View, ViewOperator} import wust.webApp.state.{PageChange, UrlConfig, UrlRoute} -class UrlConfigParsingSpec extends FreeSpec with MustMatchers { +class UrlConfigParsingSpec extends AnyFreeSpec with must.Matchers { def createUrlConfig(view: Option[View], page: Page, prevView: Option[View]) = UrlConfig.default.copy(view = view, pageChange = PageChange(page), redirectTo = prevView) def toUrlRouteAndBack(viewConfig: UrlConfig): UrlConfig = @@ -20,7 +22,7 @@ class UrlConfigParsingSpec extends FreeSpec with MustMatchers { val cfg = UrlConfigParser.fromUrlRoute(UrlRoute(None, Some(str))) val expected = createUrlConfig( Some(View.Tiled(ViewOperator.Row, NonEmptyList[View.Visible](View.Graph, View.Chat :: Nil))), - Page(NodeId(cuid1)), None) + Page(cuid1), None) cfg.pageChange mustEqual expected.pageChange cfg.view.get.viewKey mustEqual expected.view.get.viewKey } @@ -31,7 +33,7 @@ class UrlConfigParsingSpec extends FreeSpec with MustMatchers { val cfg = UrlConfigParser.fromUrlRoute(UrlRoute(None, Some(str))) val expected = createUrlConfig( Some(View.Tiled(ViewOperator.Row, NonEmptyList[View.Visible](View.Graph, View.Chat :: Nil))), - Page(NodeId(cuid1)), None) + Page(cuid1), None) cfg.pageChange mustEqual expected.pageChange cfg.view.get.viewKey mustEqual expected.view.get.viewKey } @@ -42,7 +44,7 @@ class UrlConfigParsingSpec extends FreeSpec with MustMatchers { val cfg = UrlConfigParser.fromUrlRoute(UrlRoute(None, Some(str))) val expected = createUrlConfig( Some(View.Tiled(ViewOperator.Column, NonEmptyList[View.Visible](View.Graph, View.Chat :: Nil))), - Page(NodeId(cuid1)), None) + Page(cuid1), None) cfg.pageChange mustEqual expected.pageChange cfg.view.get.viewKey mustEqual expected.view.get.viewKey } @@ -53,7 +55,7 @@ class UrlConfigParsingSpec extends FreeSpec with MustMatchers { val cfg = UrlConfigParser.fromUrlRoute(UrlRoute(None, Some(str))) val expected = createUrlConfig( Some(View.Tiled(ViewOperator.Auto, NonEmptyList[View.Visible](View.Graph, View.Chat :: Nil))), - Page(NodeId(cuid1)), None) + Page(cuid1), None) cfg.pageChange mustEqual expected.pageChange cfg.view.get.viewKey mustEqual expected.view.get.viewKey } @@ -64,7 +66,7 @@ class UrlConfigParsingSpec extends FreeSpec with MustMatchers { val cfg = UrlConfigParser.fromUrlRoute(UrlRoute(None, Some(str))) val expected = createUrlConfig( Some(View.Tiled(ViewOperator.Optional, NonEmptyList[View.Visible](View.Graph, View.Chat :: Nil))), - Page(NodeId(cuid1)), None) + Page(cuid1), None) cfg.pageChange mustEqual expected.pageChange cfg.view.get.viewKey mustEqual expected.view.get.viewKey } diff --git a/webApp/src/test/scala/wust/webApp/views/GraphChangesAutomationSpec.scala b/webApp/src/test/scala/wust/webApp/views/GraphChangesAutomationSpec.scala index 60af59c2d..7f444633f 100644 --- a/webApp/src/test/scala/wust/webApp/views/GraphChangesAutomationSpec.scala +++ b/webApp/src/test/scala/wust/webApp/views/GraphChangesAutomationSpec.scala @@ -1,6 +1,8 @@ package wust.webApp.views import org.scalatest._ +import org.scalatest.matchers._ +import org.scalatest.freespec.AnyFreeSpec import wust.graph._ import wust.ids._ import wust.webApp.state.GraphChangesAutomation @@ -8,7 +10,7 @@ import wust.webApp.state.GraphChangesAutomation import scala.collection.breakOut -class GraphChangesAutomationSpec extends FreeSpec with MustMatchers { +class GraphChangesAutomationSpec extends AnyFreeSpec with must.Matchers { def randomPositiveInt() = { val r = scala.util.Random.nextInt if (r < 0) r * -1 else r diff --git a/webApp/src/test/scala/wust/webApp/views/ViewAntiCrashSpec.scala b/webApp/src/test/scala/wust/webApp/views/ViewAntiCrashSpec.scala index dd1ea3f00..c423845cb 100644 --- a/webApp/src/test/scala/wust/webApp/views/ViewAntiCrashSpec.scala +++ b/webApp/src/test/scala/wust/webApp/views/ViewAntiCrashSpec.scala @@ -27,7 +27,7 @@ // ) // } -// class ViewAntiCrashSpec extends FreeSpec with TableDrivenPropertyChecks with MustMatchers with LocalStorageMock with RequestAnimationFrameMock { +// class ViewAntiCrashSpec extends AnyFreeSpec with TableDrivenPropertyChecks with must.Matchers with LocalStorageMock with RequestAnimationFrameMock { // def freshNodeId(i:Int) = NodeId(Cuid(i, i)) diff --git a/webUtil/src/main/scala/wust/facades/crisp/Crisp.scala b/webUtil/src/main/scala/wust/facades/crisp/Crisp.scala index 561b6f5de..2259bc9f5 100644 --- a/webUtil/src/main/scala/wust/facades/crisp/Crisp.scala +++ b/webUtil/src/main/scala/wust/facades/crisp/Crisp.scala @@ -2,11 +2,10 @@ package wust.facades.crisp import scala.scalajs.js import scala.scalajs.js.annotation._ -import com.github.ghik.silencer.silent //TODO: this is a workaround for scalajs: https://github.com/scala-js/scala-js/issues/3737 object JSNames { - @silent("possible missing interpolator") final val Crisp = "$crisp" + final val Crisp = "$crisp" } @js.native @JSGlobal(JSNames.Crisp)