From 2f6652220f2e27cb40c6ab092272bbd01753de94 Mon Sep 17 00:00:00 2001 From: tna-digital-archiving-jenkins Date: Wed, 13 Dec 2023 08:31:53 +0000 Subject: [PATCH 01/75] Update play-pac4j to 12.0.0-PLAY3.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a1d4b8b7c..aa83244fa 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,7 @@ libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0 //More details on a similar error here: https://stackoverflow.com/questions/43841091/spark2-1-0-incompatible-jackson-versions-2-7-6 dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.11.4" % Test -val playPac4jVersion = "11.1.0-PLAY2.8" +val playPac4jVersion = "12.0.0-PLAY3.0" val pac4jVersion = "5.7.2" val sttpVersion = "2.3.0" From 3338ff7e43418172e298a9ce823402676c4aa98b Mon Sep 17 00:00:00 2001 From: TomJKing Date: Thu, 14 Dec 2023 14:54:56 +0000 Subject: [PATCH 02/75] Initial commit --- app/auth/TokenSecurity.scala | 4 ++++ app/auth/UnprotectedPageController.scala | 7 +++++-- app/configuration/AccessLoggingFilter.scala | 12 +++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/auth/TokenSecurity.scala b/app/auth/TokenSecurity.scala index 35ba55ea8..f920bf44e 100644 --- a/app/auth/TokenSecurity.scala +++ b/app/auth/TokenSecurity.scala @@ -3,8 +3,10 @@ package auth import com.nimbusds.oauth2.sdk.token.BearerAccessToken import configuration.KeycloakConfiguration import io.opentelemetry.api.trace.Span +import org.pac4j.core.context.session.SessionStore import org.pac4j.core.profile.{ProfileManager, UserProfile} import org.pac4j.play.PlayWebContext +import org.pac4j.play.context.PlayFrameworkParameters import play.api.i18n.I18nSupport import play.api.mvc.{Action, AnyContent, Request, Result} import services.ConsignmentService @@ -24,6 +26,8 @@ trait TokenSecurity extends OidcSecurity with I18nSupport { val userIdKey = "UserId" def getProfile(request: Request[AnyContent]): Optional[UserProfile] = { + val parameters = new PlayFrameworkParameters(request) + val sessionStore = config.getSessionStoreFactory.newSessionStore(parameters) val webContext = new PlayWebContext(request) val profileManager = new ProfileManager(webContext, sessionStore) profileManager.getProfile diff --git a/app/auth/UnprotectedPageController.scala b/app/auth/UnprotectedPageController.scala index 222d027ac..38449efcd 100644 --- a/app/auth/UnprotectedPageController.scala +++ b/app/auth/UnprotectedPageController.scala @@ -2,9 +2,10 @@ package auth import com.nimbusds.jwt.SignedJWT import com.nimbusds.oauth2.sdk.token.BearerAccessToken -import org.pac4j.core.profile.{CommonProfile, ProfileManager} +import org.pac4j.core.profile.{CommonProfile, ProfileManager, UserProfile} import org.pac4j.play.PlayWebContext -import org.pac4j.play.scala.{Security, SecurityComponents} +import org.pac4j.play.context.PlayFrameworkParameters +import org.pac4j.play.scala.{Pac4jScalaTemplateHelper, Security, SecurityComponents} import play.api.mvc.{AnyContent, Request} import javax.inject.Inject @@ -12,6 +13,8 @@ import javax.inject.Inject class UnprotectedPageController @Inject() (val controllerComponents: SecurityComponents) extends Security[CommonProfile] { private def getProfile(request: Request[AnyContent]): ProfileManager = { + val parameters = new PlayFrameworkParameters(request) + val sessionStore = config.getSessionStoreFactory.newSessionStore(parameters) val webContext = new PlayWebContext(request) new ProfileManager(webContext, sessionStore) } diff --git a/app/configuration/AccessLoggingFilter.scala b/app/configuration/AccessLoggingFilter.scala index eec7bb5f9..2baf11080 100644 --- a/app/configuration/AccessLoggingFilter.scala +++ b/app/configuration/AccessLoggingFilter.scala @@ -3,9 +3,9 @@ package configuration import akka.stream.Materializer import auth.OidcSecurity import com.nimbusds.oauth2.sdk.token.BearerAccessToken -import org.pac4j.core.profile.ProfileManager +import org.pac4j.core.profile.{ProfileManager, UserProfile} import org.pac4j.play.PlayWebContext -import org.pac4j.play.scala.SecurityComponents +import org.pac4j.play.scala.{Pac4jScalaTemplateHelper, SecurityComponents} import play.api.Logging import play.api.mvc.{Filter, RequestHeader, Result} @@ -17,7 +17,8 @@ class AccessLoggingFilter @Inject() (implicit val mat: Materializer, val keycloakConfiguration: KeycloakConfiguration, val controllerComponents: SecurityComponents, - executionContext: ExecutionContext + executionContext: ExecutionContext, + pac4jScalaTemplateHelper: Pac4jScalaTemplateHelper[UserProfile] ) extends OidcSecurity with Filter with Logging { @@ -29,8 +30,9 @@ class AccessLoggingFilter @Inject() (implicit nextFilter(request) } else { nextFilter(request).map { result => - val webContext = new PlayWebContext(request) - val profileManager = new ProfileManager(webContext, sessionStore) + //val webContext = new PlayWebContext(request) + val profileManager = pac4jScalaTemplateHelper.createProfileManager(request) + //val profileManager = new ProfileManager(webContext, sessionStore) val userId: String = profileManager.getProfile.asScala .map(_.getAttribute("access_token").asInstanceOf[BearerAccessToken]) .flatMap(token => keycloakConfiguration.token(token.getValue)) From 5e891c8cba628553c53469ad75b67eb69f44febe Mon Sep 17 00:00:00 2001 From: TomJKing Date: Fri, 15 Dec 2023 09:37:08 +0000 Subject: [PATCH 03/75] Compiles and starts up but doesn't work --- app/configuration/AccessLoggingFilter.scala | 11 +- .../CustomSavedRequestHandler.scala | 19 +-- app/modules/SecurityModule.scala | 8 +- build.sbt | 8 +- project/plugins.sbt | 2 +- test/errors/ErrorHandlerSpec.scala | 148 +++++++++--------- test/testUtils/FrontEndTestHelper.scala | 9 +- 7 files changed, 106 insertions(+), 99 deletions(-) diff --git a/app/configuration/AccessLoggingFilter.scala b/app/configuration/AccessLoggingFilter.scala index 2baf11080..4f5a1ac20 100644 --- a/app/configuration/AccessLoggingFilter.scala +++ b/app/configuration/AccessLoggingFilter.scala @@ -5,6 +5,7 @@ import auth.OidcSecurity import com.nimbusds.oauth2.sdk.token.BearerAccessToken import org.pac4j.core.profile.{ProfileManager, UserProfile} import org.pac4j.play.PlayWebContext +import org.pac4j.play.context.PlayFrameworkParameters import org.pac4j.play.scala.{Pac4jScalaTemplateHelper, SecurityComponents} import play.api.Logging import play.api.mvc.{Filter, RequestHeader, Result} @@ -17,8 +18,7 @@ class AccessLoggingFilter @Inject() (implicit val mat: Materializer, val keycloakConfiguration: KeycloakConfiguration, val controllerComponents: SecurityComponents, - executionContext: ExecutionContext, - pac4jScalaTemplateHelper: Pac4jScalaTemplateHelper[UserProfile] + executionContext: ExecutionContext ) extends OidcSecurity with Filter with Logging { @@ -30,9 +30,10 @@ class AccessLoggingFilter @Inject() (implicit nextFilter(request) } else { nextFilter(request).map { result => - //val webContext = new PlayWebContext(request) - val profileManager = pac4jScalaTemplateHelper.createProfileManager(request) - //val profileManager = new ProfileManager(webContext, sessionStore) + val parameters = new PlayFrameworkParameters(request) + val webContext = controllerComponents.config.getWebContextFactory.newContext(parameters) + val sessionStore = controllerComponents.config.getSessionStoreFactory.newSessionStore(parameters) + val profileManager = controllerComponents.config.getProfileManagerFactory.apply(webContext, sessionStore) val userId: String = profileManager.getProfile.asScala .map(_.getAttribute("access_token").asInstanceOf[BearerAccessToken]) .flatMap(token => keycloakConfiguration.token(token.getValue)) diff --git a/app/configuration/CustomSavedRequestHandler.scala b/app/configuration/CustomSavedRequestHandler.scala index 90dc592ba..58f613f45 100644 --- a/app/configuration/CustomSavedRequestHandler.scala +++ b/app/configuration/CustomSavedRequestHandler.scala @@ -1,6 +1,6 @@ package configuration -import org.pac4j.core.context.WebContext +import org.pac4j.core.context.{CallContext, WebContext} import org.pac4j.core.context.session.SessionStore import org.pac4j.core.engine.savedrequest.SavedRequestHandler import org.pac4j.core.exception.http.{FoundAction, HttpAction} @@ -10,25 +10,26 @@ import play.api.Logging import scala.jdk.OptionConverters.RichOptional class CustomSavedRequestHandler extends SavedRequestHandler with Logging { - override def save(context: WebContext, sessionStore: SessionStore): Unit = { + override def save(context: CallContext): Unit = { logger.info("Saving webContext") + val webContext = context.webContext() - val requestedUrl = getRequestedUrl(context) + val requestedUrl = getRequestedUrl(webContext) // Need to specify the type of SessionStore so that we can pass the context into the set method context. - sessionStore - .set(context, Pac4jConstants.REQUESTED_URL, new FoundAction(requestedUrl)) + context.sessionStore().set(webContext, Pac4jConstants.REQUESTED_URL, new FoundAction(requestedUrl)) } private def getRequestedUrl(context: WebContext): String = context.getFullRequestURL - override def restore(context: WebContext, sessionStore: SessionStore, defaultUrl: String): HttpAction = { - val optRequestedUrl = sessionStore - .get(context, Pac4jConstants.REQUESTED_URL) + override def restore(context: CallContext, defaultUrl: String): HttpAction = { + val webContext = context.webContext() + val optRequestedUrl = context.sessionStore() + .get(webContext, Pac4jConstants.REQUESTED_URL) val redirectAction = optRequestedUrl.toScala .map(_.asInstanceOf[FoundAction]) .getOrElse(new FoundAction(defaultUrl)) - HttpActionHelper.buildRedirectUrlAction(context, redirectAction.getLocation) + HttpActionHelper.buildRedirectUrlAction(webContext, redirectAction.getLocation) } } diff --git a/app/modules/SecurityModule.scala b/app/modules/SecurityModule.scala index f87069e8b..d12014aca 100644 --- a/app/modules/SecurityModule.scala +++ b/app/modules/SecurityModule.scala @@ -6,7 +6,8 @@ import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod import configuration.CustomSavedRequestHandler import org.pac4j.core.client.Clients import org.pac4j.core.config.Config -import org.pac4j.core.context.session.SessionStore +import org.pac4j.core.context.FrameworkParameters +import org.pac4j.core.context.session.{SessionStore, SessionStoreFactory} import org.pac4j.core.engine.{DefaultCallbackLogic, DefaultSecurityLogic} import org.pac4j.core.profile.CommonProfile import org.pac4j.oidc.client.OidcClient @@ -61,7 +62,7 @@ class SecurityModule extends AbstractModule { } @Provides - def provideConfig(oidcClient: OidcClient): Config = { + def provideConfig(oidcClient: OidcClient, sessionStore: SessionStore): Config = { val clients = new Clients(oidcClient) val config = new Config(clients) config.setHttpActionAdapter(new FrontendHttpActionAdaptor()) @@ -72,6 +73,9 @@ class SecurityModule extends AbstractModule { config.setCallbackLogic(callbackLogic) val securityLogic = DefaultSecurityLogic.INSTANCE securityLogic.setSavedRequestHandler(customRequestHandler) + config.setSessionStoreFactory(new SessionStoreFactory { + override def newSessionStore(parameters: FrameworkParameters): SessionStore = sessionStore + }) config } diff --git a/build.sbt b/build.sbt index aa83244fa..7ccf8a41a 100644 --- a/build.sbt +++ b/build.sbt @@ -15,16 +15,16 @@ libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0 //Needed to run the tests. Prevents incompatible databind version errors. //More details on a similar error here: https://stackoverflow.com/questions/43841091/spark2-1-0-incompatible-jackson-versions-2-7-6 -dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.11.4" % Test +dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.14.2" % Test val playPac4jVersion = "12.0.0-PLAY3.0" -val pac4jVersion = "5.7.2" +val pac4jVersion = "6.0.0" val sttpVersion = "2.3.0" libraryDependencies ++= Seq( "org.pac4j" %% "play-pac4j" % playPac4jVersion, - "org.pac4j" % "pac4j-http" % pac4jVersion exclude ("com.fasterxml.jackson.core", "jackson-databind"), - "org.pac4j" % "pac4j-oidc" % pac4jVersion exclude ("commons-io", "commons-io") exclude ("com.fasterxml.jackson.core", "jackson-databind"), + "org.pac4j" % "pac4j-http" % pac4jVersion, + "org.pac4j" % "pac4j-oidc" % pac4jVersion, "io.circe" %% "circe-core" % "0.14.6", "io.circe" %% "circe-generic" % "0.14.6", "com.softwaremill.sttp.client" %% "core" % sttpVersion, diff --git a/project/plugins.sbt b/project/plugins.sbt index 405a85651..7b162b4f5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") resolvers += Resolver.jcenterRepo addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.4") diff --git a/test/errors/ErrorHandlerSpec.scala b/test/errors/ErrorHandlerSpec.scala index 405c28839..6a54e67d7 100644 --- a/test/errors/ErrorHandlerSpec.scala +++ b/test/errors/ErrorHandlerSpec.scala @@ -18,78 +18,78 @@ import java.util.concurrent.CompletionException class ErrorHandlerSpec extends AnyFlatSpec with Matchers { - val sessionStore: SessionStore = mock[SessionStore] - val pac4jTemplateHelper: Pac4jScalaTemplateHelper[CommonProfile] = new Pac4jScalaTemplateHelper[CommonProfile](sessionStore, Config.INSTANCE) - val errorHandler = new ErrorHandler(new DefaultMessagesApi(), pac4jTemplateHelper) - - "client error handler" should "return a Default response for any status code not explicitly handled" in { - val request = FakeRequest() - val unhandledStatusCode = 499 - val response = errorHandler.onClientError(request, unhandledStatusCode).futureValue - - response.header.status should equal(unhandledStatusCode) - } - - "client error handler" should "return a 401 Unauthorized response if user is unauthorized" in { - - val request = FakeRequest() - val response = errorHandler.onClientError(request, 401).futureValue - - response.header.status should equal(Status.UNAUTHORIZED) - } - - "client error handler" should "return a 403 Forbidden response if access is denied" in { - - val request = FakeRequest() - val response = errorHandler.onClientError(request, 403).futureValue - - response.header.status should equal(Status.FORBIDDEN) - } - - "client error handler" should "return a 404 Not Found response if the requested page does not exist" in { - - val request = FakeRequest() - val response = errorHandler.onClientError(request, 404).futureValue - - response.header.status should equal(Status.NOT_FOUND) - } - - "server error handler" should "return a 403 Forbidden response if an authorisation exception is thrown" in { - val request = FakeRequest() - val exception = new AuthorisationException("some authorisation error") - - val response = errorHandler.onServerError(request, exception).futureValue - - response.header.status should equal(Status.FORBIDDEN) - } - - "server error handler" should "return a 500 Internal Server Error response if an arbitrary exception is thrown" in { - val request = FakeRequest() - val exception = new Exception("some generic exception") - - val response = errorHandler.onServerError(request, exception).futureValue - - response.header.status should equal(Status.INTERNAL_SERVER_ERROR) - } - - "server error handler" should "redirect if the exception is for missing state" in { - val request = FakeRequest() - val stateException = new CompletionException("Error", new TechnicalException("State cannot be determined")) - val response = errorHandler.onServerError(request, stateException).futureValue - - response.header.status should equal(Status.SEE_OTHER) - response.header.headers("Location") should equal("/view-transfers") - } - - "redirectUrl" should "return url '/view-transfers' for non-judgment user" in { - val redirectUrl = errorHandler.redirectUrl(false) - - redirectUrl should equal("/view-transfers") - } - - "redirectUrl" should "return url '/homepage' for judgment user" in { - val redirectUrl = errorHandler.redirectUrl(true) - - redirectUrl should equal("/homepage") - } +// val sessionStore: SessionStore = mock[SessionStore] +// val pac4jTemplateHelper: Pac4jScalaTemplateHelper[CommonProfile] = new Pac4jScalaTemplateHelper[CommonProfile](sessionStore, Config.INSTANCE) +// val errorHandler = new ErrorHandler(new DefaultMessagesApi(), pac4jTemplateHelper) +// +// "client error handler" should "return a Default response for any status code not explicitly handled" in { +// val request = FakeRequest() +// val unhandledStatusCode = 499 +// val response = errorHandler.onClientError(request, unhandledStatusCode).futureValue +// +// response.header.status should equal(unhandledStatusCode) +// } +// +// "client error handler" should "return a 401 Unauthorized response if user is unauthorized" in { +// +// val request = FakeRequest() +// val response = errorHandler.onClientError(request, 401).futureValue +// +// response.header.status should equal(Status.UNAUTHORIZED) +// } +// +// "client error handler" should "return a 403 Forbidden response if access is denied" in { +// +// val request = FakeRequest() +// val response = errorHandler.onClientError(request, 403).futureValue +// +// response.header.status should equal(Status.FORBIDDEN) +// } +// +// "client error handler" should "return a 404 Not Found response if the requested page does not exist" in { +// +// val request = FakeRequest() +// val response = errorHandler.onClientError(request, 404).futureValue +// +// response.header.status should equal(Status.NOT_FOUND) +// } +// +// "server error handler" should "return a 403 Forbidden response if an authorisation exception is thrown" in { +// val request = FakeRequest() +// val exception = new AuthorisationException("some authorisation error") +// +// val response = errorHandler.onServerError(request, exception).futureValue +// +// response.header.status should equal(Status.FORBIDDEN) +// } +// +// "server error handler" should "return a 500 Internal Server Error response if an arbitrary exception is thrown" in { +// val request = FakeRequest() +// val exception = new Exception("some generic exception") +// +// val response = errorHandler.onServerError(request, exception).futureValue +// +// response.header.status should equal(Status.INTERNAL_SERVER_ERROR) +// } +// +// "server error handler" should "redirect if the exception is for missing state" in { +// val request = FakeRequest() +// val stateException = new CompletionException("Error", new TechnicalException("State cannot be determined")) +// val response = errorHandler.onServerError(request, stateException).futureValue +// +// response.header.status should equal(Status.SEE_OTHER) +// response.header.headers("Location") should equal("/view-transfers") +// } +// +// "redirectUrl" should "return url '/view-transfers' for non-judgment user" in { +// val redirectUrl = errorHandler.redirectUrl(false) +// +// redirectUrl should equal("/view-transfers") +// } +// +// "redirectUrl" should "return url '/homepage' for judgment user" in { +// val redirectUrl = errorHandler.redirectUrl(true) +// +// redirectUrl should equal("/homepage") +// } } diff --git a/test/testUtils/FrontEndTestHelper.scala b/test/testUtils/FrontEndTestHelper.scala index 6eba47b12..e90bfd4a2 100644 --- a/test/testUtils/FrontEndTestHelper.scala +++ b/test/testUtils/FrontEndTestHelper.scala @@ -69,6 +69,7 @@ import uk.gov.nationalarchives.tdr.GraphQLClient import uk.gov.nationalarchives.tdr.keycloak.Token import graphql.codegen.GetConsignment.{getConsignment => gcd} import graphql.codegen.GetConsignmentStatus.getConsignmentStatus.GetConsignment +import org.pac4j.core.context.CallContext import services.Statuses.{InProgressValue, SeriesType} import viewsapi.FrontEndInfo @@ -948,7 +949,7 @@ trait FrontEndTestHelper extends PlaySpec with MockitoSugar with Injecting with override def config: Config = testConfig - override def sessionStore: SessionStore = playCacheSessionStore + def sessionStore: SessionStore = playCacheSessionStore // scalastyle:off null override def parser: BodyParsers.Default = null @@ -977,10 +978,10 @@ trait FrontEndTestHelper extends PlaySpec with MockitoSugar with Injecting with doReturn(true).when(configuration).isUseNonce val providerMetadata = mock[OIDCProviderMetadata] doReturn(URI.create("/auth/realms/tdr/protocol/openid-connect/auth")).when(providerMetadata).getAuthorizationEndpointURI - doReturn(providerMetadata).when(configuration).getProviderMetadata + //doReturn(providerMetadata).when(configuration).getProviderMetadata val resolver = mock[AjaxRequestResolver] - doReturn(false).when(resolver).isAjax(any[PlayWebContext], any[SessionStore]) + doReturn(false).when(resolver).isAjax(any[CallContext]) // Create a concrete client val client = new OidcClient(configuration) @@ -999,7 +1000,7 @@ trait FrontEndTestHelper extends PlaySpec with MockitoSugar with Injecting with override def config: Config = testConfig - override def sessionStore: SessionStore = mock[SessionStore] + def sessionStore: SessionStore = mock[SessionStore] // scalastyle:off null override def parser: BodyParsers.Default = null From 9c6063ab6359c4de5f1479d1bfd5aa1af52e14c7 Mon Sep 17 00:00:00 2001 From: TomJKing Date: Mon, 18 Dec 2023 13:09:52 +0000 Subject: [PATCH 04/75] Update Access Logging Filter --- app/configuration/AccessLoggingFilter.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/configuration/AccessLoggingFilter.scala b/app/configuration/AccessLoggingFilter.scala index 4f5a1ac20..1ee3731db 100644 --- a/app/configuration/AccessLoggingFilter.scala +++ b/app/configuration/AccessLoggingFilter.scala @@ -31,9 +31,9 @@ class AccessLoggingFilter @Inject() (implicit } else { nextFilter(request).map { result => val parameters = new PlayFrameworkParameters(request) - val webContext = controllerComponents.config.getWebContextFactory.newContext(parameters) - val sessionStore = controllerComponents.config.getSessionStoreFactory.newSessionStore(parameters) - val profileManager = controllerComponents.config.getProfileManagerFactory.apply(webContext, sessionStore) + val sessionStore = config.getSessionStoreFactory.newSessionStore(parameters) + val webContext = new PlayWebContext(request) + val profileManager = new ProfileManager(webContext, sessionStore) val userId: String = profileManager.getProfile.asScala .map(_.getAttribute("access_token").asInstanceOf[BearerAccessToken]) .flatMap(token => keycloakConfiguration.token(token.getValue)) From 5dfce10c6d46e3e9ccc9d7f9ad261f9a5cc48b10 Mon Sep 17 00:00:00 2001 From: TomJKing Date: Thu, 21 Dec 2023 09:53:57 +0000 Subject: [PATCH 05/75] Get project to compile --- app/configuration/AccessLoggingFilter.scala | 6 +- app/configuration/KeycloakConfiguration.scala | 3 +- app/controllers/ViewTransfersController.scala | 4 +- build.sbt | 14 +- project/build.properties | 2 +- project/plugins.sbt | 2 +- .../AddAdditionalMetadataControllerSpec.scala | 2 +- .../ViewTransfersControllerSpec.scala | 2 +- test/errors/ErrorHandlerSpec.scala | 149 +++++++++--------- test/testUtils/FrontEndTestHelper.scala | 2 +- 10 files changed, 93 insertions(+), 93 deletions(-) diff --git a/app/configuration/AccessLoggingFilter.scala b/app/configuration/AccessLoggingFilter.scala index 1ee3731db..d3080ffe3 100644 --- a/app/configuration/AccessLoggingFilter.scala +++ b/app/configuration/AccessLoggingFilter.scala @@ -1,12 +1,12 @@ package configuration -import akka.stream.Materializer import auth.OidcSecurity import com.nimbusds.oauth2.sdk.token.BearerAccessToken -import org.pac4j.core.profile.{ProfileManager, UserProfile} +import org.apache.pekko.stream.Materializer +import org.pac4j.core.profile.ProfileManager import org.pac4j.play.PlayWebContext import org.pac4j.play.context.PlayFrameworkParameters -import org.pac4j.play.scala.{Pac4jScalaTemplateHelper, SecurityComponents} +import org.pac4j.play.scala.SecurityComponents import play.api.Logging import play.api.mvc.{Filter, RequestHeader, Result} diff --git a/app/configuration/KeycloakConfiguration.scala b/app/configuration/KeycloakConfiguration.scala index 3b77c182c..4fd7d619e 100644 --- a/app/configuration/KeycloakConfiguration.scala +++ b/app/configuration/KeycloakConfiguration.scala @@ -8,7 +8,8 @@ import scala.concurrent.ExecutionContext class KeycloakConfiguration @Inject() (configuration: Configuration)(implicit val executionContext: ExecutionContext) { def token(value: String): Option[Token] = { - implicit val tdrKeycloakDeployment: TdrKeycloakDeployment = TdrKeycloakDeployment(s"${configuration.get[String]("auth.url")}", "tdr", 3600) + implicit val tdrKeycloakDeployment: TdrKeycloakDeployment = + TdrKeycloakDeployment(s"${configuration.get[String]("auth.url")}", "tdr", 18000) // temp increase in user session timeout to 5 hours for TDR-3571 KeycloakUtils().token(value).toOption } } diff --git a/app/controllers/ViewTransfersController.scala b/app/controllers/ViewTransfersController.scala index 8292d1dd4..1d8a7ed17 100644 --- a/app/controllers/ViewTransfersController.scala +++ b/app/controllers/ViewTransfersController.scala @@ -66,8 +66,8 @@ class ViewTransfersController @Inject() ( userAction.transferStatus, statusColours(userAction.transferStatus), userAction, - edge.node.exportDatetime.map(DateUtils.format(_)).getOrElse("N/A"), - edge.node.createdDatetime.map(DateUtils.format(_)).getOrElse(""), + edge.node.exportDatetime.map(edt => DateUtils.format(edt, "dd/MM/yyyy HH:mm")).getOrElse("N/A"), + edge.node.createdDatetime.map(cdt => DateUtils.format(cdt, "dd/MM/yyyy HH:mm")).getOrElse(""), edge.node.totalFiles ) } diff --git a/build.sbt b/build.sbt index 7ccf8a41a..1ff54e973 100644 --- a/build.sbt +++ b/build.sbt @@ -13,17 +13,14 @@ scalaVersion := "2.13.12" libraryDependencies += guice libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test -//Needed to run the tests. Prevents incompatible databind version errors. -//More details on a similar error here: https://stackoverflow.com/questions/43841091/spark2-1-0-incompatible-jackson-versions-2-7-6 -dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.14.2" % Test - +val playVersion = "3.0.0" val playPac4jVersion = "12.0.0-PLAY3.0" val pac4jVersion = "6.0.0" val sttpVersion = "2.3.0" libraryDependencies ++= Seq( - "org.pac4j" %% "play-pac4j" % playPac4jVersion, - "org.pac4j" % "pac4j-http" % pac4jVersion, + "org.pac4j" %% "play-pac4j" % playPac4jVersion excludeAll(ExclusionRule("commons-io" , "commons-io"), ExclusionRule(organization = "com.fasterxml.jackson.core")), + "org.pac4j" % "pac4j-http" % pac4jVersion excludeAll(ExclusionRule(organization = "com.fasterxml.jackson.core")), "org.pac4j" % "pac4j-oidc" % pac4jVersion, "io.circe" %% "circe-core" % "0.14.6", "io.circe" %% "circe-generic" % "0.14.6", @@ -46,13 +43,14 @@ libraryDependencies ++= Seq( "io.opentelemetry.contrib" % "opentelemetry-aws-xray-propagator" % "1.22.0-alpha", "com.github.tomakehurst" % "wiremock-standalone" % "3.0.1" % Test, "org.mockito" % "mockito-core" % "5.8.0" % Test, - "org.scalatestplus" %% "mockito-3-4" % "3.2.10.0" % Test + "org.scalatestplus" %% "mockito-3-4" % "3.2.10.0" % Test, + "org.playframework" %% "play-cache" % playVersion ) disablePlugins(PlayLogback) scalacOptions ++= Seq("-language:implicitConversions") libraryDependencies += play.sbt.PlayImport.cacheApi -libraryDependencies += "com.github.karelcemus" %% "play-redis" % "2.7.0" +libraryDependencies += "com.github.karelcemus" %% "play-redis" % "3.0.0-M1" pipelineStages := Seq(digest) diff --git a/project/build.properties b/project/build.properties index d41519952..8cf07b7c2 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.7 \ No newline at end of file +sbt.version=1.9.8 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 7b162b4f5..b90ca66c9 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.0") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") resolvers += Resolver.jcenterRepo addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.4") diff --git a/test/controllers/AddAdditionalMetadataControllerSpec.scala b/test/controllers/AddAdditionalMetadataControllerSpec.scala index 73bdd136e..7de2cc0cc 100644 --- a/test/controllers/AddAdditionalMetadataControllerSpec.scala +++ b/test/controllers/AddAdditionalMetadataControllerSpec.scala @@ -1,6 +1,5 @@ package controllers -import akka.Done import cats.implicits.catsSyntaxOptionId import com.github.tomakehurst.wiremock.WireMockServer import com.github.tomakehurst.wiremock.client.WireMock.{okJson, post, urlEqualTo} @@ -19,6 +18,7 @@ import io.circe.Printer import io.circe.generic.auto._ import io.circe.parser.decode import io.circe.syntax._ +import org.apache.pekko.Done import org.mockito.Mockito.when import org.pac4j.play.scala.SecurityComponents import org.scalatest.matchers.should.Matchers._ diff --git a/test/controllers/ViewTransfersControllerSpec.scala b/test/controllers/ViewTransfersControllerSpec.scala index a277116d4..e52085c4f 100644 --- a/test/controllers/ViewTransfersControllerSpec.scala +++ b/test/controllers/ViewTransfersControllerSpec.scala @@ -35,7 +35,7 @@ class ViewTransfersControllerSpec extends FrontEndTestHelper { val checkPageForStaticElements = new CheckPageForStaticElements - private val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss") + private val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm") private val standardType = "standard" private val judgmentType = "judgment" diff --git a/test/errors/ErrorHandlerSpec.scala b/test/errors/ErrorHandlerSpec.scala index 6a54e67d7..0a4e40361 100644 --- a/test/errors/ErrorHandlerSpec.scala +++ b/test/errors/ErrorHandlerSpec.scala @@ -18,78 +18,79 @@ import java.util.concurrent.CompletionException class ErrorHandlerSpec extends AnyFlatSpec with Matchers { -// val sessionStore: SessionStore = mock[SessionStore] -// val pac4jTemplateHelper: Pac4jScalaTemplateHelper[CommonProfile] = new Pac4jScalaTemplateHelper[CommonProfile](sessionStore, Config.INSTANCE) -// val errorHandler = new ErrorHandler(new DefaultMessagesApi(), pac4jTemplateHelper) -// -// "client error handler" should "return a Default response for any status code not explicitly handled" in { -// val request = FakeRequest() -// val unhandledStatusCode = 499 -// val response = errorHandler.onClientError(request, unhandledStatusCode).futureValue -// -// response.header.status should equal(unhandledStatusCode) -// } -// -// "client error handler" should "return a 401 Unauthorized response if user is unauthorized" in { -// -// val request = FakeRequest() -// val response = errorHandler.onClientError(request, 401).futureValue -// -// response.header.status should equal(Status.UNAUTHORIZED) -// } -// -// "client error handler" should "return a 403 Forbidden response if access is denied" in { -// -// val request = FakeRequest() -// val response = errorHandler.onClientError(request, 403).futureValue -// -// response.header.status should equal(Status.FORBIDDEN) -// } -// -// "client error handler" should "return a 404 Not Found response if the requested page does not exist" in { -// -// val request = FakeRequest() -// val response = errorHandler.onClientError(request, 404).futureValue -// -// response.header.status should equal(Status.NOT_FOUND) -// } -// -// "server error handler" should "return a 403 Forbidden response if an authorisation exception is thrown" in { -// val request = FakeRequest() -// val exception = new AuthorisationException("some authorisation error") -// -// val response = errorHandler.onServerError(request, exception).futureValue -// -// response.header.status should equal(Status.FORBIDDEN) -// } -// -// "server error handler" should "return a 500 Internal Server Error response if an arbitrary exception is thrown" in { -// val request = FakeRequest() -// val exception = new Exception("some generic exception") -// -// val response = errorHandler.onServerError(request, exception).futureValue -// -// response.header.status should equal(Status.INTERNAL_SERVER_ERROR) -// } -// -// "server error handler" should "redirect if the exception is for missing state" in { -// val request = FakeRequest() -// val stateException = new CompletionException("Error", new TechnicalException("State cannot be determined")) -// val response = errorHandler.onServerError(request, stateException).futureValue -// -// response.header.status should equal(Status.SEE_OTHER) -// response.header.headers("Location") should equal("/view-transfers") -// } -// -// "redirectUrl" should "return url '/view-transfers' for non-judgment user" in { -// val redirectUrl = errorHandler.redirectUrl(false) -// -// redirectUrl should equal("/view-transfers") -// } -// -// "redirectUrl" should "return url '/homepage' for judgment user" in { -// val redirectUrl = errorHandler.redirectUrl(true) -// -// redirectUrl should equal("/homepage") -// } + val sessionStore: SessionStore = mock[SessionStore] + val config = mock[Config] + val pac4jTemplateHelper: Pac4jScalaTemplateHelper[CommonProfile] = new Pac4jScalaTemplateHelper[CommonProfile](config) + val errorHandler = new ErrorHandler(new DefaultMessagesApi(), pac4jTemplateHelper) + + "client error handler" should "return a Default response for any status code not explicitly handled" in { + val request = FakeRequest() + val unhandledStatusCode = 499 + val response = errorHandler.onClientError(request, unhandledStatusCode).futureValue + + response.header.status should equal(unhandledStatusCode) + } + + "client error handler" should "return a 401 Unauthorized response if user is unauthorized" in { + + val request = FakeRequest() + val response = errorHandler.onClientError(request, 401).futureValue + + response.header.status should equal(Status.UNAUTHORIZED) + } + + "client error handler" should "return a 403 Forbidden response if access is denied" in { + + val request = FakeRequest() + val response = errorHandler.onClientError(request, 403).futureValue + + response.header.status should equal(Status.FORBIDDEN) + } + + "client error handler" should "return a 404 Not Found response if the requested page does not exist" in { + + val request = FakeRequest() + val response = errorHandler.onClientError(request, 404).futureValue + + response.header.status should equal(Status.NOT_FOUND) + } + + "server error handler" should "return a 403 Forbidden response if an authorisation exception is thrown" in { + val request = FakeRequest() + val exception = new AuthorisationException("some authorisation error") + + val response = errorHandler.onServerError(request, exception).futureValue + + response.header.status should equal(Status.FORBIDDEN) + } + + "server error handler" should "return a 500 Internal Server Error response if an arbitrary exception is thrown" in { + val request = FakeRequest() + val exception = new Exception("some generic exception") + + val response = errorHandler.onServerError(request, exception).futureValue + + response.header.status should equal(Status.INTERNAL_SERVER_ERROR) + } + + "server error handler" should "redirect if the exception is for missing state" in { + val request = FakeRequest() + val stateException = new CompletionException("Error", new TechnicalException("State cannot be determined")) + val response = errorHandler.onServerError(request, stateException).futureValue + + response.header.status should equal(Status.SEE_OTHER) + response.header.headers("Location") should equal("/view-transfers") + } + + "redirectUrl" should "return url '/view-transfers' for non-judgment user" in { + val redirectUrl = errorHandler.redirectUrl(false) + + redirectUrl should equal("/view-transfers") + } + + "redirectUrl" should "return url '/homepage' for judgment user" in { + val redirectUrl = errorHandler.redirectUrl(true) + + redirectUrl should equal("/homepage") + } } diff --git a/test/testUtils/FrontEndTestHelper.scala b/test/testUtils/FrontEndTestHelper.scala index e90bfd4a2..d3f10b664 100644 --- a/test/testUtils/FrontEndTestHelper.scala +++ b/test/testUtils/FrontEndTestHelper.scala @@ -978,7 +978,7 @@ trait FrontEndTestHelper extends PlaySpec with MockitoSugar with Injecting with doReturn(true).when(configuration).isUseNonce val providerMetadata = mock[OIDCProviderMetadata] doReturn(URI.create("/auth/realms/tdr/protocol/openid-connect/auth")).when(providerMetadata).getAuthorizationEndpointURI - //doReturn(providerMetadata).when(configuration).getProviderMetadata + doReturn(providerMetadata).when(configuration) val resolver = mock[AjaxRequestResolver] doReturn(false).when(resolver).isAjax(any[CallContext]) From 16b54ea4d6e36818d4b5d540aaf51f5b5ca80ae4 Mon Sep 17 00:00:00 2001 From: ian-hoyle Date: Mon, 26 Feb 2024 16:33:55 +0000 Subject: [PATCH 06/75] trying to hack --- .../draftMetadataUpload.scala.html | 22 ++++++++++++-- npm/src/index.ts | 10 +++++++ npm/src/upload/form/upload-form.ts | 9 +++++- npm/src/upload/index.ts | 29 ++++++++++++++++++- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/app/views/draftmetadata/draftMetadataUpload.scala.html b/app/views/draftmetadata/draftMetadataUpload.scala.html index b2dc39b4a..ab6cce89b 100644 --- a/app/views/draftmetadata/draftMetadataUpload.scala.html +++ b/app/views/draftmetadata/draftMetadataUpload.scala.html @@ -5,12 +5,28 @@ @import java.util.UUID @(consignmentId: UUID, consignmentRef: String, frontEndInfo: FrontEndInfo, name: String)(implicit request: RequestHeader, messages: Messages) -@main("[WIP] Draft Metadata Upload", name = name) { +@main("[WIP] Draft Metadata Upload", name = name, backLink = Some(backLink(routes.HomepageController.homepage().url, "How would you like to enter metadata?"))) {
-

[WIP] Draft Metadata Upload

-

Work in progress

+

Upload a CSV with record metadata

+

Upload a metadata CSV with a row for every record in your consignment.

+

The CSV must contain specific populated columns for a successful upload.

+

+

For more inforamtion on the CSV structure and content, visit the metadata guidance page.

@transferReference(consignmentRef, isJudgmentUser = false) + +
+ + +
+ +
+ + + +
} diff --git a/npm/src/index.ts b/npm/src/index.ts index 388004262..922ffea6e 100644 --- a/npm/src/index.ts +++ b/npm/src/index.ts @@ -41,6 +41,10 @@ const getFrontEndInfo: () => IFrontEndInfo | Error = () => { export const renderModules = async () => { const uploadContainer: HTMLDivElement | null = document.querySelector("#file-upload") + + const draftMetadataFileUploadContainer: HTMLDivElement | null = + document.querySelector("#metadata-file-upload") + const fileChecksContainer: HTMLDivElement | null = document.querySelector( ".file-check-progress" ) @@ -57,6 +61,12 @@ export const renderModules = async () => { '[data-tdr-module="button-disabled"]' ) + if (draftMetadataFileUploadContainer) { + uploadContainer.removeAttribute("hidden") + const frontEndInfo = getFrontEndInfo() + const errorHandlingModule = await import("./errorhandling") + } + if (uploadContainer) { uploadContainer.removeAttribute("hidden") const frontEndInfo = getFrontEndInfo() diff --git a/npm/src/upload/form/upload-form.ts b/npm/src/upload/form/upload-form.ts index 2f91fb909..8ff113e00 100644 --- a/npm/src/upload/form/upload-form.ts +++ b/npm/src/upload/form/upload-form.ts @@ -213,7 +213,8 @@ export class UploadForm { ) => { ev.preventDefault() const itemSelected: IEntryWithPath = this.selectedFiles[0] - + console.error("hello") + debugger; if (itemSelected) { this.formElement.addEventListener("submit", (ev) => ev.preventDefault()) // adding new event listener, in order to prevent default submit button behaviour this.disableSubmitButtonAndDropzone() @@ -251,6 +252,12 @@ export class UploadForm { }) } + addASubmitListener() { + this.formElement.addEventListener("submit", this.handleFormSubmission, { + once: false + }) + } + readonly warningMessages: { [s: string]: HTMLElement | null } = { diff --git a/npm/src/upload/index.ts b/npm/src/upload/index.ts index 7b187aa23..6e1f4f55c 100644 --- a/npm/src/upload/index.ts +++ b/npm/src/upload/index.ts @@ -10,6 +10,7 @@ import { S3ClientConfig } from "@aws-sdk/client-s3/dist-types/S3Client" import { TdrFetchHandler } from "../s3upload/tdr-fetch-handler" import { S3Client } from "@aws-sdk/client-s3" import { IEntryWithPath } from "./form/get-files-from-drag-event" +import {UploadSingleItemForm} from "./singleitemform/upload-form"; export interface IKeycloakInstance extends KeycloakInstance { tokenParsed: IKeycloakTokenParsed @@ -117,7 +118,7 @@ export class FileUploader { document.querySelector("#file-upload-form") const itemRetriever: HTMLInputElement | null = - document.querySelector("#file-selection") + document.querySelector("#metadata-file-selection") const dropzone: HTMLElement | null = document.querySelector( ".drag-and-drop__dropzone" @@ -138,4 +139,30 @@ export class FileUploader { form.addRemoveSelectedItemListener() } } + + initialiseMetadataFormListeners(): void { + + const uploadForm: HTMLFormElement | null = + document.querySelector("#metadata-upload-form") + + const itemRetriever: HTMLInputElement | null = + document.querySelector("#metadata-file-selection") + + // const dropzone: HTMLElement | null = document.querySelector( + // ".drag-and-drop__dropzone" + // ) + + if (uploadForm && itemRetriever) { + const form = new UploadSingleItemForm( + uploadForm, + itemRetriever, + this.uploadFiles + ) + // form.addFolderListener() + form.addASubmitListener() + // form.addButtonHighlighter() + // form.addDropzoneHighlighter() + // form.addRemoveSelectedItemListener() + } + } } From aa9682223d03f982f26165d28d041bff3381b1ba Mon Sep 17 00:00:00 2001 From: ian-hoyle Date: Thu, 29 Feb 2024 07:58:44 +0000 Subject: [PATCH 07/75] more trying --- .../draftMetadataUpload.scala.html | 38 +++++++++++++------ npm/src/upload/index.ts | 27 +------------ 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/app/views/draftmetadata/draftMetadataUpload.scala.html b/app/views/draftmetadata/draftMetadataUpload.scala.html index ab6cce89b..0d4597826 100644 --- a/app/views/draftmetadata/draftMetadataUpload.scala.html +++ b/app/views/draftmetadata/draftMetadataUpload.scala.html @@ -6,27 +6,43 @@ @(consignmentId: UUID, consignmentRef: String, frontEndInfo: FrontEndInfo, name: String)(implicit request: RequestHeader, messages: Messages) @main("[WIP] Draft Metadata Upload", name = name, backLink = Some(backLink(routes.HomepageController.homepage().url, "How would you like to enter metadata?"))) { -
+

Upload a CSV with record metadata

-

Upload a metadata CSV with a row for every record in your consignment.

-

The CSV must contain specific populated columns for a successful upload.

-

-

For more inforamtion on the CSV structure and content, visit the metadata guidance page.

-
- @transferReference(consignmentRef, isJudgmentUser = false) +
+

Upload a metadata CSV with a row for every record in your consignment.

+

The CSV must contain specific populated columns for a successful upload.

+

For more information on the CSV structure and content, visit the metadata guidance page.

+
-
- -
+ @loggedOutErrorMessage("file-upload") + + + + +
+ + +
+ - +
+
+ + @transferReference(consignmentRef, isJudgmentUser = false) + } diff --git a/npm/src/upload/index.ts b/npm/src/upload/index.ts index 6e1f4f55c..6f07749dd 100644 --- a/npm/src/upload/index.ts +++ b/npm/src/upload/index.ts @@ -10,7 +10,7 @@ import { S3ClientConfig } from "@aws-sdk/client-s3/dist-types/S3Client" import { TdrFetchHandler } from "../s3upload/tdr-fetch-handler" import { S3Client } from "@aws-sdk/client-s3" import { IEntryWithPath } from "./form/get-files-from-drag-event" -import {UploadSingleItemForm} from "./singleitemform/upload-form"; + export interface IKeycloakInstance extends KeycloakInstance { tokenParsed: IKeycloakTokenParsed @@ -140,29 +140,4 @@ export class FileUploader { } } - initialiseMetadataFormListeners(): void { - - const uploadForm: HTMLFormElement | null = - document.querySelector("#metadata-upload-form") - - const itemRetriever: HTMLInputElement | null = - document.querySelector("#metadata-file-selection") - - // const dropzone: HTMLElement | null = document.querySelector( - // ".drag-and-drop__dropzone" - // ) - - if (uploadForm && itemRetriever) { - const form = new UploadSingleItemForm( - uploadForm, - itemRetriever, - this.uploadFiles - ) - // form.addFolderListener() - form.addASubmitListener() - // form.addButtonHighlighter() - // form.addDropzoneHighlighter() - // form.addRemoveSelectedItemListener() - } - } } From bde2b7c987b41028fa8732735d19ecefb2e35d15 Mon Sep 17 00:00:00 2001 From: ian-hoyle Date: Tue, 5 Mar 2024 17:12:53 +0000 Subject: [PATCH 08/75] messing around --- app/controllers/UploadController.scala | 14 +- .../draftMetadataUpload.scala.html | 54 +++-- conf/routes | 1 + npm/src/auth/index.ts | 3 +- npm/src/draftmetadatafileupload/index.ts | 35 ++++ npm/src/index.ts | 25 ++- .../upload/form/draft-metadata-upload-form.ts | 184 ++++++++++++++++++ npm/src/upload/index.ts | 38 +++- 8 files changed, 318 insertions(+), 36 deletions(-) create mode 100644 npm/src/draftmetadatafileupload/index.ts create mode 100644 npm/src/upload/form/draft-metadata-upload-form.ts diff --git a/app/controllers/UploadController.scala b/app/controllers/UploadController.scala index 4427c7bb4..d8fe045a2 100644 --- a/app/controllers/UploadController.scala +++ b/app/controllers/UploadController.scala @@ -1,5 +1,6 @@ package controllers +import akka.util.ByteString import auth.TokenSecurity import configuration.{ApplicationConfig, GraphQLConfiguration, KeycloakConfiguration} import graphql.codegen.types.{AddFileAndMetadataInput, AddMultipleFileStatusesInput, StartUploadInput} @@ -7,7 +8,7 @@ import io.circe.parser.decode import io.circe.syntax._ import org.pac4j.play.scala.SecurityComponents import play.api.i18n.I18nSupport -import play.api.mvc.{Action, AnyContent, Request} +import play.api.mvc.{Action, AnyContent, Request, ResponseHeader} import services.Statuses._ import services._ import viewsapi.Caching.preventCaching @@ -39,6 +40,17 @@ class UploadController @Inject() ( } } + def saveDraftMetadata(consignmentId: java.util.UUID): Action[AnyContent] = secureAction.async { implicit request => + println("OKay Okay") + Future(Ok("yes")) + // request.body.asJson.flatMap(body => { +// decode[StartUploadInput](body.toString).toOption +// }) match { +// case None => Future.failed(new Exception(s"Incorrect data provided ${request.body}")) +// case Some(input) => uploadService.startUpload(input, request.token.bearerAccessToken).map(Ok(_)) +// } + } + def saveClientMetadata(): Action[AnyContent] = secureAction.async { implicit request => request.body.asJson.flatMap(body => { decode[AddFileAndMetadataInput](body.toString()).toOption diff --git a/app/views/draftmetadata/draftMetadataUpload.scala.html b/app/views/draftmetadata/draftMetadataUpload.scala.html index 0d4597826..17ebc0f84 100644 --- a/app/views/draftmetadata/draftMetadataUpload.scala.html +++ b/app/views/draftmetadata/draftMetadataUpload.scala.html @@ -6,41 +6,37 @@ @(consignmentId: UUID, consignmentRef: String, frontEndInfo: FrontEndInfo, name: String)(implicit request: RequestHeader, messages: Messages) @main("[WIP] Draft Metadata Upload", name = name, backLink = Some(backLink(routes.HomepageController.homepage().url, "How would you like to enter metadata?"))) { -
+