From 38c7a7fee8810d0a74a9c5a568be952dc10f2e5d Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Fri, 13 Dec 2024 20:25:45 +0100 Subject: [PATCH] Handle scenario names with spaces when performing migration tests (#7332) --- .../ui/process/migrate/RemoteEnvironment.scala | 13 +++---------- .../migrate/StandardRemoteEnvironmentSpec.scala | 8 ++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/migrate/RemoteEnvironment.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/migrate/RemoteEnvironment.scala index ace11a76f1c..c2aedf8f98a 100644 --- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/migrate/RemoteEnvironment.scala +++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/migrate/RemoteEnvironment.scala @@ -21,19 +21,12 @@ import pl.touk.nussknacker.restmodel.scenariodetails.ScenarioWithDetailsForMigra import pl.touk.nussknacker.restmodel.validation.ValidationResults.ValidationErrors import pl.touk.nussknacker.ui.NuDesignerError.XError import pl.touk.nussknacker.ui.api.description.MigrationApiEndpoints.Dtos.ApiVersion -import pl.touk.nussknacker.ui.migrations.{ - MigrateScenarioData, - MigrateScenarioDataV1, - MigrateScenarioDataV2, - MigrationApiAdapterService -} +import pl.touk.nussknacker.ui.migrations.{MigrateScenarioData, MigrateScenarioDataV2, MigrationApiAdapterService} import pl.touk.nussknacker.ui.security.api.LoggedUser import pl.touk.nussknacker.ui.util.ScenarioGraphComparator.Difference import pl.touk.nussknacker.ui.util.{ApiAdapterServiceError, OutOfRangeAdapterRequestError, ScenarioGraphComparator} import pl.touk.nussknacker.ui.{FatalError, NuDesignerError} -import java.net.URLEncoder -import java.nio.charset.StandardCharsets import scala.collection.parallel.ExecutionContextTaskSupport import scala.collection.parallel.immutable.ParVector import scala.concurrent.duration.{DurationInt, FiniteDuration} @@ -156,7 +149,7 @@ class HttpRemoteEnvironment( ) } - override def close(): Unit = Await.ready(http.shutdownAllConnectionPools(), closeTimeout) + override def close(): Unit = Await.ready(closeAsync(), closeTimeout) def closeAsync(): Future[Unit] = http.shutdownAllConnectionPools() } @@ -355,7 +348,7 @@ trait StandardRemoteEnvironment extends FailFastCirceSupport with RemoteEnvironm HttpMethods.GET, "processesDetails" :: Nil, Query( - ("names", names.map(ns => URLEncoder.encode(ns.value, StandardCharsets.UTF_8)).mkString(",")), + ("names", names.map(_.value).mkString(",")), ("isArchived", "false"), ("skipNodeResults", "true"), ) diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/migrate/StandardRemoteEnvironmentSpec.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/migrate/StandardRemoteEnvironmentSpec.scala index b99450c78cf..f9a9feb33f2 100644 --- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/migrate/StandardRemoteEnvironmentSpec.scala +++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/migrate/StandardRemoteEnvironmentSpec.scala @@ -56,7 +56,7 @@ class StandardRemoteEnvironmentSpec request: MessageEntity, header: Seq[HttpHeader] ): Future[HttpResponse] = { - if (path.toString().startsWith(s"$baseUri/processes/a") && method == HttpMethods.GET) { + if (path == baseUri.withPath(baseUri.path + "/processes/a%20b%20c") && method == HttpMethods.GET) { Marshal( ScenarioWithDetailsConversions.fromEntityWithScenarioGraph( wrapGraphWithScenarioDetailsEntity(name, scenarioGraph), @@ -68,7 +68,7 @@ class StandardRemoteEnvironmentSpec HttpResponse(StatusCodes.OK, entity = entity) } } else { - throw new AssertionError(s"Not expected $path") + throw new AssertionError(s"Not expected ${method.value} $path") } } } @@ -91,7 +91,7 @@ class StandardRemoteEnvironmentSpec request: MessageEntity, headers: Seq[HttpHeader] ): Future[HttpResponse] = { - if (path.toString().startsWith(s"$baseUri/processes/%C5%82%C3%B3d%C5%BA") && method == HttpMethods.GET) { + if (path == baseUri.withPath(baseUri.path + "/processes/%C5%82%C3%B3d%C5%BA") && method == HttpMethods.GET) { Marshal( ScenarioWithDetailsConversions.fromEntityWithScenarioGraph( wrapGraphWithScenarioDetailsEntity(name, scenarioGraph), @@ -338,7 +338,7 @@ class StandardRemoteEnvironmentSpec object GetProcessesDetails { def unapply(arg: (Uri, HttpMethod)): Option[Set[ProcessName]] = { val uri = arg._1 - if (uri.toString().startsWith(s"$baseUri/processesDetails") && uri + if (uri.withQuery(Uri.Query.Empty) == baseUri.withPath(baseUri.path + "/processesDetails") && uri .query() .get("isArchived") .contains("false") && arg._2 == HttpMethods.GET) {