diff --git a/src/main/scala/com/advancedtelematic/director/Settings.scala b/src/main/scala/com/advancedtelematic/director/Settings.scala index d489a03..9cd41f9 100644 --- a/src/main/scala/com/advancedtelematic/director/Settings.scala +++ b/src/main/scala/com/advancedtelematic/director/Settings.scala @@ -1,10 +1,7 @@ package com.advancedtelematic.director -import com.advancedtelematic.libtuf.data.TufDataType.KeyType import com.typesafe.config.ConfigFactory -import scala.util.Try - trait Settings { import Util._ @@ -14,11 +11,4 @@ trait Settings { val port = _config.getInt("server.port") val tufUri = mkUri(_config, "keyserver.uri") - val tufBinaryUri = mkUri(_config, "tuf.binary.uri") - - val defaultKeyType: Try[KeyType] = { - Try(_config.getString("daemon.defaultKeyType")).map { defaultKeyTypeName => - namedType[KeyType](defaultKeyTypeName) - } - } } diff --git a/src/main/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResource.scala b/src/main/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResource.scala index 5097085..8165d93 100644 --- a/src/main/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResource.scala @@ -10,10 +10,8 @@ import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport._ import com.advancedtelematic.director.data.Codecs._ import com.advancedtelematic.director.db.MultiTargetUpdates import com.advancedtelematic.libats.data.DataType.Namespace - -import scala.concurrent.{ExecutionContext, Future} - - +import scala.concurrent.ExecutionContext +import com.advancedtelematic.libats.codecs.CirceCodecs._ class MultiTargetUpdatesResource(extractNamespace: Directive1[Namespace])(implicit val db: Database, val ec: ExecutionContext) { import Directives._ @@ -23,7 +21,10 @@ class MultiTargetUpdatesResource(extractNamespace: Directive1[Namespace])(implic val route = extractNamespace { ns => pathPrefix("multi_target_updates") { (get & pathPrefix(UpdateId.Path)) { uid => - complete(multiTargetUpdates.find(ns, uid)) + // For some reason director-v1 accepts `{targets: ...}` but returns `{...}` + // To make app compatible with director-v2, for now we do the same, but we should be returning what we accept: + // complete(multiTargetUpdates.find(ns, uid)) + complete(multiTargetUpdates.find(ns, uid).map(_.targets)) } ~ (post & pathEnd) { entity(as[MultiTargetUpdate]) { mtuRequest => diff --git a/src/test/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResourceSpec.scala b/src/test/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResourceSpec.scala index c019b0e..39809cb 100644 --- a/src/test/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResourceSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/MultiTargetUpdatesResourceSpec.scala @@ -1,16 +1,16 @@ package com.advancedtelematic.director.http -import cats.syntax.show._ import akka.http.scaladsl.model.StatusCodes -import com.advancedtelematic.director.data.AdminDataType.MultiTargetUpdate +import cats.syntax.show._ +import com.advancedtelematic.director.data.AdminDataType.{MultiTargetUpdate, TargetUpdateRequest} +import com.advancedtelematic.director.data.Codecs._ import com.advancedtelematic.director.data.Generators import com.advancedtelematic.director.util.{DefaultPatience, DirectorSpec, RouteResourceSpec} +import com.advancedtelematic.libats.codecs.CirceCodecs._ +import com.advancedtelematic.libats.data.ErrorCodes.MissingEntity import com.advancedtelematic.libats.data.ErrorRepresentation import com.advancedtelematic.libats.messaging_datatype.DataType.UpdateId -import com.advancedtelematic.libats.data.ErrorCodes.MissingEntity +import com.advancedtelematic.libtuf.data.TufDataType.HardwareIdentifier import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport._ -import com.advancedtelematic.director.data.GeneratorOps._ -import com.advancedtelematic.director.data.Codecs._ -import com.advancedtelematic.director.http.AdminResources class MultiTargetUpdatesResourceSpec extends DirectorSpec with Generators with DefaultPatience with RouteResourceSpec with AdminResources { @@ -24,7 +24,18 @@ class MultiTargetUpdatesResourceSpec extends DirectorSpec } } + testWithNamespace("Legacy API: can GET multi-target updates") { implicit ns => + val mtu = createMtuOk() + + Get(apiUri(s"multi_target_updates/${mtu.show}")).namespaced ~> routes ~> check { + status shouldBe StatusCodes.OK + responseAs[Map[HardwareIdentifier, TargetUpdateRequest]] // This should be responseAs[MultiTargetUpdate], see comments on resource + } + } + testWithNamespace("can GET multi-target updates") { implicit ns => + pending // due to legacy api support + val mtu = createMtuOk() Get(apiUri(s"multi_target_updates/${mtu.show}")).namespaced ~> routes ~> check { @@ -33,6 +44,7 @@ class MultiTargetUpdatesResourceSpec extends DirectorSpec } } + testWithNamespace("accepts mtu with an update") { implicit ns => createMtuOk() }