diff --git a/.travis.yml b/.travis.yml index ab66fdd..6ba12bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,13 @@ install: - docker run -it -v "$PWD":/tmp -w /tmp composer/composer:1-alpine install script: - - sbt coverage assembly - - sbt run > log.txt & - - bash <(curl -s https://raw.githubusercontent.com/s12v/wait4port/master/wait4port.sh) localhost:9911 localhost:9324 + - sbt coverage test coverageReport + - sbt assembly + - java -jar $(ls $TRAVIS_BUILD_DIR/target/scala-2.11/sns-*.jar | tail -1) > log.txt & + - > + bash <(curl -s https://raw.githubusercontent.com/s12v/wait4port/master/wait4port.sh) + http://localhost:9911 + http://localhost:9324 - bundle exec cucumber - > docker run -it diff --git a/Dockerfile b/Dockerfile index d2dc72a..26a58fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ EXPOSE 9911 VOLUME /etc/sns -ENV DB_PATH=/etc/sns/db.json VERSION=0.0.2 +ENV DB_PATH=/etc/sns/db.json VERSION=0.1.0 ADD https://github.com/s12v/sns/releases/download/$VERSION/sns-$VERSION.jar /sns.jar diff --git a/README.md b/README.md index c88ae60..e091795 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://travis-ci.org/s12v/sns.svg?branch=master)](https://travis-ci.org/s12v/sns) -# SNS +[![codecov](https://codecov.io/gh/s12v/sns/branch/master/graph/badge.svg)](https://codecov.io/gh/s12v/sns) +# Fake SNS Fake Amazon Simple Notification Service (SNS) for testing. Supports: - Create/List/Delete topics @@ -20,7 +21,7 @@ docker run -d -p 9911:9911 -v example:/etc/sns s12v/sns Download the latest release from https://github.com/s12v/sns/releases and run: ``` -DB_PATH=/tmp/db.json java -jar sns-0.0.1.jar +DB_PATH=/tmp/db.json java -jar sns-0.1.0.jar ``` Requires Java8. diff --git a/build.sbt b/build.sbt index 7ed7738..6147d54 100644 --- a/build.sbt +++ b/build.sbt @@ -1,26 +1,30 @@ name := "sns" -version := "0.0.2" +version := "0.1.0" scalaVersion := "2.11.8" +// sbt-assembly assemblyJarName in assembly := s"sns-${version.value}.jar" +test in assembly := {} libraryDependencies ++= { - val akkaVersion = "2.4.6" + val akkaVersion = "2.4.7" + val camelVersion = "2.17.0" Seq( "com.typesafe.akka" %% "akka-actor" % akkaVersion, "com.typesafe.akka" %% "akka-stream" % akkaVersion, "com.typesafe.akka" %% "akka-http-experimental" % akkaVersion, "com.typesafe.akka" %% "akka-http-xml-experimental" % akkaVersion, - "com.typesafe.akka" %% "akka-http-spray-json-experimental" % akkaVersion, + "com.typesafe.akka" %% "akka-http-spray-json-experimental" % akkaVersion + , "com.typesafe.akka" %% "akka-http-testkit" % akkaVersion % Test, "org.slf4j" % "slf4j-api" % "1.7.2", "ch.qos.logback" % "logback-classic" % "1.0.7", - "com.typesafe.akka" %% "akka-camel" % "2.3.15", - "org.apache.camel" % "camel-aws" % "2.17.0" + "com.typesafe.akka" %% "akka-camel" % akkaVersion, + "org.apache.camel" % "camel-aws" % camelVersion exclude("com.amazonaws", "aws-java-sdk-acm") exclude("com.amazonaws", "aws-java-sdk-api-gateway") exclude("com.amazonaws", "aws-java-sdk-autoscaling") @@ -76,10 +80,11 @@ libraryDependencies ++= { exclude("com.amazonaws", "aws-java-sdk-elasticbeanstalk") exclude("com.amazonaws", "aws-java-sdk-ecr") , - "org.apache.camel" % "camel-http" % "2.17.0", - "org.apache.camel" % "camel-rabbitmq" % "2.17.0", - "org.apache.camel" % "camel-slack" % "2.17.0", - - "org.scalatest" %% "scalatest" % "2.2.6" % Test + "org.apache.camel" % "camel-http" % camelVersion, + "org.apache.camel" % "camel-rabbitmq" % camelVersion, + "org.apache.camel" % "camel-slack" % camelVersion + exclude("junit", "junit") + , + "org.scalatest" %% "scalatest" % "2.2.6" % Test ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 31a7c8b..c71114e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,3 @@ -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") diff --git a/src/main/scala/me/snov/sns/api/TopicApi.scala b/src/main/scala/me/snov/sns/api/TopicApi.scala index 08499b0..9ed2a0a 100644 --- a/src/main/scala/me/snov/sns/api/TopicApi.scala +++ b/src/main/scala/me/snov/sns/api/TopicApi.scala @@ -38,7 +38,7 @@ object TopicApi { case _ => HttpResponse(404, entity = "NotFound") } } - case _ => complete(HttpResponse(400, entity = "Invalid topic name")) + case _ => complete(HttpResponse(400, entity = "Invalid topic ARN")) } ~ complete(HttpResponse(404, entity = "NotFound")) } ~ diff --git a/src/test/scala/me/snov/sns/api/TopicSpec.scala b/src/test/scala/me/snov/sns/api/TopicSpec.scala index 06ed34a..77332ec 100644 --- a/src/test/scala/me/snov/sns/api/TopicSpec.scala +++ b/src/test/scala/me/snov/sns/api/TopicSpec.scala @@ -29,6 +29,12 @@ class TopicSpec extends WordSpec with Matchers with ScalatestRouteTest { } } + "TopicDelete validates topic name" in { + Post("/", FormData(Map("Action" -> "DeleteTopic", "TopicArn" -> "f$$"))) ~> route ~> check { + status shouldBe StatusCodes.BadRequest + } + } + "Sends create command to actor" in { probe.setAutoPilot(new TestActor.AutoPilot { def run(sender: ActorRef, msg: Any) = {