Skip to content

Commit cc9b242

Browse files
committed
WIP: build.sbt,ApiImplSpec.scala,AuthApiImplSpec.scala,GuardDslSpec.scala,JWTSpec.scala,DbSpec.scala,GraphSpec.scala,CuidSpec.scala,OAuthClientSpec.scala,WustEventMapperSpec.scala,AlgorithmsSpec.scala,CollectionSpec.scala,DepthFirstSearchSpec.scala,UrlConfigParsingSpec.scala,GraphChangesAutomationSpec.scala,ViewAntiCrashSpec.scala
1 parent 84d3527 commit cc9b242

File tree

16 files changed

+69
-53
lines changed

16 files changed

+69
-53
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dynver in ThisBuild ~= (_.replace('+', '-')) // TODO: https://github.com/dwijnan
77
import Def.{setting => dep}
88

99
// -- common setting --
10-
scalaVersion in ThisBuild := "2.13.3"
10+
scalaVersion in ThisBuild := "2.12.12"
1111

1212
inThisBuild(
1313
List(

core/src/test/scala/wust/core/ApiImplSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// import java.time.LocalDateTime
1111
// import scala.concurrent.duration._
1212

13-
// class ApiImplSpec extends AsyncFreeSpec with MustMatchers with ApiTestKit {
13+
// class ApiImplSpec extends AsyncFreeSpec with must.Matchers with ApiTestKit {
1414

1515
// object User {
1616
// def apply(id: Long, name: String): User = new User(id, name, isImplicit = false, 0)

core/src/test/scala/wust/core/AuthApiImplSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// import scala.concurrent.duration._
1313
// import com.roundeights.hasher.Hasher
1414

15-
// class AuthApiImplSpec extends AsyncFreeSpec with MustMatchers with ApiTestKit {
15+
// class AuthApiImplSpec extends AsyncFreeSpec with must.Matchers with ApiTestKit {
1616
// implicit def passwordToDigest(pw: String): Array[Byte] = Hasher(pw).bcrypt
1717
// // implicit class EqualityByteArray(val arr: Array[Byte]) {
1818
// // def mustEqualDigest(pw: String) = assert(passwordToDigest(pw)

core/src/test/scala/wust/core/GuardDslSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// import scala.concurrent.Future
1313
// import scala.concurrent.duration._
1414

15-
// class GuardDslSpec extends AsyncFreeSpec with MustMatchers with DbMocks {
15+
// class GuardDslSpec extends AsyncFreeSpec with must.Matchers with DbMocks {
1616
// val implicitUserDb = Data.User(14, "implicit", isImplicit = true, 0)
1717
// val implicitUser = DbConversions.forClient(implicitUserDb)
1818
// val initialUser = User(11, "existing", isImplicit = false, 0)

core/src/test/scala/wust/core/JWTSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package wust.core
33
import java.time.Instant
44

55
import org.scalatest._
6+
import org.scalatest.matchers._
7+
import org.scalatest.freespec.AnyFreeSpec
68
import wust.api.{AuthUser, Authentication}
79
import wust.core.auth.JWT
810
import wust.ids._
9-
import org.scalatest.matchers._
1011

1112
import scala.concurrent.duration._
12-
import org.scalatest.freespec.AnyFreeSpec
1313

1414
class JWTSpec extends AnyFreeSpec with must.Matchers {
1515
val jwt = new JWT("secret", 1 hours)

database/src/it/scala/wust/db/DbSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// }
2626
//}
2727

28-
//class DbSpec extends DbIntegrationTestSpec with MustMatchers {
28+
//class DbSpec extends DbIntegrationTestSpec with must.Matchers {
2929
// import DbSpec._
3030
// implicit def passwordToDigest(pw: String): Array[Byte] = pw.map(_.toByte).toArray
3131
// implicit class EqualityByteArray(val arr: Array[Byte]) {

graph/src/test/scala/wust/graph/GraphSpec.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package wust.graph
22

33
import org.scalatest._
4+
import org.scalatest.matchers._
5+
import org.scalatest.freespec.AnyFreeSpec
46
import wust.ids._
57

6-
class GraphSpec extends FreeSpec with MustMatchers {
8+
class GraphSpec extends AnyFreeSpec with must.Matchers {
79
implicit def intToNodeId(id: Int): NodeId = NodeId(Cuid(id, 0))
810
implicit def idToNode(id: Int): Node = Node.Content(id = id, data = NodeData.PlainText("content"), role = NodeRole.default, meta = NodeMeta(NodeAccess.ReadWrite))
911
implicit def nodeListToMap(nodes: List[Int]): List[Node] = nodes.map(idToNode)

ids/src/test/scala/wust/ids/CuidSpec.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package wust.ids
33
import java.util.UUID
44

55
import org.scalatest._
6+
import org.scalatest.matchers._
7+
import org.scalatest.freespec.AnyFreeSpec
68

7-
class CuidSpec extends FreeSpec with MustMatchers {
9+
class CuidSpec extends AnyFreeSpec with must.Matchers {
810
"uuid" in {
911
val original = new UUID(12, 25)
1012
val bag = Cuid.fromUuid(original)

sdk/jvm/src/test/scala/wust/sdk/OAuthClientSpec.scala

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ import java.util.UUID
55
import akka.http.scaladsl.testkit.ScalatestRouteTest
66
import monix.reactive.subjects.PublishSubject
77
import org.scalatest._
8+
import org.scalatest.matchers._
9+
import org.scalatest.freespec.AnyFreeSpec
810
import wust.api.{AuthUser, Authentication}
911
import wust.ids.UserId
1012

11-
class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers {
13+
class OAuthClientBasicSpec extends AnyFreeSpec with EitherValues with must.Matchers {
1214

1315
def getClient(path: String = "wust.test") = {
1416
Config.load(path).map(config => OAuthClient.apply(config.oAuth, config.appServer, config.wustServer))
1517
}
1618

1719
"load config" in {
1820
val config = Config.load("wust.test")
19-
config should be ('right)
21+
config must be ('right)
2022
}
2123

2224
"can instanziate client" in {
2325
val client = getClient()
2426

25-
client should be ('right)
27+
client must be ('right)
2628
}
2729

2830
"generate url" in {
@@ -31,8 +33,8 @@ class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers {
3133
val randomState = UUID.randomUUID().toString
3234
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))
3335

34-
url should be ('right)
35-
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"))
36+
url must be ('right)
37+
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"))
3638

3739
}
3840

@@ -42,34 +44,34 @@ class OAuthClientBasicSpec extends FreeSpec with EitherValues with Matchers {
4244
val randomState = UUID.randomUUID().toString
4345
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))
4446

45-
url should be ('right)
46-
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"))
47+
url must be ('right)
48+
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"))
4749

4850
}
4951
}
5052

51-
class OAuthClientRoutingSpec extends WordSpec with EitherValues with Matchers with ScalatestRouteTest {
52-
53-
private val client = Config.load("wust.test").map(config => OAuthClient.apply(config.oAuth, config.appServer, config.wustServer)).toOption.get
54-
private val tokenObserver = PublishSubject[AuthenticationData]
55-
private val testRoute = client.route(tokenObserver)
56-
57-
"oauth ignore empty routing" in {
58-
Get() ~> testRoute ~> check {
59-
handled shouldBe false
60-
}
61-
}
62-
63-
"oauth ignore route without paramaters" in {
64-
Get(client.oAuthConfig.authPath.getOrElse("oauth/auth")) ~> testRoute ~> check {
65-
handled shouldBe false
66-
}
67-
}
68-
69-
"oauth handles route with paramaters correctly" in {
70-
val routePath = s"/${client.oAuthConfig.authPath.getOrElse("oauth/auth")}?code=blub&state=bla"
71-
Get(routePath) ~> testRoute ~> check {
72-
handled shouldBe true
73-
}
74-
}
75-
}
53+
// class OAuthClientRoutingSpec extends AnyFreeSpec with EitherValues with must.Matchers with ScalatestRouteTest {
54+
55+
// private val client = Config.load("wust.test").map(config => OAuthClient.apply(config.oAuth, config.appServer, config.wustServer)).toOption.get
56+
// private val tokenObserver = PublishSubject[AuthenticationData]
57+
// private val testRoute = client.route(tokenObserver)
58+
59+
// "oauth ignore empty routing" in {
60+
// Get() ~> testRoute ~> check {
61+
// handled mustBe false
62+
// }
63+
// }
64+
65+
// "oauth ignore route without paramaters" in {
66+
// Get(client.oAuthConfig.authPath.getOrElse("oauth/auth")) ~> testRoute ~> check {
67+
// handled mustBe false
68+
// }
69+
// }
70+
71+
// "oauth handles route with paramaters correctly" in {
72+
// val routePath = s"/${client.oAuthConfig.authPath.getOrElse("oauth/auth")}?code=blub&state=bla"
73+
// Get(routePath) ~> testRoute ~> check {
74+
// handled mustBe true
75+
// }
76+
// }
77+
// }

slackApp/src/test/scala/wust/slack/WustEventMapperSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ object TestConstants {
7171
val userId: UserId = UserId.fromBase58String("5R5TZsZJeL3enTMmq8Jwmg").right.get
7272
}
7373

74-
class WustEventMapperSpec extends FreeSpec with EitherValues with Matchers {
74+
class WustEventMapperSpec extends AnyFreeSpec with EitherValues with Matchers {
7575

7676
implicit val system: ActorSystem = ActorSystem("slack-test-wust-event")
7777
import monix.execution.Scheduler.Implicits.global

0 commit comments

Comments
 (0)