diff --git a/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala index ace88b2086..497fa527c7 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala @@ -88,7 +88,7 @@ class AttachmentCtrl @Inject() ( header = ResponseHeader( 200, Map( - "Content-Disposition" -> s"""attachment; ${HttpHeaderParameterEncoding.encode("filename", filename)}.zip""", + "Content-Disposition" -> s"""attachment; ${HttpHeaderParameterEncoding.encode("filename", s"$filename.zip")}""", "Content-Type" -> "application/zip", "Content-Transfer-Encoding" -> "binary", "Content-Length" -> Files.size(f).toString diff --git a/thehive/test/org/thp/thehive/TestAppBuilder.scala b/thehive/test/org/thp/thehive/TestAppBuilder.scala index 6dda1f1362..208fcaa035 100644 --- a/thehive/test/org/thp/thehive/TestAppBuilder.scala +++ b/thehive/test/org/thp/thehive/TestAppBuilder.scala @@ -1,6 +1,7 @@ package org.thp.thehive import akka.actor.ActorSystem +import akka.actor.typed.scaladsl.Behaviors import akka.actor.typed.{ActorRef => TypedActorRef} import akka.actor.typed.scaladsl.adapter.ClassicActorSystemOps import org.apache.commons.io.FileUtils @@ -18,6 +19,7 @@ import org.thp.thehive.services.{UserSrv => _, _} import java.io.File import java.nio.file.{Files, Paths} +import java.util.UUID import javax.inject.{Inject, Provider, Singleton} import scala.util.Try @@ -60,6 +62,7 @@ trait TestAppBuilder { ) .bindActor[DummyActor]("config-actor") .bindActor[DummyActor]("notification-actor") + .bindToProvider[TypedActorRef[IntegrityCheck.Request], DummyTypedActorProvider[IntegrityCheck.Request]] .bindActor[DummyActor]("integrity-check-actor") .bindActor[DummyActor]("flow-actor") .addConfiguration("auth.providers = [{name:local},{name:key},{name:header, userHeader:user}]") @@ -135,3 +138,10 @@ class TestNumberActorProvider @Inject() (actorSystem: ActorSystem) extends Provi .toTyped .systemActorOf(CaseNumberActor.caseNumberProvider(getNextNumber = () => 36, reloadTimer = () => (), nextNumber = 36), "case-number") } + +class DummyTypedActorProvider[T] @Inject() (actorSystem: ActorSystem) extends Provider[TypedActorRef[T]] { + override def get(): TypedActorRef[T] = + actorSystem + .toTyped + .systemActorOf(Behaviors.empty, UUID.randomUUID().toString) +} diff --git a/thehive/test/org/thp/thehive/services/UserSrvTest.scala b/thehive/test/org/thp/thehive/services/UserSrvTest.scala index bd46ea535d..37d8a19ff5 100644 --- a/thehive/test/org/thp/thehive/services/UserSrvTest.scala +++ b/thehive/test/org/thp/thehive/services/UserSrvTest.scala @@ -11,6 +11,7 @@ import org.thp.thehive.services.OrganisationOps._ import org.thp.thehive.services.UserOps._ import play.api.test.PlaySpecification +import scala.concurrent.duration.DurationInt import scala.util.{Failure, Success} class UserSrvTest extends PlaySpecification with TestAppBuilder { @@ -73,7 +74,7 @@ class UserSrvTest extends PlaySpecification with TestAppBuilder { if (userCount == 2) Success(()) else Failure(new Exception(s"User certadmin is not in cert organisation twice ($userCount)")) } - new UserIntegrityCheck(db, userSrv, profileSrv, organisationSrv, roleSrv).dedup(KillSwitch.alwaysOn) + new UserIntegrityCheck(db, userSrv, profileSrv, organisationSrv, roleSrv).runGlobalCheck(5.minutes, KillSwitch.alwaysOn) db.roTransaction { implicit graph => val userCount = userSrv.get(EntityName("certadmin@thehive.local")).organisations.get(EntityName("cert")).getCount userCount must beEqualTo(1)