|
| 1 | +/* |
| 2 | + * scala-exercises - evaluator-server-smoke-tests |
| 3 | + * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com> |
| 4 | + */ |
| 5 | + |
1 | 6 | package org.scalaexercises.evaluator
|
2 | 7 |
|
| 8 | +import io.circe.Printer |
3 | 9 | import org.scalatest._
|
4 | 10 | import org.http4s._
|
5 | 11 | import org.http4s.client.blaze._
|
6 | 12 | import org.http4s.circe._
|
7 | 13 | import io.circe.generic.auto._
|
8 |
| -import scalaz.concurrent.Task |
9 |
| -import scala.concurrent.duration._ |
10 | 14 |
|
| 15 | +import scala.concurrent.duration._ |
11 | 16 | import pdi.jwt.{Jwt, JwtAlgorithm}
|
12 | 17 |
|
13 | 18 | class Smoketests extends FunSpec with Matchers with CirceInstances {
|
14 | 19 |
|
15 |
| - case class EvaluatorResponse(msg: String, |
16 |
| - value: String, |
17 |
| - valueType: String, |
18 |
| - compilationInfos: Map[String, String]) |
| 20 | + case class EvaluatorResponse( |
| 21 | + msg: String, |
| 22 | + value: String, |
| 23 | + valueType: String, |
| 24 | + compilationInfos: Map[String, String]) |
19 | 25 |
|
20 | 26 | implicit val decoder: EntityDecoder[EvaluatorResponse] =
|
21 | 27 | jsonOf[EvaluatorResponse]
|
22 | 28 |
|
23 |
| - val validToken = Jwt.encode( |
24 |
| - """{"user": "scala-exercises"}""", |
25 |
| - auth.secretKey, |
26 |
| - JwtAlgorithm.HS256) |
| 29 | + val validToken = |
| 30 | + Jwt.encode("""{"user": "scala-exercises"}""", auth.secretKey, JwtAlgorithm.HS256) |
27 | 31 |
|
28 | 32 | def makeRequest(code: String)(
|
29 |
| - expectation: EvaluatorResponse => Unit, |
30 |
| - failExpectation: Throwable => Unit = fail(_)): Unit = { |
| 33 | + expectation: EvaluatorResponse => Unit, |
| 34 | + failExpectation: Throwable => Unit = fail(_)): Unit = { |
31 | 35 |
|
32 | 36 | val request = new Request(
|
33 | 37 | method = Method.POST,
|
34 |
| - uri = Uri.uri("http://scala-evaluator.herokuapp.com/eval"), |
| 38 | + uri = Uri.uri("https://scala-evaluator.herokuapp.com/eval"), |
35 | 39 | headers = Headers(headers)
|
36 |
| - ).withBody( |
37 |
| - s"""{"resolvers" : [], "dependencies" : [], "code" : "$code"}""") |
| 40 | + ).withBody(s"""{"resolvers" : [], "dependencies" : [], "code" : "$code"}""") |
38 | 41 |
|
39 | 42 | val task = client.expect[EvaluatorResponse](request)
|
40 | 43 |
|
@@ -70,10 +73,11 @@ class Smoketests extends FunSpec with Matchers with CirceInstances {
|
70 | 73 | it("should not expose sensitive details by calling sys.env") {
|
71 | 74 | val keywords = List("password", "key", "api")
|
72 | 75 | makeRequest("sys.env") { evaluatorResponse =>
|
73 |
| - keywords.foreach(kw => |
74 |
| - evaluatorResponse.value.contains(kw) shouldBe false) |
| 76 | + keywords.foreach(kw => evaluatorResponse.value.contains(kw) shouldBe false) |
75 | 77 | }
|
76 | 78 |
|
77 | 79 | }
|
78 | 80 | }
|
| 81 | + |
| 82 | + override protected def defaultPrinter: Printer = Printer.noSpaces.copy(dropNullKeys = true) |
79 | 83 | }
|
0 commit comments