From 14054decf881422f710af65090842e772f10d6ae Mon Sep 17 00:00:00 2001
From: Jordan Rowe <37838443+jordanrowe@users.noreply.github.com>
Date: Wed, 22 May 2024 16:01:01 +0100
Subject: [PATCH] BDOG-3023 remove isAssistedDigital feature flag in config
(#525)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* BDOG-3023 remove isAssistedDigital feature flag in config
* BDOG-3023 add test only filter to simulate admin proxy routing
* BDOG-3023 update KeepAliveController and views to derive isAssistedDigital flag
* BDOG-3023 remove unused SessionExpiredView
* BDOG-3023 run formatter and update README
* fix A11y tests
* remove comment
* BDOG-3023 address lookup frontend callback url logic
* add flag to test only page
* fix error template styling
* fix tests
---------
Co-authored-by: “Taiwo-AB” <63714619+Taiwo-AB@users.noreply.github.com>
Co-authored-by: mywyau <47248104+mywyau@users.noreply.github.com>
---
README.md | 13 ++-
a11y/FrontendAccessibilitySpec.scala | 55 +++++++----
.../auth/AuthRequest.scala | 6 +-
.../auth/StrideAuthAction.scala | 47 ++++++----
.../config/AppConfig.scala | 20 ++--
.../AddressLookupFrontendConnector.scala | 9 +-
.../CannotAccessPageController.scala | 6 +-
.../CheckYourAnswersAmendHandler.scala | 2 +-
.../CheckYourAnswersController.scala | 8 +-
.../CheckYourAnswersNewHandler.scala | 2 +-
.../DeclarationConfirmationController.scala | 38 +++++---
.../controllers/DeclarationGoodsRequest.scala | 2 +
.../DeclarationJourneyActionProvider.scala | 23 ++---
.../DeclarationJourneyRequest.scala | 1 +
.../EnterAgentAddressController.scala | 2 +-
.../controllers/EnterEmailController.scala | 4 +-
.../GoodsDestinationController.scala | 14 ++-
.../GoodsOverThresholdController.scala | 2 -
.../controllers/GoodsRemovedController.scala | 2 +-
.../ImportExportChoiceController.scala | 9 +-
.../controllers/KeepAliveController.scala | 18 +++-
.../controllers/Navigator.scala | 91 ++++++++++---------
...PreviousDeclarationDetailsController.scala | 9 +-
.../controllers/StartController.scala | 2 +-
.../testonly/TestOnlyController.scala | 30 ++++--
.../filters/AdminJourneyFilter.scala | 45 +++++++++
.../forms/EnterEmailForm.scala | 3 +-
.../model/api/Amendment.scala | 4 +-
.../model/api/Declaration.scala | 4 +-
.../model/api/JourneySourceFinder.scala | 25 -----
.../model/core/DeclarationJourney.scala | 41 +++++----
.../navigation/NavigationRequest.scala | 6 +-
.../views/AgentDetailsView.scala.html | 5 +-
.../views/CannotAccessPageView.scala.html | 11 ++-
.../CannotUseServiceIrelandView.scala.html | 5 +-
.../views/CannotUseServiceView.scala.html | 5 +-
...CheckYourAnswersAmendExportView.scala.html | 7 +-
...CheckYourAnswersAmendImportView.scala.html | 7 +-
.../CheckYourAnswersExportView.scala.html | 7 +-
.../CheckYourAnswersImportView.scala.html | 9 +-
.../views/CustomsAgentView.scala.html | 5 +-
.../DeclarationConfirmationView.scala.html | 13 ++-
.../views/DeclarationNotFoundView.scala.html | 9 +-
.../views/EnterEmailView.scala.html | 7 +-
.../views/EnterOptionalEmailView.scala.html | 7 +-
.../views/EoriNumberView.scala.html | 6 +-
.../views/ErrorTemplate.scala.html | 4 +-
.../ExciseAndRestrictedGoodsView.scala.html | 5 +-
.../views/GoodsDestinationView.scala.html | 5 +-
.../views/GoodsInVehicleView.scala.html | 5 +-
.../views/GoodsOriginView.scala.html | 5 +-
.../views/GoodsOverThresholdView.scala.html | 7 +-
.../views/GoodsRemovedView.scala.html | 5 +-
.../views/GoodsTypeView.scala.html | 5 +-
.../views/GoodsVatRateView.scala.html | 5 +-
.../views/ImportExportChoice.scala.html | 7 +-
.../views/JourneyDetailsPage.scala.html | 6 +-
.../views/Layout.scala.html | 9 +-
.../views/NewOrExistingView.scala.html | 5 +-
.../views/NoDeclarationNeededView.scala.html | 5 +-
.../views/PaymentCalculationView.scala.html | 6 +-
.../PreviousDeclarationDetailsView.scala.html | 6 +-
.../views/ProgressDeletedView.scala.html | 13 +--
.../PurchaseDetailsExportView.scala.html | 6 +-
.../PurchaseDetailsImportView.scala.html | 6 +-
.../views/RemoveGoodsView.scala.html | 5 +-
.../views/RetrieveDeclarationView.scala.html | 6 +-
.../views/ReviewGoodsView.scala.html | 7 +-
.../views/SearchGoodsCountryView.scala.html | 11 +--
.../views/ServiceTimeoutView.scala.html | 14 +--
.../views/SessionExpiredView.scala.html | 48 ----------
.../TestOnlyDeclarationJourneyPage.scala.html | 4 +-
.../views/TravellerDetailsPage.scala.html | 5 +-
.../views/ValueWeightOfGoodsView.scala.html | 5 +-
.../VehicleRegistrationNumberView.scala.html | 5 +-
.../views/VehicleSizeView.scala.html | 5 +-
.../views/ViewUtils.scala | 12 ++-
.../views/layouts/govukLayout.scala.html | 21 +++--
conf/application.conf | 7 +-
conf/prod.routes | 1 -
run-locally.sh | 2 +-
.../merchandiseinbaggage/CoreTestData.scala | 18 ++--
.../auth/StrideAuthActionSpec.scala | 63 +++++++++++++
.../config/AppConfigSpec.scala | 4 +-
.../AddressLookupFrontendConnectorSpec.scala | 3 +-
.../AgentDetailsControllerSpec.scala | 20 +++-
.../CannotAccessPageControllerSpec.scala | 6 +-
.../CannotUseServiceControllerSpec.scala | 3 +-
...annotUseServiceIrelandControllerSpec.scala | 3 +-
.../CheckYourAnswersAmendHandlerSpec.scala | 3 +-
.../CheckYourAnswersControllerSpec.scala | 34 ++++---
.../CheckYourAnswersNewHandlerSpec.scala | 6 +-
.../CustomsAgentControllerSpec.scala | 21 ++++-
...eclarationConfirmationControllerSpec.scala | 4 +-
...DeclarationJourneyActionProviderSpec.scala | 63 -------------
.../DeclarationJourneyControllerSpec.scala | 59 ++++++++++--
.../EnterEmailControllerSpec.scala | 22 +++--
.../EoriNumberControllerSpec.scala | 18 +++-
...ciseAndRestrictedGoodsControllerSpec.scala | 22 +++--
.../GoodsDestinationControllerSpec.scala | 22 +++--
.../GoodsInVehicleControllerSpec.scala | 27 ++++--
.../GoodsOriginControllerSpec.scala | 20 +++-
.../GoodsOverThresholdControllerSpec.scala | 7 +-
.../GoodsRemovedControllerSpec.scala | 4 +-
.../controllers/GoodsTypeControllerSpec.scala | 26 ++++--
.../GoodsVatRateControllerSpec.scala | 21 ++++-
.../ImportExportChoiceControllerSpec.scala | 33 +++++--
.../JourneyDetailsControllerSpec.scala | 31 +++++--
.../controllers/KeepAliveControllerSpec.scala | 5 +-
.../controllers/NavigatorSpec.scala | 9 +-
.../NewOrExistingControllerSpec.scala | 31 +++++--
.../NoDeclarationNeededControllerSpec.scala | 5 +-
.../PaymentCalculationControllerSpec.scala | 6 +-
...iousDeclarationDetailsControllerSpec.scala | 16 +++-
.../PurchaseDetailsControllerSpec.scala | 21 ++++-
.../RemoveGoodsControllerSpec.scala | 9 +-
.../RetrieveDeclarationControllerSpec.scala | 34 +++++--
.../ReviewGoodsControllerSpec.scala | 42 ++++++---
.../SearchGoodsCountryControllerSpec.scala | 21 ++++-
.../StartExportControllerSpec.scala | 4 +-
.../StartImportControllerSpec.scala | 4 +-
.../TravellerDetailsControllerSpec.scala | 23 +++--
.../ValueWeightOfGoodsControllerSpec.scala | 23 +++--
...icleRegistrationNumberControllerSpec.scala | 23 +++--
.../VehicleSizeControllerSpec.scala | 28 ++++--
.../model/api/AmendmentSpec.scala | 42 ---------
.../model/api/JourneySourceFinderSpec.scala | 32 -------
.../model/core/DeclarationJourneySpec.scala | 2 +-
.../model/core/DeclarationSpec.scala | 28 +-----
.../scheduler/ScheduledJobSpec.scala | 6 +-
.../utils/ObfuscateSpec.scala | 1 +
.../view/ViewUtilsSpec.scala | 14 +--
132 files changed, 1130 insertions(+), 781 deletions(-)
create mode 100644 app/uk/gov/hmrc/merchandiseinbaggage/filters/AdminJourneyFilter.scala
delete mode 100644 app/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinder.scala
delete mode 100644 app/uk/gov/hmrc/merchandiseinbaggage/views/SessionExpiredView.scala.html
create mode 100644 test/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthActionSpec.scala
delete mode 100644 test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProviderSpec.scala
delete mode 100644 test/uk/gov/hmrc/merchandiseinbaggage/model/api/AmendmentSpec.scala
delete mode 100644 test/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinderSpec.scala
diff --git a/README.md b/README.md
index 9d39e793b..4f9e69760 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Business travellers carrying commercial goods for both import or export.
## How to start the service locally
-`sbt run` This will only start the service as standalone but unable to interact with any other services including Backend and DataBase
+`sbt run` This will only start the service as standalone but unable to interact with any other services including Backend and Database
To load all related services:
@@ -57,6 +57,17 @@ To run the tests locally, simply run:
sbt clean A11y/test
```
+## How to enable 'Admin Mode'
+
+This service is built to accept traffic from the `admin.tax.service.gov.uk` domain as well for assisted digital journeys.
+The service can detect where the traffic has come from by inspecting the `x-forwarded-host` header, this is done in
+`auth/StrideAuthAction.scala` - this will change some content on some of the pages and also alters the payment journey.
+
+When testing locally, you can enable a filter which will add a header to each request to simulate it coming from the admin domain.
+
+This can be done by updating the `adminJourneyFilter.enabled` flag in application.conf to be `true` or alternatively passing it in as
+a system property e.g. `sbt run -DadminJourneyFilter.enabled=true`
+
## License
This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").
diff --git a/a11y/FrontendAccessibilitySpec.scala b/a11y/FrontendAccessibilitySpec.scala
index 36f76882d..3229e07d7 100644
--- a/a11y/FrontendAccessibilitySpec.scala
+++ b/a11y/FrontendAccessibilitySpec.scala
@@ -18,7 +18,9 @@ import org.scalacheck.Arbitrary
import play.api.data.Form
import play.api.data.Forms._
import play.twirl.api.Html
+import uk.gov.hmrc.merchandiseinbaggage.auth.AuthRequest
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
+import uk.gov.hmrc.merchandiseinbaggage.controllers.{DeclarationGoodsRequest, DeclarationJourneyRequest}
import uk.gov.hmrc.merchandiseinbaggage.forms._
import uk.gov.hmrc.merchandiseinbaggage.model.api._
import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation.CalculationResults
@@ -34,27 +36,43 @@ class FrontendAccessibilitySpec extends AutomaticAccessibilitySpec {
private val optionEmailForm: Form[Option[Email]] = EnterEmailForm.optionalForm
private val booleanForm: Form[Boolean] = Form("value" -> boolean)
private val stringForm: Form[String] = Form("value" -> text)
+ private val authRequest = AuthRequest(
+ request = fakeRequest,
+ credentials = None,
+ isAssistedDigital = false
+ )
+ private val declarationJourneyRequest = new DeclarationJourneyRequest(
+ declarationJourney = completedDeclarationJourney,
+ request = authRequest
+ )
+ private val declarationGoodsRequest = new DeclarationGoodsRequest(
+ declarationJourneyRequest = declarationJourneyRequest,
+ goodsEntry = completedImportGoods
+ )
- implicit val arbHtml: Arbitrary[Html] = fixed(Html(""))
- implicit val arbForm: Arbitrary[Form[_]] = fixed(booleanForm)
- implicit val arbString: Arbitrary[String] = fixed("http://something")
- implicit val arbFormString: Arbitrary[Form[String]] = fixed(stringForm)
- implicit val arbAppConfig: Arbitrary[AppConfig] = fixed(appConfig)
- implicit val arbEnterEmailForm: Arbitrary[Form[Email]] = fixed(emailForm)
- implicit val arbEnterOptionEmailForm: Arbitrary[Form[Option[Email]]] = fixed(optionEmailForm)
- implicit val arbDeclarationType: Arbitrary[DeclarationType] = fixed(DeclarationType.Import)
- implicit val arbGoodsDestination: Arbitrary[GoodsDestination] = fixed(GoodsDestinations.GreatBritain)
- implicit val arbDeclaration: Arbitrary[Declaration] = fixed(declaration)
- implicit val arbJourneyType: Arbitrary[JourneyType] = fixed(JourneyTypes.New)
- implicit val arbCheckYourAnswersImport: Arbitrary[CalculationResults] = fixed(aCalculationResultsWithNoTax)
- implicit val arbCheckYourAnswersAmendExport: Arbitrary[Amendment] = fixed(aAmendment)
- implicit val arbCheckYourAnswersExport: Arbitrary[YesNo] = fixed(YesNo.Yes)
- implicit val arbJourneyDetailsEntry: Arbitrary[Form[JourneyDetailsEntry]] = fixed(
+ implicit val arbHtml: Arbitrary[Html] = fixed(Html(""))
+ implicit val arbForm: Arbitrary[Form[_]] = fixed(booleanForm)
+ implicit val arbString: Arbitrary[String] = fixed("http://something")
+ implicit val arbFormString: Arbitrary[Form[String]] = fixed(stringForm)
+ implicit val arbAppConfig: Arbitrary[AppConfig] = fixed(appConfig)
+ implicit val arbEnterEmailForm: Arbitrary[Form[Email]] = fixed(emailForm)
+ implicit val arbEnterOptionEmailForm: Arbitrary[Form[Option[Email]]] = fixed(optionEmailForm)
+ implicit val arbDeclarationType: Arbitrary[DeclarationType] = fixed(DeclarationType.Import)
+ implicit val arbGoodsDestination: Arbitrary[GoodsDestination] = fixed(GoodsDestinations.GreatBritain)
+ implicit val arbDeclaration: Arbitrary[Declaration] = fixed(declaration)
+ implicit val arbJourneyType: Arbitrary[JourneyType] = fixed(JourneyTypes.New)
+ implicit val arbCheckYourAnswersImport: Arbitrary[CalculationResults] = fixed(aCalculationResultsWithNoTax)
+ implicit val arbCheckYourAnswersAmendExport: Arbitrary[Amendment] = fixed(aAmendment)
+ implicit val arbCheckYourAnswersExport: Arbitrary[YesNo] = fixed(YesNo.Yes)
+ implicit val arbJourneyDetailsEntry: Arbitrary[Form[JourneyDetailsEntry]] = fixed(
JourneyDetailsForm.form(DeclarationType.Import, journeyDate)
)
- implicit val arbPreviousDeclarationDetails: Arbitrary[ThresholdAllowance] = fixed(aThresholdAllowance)
- implicit val arbPurchaseDetailsExport: Arbitrary[Form[PurchaseDetailsInput]] = fixed(PurchaseDetailsForm.form)
- implicit val arbTravellerDetails: Arbitrary[Form[Name]] = fixed(TravellerDetailsForm.form)
+ implicit val arbPreviousDeclarationDetails: Arbitrary[ThresholdAllowance] = fixed(aThresholdAllowance)
+ implicit val arbPurchaseDetailsExport: Arbitrary[Form[PurchaseDetailsInput]] = fixed(PurchaseDetailsForm.form)
+ implicit val arbTravellerDetails: Arbitrary[Form[Name]] = fixed(TravellerDetailsForm.form)
+ implicit val arbAuthRequest: Arbitrary[AuthRequest[_]] = fixed(authRequest)
+ implicit val arbDeclarationJourneyRequest: Arbitrary[DeclarationJourneyRequest[_]] = fixed(declarationJourneyRequest)
+ implicit val arbDeclarationGoodsRequest: Arbitrary[DeclarationGoodsRequest[_]] = fixed(declarationGoodsRequest)
val viewPackageName = "uk.gov.hmrc.merchandiseinbaggage.views.html"
@@ -98,7 +116,6 @@ class FrontendAccessibilitySpec extends AutomaticAccessibilitySpec {
case reviewGoodsView: ReviewGoodsView => render(reviewGoodsView)
case searchGoodsCountryView: SearchGoodsCountryView => render(searchGoodsCountryView)
case serviceTimeoutView: ServiceTimeoutView => render(serviceTimeoutView)
- case sessionExpiredView: SessionExpiredView => render(sessionExpiredView)
case testOnlyDeclarationJourneyPage: TestOnlyDeclarationJourneyPage => render(testOnlyDeclarationJourneyPage)
case travellerDetailsPage: TravellerDetailsPage => render(travellerDetailsPage)
case valueWeightOfGoodsView: ValueWeightOfGoodsView => render(valueWeightOfGoodsView)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/auth/AuthRequest.scala b/app/uk/gov/hmrc/merchandiseinbaggage/auth/AuthRequest.scala
index 9cedcc1b6..b87233c5d 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/auth/AuthRequest.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/auth/AuthRequest.scala
@@ -19,4 +19,8 @@ package uk.gov.hmrc.merchandiseinbaggage.auth
import play.api.mvc.{Request, WrappedRequest}
import uk.gov.hmrc.auth.core.retrieve.Credentials
-case class AuthRequest[A](request: Request[A], credentials: Option[Credentials]) extends WrappedRequest[A](request)
+case class AuthRequest[A](
+ request: Request[A],
+ credentials: Option[Credentials],
+ isAssistedDigital: Boolean
+) extends WrappedRequest[A](request)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthAction.scala b/app/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthAction.scala
index 5f70922a4..7f1729baa 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthAction.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthAction.scala
@@ -59,23 +59,38 @@ class StrideAuthAction @Inject() (
toStrideLogin(uri)
}
- authorised(AuthProviders(PrivilegedApplication))
- .retrieve(credentials and allEnrolments) { case creds ~ enrolments =>
- if (hasRequiredRoles(enrolments)) {
- block(AuthRequest(request, creds))
- } else {
- Future successful Unauthorized("Insufficient Roles")
+ // This service handles traffic from the public internet as well as the stride domain.
+ // Traffic from the stride domain can be identified by the x-forwarded-host header.
+ // In the case that it's not from the stride domain, we don't need stride auth, instead
+ // we invoke the block with an AuthRequest with no credentials and the isAssistedDigital
+ // flag set to false
+
+ val isFromAdminDomain: Boolean =
+ request.headers
+ .get("x-forwarded-host")
+ .exists(host => host.startsWith("admin") || host.startsWith("test-admin"))
+
+ if (!isFromAdminDomain) {
+ block(AuthRequest(request, credentials = None, isAssistedDigital = false))
+ } else {
+ authorised(AuthProviders(PrivilegedApplication))
+ .retrieve(credentials and allEnrolments) { case creds ~ enrolments =>
+ if (hasRequiredRoles(enrolments)) {
+ block(AuthRequest(request, creds, isAssistedDigital = true))
+ } else {
+ Future successful Unauthorized("Insufficient Roles")
+ }
}
- }
- .recover {
- case e: NoActiveSession =>
- redirectToStrideLogin(e.getMessage)
- case e: InternalError =>
- redirectToStrideLogin(e.getMessage)
- case e: AuthorisationException =>
- logger.warn(s"User is forbidden because of ${e.reason}, $e")
- Forbidden
- }
+ .recover {
+ case e: NoActiveSession =>
+ redirectToStrideLogin(e.getMessage)
+ case e: InternalError =>
+ redirectToStrideLogin(e.getMessage)
+ case e: AuthorisationException =>
+ logger.warn(s"User is forbidden because of ${e.reason}, $e")
+ Forbidden
+ }
+ }
}
private def hasRequiredRoles(enrolments: Enrolments): Boolean = {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/config/AppConfig.scala b/app/uk/gov/hmrc/merchandiseinbaggage/config/AppConfig.scala
index 567991392..63f6e3b8a 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/config/AppConfig.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/config/AppConfig.scala
@@ -17,7 +17,6 @@
package uk.gov.hmrc.merchandiseinbaggage.config
import com.google.inject.Inject
-import com.typesafe.config.ConfigFactory
import play.api.{Configuration, Environment}
import uk.gov.hmrc.merchandiseinbaggage.model.api.tpspayments.TpsNavigation
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig
@@ -25,8 +24,11 @@ import uk.gov.hmrc.play.bootstrap.config.ServicesConfig
import javax.inject.Singleton
@Singleton
-class AppConfig @Inject() (val config: Configuration, val env: Environment, servicesConfig: ServicesConfig)()
- extends IsAssistedDigitalConfiguration {
+class AppConfig @Inject() (
+ val config: Configuration,
+ val env: Environment,
+ servicesConfig: ServicesConfig
+) {
private val serviceIdentifier = "mib"
@@ -62,11 +64,11 @@ class AppConfig @Inject() (val config: Configuration, val env: Environment, serv
lazy val tpsPaymentsBackendUrl: String = servicesConfig.baseUrl("tps-payments-backend")
lazy val merchandiseInBaggageUrl: String = servicesConfig.baseUrl("merchandise-in-baggage")
lazy val addressLookupFrontendUrl: String = servicesConfig.baseUrl("address-lookup-frontend")
- lazy val addressLookupCallbackUrl: String =
- config.get[String]("microservice.services.address-lookup-frontend.callback")
-}
-trait IsAssistedDigitalConfiguration {
- // to avoid re writing the codebase, need to improve in the future to allow injection
- lazy val isAssistedDigital: Boolean = ConfigFactory.load().getBoolean("assistedDigital")
+ def addressLookupCallbackUrl(isAssistedDigital: Boolean): String =
+ if (isAssistedDigital) {
+ config.get[String]("microservice.services.address-lookup-frontend.adminCallback")
+ } else {
+ config.get[String]("microservice.services.address-lookup-frontend.callback")
+ }
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnector.scala b/app/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnector.scala
index 1178c53d8..7e9577ae9 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnector.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnector.scala
@@ -31,13 +31,16 @@ import scala.concurrent.{ExecutionContext, Future}
@Singleton
class AddressLookupFrontendConnector @Inject() (appConfig: AppConfig, http: HttpClient) {
- private val baseUrl = appConfig.addressLookupFrontendUrl
- private val callback = appConfig.addressLookupCallbackUrl
+ private val baseUrl = appConfig.addressLookupFrontendUrl
private lazy val initJourneyUrl = s"$baseUrl/api/v2/init"
private def confirmJourneyUrl(id: String) = s"$baseUrl/api/confirmed?id=$id"
- def initJourney(call: Call)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[String] = {
+ def initJourney(call: Call, isAssistedDigital: Boolean)(implicit
+ hc: HeaderCarrier,
+ ec: ExecutionContext
+ ): Future[String] = {
+ val callback = appConfig.addressLookupCallbackUrl(isAssistedDigital)
val addressConfig = Json.toJson(configAddressLookup(s"$callback${call.url}"))
http.POST[JsValue, HttpResponse](initJourneyUrl, addressConfig) map { response =>
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageController.scala
index 81a329f3a..ab43d4c7e 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageController.scala
@@ -20,18 +20,18 @@ import javax.inject.{Inject, Singleton}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
import uk.gov.hmrc.merchandiseinbaggage.views.html.CannotAccessPageView
-import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import scala.concurrent.ExecutionContext
@Singleton
class CannotAccessPageController @Inject() (
override val controllerComponents: MessagesControllerComponents,
+ actionProvider: DeclarationJourneyActionProvider,
view: CannotAccessPageView
)(implicit val ec: ExecutionContext, appConfig: AppConfig)
- extends FrontendBaseController {
+ extends DeclarationJourneyController {
- def onPageLoad(): Action[AnyContent] = Action { implicit request =>
+ val onPageLoad: Action[AnyContent] = actionProvider.journeyAction { implicit request =>
Ok(view())
}
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandler.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandler.scala
index b5006e26b..1998c87d7 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandler.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandler.scala
@@ -50,7 +50,7 @@ class CheckYourAnswersAmendHandler @Inject() (
def onPageLoad(declarationJourney: DeclarationJourney, amendment: Amendment, isAgent: YesNo)(implicit
hc: HeaderCarrier,
- request: Request[_],
+ request: DeclarationJourneyRequest[_],
messages: Messages
): Future[Result] =
(for {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersController.scala
index dc3aa6a58..c93ad62c5 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersController.scala
@@ -18,7 +18,6 @@ package uk.gov.hmrc.merchandiseinbaggage.controllers
import javax.inject.{Inject, Singleton}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
-import uk.gov.hmrc.merchandiseinbaggage.config.IsAssistedDigitalConfiguration
import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyController.incompleteMessage
import uk.gov.hmrc.merchandiseinbaggage.model.api.JourneyTypes.{Amend, New}
import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
@@ -36,8 +35,7 @@ class CheckYourAnswersController @Inject() (
amendHandler: CheckYourAnswersAmendHandler,
override val repo: DeclarationJourneyRepository
)(implicit ec: ExecutionContext)
- extends IsAssistedDigitalConfiguration
- with DeclarationJourneyUpdateController {
+ extends DeclarationJourneyUpdateController {
val onPageLoad: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
import request.declarationJourney._
@@ -61,7 +59,7 @@ class CheckYourAnswersController @Inject() (
case New =>
request.declarationJourney.declarationIfRequiredAndComplete
.fold(actionProvider.invalidRequestF(incompleteMessage)) { declaration =>
- if (isAssistedDigital) {
+ if (request.isAssistedDigital) {
newHandler.onSubmitTps(declaration.copy(lang = messages.lang.code))
} else {
newHandler.onSubmit(declaration.copy(lang = messages.lang.code))
@@ -70,7 +68,7 @@ class CheckYourAnswersController @Inject() (
case Amend =>
request.declarationJourney.amendmentIfRequiredAndComplete
.fold(actionProvider.invalidRequestF(incompleteMessage)) { amendment =>
- if (isAssistedDigital) {
+ if (request.isAssistedDigital) {
amendHandler.onSubmitTps(
declarationId = request.declarationJourney.declarationId,
newAmendment = amendment.copy(lang = messages.lang.code)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandler.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandler.scala
index 7dc875806..65a0e4bdb 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandler.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandler.scala
@@ -45,7 +45,7 @@ class CheckYourAnswersNewHandler @Inject() (
def onPageLoad(declaration: Declaration, isAgent: YesNo)(implicit
hc: HeaderCarrier,
- request: Request[_],
+ request: DeclarationJourneyRequest[_],
messages: Messages
): Future[Result] =
mibService.paymentCalculations(declaration.declarationGoods.goods, declaration.goodsDestination).map {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationController.scala
index 596482f57..5ca1e10b4 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationController.scala
@@ -18,7 +18,7 @@ package uk.gov.hmrc.merchandiseinbaggage.controllers
import javax.inject.Inject
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents, Result}
-import uk.gov.hmrc.merchandiseinbaggage.config.{AppConfig, IsAssistedDigitalConfiguration}
+import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
import uk.gov.hmrc.merchandiseinbaggage.connectors.MibConnector
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.{Export, Import}
import uk.gov.hmrc.merchandiseinbaggage.model.api.JourneyTypes.{Amend, New}
@@ -37,55 +37,63 @@ class DeclarationConfirmationController @Inject() (
connector: MibConnector,
val repo: DeclarationJourneyRepository
)(implicit ec: ExecutionContext, appConf: AppConfig)
- extends IsAssistedDigitalConfiguration
- with DeclarationJourneyController {
+ extends DeclarationJourneyController {
val onPageLoad: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
val declarationId = request.declarationJourney.declarationId
val journeyType = request.declarationJourney.journeyType
connector.findDeclaration(declarationId).flatMap {
- case Some(declaration) if canShowConfirmation(declaration, journeyType) =>
+ case Some(declaration) if canShowConfirmation(declaration, journeyType, request.isAssistedDigital) =>
cleanAnswersAndConfirm(journeyType, declaration)
- case Some(_) =>
+ case Some(_) =>
clearAnswers()
.map(_ => actionProvider.invalidRequest("declaration is found in the db, but can't show confirmation"))
- case _ => actionProvider.invalidRequestF(s"declaration not found for id:${declarationId.value}")
+ case _ => actionProvider.invalidRequestF(s"declaration not found for id:${declarationId.value}")
}
}
private def cleanAnswersAndConfirm(journeyType: JourneyType, declaration: Declaration)(implicit
request: DeclarationJourneyRequest[AnyContent]
): Future[Result] =
- if (isAssistedDigital) {
+ if (request.isAssistedDigital) {
for {
_ <- clearAnswers()
res <-
connector.calculatePayments(declaration.latestGoods.map(_.calculationRequest(declaration.goodsDestination)))
- } yield Ok(view(declaration, journeyType, isAssistedDigital, res.results.totalTaxDue))
+ } yield Ok(view(declaration, journeyType, res.results.totalTaxDue))
} else {
- clearAnswers().map(_ => Ok(view(declaration, journeyType, isAssistedDigital, AmountInPence(0))))
+ clearAnswers().map(_ => Ok(view(declaration, journeyType, AmountInPence(0))))
}
val makeAnotherDeclaration: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
import request.declarationJourney._
- repo.upsert(DeclarationJourney(sessionId, declarationType)) map { _ =>
- Redirect(routes.GoodsDestinationController.onPageLoad)
+ repo.upsert(DeclarationJourney(sessionId, declarationType, isAssistedDigital = request.isAssistedDigital)) map {
+ _ =>
+ Redirect(routes.GoodsDestinationController.onPageLoad)
}
}
val addGoodsToAnExistingDeclaration: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
import request.declarationJourney._
- repo.upsert(DeclarationJourney(sessionId, declarationType)) map { _ =>
- Redirect(routes.RetrieveDeclarationController.onPageLoad)
+ repo.upsert(DeclarationJourney(sessionId, declarationType, isAssistedDigital = request.isAssistedDigital)) map {
+ _ =>
+ Redirect(routes.RetrieveDeclarationController.onPageLoad)
}
}
private def clearAnswers()(implicit request: DeclarationJourneyRequest[AnyContent]): Future[DeclarationJourney] = {
import request.declarationJourney._
- repo.upsert(DeclarationJourney(sessionId, declarationType).copy(declarationId = declarationId))
+ repo.upsert(
+ DeclarationJourney(sessionId, declarationType, isAssistedDigital = request.isAssistedDigital)
+ .copy(declarationId = declarationId)
+ )
}
- private def canShowConfirmation(declaration: Declaration, journeyType: JourneyType): Boolean =
+ private def canShowConfirmation(
+ declaration: Declaration,
+ journeyType: JourneyType,
+ isAssistedDigital: Boolean
+ ): Boolean =
(declaration.declarationType, journeyType, isAssistedDigital) match {
case (Export, _, _) => true
case (Import, New, true) =>
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationGoodsRequest.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationGoodsRequest.scala
index d240edbdd..00866a890 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationGoodsRequest.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationGoodsRequest.scala
@@ -27,4 +27,6 @@ final class DeclarationGoodsRequest[A](
val declarationJourney: DeclarationJourney = declarationJourneyRequest.declarationJourney
val declarationType: DeclarationType = declarationJourney.declarationType
+
+ def isAssistedDigital: Boolean = declarationJourneyRequest.isAssistedDigital
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProvider.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProvider.scala
index 723180f3f..86de3f999 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProvider.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProvider.scala
@@ -21,7 +21,6 @@ import play.api.mvc.Results.Redirect
import play.api.mvc._
import uk.gov.hmrc.http.SessionKeys
import uk.gov.hmrc.merchandiseinbaggage.auth.{AuthRequest, StrideAuthAction}
-import uk.gov.hmrc.merchandiseinbaggage.config.IsAssistedDigitalConfiguration
import uk.gov.hmrc.merchandiseinbaggage.model.api.SessionId
import uk.gov.hmrc.merchandiseinbaggage.repositories.DeclarationJourneyRepository
import uk.gov.hmrc.merchandiseinbaggage.utils.DeclarationJourneyLogger
@@ -32,23 +31,15 @@ class DeclarationJourneyActionProvider @Inject() (
defaultActionBuilder: DefaultActionBuilder,
repo: DeclarationJourneyRepository,
strideAuthAction: StrideAuthAction
-)(implicit ec: ExecutionContext)
- extends IsAssistedDigitalConfiguration {
+)(implicit ec: ExecutionContext) {
val initJourneyAction: ActionBuilder[AuthRequest, AnyContent] = defaultActionBuilder andThen strideAuthAction
- private val internalJourneyAction: ActionBuilder[DeclarationJourneyRequest, AnyContent] =
- defaultActionBuilder andThen strideAuthAction andThen journeyActionRefiner
-
val journeyAction: ActionBuilder[DeclarationJourneyRequest, AnyContent] =
- if (isAssistedDigital) {
- internalJourneyAction
- } else {
- defaultActionBuilder andThen journeyActionRefiner
- }
+ defaultActionBuilder andThen strideAuthAction andThen journeyActionRefiner
def goodsAction(idx: Int): ActionBuilder[DeclarationGoodsRequest, AnyContent] =
- defaultActionBuilder andThen journeyActionRefiner andThen goodsActionRefiner(idx)
+ journeyAction andThen goodsActionRefiner(idx)
def invalidRequest(warnMessage: String)(implicit request: RequestHeader): Result = {
DeclarationJourneyLogger.info(s"$warnMessage so redirecting to ${routes.CannotAccessPageController.onPageLoad}")(
@@ -60,16 +51,16 @@ class DeclarationJourneyActionProvider @Inject() (
def invalidRequestF(warningMessage: String)(implicit request: RequestHeader): Future[Result] =
Future.successful(invalidRequest(warningMessage))
- private def journeyActionRefiner: ActionRefiner[Request, DeclarationJourneyRequest] =
- new ActionRefiner[Request, DeclarationJourneyRequest] {
+ private def journeyActionRefiner: ActionRefiner[AuthRequest, DeclarationJourneyRequest] =
+ new ActionRefiner[AuthRequest, DeclarationJourneyRequest] {
- override protected def refine[A](request: Request[A]): Future[Either[Result, DeclarationJourneyRequest[A]]] =
+ override protected def refine[A](request: AuthRequest[A]): Future[Either[Result, DeclarationJourneyRequest[A]]] =
request.session.get(SessionKeys.sessionId) match {
case None => Future successful Left(invalidRequest("Session Id not found")(request))
case Some(sessionId) =>
repo.findBySessionId(SessionId(sessionId)).map {
case Some(declarationJourney) =>
- Right(new DeclarationJourneyRequest(declarationJourney, AuthRequest(request, None)))
+ Right(new DeclarationJourneyRequest(declarationJourney, request))
case _ =>
Left(invalidRequest(s"Persisted declaration journey not found for session: $sessionId")(request))
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyRequest.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyRequest.scala
index 5ff983526..37e4d3944 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyRequest.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyRequest.scala
@@ -25,4 +25,5 @@ final class DeclarationJourneyRequest[A](val declarationJourney: DeclarationJour
extends WrappedRequest[A](request) {
def declarationType: DeclarationType = declarationJourney.declarationType
+ def isAssistedDigital: Boolean = request.isAssistedDigital
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterAgentAddressController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterAgentAddressController.scala
index 2f89851e5..7c6f8b6c3 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterAgentAddressController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterAgentAddressController.scala
@@ -35,7 +35,7 @@ class EnterAgentAddressController @Inject() (
val onPageLoad: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
addressLookupFrontendConnector
- .initJourney(routes.EnterAgentAddressController.returnFromAddressLookup())
+ .initJourney(routes.EnterAgentAddressController.returnFromAddressLookup(), request.isAssistedDigital)
.map(Redirect(_))
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailController.scala
index b7c23c748..6e94ee215 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailController.scala
@@ -43,7 +43,7 @@ class EnterEmailController @Inject() (
val onPageLoad: Action[AnyContent] =
actionProvider.journeyAction { implicit request =>
- if (appConfig.isAssistedDigital) {
+ if (request.isAssistedDigital) {
val preparedForm = optionalForm.fill(request.declarationJourney.maybeEmailAddress)
Ok(viewOptional(preparedForm, request.declarationType, backButtonUrl))
} else {
@@ -53,7 +53,7 @@ class EnterEmailController @Inject() (
}
val onSubmit: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
- if (appConfig.isAssistedDigital) {
+ if (request.isAssistedDigital) {
optionalForm
.bindFromRequest()
.fold(
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationController.scala
index cc47f9516..d0601d6c9 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationController.scala
@@ -16,7 +16,7 @@
package uk.gov.hmrc.merchandiseinbaggage.controllers
-import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
+import play.api.mvc.{Action, AnyContent, Call, MessagesControllerComponents}
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
import uk.gov.hmrc.merchandiseinbaggage.forms.GoodsDestinationForm.form
@@ -37,8 +37,8 @@ class GoodsDestinationController @Inject() (
)(implicit ec: ExecutionContext, appConfig: AppConfig)
extends DeclarationJourneyUpdateController {
- private val backLink =
- if (appConfig.isAssistedDigital) ImportExportChoiceController.onPageLoad else NewOrExistingController.onPageLoad
+ private def backLink(isAssistedDigital: Boolean): Call =
+ if (isAssistedDigital) ImportExportChoiceController.onPageLoad else NewOrExistingController.onPageLoad
val onPageLoad: Action[AnyContent] = actionProvider.journeyAction { implicit request =>
Ok(
@@ -46,7 +46,7 @@ class GoodsDestinationController @Inject() (
request.declarationJourney.maybeGoodsDestination
.fold(form(request.declarationType))(form(request.declarationType).fill),
request.declarationJourney.declarationType,
- backLink
+ backLink(request.isAssistedDigital)
)
)
}
@@ -56,7 +56,11 @@ class GoodsDestinationController @Inject() (
.bindFromRequest()
.fold(
formWithErrors =>
- Future.successful(BadRequest(view(formWithErrors, request.declarationJourney.declarationType, backLink))),
+ Future.successful(
+ BadRequest(
+ view(formWithErrors, request.declarationJourney.declarationType, backLink(request.isAssistedDigital))
+ )
+ ),
value => {
val updated = request.declarationJourney.copy(maybeGoodsDestination = Some(value))
navigator
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdController.scala
index a0e30d214..86dc7f902 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdController.scala
@@ -19,7 +19,6 @@ package uk.gov.hmrc.merchandiseinbaggage.controllers
import javax.inject.{Inject, Singleton}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
-import uk.gov.hmrc.merchandiseinbaggage.connectors.MibConnector
import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyController.{goodsDeclarationIncompleteMessage, goodsDestinationUnansweredMessage}
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.{Export, Import}
import uk.gov.hmrc.merchandiseinbaggage.service.MibService
@@ -33,7 +32,6 @@ class GoodsOverThresholdController @Inject() (
override val controllerComponents: MessagesControllerComponents,
actionProvider: DeclarationJourneyActionProvider,
mibService: MibService,
- mibConnector: MibConnector,
view: GoodsOverThresholdView
)(implicit val appConfig: AppConfig, ec: ExecutionContext)
extends DeclarationJourneyController {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedController.scala
index 79cbf2b28..eff8e57f4 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedController.scala
@@ -32,7 +32,7 @@ class GoodsRemovedController @Inject() (
val onPageLoad: Action[AnyContent] = actionProvider.journeyAction { implicit request =>
val startAgainUrl =
- if (appConfig.isAssistedDigital) {
+ if (request.isAssistedDigital) {
routes.ImportExportChoiceController.onPageLoad.url
} else {
backUrl(request)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceController.scala
index 5de7c975c..c8fc4566e 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceController.scala
@@ -50,7 +50,14 @@ class ImportExportChoiceController @Inject() (
formWithErrors => Future successful BadRequest(view(formWithErrors)),
choice =>
navigator
- .nextPage(ImportExportChoiceRequest(choice, SessionId(request.session(SessionKeys.sessionId)), repo.upsert))
+ .nextPage(
+ ImportExportChoiceRequest(
+ choice,
+ SessionId(request.session(SessionKeys.sessionId)),
+ repo.upsert,
+ request.isAssistedDigital
+ )
+ )
.map { call =>
choice match {
case AddToExisting => Redirect(call).addingToSession("journeyType" -> "amend")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveController.scala
index da649d336..86a1fb0d5 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveController.scala
@@ -16,40 +16,48 @@
package uk.gov.hmrc.merchandiseinbaggage.controllers
+import play.api.i18n.Messages
+
import javax.inject.{Inject, Singleton}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents, Request, Result}
import uk.gov.hmrc.http.SessionKeys
+import uk.gov.hmrc.merchandiseinbaggage.auth.StrideAuthAction
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
import uk.gov.hmrc.merchandiseinbaggage.repositories.DeclarationJourneyRepository
import uk.gov.hmrc.merchandiseinbaggage.views.html.{ProgressDeletedView, ServiceTimeoutView}
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
-import scala.concurrent.ExecutionContext
+import scala.concurrent.{ExecutionContext, Future}
@Singleton
class KeepAliveController @Inject() (
override val controllerComponents: MessagesControllerComponents,
actionProvider: DeclarationJourneyActionProvider,
+ strideAction: StrideAuthAction,
repo: DeclarationJourneyRepository,
progressDeletedView: ProgressDeletedView,
serviceTimeoutView: ServiceTimeoutView
)(implicit ec: ExecutionContext, appConfig: AppConfig)
extends FrontendBaseController {
+ implicit def messages(implicit request: Request[_]): Messages = controllerComponents.messagesApi.preferred(request)
+
val onKeepAlive: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
repo.upsert(request.declarationJourney).map { _ =>
NoContent
}
}
- val onProgressDelete: Action[AnyContent] = Action { implicit request =>
+ // strideAction is only used to determine isAssistedDigital flag for the view
+ val onProgressDelete: Action[AnyContent] = strideAction.async { implicit request =>
removeSession(request)(Ok(progressDeletedView()))
}
- val onServiceTimeout: Action[AnyContent] = Action { implicit request =>
+ // strideAction is only used to determine isAssistedDigital flag for the view
+ val onServiceTimeout: Action[AnyContent] = strideAction.async { implicit request =>
removeSession(request)(Ok(serviceTimeoutView()))
}
- private def removeSession(implicit request: Request[_]): Result => Result = result =>
- result.removingFromSession(SessionKeys.sessionId)
+ private def removeSession(implicit request: Request[_]): Result => Future[Result] = result =>
+ Future.successful(result.removingFromSession(SessionKeys.sessionId))
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/Navigator.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/Navigator.scala
index 7652604a2..775e730b6 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/Navigator.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/Navigator.scala
@@ -35,39 +35,40 @@ class Navigator {
import NavigatorMapping._
def nextPage(request: NavigationRequest)(implicit ec: ExecutionContext): Future[Call] = request match {
- case ImportExportChoiceRequest(choice, sessionId, upsert) => importExportChoice(choice, sessionId, upsert)
- case ReviewGoodsRequest(value, journey, overThresholdCheck, upsert) =>
+ case ImportExportChoiceRequest(choice, sessionId, upsert, isAssistedDigital) =>
+ importExportChoice(choice, sessionId, upsert, isAssistedDigital)
+ case ReviewGoodsRequest(value, journey, overThresholdCheck, upsert) =>
reviewGoods(value, journey, overThresholdCheck, upsert)
- case PurchaseDetailsRequest(input, idx, journey, entries, upsert) =>
+ case PurchaseDetailsRequest(input, idx, journey, entries, upsert) =>
purchaseDetails(input, idx, entries, journey, upsert)
- case RemoveGoodsRequest(idx, journey, value, upsert) => removeGoodOrRedirect(idx, journey, value, upsert)
- case RetrieveDeclarationRequest(declaration, journey, upsert) => retrieveDeclaration(declaration, journey, upsert)
- case VehicleRegistrationNumberRequest(journey, regNumber, upsert) =>
+ case RemoveGoodsRequest(idx, journey, value, upsert) => removeGoodOrRedirect(idx, journey, value, upsert)
+ case RetrieveDeclarationRequest(declaration, journey, upsert) => retrieveDeclaration(declaration, journey, upsert)
+ case VehicleRegistrationNumberRequest(journey, regNumber, upsert) =>
vehicleRegistrationNumber(journey, regNumber, upsert)
- case CustomsAgentRequest(value, journey, upsert, complete) => customsAgent(value, journey, upsert, complete)
- case EnterEmailRequest(journey, upsert, complete) => enterEmail(journey, upsert, complete)
- case EoriNumberRequest(journey, upsert, complete) => enterEori(journey, upsert, complete)
- case ExciseAndRestrictedGoodsRequest(value, journey, upsert, complete) =>
+ case CustomsAgentRequest(value, journey, upsert, complete) => customsAgent(value, journey, upsert, complete)
+ case EnterEmailRequest(journey, upsert, complete) => enterEmail(journey, upsert, complete)
+ case EoriNumberRequest(journey, upsert, complete) => enterEori(journey, upsert, complete)
+ case ExciseAndRestrictedGoodsRequest(value, journey, upsert, complete) =>
exciseAndRestrictedGoods(value, journey, upsert, complete)
- case GoodsDestinationRequest(value, journey, upsert, complete) => goodsDestination(value, journey, upsert, complete)
- case GoodsInVehicleRequest(value, journey, upsert, complete) =>
+ case GoodsDestinationRequest(value, journey, upsert, complete) => goodsDestination(value, journey, upsert, complete)
+ case GoodsInVehicleRequest(value, journey, upsert, complete) =>
goodsInVehicleController(value, journey, upsert, complete)
- case JourneyDetailsRequest(journey, upsert, complete) => journeyDetails(journey, upsert, complete)
- case TravellerDetailsRequest(journey, upsert, complete) => travellerDetails(journey, upsert, complete)
- case ValueWeightOfGoodsRequest(value, idx, journey, upsert, complete) =>
+ case JourneyDetailsRequest(journey, upsert, complete) => journeyDetails(journey, upsert, complete)
+ case TravellerDetailsRequest(journey, upsert, complete) => travellerDetails(journey, upsert, complete)
+ case ValueWeightOfGoodsRequest(value, idx, journey, upsert, complete) =>
valueWeightOfGoods(value, idx, journey, upsert, complete)
- case VehicleSizeRequest(value, journey, upsert, complete) => vehicleSizeController(value, journey, upsert, complete)
- case NewOrExistingRequest(journey, upsert, complete) => newOrExisting(journey, upsert, complete)
- case AgentDetailsRequest(agentName, journey, upsert) => agentDetails(agentName, journey, upsert)
- case PreviousDeclarationDetailsRequest(journey, declaration, upsert) =>
- previousDeclarationDetails(journey, declaration, upsert)
- case GoodsTypeRequest(journey, entries, idx, category, upsert) => goodsType(journey, entries, idx, category, upsert)
- case GoodsOriginRequest(journey, entries, idx, upsert) =>
- persistAndRedirect(journey, entries, idx, GoodsVatRateController.onPageLoad(idx), upsert)
- case GoodsVatRateRequest(journey, entries, idx, upsert) =>
- persistAndRedirect(journey, entries, idx, ReviewGoodsController.onPageLoad, upsert)
- case SearchGoodsCountryRequest(journey, entries, idx, upsert) =>
- persistAndRedirect(journey, entries, idx, ReviewGoodsController.onPageLoad, upsert)
+ case VehicleSizeRequest(value, journey, upsert, complete) => vehicleSizeController(value, journey, upsert, complete)
+ case NewOrExistingRequest(journey, upsert, complete) => newOrExisting(journey, upsert, complete)
+ case AgentDetailsRequest(agentName, journey, upsert) => agentDetails(agentName, journey, upsert)
+ case PreviousDeclarationDetailsRequest(journey, declaration, upsert, isAssistedDigital) =>
+ previousDeclarationDetails(journey, declaration, upsert, isAssistedDigital)
+ case GoodsTypeRequest(journey, entries, idx, category, upsert) => goodsType(journey, entries, idx, category, upsert)
+ case GoodsOriginRequest(journey, entries, idx, upsert) =>
+ persistAndRedirectIndexed(journey, entries, idx, GoodsVatRateController.onPageLoad(idx), upsert)
+ case GoodsVatRateRequest(journey, entries, idx, upsert) =>
+ persistAndRedirectIndexed(journey, entries, idx, ReviewGoodsController.onPageLoad, upsert)
+ case SearchGoodsCountryRequest(journey, entries, idx, upsert) =>
+ persistAndRedirectIndexed(journey, entries, idx, ReviewGoodsController.onPageLoad, upsert)
}
}
@@ -92,10 +93,11 @@ object NavigatorMapping {
def previousDeclarationDetails(
journey: DeclarationJourney,
originalDeclaration: Declaration,
- upsert: DeclarationJourney => Future[DeclarationJourney]
+ upsert: DeclarationJourney => Future[DeclarationJourney],
+ isAssistedDigital: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
val updatedDeclaration =
- DeclarationJourney(journey.sessionId, originalDeclaration.declarationType)
+ DeclarationJourney(journey.sessionId, originalDeclaration.declarationType, isAssistedDigital = isAssistedDigital)
.copy(
declarationId = originalDeclaration.declarationId,
journeyType = Amend,
@@ -112,7 +114,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = value match {
+ val redirectTo: Call = value match {
case Yes => VehicleRegistrationNumberController.onPageLoad
case No => CannotUseServiceController.onPageLoad
}
@@ -125,7 +127,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = value match {
+ val redirectTo: Call = value match {
case Yes => CannotUseServiceController.onPageLoad
case No => ValueWeightOfGoodsController.onPageLoad
}
@@ -139,7 +141,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = value match {
+ val redirectTo: Call = value match {
case No => CannotUseServiceController.onPageLoad
case Yes => GoodsTypeController.onPageLoad(entriesSize)
}
@@ -152,7 +154,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = value match {
+ val redirectTo: Call = value match {
case Yes => AgentDetailsController.onPageLoad
case No => EoriNumberController.onPageLoad
}
@@ -189,7 +191,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = value match {
+ val redirectTo: Call = value match {
case NorthernIreland => CannotUseServiceIrelandController.onPageLoad
case GreatBritain => ExciseAndRestrictedGoodsController.onPageLoad
}
@@ -202,7 +204,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = value match {
+ val redirectTo: Call = value match {
case Yes => VehicleSizeController.onPageLoad
case No => CheckYourAnswersController.onPageLoad
}
@@ -238,7 +240,7 @@ object NavigatorMapping {
upsert: DeclarationJourney => Future[DeclarationJourney],
declarationRequiredAndComplete: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
- val redirectTo = updatedDeclarationJourney.journeyType match {
+ val redirectTo: Call = updatedDeclarationJourney.journeyType match {
case New => GoodsDestinationController.onPageLoad
case Amend => RetrieveDeclarationController.onPageLoad
}
@@ -271,7 +273,7 @@ object NavigatorMapping {
case entry: ExportGoodsEntry => entry.copy(maybeCategory = Some(category))
}
- persistAndRedirect(journey, updatedGoodsEntry, idx, PurchaseDetailsController.onPageLoad(idx), upsert)
+ persistAndRedirectIndexed(journey, updatedGoodsEntry, idx, PurchaseDetailsController.onPageLoad(idx), upsert)
}
def reviewGoods(
@@ -315,7 +317,13 @@ object NavigatorMapping {
.getCurrencyByCode(purchaseDetailsInput.currency)
.fold(Future(CannotAccessPageController.onPageLoad)) { currency =>
val updatedGoodsEntry: GoodsEntry = updateGoodsEntry(purchaseDetailsInput.price, currency, goodsEntry)
- persistAndRedirect(declarationJourney, updatedGoodsEntry, idx, GoodsOriginController.onPageLoad(idx), upsert)
+ persistAndRedirectIndexed(
+ declarationJourney,
+ updatedGoodsEntry,
+ idx,
+ GoodsOriginController.onPageLoad(idx),
+ upsert
+ )
}
private def updateGoodsEntry(amount: String, currency: Currency, goodsEntry: GoodsEntry): GoodsEntry =
@@ -379,7 +387,7 @@ object NavigatorMapping {
case Import => declaration.paymentStatus.contains(Paid) || declaration.paymentStatus.contains(NotRequired)
}
- def persistAndRedirect(
+ def persistAndRedirectIndexed(
declarationJourney: DeclarationJourney,
updatedGoodsEntry: GoodsEntry,
index: Int,
@@ -402,7 +410,8 @@ object NavigatorMapping {
def importExportChoice(
choice: ImportExportChoice,
sessionId: SessionId,
- upsert: DeclarationJourney => Future[DeclarationJourney]
+ upsert: DeclarationJourney => Future[DeclarationJourney],
+ isAssistedDigital: Boolean
)(implicit ec: ExecutionContext): Future[Call] = {
val (declarationType, journeyType) = choice match {
case MakeImport => (Import, New)
@@ -410,7 +419,7 @@ object NavigatorMapping {
case AddToExisting => (Import, Amend) //defaults to Import, will be set correctly in the next page
}
- upsert(DeclarationJourney(sessionId, declarationType, journeyType))
+ upsert(DeclarationJourney(sessionId, declarationType, isAssistedDigital, journeyType))
.map { _ =>
journeyType match {
case New => GoodsDestinationController.onPageLoad
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsController.scala
index dc0400a53..d6ca2afcf 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsController.scala
@@ -60,7 +60,14 @@ class PreviousDeclarationDetailsController @Inject() (
.invalidRequestF(s"declaration not found for id:${request.declarationJourney.declarationId.value}")
) { originalDeclaration =>
navigator
- .nextPage(PreviousDeclarationDetailsRequest(request.declarationJourney, originalDeclaration, repo.upsert))
+ .nextPage(
+ PreviousDeclarationDetailsRequest(
+ request.declarationJourney,
+ originalDeclaration,
+ repo.upsert,
+ request.isAssistedDigital
+ )
+ )
.map(Redirect)
}
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/StartController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/StartController.scala
index 9042fba4a..52f663fd2 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/StartController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/StartController.scala
@@ -32,7 +32,7 @@ trait StartController extends DeclarationJourneyController {
val processRequest: Action[AnyContent] = Action.async { implicit request =>
val sessionId = SessionId(request.session(SessionKeys.sessionId))
- repo.upsert(DeclarationJourney(sessionId, declarationType)).map { _ =>
+ repo.upsert(DeclarationJourney(sessionId, declarationType, isAssistedDigital = false)).map { _ =>
Redirect(routes.NewOrExistingController.onPageLoad)
}
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/testonly/TestOnlyController.scala b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/testonly/TestOnlyController.scala
index d1c2e4c16..9c84e6cc2 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/controllers/testonly/TestOnlyController.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/controllers/testonly/TestOnlyController.scala
@@ -16,47 +16,58 @@
package uk.gov.hmrc.merchandiseinbaggage.controllers.testonly
+import play.api.Logging
import play.api.data.Form
-import play.api.libs.json.{JsError, JsSuccess, Json}
import play.api.libs.json.Json.{prettyPrint, toJson}
-import play.api.mvc.{Action, AnyContent, MessagesControllerComponents, Result}
+import play.api.libs.json.{JsError, JsSuccess, Json}
+import play.api.mvc._
import uk.gov.hmrc.http.SessionKeys.sessionId
import uk.gov.hmrc.merchandiseinbaggage._
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
+import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyActionProvider
import uk.gov.hmrc.merchandiseinbaggage.controllers.testonly.TestOnlyController.sampleDeclarationJourney
import uk.gov.hmrc.merchandiseinbaggage.forms.testonly.DeclarationJourneyFormProvider
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.{Export, Import}
import uk.gov.hmrc.merchandiseinbaggage.model.api.GoodsDestinations.GreatBritain
import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo._
+import uk.gov.hmrc.merchandiseinbaggage.model.api._
import uk.gov.hmrc.merchandiseinbaggage.model.api.addresslookup.{Address, AddressLookupCountry}
-import uk.gov.hmrc.merchandiseinbaggage.model.api.{Currency, PurchaseDetails, _}
import uk.gov.hmrc.merchandiseinbaggage.model.core.{DeclarationJourney, GoodsEntries, ImportGoodsEntry}
import uk.gov.hmrc.merchandiseinbaggage.repositories.DeclarationJourneyRepository
import uk.gov.hmrc.merchandiseinbaggage.views.html.TestOnlyDeclarationJourneyPage
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController
-import java.time.LocalDate.now
+import java.time.LocalDate.now
import javax.inject.Inject
-import play.api.Logging
-
import scala.concurrent.{ExecutionContext, Future}
class TestOnlyController @Inject() (
mcc: MessagesControllerComponents,
repository: DeclarationJourneyRepository,
formProvider: DeclarationJourneyFormProvider,
+ actionProvider: DeclarationJourneyActionProvider,
page: TestOnlyDeclarationJourneyPage
)(implicit val ec: ExecutionContext, appConfig: AppConfig)
extends FrontendController(mcc)
with Logging {
private val form = formProvider()
+ def isFromAdminDomain()(implicit request: Request[_]): Boolean =
+ request.headers
+ .get("x-forwarded-host")
+ .exists(host => host.startsWith("admin") || host.startsWith("test-admin"))
+
val displayDeclarationJourneyPage: Action[AnyContent] = Action { implicit request =>
- Ok(page(form.fill(prettyPrint(toJson(sampleDeclarationJourney(SessionId()))))))
+ Ok(
+ page(
+ form.fill(prettyPrint(toJson(sampleDeclarationJourney(SessionId(), isFromAdminDomain())))),
+ isFromAdminDomain()
+ )
+ )
}
val submitDeclarationJourneyPage: Action[AnyContent] = Action.async { implicit request =>
- def onError(form: Form[String]): Future[Result] = Future successful BadRequest(page(form))
+ def onError(form: Form[String]): Future[Result] = Future successful BadRequest(page(form, isFromAdminDomain()))
form
.bindFromRequest()
@@ -92,10 +103,11 @@ object TestOnlyController {
Some(PurchaseDetails("99.99", Currency("EUR", "title.euro_eur", Some("EUR"), List("Europe", "European"))))
)
- def sampleDeclarationJourney(sessionId: SessionId): DeclarationJourney =
+ def sampleDeclarationJourney(sessionId: SessionId, isAssistedDigital: Boolean): DeclarationJourney =
DeclarationJourney(
sessionId = sessionId,
declarationType = DeclarationType.Import,
+ isAssistedDigital = isAssistedDigital,
maybeExciseOrRestrictedGoods = Some(No),
maybeGoodsDestination = Some(GreatBritain),
maybeValueWeightOfGoodsBelowThreshold = Some(Yes),
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/filters/AdminJourneyFilter.scala b/app/uk/gov/hmrc/merchandiseinbaggage/filters/AdminJourneyFilter.scala
new file mode 100644
index 000000000..40c48713b
--- /dev/null
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/filters/AdminJourneyFilter.scala
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2024 HM Revenue & Customs
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.gov.hmrc.merchandiseinbaggage.filters
+
+import org.apache.pekko.stream.Materializer
+import play.api.{Configuration, Logging}
+import play.api.mvc.{Filter, RequestHeader, Result}
+
+import javax.inject.Inject
+import scala.concurrent.Future
+
+class AdminJourneyFilter @Inject() (
+ override val mat: Materializer,
+ config: Configuration
+) extends Filter
+ with Logging {
+
+ private val enabled: Boolean = config.get[Boolean]("adminJourneyFilter.enabled")
+
+ override def apply(f: RequestHeader => Future[Result])(rh: RequestHeader): Future[Result] =
+ if (enabled) {
+ val rhWithAdminHeader = {
+ val headers = rh.headers.add("x-forwarded-host" -> "admin.tax.service.gov.uk")
+ rh.withHeaders(headers)
+ }
+ logger.info("Request modified to add header 'x-forwarded-host: admin.tax.service.gov.uk' for testing purposes.")
+ f(rhWithAdminHeader)
+ } else {
+ f(rh)
+ }
+}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/forms/EnterEmailForm.scala b/app/uk/gov/hmrc/merchandiseinbaggage/forms/EnterEmailForm.scala
index b56ed77f5..22332fb36 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/forms/EnterEmailForm.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/forms/EnterEmailForm.scala
@@ -19,11 +19,10 @@ package uk.gov.hmrc.merchandiseinbaggage.forms
import play.api.data.{Form, Forms}
import play.api.data.Forms.{mapping, optional}
import play.api.data.validation.{Constraint, Invalid, Valid}
-import uk.gov.hmrc.merchandiseinbaggage.config.IsAssistedDigitalConfiguration
import uk.gov.hmrc.merchandiseinbaggage.forms.mappings.Mappings
import uk.gov.hmrc.merchandiseinbaggage.model.api.Email
-object EnterEmailForm extends Mappings with IsAssistedDigitalConfiguration {
+object EnterEmailForm extends Mappings {
private val emailRegex =
"""^[a-zA-Z0-9\.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$""".r
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Amendment.scala b/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Amendment.scala
index a4450bec7..652abd437 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Amendment.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Amendment.scala
@@ -31,7 +31,7 @@ case class Amendment(
emailsSent: Boolean
)
-object Amendment extends JourneySourceFinder {
+object Amendment {
implicit val format: OFormat[Amendment] = Json.format[Amendment]
def apply(
@@ -40,7 +40,7 @@ object Amendment extends JourneySourceFinder {
goods: DeclarationGoods,
maybeTotalCalculationResult: Option[TotalCalculationResult] = None,
paymentStatus: Option[PaymentStatus] = None,
- source: Option[String] = findSource,
+ source: Option[String] = None,
emailsSent: Boolean = false
): Amendment =
Amendment(reference, dateOfAmendment, goods, maybeTotalCalculationResult, paymentStatus, source, "en", emailsSent)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Declaration.scala b/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Declaration.scala
index c4652d608..3c3160c65 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Declaration.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/model/api/Declaration.scala
@@ -41,7 +41,7 @@ case class Declaration(
amendments: Seq[Amendment]
)
-object Declaration extends JourneySourceFinder {
+object Declaration {
implicit val format: OFormat[Declaration] = Json.format[Declaration]
def apply(
@@ -59,7 +59,7 @@ object Declaration extends JourneySourceFinder {
mibReference: MibReference,
maybeTotalCalculationResult: Option[TotalCalculationResult] = None,
paymentStatus: Option[PaymentStatus] = None,
- source: Option[String] = findSource,
+ source: Option[String] = None,
amendments: Seq[Amendment] = Seq.empty
): Declaration =
Declaration(
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinder.scala b/app/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinder.scala
deleted file mode 100644
index 8a37dd8e7..000000000
--- a/app/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinder.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2024 HM Revenue & Customs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package uk.gov.hmrc.merchandiseinbaggage.model.api
-
-import uk.gov.hmrc.merchandiseinbaggage.config.IsAssistedDigitalConfiguration
-
-trait JourneySourceFinder extends IsAssistedDigitalConfiguration {
-
- def findSource: Option[String] =
- if (isAssistedDigital) Some("AssistedDigital") else Some("Digital")
-}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourney.scala b/app/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourney.scala
index 8d38ce112..b93924ac7 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourney.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourney.scala
@@ -17,7 +17,6 @@
package uk.gov.hmrc.merchandiseinbaggage.model.core
import play.api.libs.json._
-import uk.gov.hmrc.merchandiseinbaggage.config.IsAssistedDigitalConfiguration
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.{Export, Import}
import uk.gov.hmrc.merchandiseinbaggage.model.api.GoodsDestinations.GreatBritain
import uk.gov.hmrc.merchandiseinbaggage.model.api.JourneyTypes.{Amend, New}
@@ -78,6 +77,7 @@ object GoodsEntries {
case class DeclarationJourney(
sessionId: SessionId,
declarationType: DeclarationType,
+ isAssistedDigital: Boolean,
journeyType: JourneyType = New,
createdAt: LocalDateTime = LocalDateTime
.now(ZoneOffset.UTC)
@@ -98,8 +98,7 @@ case class DeclarationJourney(
maybeRegistrationNumber: Option[String] = None,
maybeRetrieveDeclaration: Option[RetrieveDeclaration] = None,
declarationId: DeclarationId = DeclarationId(UUID.randomUUID().toString)
-) extends MibReferenceGenerator
- with IsAssistedDigitalConfiguration {
+) extends MibReferenceGenerator {
val maybeCustomsAgent: Option[CustomsAgent] =
for {
@@ -121,6 +120,8 @@ case class DeclarationJourney(
}
}
+ val source: Option[String] = if (isAssistedDigital) Some("AssistedDigital") else Some("Digital")
+
val declarationIfRequiredAndComplete: Option[Declaration] = journeyType match {
case Amend => None
case New =>
@@ -150,7 +151,8 @@ case class DeclarationJourney(
eori,
journeyDetails,
LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS),
- mibReference
+ mibReference,
+ source = source
)
}
@@ -160,7 +162,7 @@ case class DeclarationJourney(
case New => None
case Amend =>
goodsEntries.declarationGoodsIfComplete.map(goods =>
- Amendment(1, LocalDateTime.now.truncatedTo(ChronoUnit.MILLIS), goods)
+ Amendment(1, LocalDateTime.now.truncatedTo(ChronoUnit.MILLIS), goods, source = source)
)
}
@@ -213,10 +215,16 @@ object DeclarationJourney {
implicit val dateFormat: Format[LocalDateTime] = Format(localDateTimeRead, localDateTimeWrites)
implicit val format: OFormat[DeclarationJourney] = Json.format[DeclarationJourney]
- def apply(sessionId: SessionId, declarationType: DeclarationType, journeyType: JourneyType): DeclarationJourney =
+ def apply(
+ sessionId: SessionId,
+ declarationType: DeclarationType,
+ isAssistedDigital: Boolean,
+ journeyType: JourneyType
+ ): DeclarationJourney =
DeclarationJourney(
sessionId = sessionId,
declarationType = declarationType,
+ isAssistedDigital = isAssistedDigital,
journeyType = journeyType,
goodsEntries = goodsEntries(declarationType)
)
@@ -227,20 +235,13 @@ object DeclarationJourney {
case Export => GoodsEntries(ExportGoodsEntry())
}
- def apply(sessionId: SessionId, declarationType: DeclarationType): DeclarationJourney = declarationType match {
- case Import =>
- DeclarationJourney(
- sessionId = sessionId,
- declarationType = declarationType,
- goodsEntries = GoodsEntries(ImportGoodsEntry())
- )
- case Export =>
- DeclarationJourney(
- sessionId = sessionId,
- declarationType = declarationType,
- goodsEntries = GoodsEntries(ExportGoodsEntry())
- )
- }
+ def apply(sessionId: SessionId, declarationType: DeclarationType, isAssistedDigital: Boolean): DeclarationJourney =
+ DeclarationJourney(
+ sessionId = sessionId,
+ declarationType = declarationType,
+ isAssistedDigital = isAssistedDigital,
+ goodsEntries = goodsEntries(declarationType)
+ )
val id = "sessionId"
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/navigation/NavigationRequest.scala b/app/uk/gov/hmrc/merchandiseinbaggage/navigation/NavigationRequest.scala
index 298291641..6f9aa50f7 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/navigation/NavigationRequest.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/navigation/NavigationRequest.scala
@@ -129,7 +129,8 @@ final case class VehicleSizeRequest(
final case class ImportExportChoiceRequest(
choice: ImportExportChoice,
sessionId: SessionId,
- upsert: DeclarationJourney => Future[DeclarationJourney]
+ upsert: DeclarationJourney => Future[DeclarationJourney],
+ isAssistedDigital: Boolean
) extends NavigationRequest
final case class NewOrExistingRequest(
@@ -147,7 +148,8 @@ final case class AgentDetailsRequest(
final case class PreviousDeclarationDetailsRequest(
journey: DeclarationJourney,
originalDeclaration: Declaration,
- upsert: DeclarationJourney => Future[DeclarationJourney]
+ upsert: DeclarationJourney => Future[DeclarationJourney],
+ isAssistedDigital: Boolean
) extends NavigationRequest
final case class GoodsTypeRequest(
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/AgentDetailsView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/AgentDetailsView.scala.html
index 90e9d4cf7..32db25ef2 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/AgentDetailsView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/AgentDetailsView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -26,9 +27,9 @@
button: components.button,
text: components.inputText)
-@(form: Form[_], backButtonUrl: Call, declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], backButtonUrl: Call, declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, "agentDetails.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "agentDetails.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = AgentDetailsController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotAccessPageView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotAccessPageView.scala.html
index 009861066..0f484e472 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotAccessPageView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotAccessPageView.scala.html
@@ -17,23 +17,24 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(layout: Layout, link: components.link, p: components.p)
-@()(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@()(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm("invalidRequest.title")), maybeBackButtonUrl = None, maybeDeclarationType = None) {
+@layout(pageTitle = Some(titleNoForm("invalidRequest.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, isAssistedDigital = request.isAssistedDigital) {
@messages("invalidRequest.title")
@p(Html(messages("invalidRequest.li1")))
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@messages("invalidRequest.ad")
} else {
@p(Html(messages("invalidRequest.li2")))
- - @link(StartImportController.onPageLoad.url, messages("invalidRequest.Import.restart"), true)
- - @link(StartExportController.onPageLoad.url, messages("invalidRequest.Export.restart"), true)
+ - @link(StartImportController.onPageLoad.url, messages("invalidRequest.Import.restart"), attrTarget = true)
+ - @link(StartExportController.onPageLoad.url, messages("invalidRequest.Export.restart"), attrTarget = true)
}
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceIrelandView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceIrelandView.scala.html
index 115e17f88..8aaf6fbc2 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceIrelandView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceIrelandView.scala.html
@@ -17,6 +17,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -25,9 +26,9 @@
link: components.link
)
-@(declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm(s"cannotUseServiceIreland.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(titleNoForm(s"cannotUseServiceIreland.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@h1("cannotUseServiceIreland.heading")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceView.scala.html
index a08c10e8a..2c12d5c30 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CannotUseServiceView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.GoodsDestination
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -26,9 +27,9 @@
link: components.link
)
-@(declarationType: DeclarationType, goodsDestination: GoodsDestination, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(declarationType: DeclarationType, goodsDestination: GoodsDestination, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm(s"cannotUseService.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(titleNoForm(s"cannotUseService.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@h1(s"cannotUseService.$declarationType.heading")
@p(Html(messages(s"cannotUseService.$declarationType.p1")))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendExportView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendExportView.scala.html
index e0ffca65e..ada91bf95 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendExportView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendExportView.scala.html
@@ -19,14 +19,15 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Export
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(layout: Layout, formHelper: FormWithCSRF, errorSummary: components.errorSummary, summaryList: includes.goodsSummary, button: components.button)
-@(form: Form[_], amendment: Amendment, isAgent: YesNo)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], amendment: Amendment, isAgent: YesNo)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@agentOrTrader = @{if(YesNo.to(isAgent)) "agent" else "trader"}
-@layout(pageTitle = Some(title(form, "checkYourAnswers.amend.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(Export)) {
+@layout(pageTitle = Some(title(form, "checkYourAnswers.amend.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(Export), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = CheckYourAnswersController.onSubmit) {
@@ -48,7 +49,7 @@
@messages("checkYourAnswe
@messages(s"checkYourAnswers.${agentOrTrader}.sendDeclaration")
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@messages("checkYourAnswers.sendDeclaration.acknowledgement.AD")
} else {
@messages("checkYourAnswers.sendDeclaration.acknowledgement")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendImportView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendImportView.scala.html
index 84091c030..090b0fa0e 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendImportView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersAmendImportView.scala.html
@@ -22,14 +22,15 @@
@import uk.gov.hmrc.merchandiseinbaggage.forms.CheckYourAnswersForm.taxDue
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Import
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(layout: Layout, formHelper: FormWithCSRF, errorSummary: components.errorSummary, summaryList: includes.goodsSummary, button: components.button)
-@(form: Form[_], amendment: Amendment, calculationResults: CalculationResults, outstandingBalance: AmountInPence, isAgent: YesNo)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], amendment: Amendment, calculationResults: CalculationResults, outstandingBalance: AmountInPence, isAgent: YesNo)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@agentOrTrader = @{if(YesNo.to(isAgent)) "agent" else "trader"}
-@layout(pageTitle = Some(title(form, "checkYourAnswers.amend.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(Import)) {
+@layout(pageTitle = Some(title(form, "checkYourAnswers.amend.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(Import), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = CheckYourAnswersController.onSubmit) {
@@ -58,7 +59,7 @@ @messages("checkYourAnswe
@messages(s"checkYourAnswers.${agentOrTrader}.sendDeclaration")
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@messages("checkYourAnswers.sendDeclaration.acknowledgement.AD")
} else {
@messages("checkYourAnswers.sendDeclaration.acknowledgement")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersExportView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersExportView.scala.html
index 5054bbb35..482193d1d 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersExportView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersExportView.scala.html
@@ -20,16 +20,17 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
@import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration
@import uk.gov.hmrc.merchandiseinbaggage.utils.DateUtils._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(layout: Layout, formHelper: FormWithCSRF, errorSummary: components.errorSummary, summaryList: includes.goodsSummary, button: components.button)
-@(form: Form[_], declaration: Declaration, isAgent: YesNo)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], declaration: Declaration, isAgent: YesNo)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@agentOrTrader = @{if(YesNo.to(isAgent)) "agent" else "trader"}
@change = @{messages("checkYourAnswers.change")}
-@layout(pageTitle = Some(title(form, "checkYourAnswers.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declaration.declarationType)) {
+@layout(pageTitle = Some(title(form, "checkYourAnswers.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declaration.declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = CheckYourAnswersController.onSubmit) {
@@ -172,7 +173,7 @@ @messages("checkYourAnswers.journeyDetails")
@messages(s"checkYourAnswers.${agentOrTrader}.sendDeclaration")
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@messages("checkYourAnswers.sendDeclaration.acknowledgement.AD")
} else {
@messages("checkYourAnswers.sendDeclaration.acknowledgement")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersImportView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersImportView.scala.html
index fc9ba25bb..a19acd1be 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersImportView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CheckYourAnswersImportView.scala.html
@@ -18,23 +18,22 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo._
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation.CalculationResults
@import uk.gov.hmrc.merchandiseinbaggage.forms.CheckYourAnswersForm.taxDue
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.AmountInPence
@import uk.gov.hmrc.merchandiseinbaggage.utils.DateUtils._
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(layout: Layout, formHelper: FormWithCSRF, errorSummary: components.errorSummary, summaryList: includes.goodsSummary, button: components.button)
-@(form: Form[_], declaration: Declaration, calculationResults: CalculationResults, isAgent: YesNo)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], declaration: Declaration, calculationResults: CalculationResults, isAgent: YesNo)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@agentOrTrader = @{if(YesNo.to(isAgent)) "agent" else "trader"}
@change = @{messages("checkYourAnswers.change")}
-@layout(pageTitle = Some(title(form, "checkYourAnswers.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declaration.declarationType)) {
+@layout(pageTitle = Some(title(form, "checkYourAnswers.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declaration.declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = CheckYourAnswersController.onSubmit) {
@@ -184,7 +183,7 @@ @messages("checkYourAnswers.journeyDetails")
@messages(s"checkYourAnswers.${agentOrTrader}.sendDeclaration")
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@messages("checkYourAnswers.sendDeclaration.acknowledgement.AD")
} else {
@messages("checkYourAnswers.sendDeclaration.acknowledgement")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/CustomsAgentView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/CustomsAgentView.scala.html
index 531af1cf4..25fabaf20 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/CustomsAgentView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/CustomsAgentView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -27,9 +28,9 @@
button: components.button
)
-@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConf: AppConfig)
+@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConf: AppConfig)
-@layout(pageTitle = Some(title(form, "customsAgent.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "customsAgent.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = CustomsAgentController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationConfirmationView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationConfirmationView.scala.html
index feb1d8e33..df52c8a17 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationConfirmationView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationConfirmationView.scala.html
@@ -18,19 +18,18 @@
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
@import uk.gov.hmrc.merchandiseinbaggage.views.html.components.link
@import uk.gov.hmrc.merchandiseinbaggage.views.html.Layout
@import uk.gov.hmrc.merchandiseinbaggage.utils.DateUtils._
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.viewmodels.DeclarationView._
@import uk.gov.hmrc.merchandiseinbaggage.views.ViewUtils
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(layout: Layout, formHelper: FormWithCSRF, link: link)
-@(declaration: Declaration, journeyType: JourneyType, isAssistedDigital: Boolean, totalTaxDue: AmountInPence)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(declaration: Declaration, journeyType: JourneyType, totalTaxDue: AmountInPence)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@printLink = {
}
-@layout(pageTitle = Some(titleNoForm("declarationConfirmation.title")), scriptsBlock = Some(printLink), maybeBackButtonUrl = None, maybeDeclarationType = Some(declaration.declarationType)) {
+@layout(pageTitle = Some(titleNoForm("declarationConfirmation.title")), scriptsBlock = Some(printLink), maybeBackButtonUrl = None, maybeDeclarationType = Some(declaration.declarationType), isAssistedDigital = request.isAssistedDigital) {
@messages("declarationConfirmation.banner.title")
@@ -64,7 +63,7 @@ @messages("declarationConfirmat
@messages("declarationConfirmation.amount.label")
- @if(declaration.declarationType == Import && isAssistedDigital && totalTaxDue.value > 0) {
+ @if(declaration.declarationType == Import && request.isAssistedDigital && totalTaxDue.value > 0) {
@{totalTaxDue.formattedInPounds}
} else { @messages("declarationConfirmation.nothingtopay.label") }
@@ -85,7 +84,7 @@ @messages("declarationConfirmati
@messages(s"declarationConfirmation.ul.2")
@messages(s"declarationConfirmation.ul.3")
- @if(ViewUtils.proofOfOriginNeeded(declaration)) {
+ @if(ViewUtils.proofOfOriginNeeded(declaration, request.isAssistedDigital)) {
@messages("declarationConfirmation.ul.4")
}
@@ -106,7 +105,7 @@ @messages("declarationConfirm
- @link(FeedbackSurveyController.startSurvey().url, "declarationConfirmation.feedbackSurvey", true, Some("feedbackSurvey"))
+ @link(FeedbackSurveyController.startSurvey().url, "declarationConfirmation.feedbackSurvey", attrTarget = true, Some("feedbackSurvey"))
@messages("declarationConfirmation.feedbackSurvey.info")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationNotFoundView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationNotFoundView.scala.html
index fa44d437a..ea8742c20 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationNotFoundView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/DeclarationNotFoundView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -26,11 +27,11 @@
link: components.link
)
-@(declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm("declarationNotFound.title")), maybeBackButtonUrl = Some(RetrieveDeclarationController.onPageLoad), maybeDeclarationType = None) {
+@layout(pageTitle = Some(titleNoForm("declarationNotFound.title")), maybeBackButtonUrl = Some(RetrieveDeclarationController.onPageLoad), maybeDeclarationType = None, isAssistedDigital = request.isAssistedDigital) {
- @h1(("declarationNotFound.heading"))
+ @h1("declarationNotFound.heading")
@p(Html(messages("declarationNotFound.li1")), Some("p.l1"))
@@ -42,7 +43,7 @@
@messages("declarationNotFound.li4.a.text")
@link(RetrieveDeclarationController.onPageLoad.url, "declarationNotFound.li4.b.text", id = Some("tryAgain"))
@messages("declarationNotFound.li4.c.text")
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@link(ImportExportChoiceController.onPageLoad.url, "declarationNotFound.li4.d.text", id = Some("makeNewDeclaration"))
} else {
@link(GoodsDestinationController.onPageLoad.url, "declarationNotFound.li4.d.text", id = Some("makeNewDeclaration"))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterEmailView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterEmailView.scala.html
index c8e96e611..7a35c06f5 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterEmailView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterEmailView.scala.html
@@ -19,6 +19,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.Email
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -28,14 +29,14 @@
text: components.inputText,
h1: components.h1)
-@(form: Form[Email], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[Email], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@notMatching = @{
if(form.errors.find(_.message == "enterEmail.error.notMatching").isDefined) Some("confirmation")
else None
}
-@layout(pageTitle = Some(title(form, "enterEmail.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "enterEmail.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = EnterEmailController.onSubmit, Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, notMatching)
@h1(messages("enterEmail.heading"), classes = Some("govuk-fieldset__legend govuk-fieldset__legend--xl"))
@@ -47,7 +48,7 @@
id = "email",
name = "email",
inputType = "email",
- label = if(appConfig.isAssistedDigital) { "enterEmail.email.optional" } else { "enterEmail.email" },
+ label = if(request.isAssistedDigital) { "enterEmail.email.optional" } else { "enterEmail.email" },
isPageHeading = false,
attributes = Map("autocomplete" -> "email", "aria-describedby" -> "email-hint"),
classes = Some("govuk-input--width-20")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterOptionalEmailView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterOptionalEmailView.scala.html
index 0b3da86c0..7d37a15ea 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterOptionalEmailView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/EnterOptionalEmailView.scala.html
@@ -19,6 +19,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.Email
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -28,14 +29,14 @@
text: components.inputText,
h1: components.h1)
-@(form: Form[Option[Email]], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[Option[Email]], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@notMatching = @{
if(form.errors.find(_.message == "enterEmail.error.notMatching").isDefined) Some("confirmation")
else None
}
-@layout(pageTitle = Some(title(form, "enterEmail.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "enterEmail.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = EnterEmailController.onSubmit, Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, notMatching)
@h1(messages("enterEmail.heading"), classes = Some("govuk-fieldset__legend govuk-fieldset__legend--xl"))
@@ -47,7 +48,7 @@
id = "email",
name = "email",
inputType = "email",
-label = if(appConfig.isAssistedDigital) { "enterEmail.email.optional" } else { "enterEmail.email" },
+label = if(request.isAssistedDigital) { "enterEmail.email.optional" } else { "enterEmail.email" },
isPageHeading = false,
attributes = Map("autocomplete" -> "email", "aria-describedby" -> "email-hint"),
classes = Some("govuk-input--width-20")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/EoriNumberView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/EoriNumberView.scala.html
index 616348957..82094156b 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/EoriNumberView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/EoriNumberView.scala.html
@@ -17,8 +17,8 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -28,13 +28,13 @@
button: components.button
)
-@(form: Form[_], isAgent: YesNo, backButtonUrl: Call, declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], isAgent: YesNo, backButtonUrl: Call, declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@agentOrTrader = @{if(YesNo.to(isAgent)) "agent" else "trader"}
@hintText = @{if(isAgent == Yes) "eoriNumber.agent.hint" else "eoriNumber.trader.hint"}
-@layout(pageTitle = Some(title(form, s"eoriNumber.$agentOrTrader.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"eoriNumber.$agentOrTrader.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = EoriNumberController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ErrorTemplate.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ErrorTemplate.scala.html
index 141b00a74..268daba46 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ErrorTemplate.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ErrorTemplate.scala.html
@@ -16,11 +16,13 @@
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.views.html.Layout
+@import uk.gov.hmrc.merchandiseinbaggage.views.ViewUtils
@this(layout: Layout)
@(pageTitle: String, heading: String, message: String)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(pageTitle), maybeBackButtonUrl = None, maybeDeclarationType = None) {
+
+@layout(pageTitle = Some(pageTitle), maybeBackButtonUrl = None, maybeDeclarationType = None, isAssistedDigital = ViewUtils.isFromAdminDomain()) {
@{Text(heading).asHtml}
@{Text(message).asHtml}
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ExciseAndRestrictedGoodsView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ExciseAndRestrictedGoodsView.scala.html
index 1942a22b2..1572c4ee3 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ExciseAndRestrictedGoodsView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ExciseAndRestrictedGoodsView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -29,9 +30,9 @@
button: components.button
)
-@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, s"exciseAndRestrictedGoods.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"exciseAndRestrictedGoods.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = ExciseAndRestrictedGoodsController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsDestinationView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsDestinationView.scala.html
index b5c1a34cf..a4f34bef2 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsDestinationView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsDestinationView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.GoodsDestinations
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -27,9 +28,9 @@
button: components.button
)
-@(form: Form[_], declarationType: DeclarationType, backLink: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], declarationType: DeclarationType, backLink: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, s"goodsDestination.$declarationType.title")), maybeBackButtonUrl = Some(backLink), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"goodsDestination.$declarationType.title")), maybeBackButtonUrl = Some(backLink), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = GoodsDestinationController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, GoodsDestinations.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsInVehicleView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsInVehicleView.scala.html
index 69fef43fa..4241d08e9 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsInVehicleView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsInVehicleView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -27,9 +28,9 @@
button: components.button
)
-@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConf: AppConfig)
+@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConf: AppConfig)
-@layout(pageTitle = Some(title(form, s"goodsInVehicle.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"goodsInVehicle.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = GoodsInVehicleController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOriginView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOriginView.scala.html
index 0584887f6..abcf3e9a8 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOriginView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOriginView.scala.html
@@ -19,6 +19,7 @@
@import uk.gov.hmrc.govukfrontend.views.html.components._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Import
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNoDontKnow
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -30,13 +31,13 @@
details: components.details
)
-@(form: Form[_], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
@inset = @{
HtmlContent(s"""${messages("goodsOrigin.inset")} $goodsCategory""")
}
-@layout(pageTitle = Some(title(form, "goodsOrigin.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(Import)) {
+@layout(pageTitle = Some(title(form, "goodsOrigin.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(Import), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = GoodsOriginController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNoDontKnow.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOverThresholdView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOverThresholdView.scala.html
index 3aac502f2..d73030a35 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOverThresholdView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsOverThresholdView.scala.html
@@ -21,6 +21,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.AmountInPence
@import uk.gov.hmrc.merchandiseinbaggage.model.api.ConversionRatePeriod
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -29,9 +30,9 @@
p: components.p
)
-@(dest: GoodsDestination, totalValue: AmountInPence, rates: Seq[ConversionRatePeriod], declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(dest: GoodsDestination, totalValue: AmountInPence, rates: Seq[ConversionRatePeriod], declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm(s"goodsOverThreshold.${dest.toString}.title", titleMessageArgs = Seq(dest.threshold.formattedInPounds))), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(titleNoForm(s"goodsOverThreshold.${dest.toString}.title", titleMessageArgs = Seq(dest.threshold.formattedInPounds))), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@h1(messages(s"goodsOverThreshold.${dest.toString}.heading", dest.threshold.formattedInPounds))
@messages(s"goodsOverThreshold.${dest.toString}.${declarationType}.p1", dest.threshold.formattedInPounds)
@@ -52,7 +53,7 @@
- @if(appConfig.isAssistedDigital) {
+ @if(request.isAssistedDigital) {
@messages("goodsOverThreshold.p5")
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsRemovedView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsRemovedView.scala.html
index 515d85213..c16886358 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsRemovedView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsRemovedView.scala.html
@@ -17,6 +17,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -24,9 +25,9 @@
p: components.p
)
-@(startAgainUrl: String, declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(startAgainUrl: String, declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm("goodsRemoved.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(titleNoForm("goodsRemoved.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@h1("goodsRemoved.heading")
@p(Html(messages("goodsRemoved.p1")))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsTypeView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsTypeView.scala.html
index 56a74d6bc..6c5f94db7 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsTypeView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsTypeView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -28,9 +29,9 @@
h1: components.h1,
p: components.p)
-@(form: Form[_], idx: Int, declarationType: DeclarationType, journeyType: JourneyType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], idx: Int, declarationType: DeclarationType, journeyType: JourneyType, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, if(idx == 1) s"goodsType.$journeyType.title" else s"goodsType.$journeyType.next.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, if(idx == 1) s"goodsType.$journeyType.title" else s"goodsType.$journeyType.next.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = GoodsTypeController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsVatRateView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsVatRateView.scala.html
index cc75f88cf..77f5c5a0c 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsVatRateView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/GoodsVatRateView.scala.html
@@ -19,6 +19,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.govukfrontend.views.html.components._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -31,9 +32,9 @@
button: components.button
)
-@(form: Form[_], idx: Int, goodsCategory: String, declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], idx: Int, goodsCategory: String, declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, "goodsVatRate.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "goodsVatRate.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = GoodsVatRateController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, GoodsVatRates.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ImportExportChoice.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ImportExportChoice.scala.html
index 06cdcce54..3ec7ad5ae 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ImportExportChoice.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ImportExportChoice.scala.html
@@ -16,10 +16,9 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api._
@import uk.gov.hmrc.merchandiseinbaggage.model.core._
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
-@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.auth.AuthRequest
@this(
layout: Layout,
@@ -29,9 +28,9 @@
button: components.button
)
-@(form: Form[_])(implicit request: Request[_], messages: Messages, appConf: AppConfig)
+@(form: Form[_])(implicit request: AuthRequest[_], messages: Messages, appConf: AppConfig)
-@layout(pageTitle = Some(title(form, "importExportChoice.title")), maybeBackButtonUrl = None, maybeDeclarationType = None) {
+@layout(pageTitle = Some(title(form, "importExportChoice.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = ImportExportChoiceController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, ImportExportChoices.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/JourneyDetailsPage.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/JourneyDetailsPage.scala.html
index fc4935444..f8a9dde4a 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/JourneyDetailsPage.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/JourneyDetailsPage.scala.html
@@ -24,6 +24,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.service.PortService
@import play.api.libs.json.Json
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -34,7 +35,7 @@
date: components.inputDate,
h1: components.h1)
-@(form: Form[JourneyDetailsEntry], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[JourneyDetailsEntry], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@scripts = {
@@ -56,7 +57,8 @@
pageTitle = Some(title(form, "journeyDetails.title")),
scriptsBlock = Some(scripts),
maybeBackButtonUrl = Some(backButtonUrl),
- maybeDeclarationType = Some(declarationType)
+ maybeDeclarationType = Some(declarationType),
+ isAssistedDigital = request.isAssistedDigital
) {
@formHelper(action = JourneyDetailsController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/Layout.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/Layout.scala.html
index d679c0309..7088cf77f 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/Layout.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/Layout.scala.html
@@ -32,6 +32,7 @@
scriptsBlock: Option[Html] = None,
maybeBackButtonUrl: Option[play.api.mvc.Call],
maybeDeclarationType: Option[DeclarationType],
+ isAssistedDigital: Boolean,
timeOut: Boolean = true
)(contentBlock: Html)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
@@ -67,14 +68,15 @@
@scriptsBlock
}
-@if(appConfig.isAssistedDigital) {
+@if(isAssistedDigital) {
@govukLayout(
pageTitle = pageTitle,
headBlock = Some(head(Some(defaultHead))),
scriptsBlock = Some(defaultScripts),
beforeContentBlock = None,
maybeBackButtonUrl = maybeBackButtonUrl,
- declarationType = None
+ declarationType = None,
+ isAssistedDigital = isAssistedDigital
)(contentBlock)
} else {
@govukLayout(
@@ -83,5 +85,6 @@
scriptsBlock = Some(defaultScripts),
beforeContentBlock = None,
maybeBackButtonUrl = maybeBackButtonUrl,
- declarationType = maybeDeclarationType)(contentBlock)
+ declarationType = maybeDeclarationType,
+ isAssistedDigital = isAssistedDigital)(contentBlock)
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/NewOrExistingView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/NewOrExistingView.scala.html
index 49e42bf27..ed5855922 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/NewOrExistingView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/NewOrExistingView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.JourneyTypes
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -27,9 +28,9 @@
button: components.button
)
-@(form: Form[_], declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, "newOrExisting.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "newOrExisting.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = NewOrExistingController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, JourneyTypes.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/NoDeclarationNeededView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/NoDeclarationNeededView.scala.html
index 934ad712d..4d8d9e49e 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/NoDeclarationNeededView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/NoDeclarationNeededView.scala.html
@@ -16,6 +16,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -23,9 +24,9 @@
p: components.p
)
-@(declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm("noDeclarationNeeded.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(titleNoForm("noDeclarationNeeded.title")), maybeBackButtonUrl = None, maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@h1("noDeclarationNeeded.heading")
@p(Html(messages("noDeclarationNeeded.p")))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/PaymentCalculationView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/PaymentCalculationView.scala.html
index 91a653fe8..d0a771a24 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/PaymentCalculationView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/PaymentCalculationView.scala.html
@@ -16,9 +16,9 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation.CalculationResults
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.ConversionRatePeriod
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Import
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -29,7 +29,7 @@
button: components.button
)
-@(calculationResults: CalculationResults, next: Call, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(calculationResults: CalculationResults, next: Call, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
@title = @{
if(calculationResults.isNothingToPay)
@@ -45,7 +45,7 @@
@rates = @{ calculationResults.calculationResults.flatMap(_.conversionRatePeriod).distinct }
-@layout(pageTitle = Some(title), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(Import)) {
+@layout(pageTitle = Some(title), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(Import), isAssistedDigital = request.isAssistedDigital) {
@h1(heading)
@p(Html(s"""${messages("paymentCalculation.greenchannel.p1")} ${messages("paymentCalculation.greenchannel.p2")} ${messages("paymentCalculation.greenchannel.p3")}"""))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/PreviousDeclarationDetailsView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/PreviousDeclarationDetailsView.scala.html
index 3dccdb0df..32e09cdeb 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/PreviousDeclarationDetailsView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/PreviousDeclarationDetailsView.scala.html
@@ -18,13 +18,13 @@
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation._
@import uk.gov.hmrc.merchandiseinbaggage.model.core.ThresholdAllowance
@import uk.gov.hmrc.merchandiseinbaggage.model.core.ThresholdAllowance._
@import uk.gov.hmrc.merchandiseinbaggage.utils.DateUtils._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Import
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched.AmountInPenceEnriched
@import uk.gov.hmrc.merchandiseinbaggage.viewmodels.DeclarationView._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -38,9 +38,9 @@
summaryList: GovukSummaryList
)
-@(declaration: Declaration, allowance: ThresholdAllowance)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(declaration: Declaration, allowance: ThresholdAllowance)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(titleNoForm(messages("previousDeclarationDetails.title"))), maybeBackButtonUrl = Some(RetrieveDeclarationController.onPageLoad), maybeDeclarationType = Some(declaration.declarationType)) {
+@layout(pageTitle = Some(titleNoForm(messages("previousDeclarationDetails.title"))), maybeBackButtonUrl = Some(RetrieveDeclarationController.onPageLoad), maybeDeclarationType = Some(declaration.declarationType), isAssistedDigital = request.isAssistedDigital) {
@h1(("previousDeclarationDetails.heading"))
@h2(("previousDeclarationDetails.details"), Some("govuk-heading-m"))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ProgressDeletedView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ProgressDeletedView.scala.html
index 1fedad320..a0adecfc2 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ProgressDeletedView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ProgressDeletedView.scala.html
@@ -16,10 +16,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
-@import uk.gov.hmrc.merchandiseinbaggage.service.CountryService
-@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
-@import play.api.libs.json.Json
+@import uk.gov.hmrc.merchandiseinbaggage.auth.AuthRequest
@this(
layout: Layout,
@@ -31,10 +28,10 @@
)
-@()(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@()(implicit request: AuthRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(messages("progressDeleted.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, timeOut = false) {
+@layout(pageTitle = Some(messages("progressDeleted.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, timeOut = false, isAssistedDigital = request.isAssistedDigital) {
@h1(messages("progressDeleted.heading"))
@@ -42,7 +39,7 @@
@p(Html(messages("progressDeleted.restart.p")), Some("expiredRestartId"))
- - @link(StartImportController.onPageLoad.url, messages("progressDeleted.Import.restart"), true)
- - @link(StartExportController.onPageLoad.url, messages("progressDeleted.Export.restart"), true)
+ - @link(StartImportController.onPageLoad.url, messages("progressDeleted.Import.restart"), attrTarget = true)
+ - @link(StartExportController.onPageLoad.url, messages("progressDeleted.Export.restart"), attrTarget = true)
}
\ No newline at end of file
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsExportView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsExportView.scala.html
index 6af4c4300..7c38993ad 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsExportView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsExportView.scala.html
@@ -20,6 +20,7 @@
@import uk.gov.hmrc.hmrcfrontend.views.html.components.HmrcCurrencyInput
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Export
@import uk.gov.hmrc.hmrcfrontend.views.Aliases.CurrencyInput
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -31,12 +32,13 @@
button: components.button
)
-@(form: Form[PurchaseDetailsInput], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[PurchaseDetailsInput], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
@layout(
pageTitle = Some(title(form, "purchaseDetails.title", titleMessageArgs = Seq(goodsCategory))),
maybeBackButtonUrl = Some(backButtonUrl),
- maybeDeclarationType = Some(Export)
+ maybeDeclarationType = Some(Export),
+ isAssistedDigital = request.isAssistedDigital
) {
@formHelper(action = PurchaseDetailsController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsImportView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsImportView.scala.html
index a6de5b70e..631342c7d 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsImportView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/PurchaseDetailsImportView.scala.html
@@ -22,6 +22,7 @@
@import play.api.libs.json.Json
@import uk.gov.hmrc.merchandiseinbaggage.service.CurrencyService
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -33,7 +34,7 @@
button: components.button
)
-@(form: Form[PurchaseDetailsInput], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[PurchaseDetailsInput], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
@scripts = {
@@ -54,7 +55,8 @@
pageTitle = Some(title(form, "purchaseDetails.title")),
scriptsBlock = Some(scripts),
maybeBackButtonUrl = Some(backButtonUrl),
- maybeDeclarationType = Some(Import)
+ maybeDeclarationType = Some(Import),
+ isAssistedDigital = request.isAssistedDigital
) {
@formHelper(action = PurchaseDetailsController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/RemoveGoodsView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/RemoveGoodsView.scala.html
index bf539fa4b..06ada7209 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/RemoveGoodsView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/RemoveGoodsView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -27,9 +28,9 @@
button: components.button
)
-@(form: Form[_], idx: Int, goodsCategory: String, declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], idx: Int, goodsCategory: String, declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, s"removeGoods.title", titleMessageArgs = Seq(goodsCategory))), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"removeGoods.title", titleMessageArgs = Seq(goodsCategory))), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = RemoveGoodsController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/RetrieveDeclarationView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/RetrieveDeclarationView.scala.html
index ed64c8c4f..4951daf6a 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/RetrieveDeclarationView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/RetrieveDeclarationView.scala.html
@@ -17,7 +17,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -29,9 +29,9 @@
p: components.p
)
-@(form: Form[_], backButtonUrl: Call, declarationType: DeclarationType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], backButtonUrl: Call, declarationType: DeclarationType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, s"retrieveDeclaration.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"retrieveDeclaration.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = RetrieveDeclarationController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors)
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ReviewGoodsView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ReviewGoodsView.scala.html
index 865f75bbf..ba41aa390 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ReviewGoodsView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ReviewGoodsView.scala.html
@@ -20,9 +20,8 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation._
@import uk.gov.hmrc.merchandiseinbaggage.model.core.ThresholdAllowance
@import uk.gov.hmrc.merchandiseinbaggage.model.core.ThresholdAllowance._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.JourneyTypes._
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched.AmountInPenceEnriched
-@import uk.gov.hmrc.merchandiseinbaggage.viewmodels.GoodsSummaryList
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -35,9 +34,9 @@
button: components.button
)
-@(form: Form[_], allowance: ThresholdAllowance, backButtonUrl: Call, declarationType: DeclarationType, journeyType: JourneyType)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], allowance: ThresholdAllowance, backButtonUrl: Call, declarationType: DeclarationType, journeyType: JourneyType)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, s"reviewGoods.$journeyType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"reviewGoods.$journeyType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = ReviewGoodsController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/SearchGoodsCountryView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/SearchGoodsCountryView.scala.html
index b38e57c44..3ff582ea3 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/SearchGoodsCountryView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/SearchGoodsCountryView.scala.html
@@ -17,12 +17,8 @@
@import views.html.helper.CSPNonce
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
-@import uk.gov.hmrc.merchandiseinbaggage.service.CountryService
-@import uk.gov.hmrc.merchandiseinbaggage.model.api._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
-@import play.api.libs.json.Json
-@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
-@import uk.gov.hmrc.merchandiseinbaggage.views.ViewUtils
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationGoodsRequest
@this(
layout: Layout,
@@ -33,7 +29,7 @@
button: components.button
)
-@(form: Form[_], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], idx: Int, goodsCategory: String, backButtonUrl: Call)(implicit request: DeclarationGoodsRequest[_], messages: Messages, appConfig: AppConfig)
@scripts = {
@@ -54,7 +50,8 @@
pageTitle = Some(title(form, s"searchGoodsCountry.title", titleMessageArgs = Seq(goodsCategory))),
scriptsBlock = Some(scripts),
maybeBackButtonUrl = Some(backButtonUrl),
- maybeDeclarationType = Some(Import)
+ maybeDeclarationType = Some(Import),
+ isAssistedDigital = request.isAssistedDigital
) {
@formHelper(action = SearchGoodsCountryController.onSubmit(idx), Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ServiceTimeoutView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ServiceTimeoutView.scala.html
index 97255e596..9c28073fb 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ServiceTimeoutView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ServiceTimeoutView.scala.html
@@ -16,10 +16,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
-@import uk.gov.hmrc.merchandiseinbaggage.service.CountryService
-@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
-@import play.api.libs.json.Json
+@import uk.gov.hmrc.merchandiseinbaggage.auth.AuthRequest
@this(
layout: Layout,
@@ -30,11 +27,10 @@
button: components.button
)
+@()(implicit request: AuthRequest[_], messages: Messages, appConfig: AppConfig)
-@()(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
-
-@layout(pageTitle = Some(messages("timeOut.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, timeOut = false) {
+@layout(pageTitle = Some(messages("timeOut.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, timeOut = false, isAssistedDigital = request.isAssistedDigital) {
@h1(messages("timeOut.heading"))
@@ -43,7 +39,7 @@
@p(Html(messages("timeOut.restart.p")), Some("expiredRestartId"))
- - @link(StartImportController.onPageLoad.url, messages("timeOut.Import.restart"), true)
- - @link(StartExportController.onPageLoad.url, messages("timeOut.Export.restart"), true)
+ - @link(StartImportController.onPageLoad.url, messages("timeOut.Import.restart"), attrTarget = true)
+ - @link(StartExportController.onPageLoad.url, messages("timeOut.Export.restart"), attrTarget = true)
}
\ No newline at end of file
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/SessionExpiredView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/SessionExpiredView.scala.html
deleted file mode 100644
index 5b80c15e4..000000000
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/SessionExpiredView.scala.html
+++ /dev/null
@@ -1,48 +0,0 @@
-@*
- * Copyright 2024 HM Revenue & Customs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *@
-
-@import uk.gov.hmrc.merchandiseinbaggage.views.html.{Layout, components}
-@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
-@import uk.gov.hmrc.merchandiseinbaggage.service.CountryService
-@import uk.gov.hmrc.merchandiseinbaggage.model.api._
-@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType._
-@import play.api.libs.json.Json
-
-@this(
- layout: Layout,
- formHelper: FormWithCSRF,
- h1: components.h1,
- p: components.p,
- link: components.link,
- button: components.button
-)
-
-
-@()(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
-
-
-@layout(pageTitle = Some(messages("sessionExpired.title")), maybeBackButtonUrl = None, maybeDeclarationType = None, timeOut = false) {
-
- @h1(messages("sessionExpired.heading"))
-
- @p(Html(messages("sessionExpired.guidance")), Some("expiredGuidanceId"))
- @p(Html(messages("sessionExpired.restart.p")), Some("expiredRestartId"))
-
-
- - @link(StartImportController.onPageLoad.url, messages("sessionExpired.Import.restart"), true)
- - @link(StartExportController.onPageLoad.url, messages("sessionExpired.Export.restart"), true)
-
-}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/TestOnlyDeclarationJourneyPage.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/TestOnlyDeclarationJourneyPage.scala.html
index 49390d5f7..bfebb1c06 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/TestOnlyDeclarationJourneyPage.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/TestOnlyDeclarationJourneyPage.scala.html
@@ -24,9 +24,9 @@
formWithCSRF: FormWithCSRF
)
-@(form: Form[String])(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[String], isAssistedDigital: Boolean)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, "Create a test declaration journey")), maybeBackButtonUrl = None, maybeDeclarationType = None) {
+@layout(pageTitle = Some(title(form, "Create a test declaration journey")), maybeBackButtonUrl = None, maybeDeclarationType = None, isAssistedDigital = isAssistedDigital) {
Create a test declaration journey
@formWithCSRF(action = testonly.routes.TestOnlyController.submitDeclarationJourneyPage) {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/TravellerDetailsPage.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/TravellerDetailsPage.scala.html
index 480afafe6..a34d7b115 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/TravellerDetailsPage.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/TravellerDetailsPage.scala.html
@@ -19,6 +19,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.Name
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -29,9 +30,9 @@
text: components.inputText,
h1: components.h1)
-@(form: Form[Name], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[Name], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, "travellerDetails.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "travellerDetails.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = TravellerDetailsController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors)
@h1(messages("travellerDetails.heading"), classes = Some("govuk-fieldset__legend govuk-fieldset__legend--xl"))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ValueWeightOfGoodsView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/ValueWeightOfGoodsView.scala.html
index a525d63fc..f347db174 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ValueWeightOfGoodsView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ValueWeightOfGoodsView.scala.html
@@ -20,6 +20,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
@import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched.AmountInPenceEnriched
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -29,9 +30,9 @@
button: components.button
)
-@(form: Form[_], dest: GoodsDestination, declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], dest: GoodsDestination, declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, s"valueWeightOfGoods.${dest.toString}.title", titleMessageArgs = Seq(dest.threshold.formattedInPounds))), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"valueWeightOfGoods.${dest.toString}.title", titleMessageArgs = Seq(dest.threshold.formattedInPounds))), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = ValueWeightOfGoodsController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleRegistrationNumberView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleRegistrationNumberView.scala.html
index 11134751a..4cb1e6028 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleRegistrationNumberView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleRegistrationNumberView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -26,9 +27,9 @@
button: components.button,
text: components.inputText)
-@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConfig: AppConfig)
+@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConfig: AppConfig)
-@layout(pageTitle = Some(title(form, "vehicleRegistrationNumber.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, "vehicleRegistrationNumber.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = VehicleRegistrationNumberController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleSizeView.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleSizeView.scala.html
index 72daf7c61..0f57f9634 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleSizeView.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/VehicleSizeView.scala.html
@@ -18,6 +18,7 @@
@import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
@import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
@import uk.gov.hmrc.merchandiseinbaggage.model.api.YesNo
+@import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
@this(
layout: Layout,
@@ -27,9 +28,9 @@
button: components.button
)
-@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: Request[_], messages: Messages, appConf: AppConfig)
+@(form: Form[_], declarationType: DeclarationType, backButtonUrl: Call)(implicit request: DeclarationJourneyRequest[_], messages: Messages, appConf: AppConfig)
-@layout(pageTitle = Some(title(form, s"vehicleSize.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType)) {
+@layout(pageTitle = Some(title(form, s"vehicleSize.$declarationType.title")), maybeBackButtonUrl = Some(backButtonUrl), maybeDeclarationType = Some(declarationType), isAssistedDigital = request.isAssistedDigital) {
@formHelper(action = VehicleSizeController.onSubmit, Symbol("autoComplete") -> "off", Symbol("novalidate") -> "novalidate") {
@errorSummary(form.errors, YesNo.values.headOption.map(_.entryName))
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/ViewUtils.scala b/app/uk/gov/hmrc/merchandiseinbaggage/views/ViewUtils.scala
index dac2bb6db..fb050cb48 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/ViewUtils.scala
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/ViewUtils.scala
@@ -19,13 +19,13 @@ package uk.gov.hmrc.merchandiseinbaggage.views
import play.api.data.Form
import play.api.i18n.Messages
import play.api.libs.json.Json
-import uk.gov.hmrc.merchandiseinbaggage.config.IsAssistedDigitalConfiguration
+import play.api.mvc.Request
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Import
import uk.gov.hmrc.merchandiseinbaggage.model.api.{Country, Declaration, NotRequired, Paid, TotalCalculationResult, YesNoDontKnow}
import uk.gov.hmrc.merchandiseinbaggage.service.CountryService
import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._
-object ViewUtils extends IsAssistedDigitalConfiguration {
+object ViewUtils {
def title(form: Form[_], titleStr: String, section: Option[String] = None, titleMessageArgs: Seq[String] = Seq())(
implicit messages: Messages
@@ -47,7 +47,7 @@ object ViewUtils extends IsAssistedDigitalConfiguration {
lazy val exportCountries: List[Country] =
CountryService.getAllCountries.filterNot(_.code == "GB")
- def proofOfOriginNeeded(declaration: Declaration): Boolean = {
+ def proofOfOriginNeeded(declaration: Declaration, isAssistedDigital: Boolean): Boolean = {
def calcAmount(maybeTotalCalculationResult: Option[TotalCalculationResult]): Long =
maybeTotalCalculationResult.fold(0L) {
_.calculationResults.calculationResults
@@ -65,4 +65,10 @@ object ViewUtils extends IsAssistedDigitalConfiguration {
false
}
}
+
+ def isFromAdminDomain()(implicit request: Request[_]): Boolean =
+ request.headers
+ .get("x-forwarded-host")
+ .exists(host => host.startsWith("admin") || host.startsWith("test-admin"))
+
}
diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/views/layouts/govukLayout.scala.html b/app/uk/gov/hmrc/merchandiseinbaggage/views/layouts/govukLayout.scala.html
index 9185815ca..17277549e 100644
--- a/app/uk/gov/hmrc/merchandiseinbaggage/views/layouts/govukLayout.scala.html
+++ b/app/uk/gov/hmrc/merchandiseinbaggage/views/layouts/govukLayout.scala.html
@@ -38,14 +38,15 @@
)
@(
- pageTitle: Option[String] = None,
- headBlock: Option[Html] = None,
- headerBlock: Option[Html] = None,
- beforeContentBlock: Option[Html] = None,
- bodyEndBlock: Option[Html] = None,
- scriptsBlock: Option[Html] = None,
- maybeBackButtonUrl: Option[play.api.mvc.Call],
- declarationType: Option[DeclarationType]
+ pageTitle: Option[String] = None,
+ headBlock: Option[Html] = None,
+ headerBlock: Option[Html] = None,
+ beforeContentBlock: Option[Html] = None,
+ bodyEndBlock: Option[Html] = None,
+ scriptsBlock: Option[Html] = None,
+ maybeBackButtonUrl: Option[play.api.mvc.Call],
+ declarationType: Option[DeclarationType],
+ isAssistedDigital: Boolean
)(contentBlock: Html)(implicit messages: Messages, appConfig: AppConfig, request: Request[_])
@headDefault = {
@@ -55,7 +56,7 @@
@headerDefault = {
- @if(appConfig.isAssistedDigital) {
+ @if(isAssistedDigital) {
@siteHeader()
} else {
@headerBlock.getOrElse {
@@ -86,7 +87,7 @@
}
}
-@if(!appConfig.isAssistedDigital && appConfig.languageTranslationEnabled) {
+@if(!isAssistedDigital && appConfig.languageTranslationEnabled) {
@languageSelection()
}
diff --git a/conf/application.conf b/conf/application.conf
index adad555ed..1e2564e23 100644
--- a/conf/application.conf
+++ b/conf/application.conf
@@ -29,6 +29,10 @@ play.modules.enabled += "uk.gov.hmrc.mongo.play.PlayMongoModule"
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.AuthModule"
play.filters.enabled += play.filters.csp.CSPFilter
+# AdminJourneyFilter modifies the request to add the header 'x-forwarded-host: admin.tax.service.gov.uk'
+# only when adminJourneyFilter.enabled is set to true - this is for testing purposes only.
+play.filters.enabled += uk.gov.hmrc.merchandiseinbaggage.filters.AdminJourneyFilter
+adminJourneyFilter.enabled = false
# Play Modules
# ~~~~
@@ -51,6 +55,7 @@ microservice {
host = localhost
port = 9028
callback = "http://localhost:8281"
+ adminCallback = "http://localhost:8281"
}
merchandise-in-baggage {
@@ -118,8 +123,6 @@ stride {
roles = ["tps_payment_taker_call_handler", "digital_mib_call_handler"]
}
-assistedDigital = false
-
play.i18n.langs = ["en", "cy"]
features {
diff --git a/conf/prod.routes b/conf/prod.routes
index d3b514a96..cac829043 100644
--- a/conf/prod.routes
+++ b/conf/prod.routes
@@ -1,4 +1,3 @@
# Add all the application routes to the app.routes file
--> /declare-commercial-goods-admin app.Routes
-> /declare-commercial-goods/ app.Routes
-> / health.Routes
diff --git a/run-locally.sh b/run-locally.sh
index c2d10ea89..342124afe 100755
--- a/run-locally.sh
+++ b/run-locally.sh
@@ -1 +1 @@
-sbt run -Dplay.http.router=testOnlyDoNotUseInAppConf.Routes -DassistedDigital=false
+sbt run -Dplay.http.router=testOnlyDoNotUseInAppConf.Routes -DadminJourneyFilter.enabled=false
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/CoreTestData.scala b/test/uk/gov/hmrc/merchandiseinbaggage/CoreTestData.scala
index ff2599c0b..6dfc9b9e3 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/CoreTestData.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/CoreTestData.scala
@@ -18,7 +18,9 @@ package uk.gov.hmrc.merchandiseinbaggage
import play.api.Application
import play.api.i18n.Messages
+import uk.gov.hmrc.merchandiseinbaggage.auth.AuthRequest
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
+import uk.gov.hmrc.merchandiseinbaggage.controllers.DeclarationJourneyRequest
import uk.gov.hmrc.merchandiseinbaggage.controllers.testonly.TestOnlyController
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.{Export, Import}
import uk.gov.hmrc.merchandiseinbaggage.model.api.GoodsDestinations.{GreatBritain, NorthernIreland}
@@ -58,9 +60,9 @@ trait CoreTestData {
val eori = Eori("GB123456780000")
val aDeclarationId = DeclarationId(UUID.randomUUID().toString)
- val startedImportJourney: DeclarationJourney = DeclarationJourney(aSessionId, Import)
+ val startedImportJourney: DeclarationJourney = DeclarationJourney(aSessionId, Import, isAssistedDigital = false)
- val startedExportJourney: DeclarationJourney = DeclarationJourney(aSessionId, Export)
+ val startedExportJourney: DeclarationJourney = DeclarationJourney(aSessionId, Export, isAssistedDigital = false)
val startedExportFromGreatBritain: DeclarationJourney =
startedExportJourney.copy(maybeGoodsDestination = Some(GreatBritain))
@@ -115,7 +117,7 @@ trait CoreTestData {
)
}
- val completedDeclarationJourney: DeclarationJourney = TestOnlyController.sampleDeclarationJourney(aSessionId)
+ val completedDeclarationJourney: DeclarationJourney = TestOnlyController.sampleDeclarationJourney(aSessionId, false)
val declaration: Declaration = completedDeclarationJourney.declarationIfRequiredAndComplete.get
@@ -167,10 +169,10 @@ trait CoreTestData {
.copy(maybeIsACustomsAgent = Some(No), maybeJourneyDetailsEntry = Some(JourneyDetailsEntry("LHR", journeyDate)))
val startedAmendImportJourney: DeclarationJourney =
- DeclarationJourney(aSessionId, Import).copy(journeyType = Amend)
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false).copy(journeyType = Amend)
val startedAmendExportJourney: DeclarationJourney =
- DeclarationJourney(aSessionId, Export).copy(journeyType = Amend)
+ DeclarationJourney(aSessionId, Export, isAssistedDigital = false).copy(journeyType = Amend)
val amendImportJourneyWithGoodsEntries: DeclarationJourney =
startedAmendImportJourney.copy(goodsEntries = GoodsEntries(completedImportGoods))
@@ -313,15 +315,17 @@ trait CoreTestData {
} else declaration
}
+ val declarationJourneyRequest =
+ new DeclarationJourneyRequest(journey, AuthRequest(fakeRequest, None, isAssistedDigital = false))
+
val declarationConfirmationView = new DeclarationConfirmationView(layout, null, link)
val result =
declarationConfirmationView.apply(
persistedDeclaration.get,
journeyType,
- isAssistedDigital = false,
AmountInPence(0)
)(
- fakeRequest,
+ declarationJourneyRequest,
message,
appConfig
)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthActionSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthActionSpec.scala
new file mode 100644
index 000000000..f8d49870f
--- /dev/null
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/auth/StrideAuthActionSpec.scala
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2024 HM Revenue & Customs
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.gov.hmrc.merchandiseinbaggage.auth
+
+import play.api.http.Status.SEE_OTHER
+import play.api.mvc.MessagesControllerComponents
+import play.api.mvc.Results.Ok
+import play.api.test.Helpers._
+import play.api.test.FakeRequest
+import uk.gov.hmrc.auth.core.AuthConnector
+import uk.gov.hmrc.merchandiseinbaggage.BaseSpecWithApplication
+
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.concurrent.Future
+
+class StrideAuthActionSpec extends BaseSpecWithApplication {
+
+ val authConnector = injector.instanceOf[AuthConnector]
+ val mcc = injector.instanceOf[MessagesControllerComponents]
+
+ val action = new StrideAuthAction(authConnector, appConfig, mcc)
+
+ "StrideAuthAction" must {
+ "not auth when traffic from public facing domain" in {
+ val request = FakeRequest("GET", "/").withHeaders("x-forwarded-host" -> "tax.service.gov.uk")
+
+ action.invokeBlock(
+ request,
+ { authRequest: AuthRequest[_] =>
+ authRequest.isAssistedDigital mustBe false
+ Future.successful(Ok("200"))
+ }
+ )
+ }
+
+ "auth when traffic from stride domain" in {
+ val request = FakeRequest("GET", "/").withHeaders("x-forwarded-host" -> "admin.tax.service.gov.uk")
+
+ val result = action.invokeBlock(
+ request,
+ { _: AuthRequest[_] =>
+ Future.successful(Ok("200"))
+ }
+ )
+
+ status(result) mustBe SEE_OTHER
+ }
+ }
+}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/config/AppConfigSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/config/AppConfigSpec.scala
index 6cc5b3cb9..9721df766 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/config/AppConfigSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/config/AppConfigSpec.scala
@@ -60,9 +60,9 @@ class AppConfigSpec extends BaseSpecWithApplication {
appConfig.tpsPaymentsBackendUrl mustBe "http://localhost:9125"
appConfig.merchandiseInBaggageUrl mustBe "http://localhost:8280"
appConfig.addressLookupFrontendUrl mustBe "http://localhost:9028"
- appConfig.addressLookupCallbackUrl mustBe "http://localhost:8281"
+ appConfig.addressLookupCallbackUrl(isAssistedDigital = false) mustBe "http://localhost:8281"
+ appConfig.addressLookupCallbackUrl(isAssistedDigital = true) mustBe "http://localhost:8281"
- appConfig.isAssistedDigital mustBe false
}
"throw an exception when the config value is not found" in {
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnectorSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnectorSpec.scala
index b046995fb..55038ef86 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnectorSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/connectors/AddressLookupFrontendConnectorSpec.scala
@@ -31,7 +31,8 @@ class AddressLookupFrontendConnectorSpec extends BaseSpecWithApplication with Ev
"init a journey" in {
givenInitJourney(wireMockServer)
- val response: String = connector.initJourney(Call("GET", "/address-lookup-return")).futureValue
+ val response: String =
+ connector.initJourney(Call("GET", "/address-lookup-return"), isAssistedDigital = false).futureValue
response mustBe "/blah"
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala
index 5a0bb9801..35e01f406 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala
@@ -45,7 +45,7 @@ class AgentDetailsControllerSpec extends DeclarationJourneyControllerSpec {
)
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, Import).copy(maybeGoodsDestination = Some(GreatBritain))
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false).copy(maybeGoodsDestination = Some(GreatBritain))
"onPageLoad" should {
"return 200 with correct content" in {
@@ -62,8 +62,13 @@ class AgentDetailsControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
"redirect to /enter-agent-address after successful form" in {
- val request = buildPost(routes.AgentDetailsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "business name")
+ val request =
+ buildPost(
+ routes.AgentDetailsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "business name")
+ )
when(mockNavigator.nextPage(any[AgentDetailsRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(EnterAgentAddressController.onPageLoad))
@@ -76,8 +81,13 @@ class AgentDetailsControllerSpec extends DeclarationJourneyControllerSpec {
}
"return 400 with any form errors" in {
- val request = buildPost(routes.AgentDetailsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value1" -> "in valid")
+ val request =
+ buildPost(
+ routes.AgentDetailsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value1" -> "in valid")
+ )
val eventualResult: Future[Result] = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala
index aa51ffa80..a898ebb56 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala
@@ -17,16 +17,18 @@
package uk.gov.hmrc.merchandiseinbaggage.controllers
import play.api.test.Helpers._
+import uk.gov.hmrc.merchandiseinbaggage.CoreTestData
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
import uk.gov.hmrc.merchandiseinbaggage.views.html.CannotAccessPageView
import scala.concurrent.ExecutionContext.Implicits.global
-class CannotAccessPageControllerSpec extends DeclarationJourneyControllerSpec {
+class CannotAccessPageControllerSpec extends DeclarationJourneyControllerSpec with CoreTestData {
private val view = app.injector.instanceOf[CannotAccessPageView]
- def controller: CannotAccessPageController = new CannotAccessPageController(controllerComponents, view)
+ def controller: CannotAccessPageController =
+ new CannotAccessPageController(controllerComponents, stubProvider(startedImportJourney), view)
declarationTypes.foreach { importOrExport: DeclarationType =>
"onPageLoad" should {
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala
index 454769a5b..9fca328d7 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala
@@ -31,7 +31,8 @@ class CannotUseServiceControllerSpec extends DeclarationJourneyControllerSpec {
declarationTypes.foreach { importOrExport: DeclarationType =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport).copy(maybeGoodsDestination = Some(GreatBritain))
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
+ .copy(maybeGoodsDestination = Some(GreatBritain))
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala
index 9b2a5a2eb..49d61efd0 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala
@@ -31,7 +31,8 @@ class CannotUseServiceIrelandControllerSpec extends DeclarationJourneyController
declarationTypes.foreach { importOrExport: DeclarationType =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport).copy(maybeGoodsDestination = Some(GreatBritain))
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
+ .copy(maybeGoodsDestination = Some(GreatBritain))
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala
index b6399150a..713edf4b8 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala
@@ -89,7 +89,8 @@ class CheckYourAnswersAmendHandlerSpec extends DeclarationJourneyControllerSpec
id
)
- implicit val request: Request[_] = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ implicit val request: DeclarationJourneyRequest[_] =
+ buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
val amendment = completedAmendment(importOrExport)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala
index 221a1adbe..575ec9635 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala
@@ -95,9 +95,9 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
s"redirect to /cannot-access-service for in-completed journeys for $journeyType" in {
val sessionId = SessionId()
val inCompletedJourney: DeclarationJourney =
- DeclarationJourney(aSessionId, Import).copy(journeyType = journeyType)
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false).copy(journeyType = journeyType)
- val request = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ val request = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId, inCompletedJourney)
val eventualResult = controller(declarationJourney = inCompletedJourney).onPageLoad()(request)
status(eventualResult) mustBe SEE_OTHER
@@ -109,7 +109,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
val sessionId = SessionId()
val journey: DeclarationJourney = completedDeclarationJourney.copy(sessionId = sessionId, journeyType = New)
givenADeclarationJourneyIsPersisted(journey)
- val request = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ val request = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId, journey)
when(mockMibService.paymentCalculations(any[Seq[ImportGoods]], any[GoodsDestination])(any[HeaderCarrier]))
.thenReturn(Future.successful(CalculationResponse(aCalculationResults, WithinThreshold)))
@@ -137,7 +137,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
when(mockMibService.paymentCalculations(any[Seq[Goods]], any[GoodsDestination])(any[HeaderCarrier]))
.thenReturn(Future.successful(CalculationResponse(aTotalCalculationResult.calculationResults, WithinThreshold)))
- val request = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ val request = buildGet(routes.CheckYourAnswersController.onPageLoad.url, sessionId, journey)
val result = controller(declarationJourney = journey).onPageLoad()(request)
status(result) mustBe OK
@@ -148,19 +148,20 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
journeyTypes.foreach { journeyType =>
s"redirect to /cannot-access-service for in-completed journeys for $journeyType" in {
val sessionId = SessionId()
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, Import).copy(journeyType = journeyType)
+ val journey: DeclarationJourney =
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false).copy(journeyType = journeyType)
- val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId, journey)
val eventualResult = controller(declarationJourney = journey).onSubmit()(request)
status(eventualResult) mustBe SEE_OTHER
redirectLocation(eventualResult) mustBe Some(routes.CannotAccessPageController.onPageLoad.url)
}
- s"will invoke assisted digital on submit with $PayApiResponse if flag is set for $journeyType" in new DeclarationJourneyControllerSpec {
+ s"will invoke assisted digital on submit with $PayApiResponse if flag is set for $journeyType" in {
val sessionId = SessionId()
val journey: DeclarationJourney =
- completedDeclarationJourney.copy(sessionId = sessionId, journeyType = journeyType)
+ completedDeclarationJourney.copy(sessionId = sessionId, journeyType = journeyType, isAssistedDigital = true)
val mockHandler: CheckYourAnswersNewHandler = mock[CheckYourAnswersNewHandler]
val mockAmendHandler: CheckYourAnswersAmendHandler = mock[CheckYourAnswersAmendHandler]
@@ -171,9 +172,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
mockHandler,
mockAmendHandler,
stubRepo(journey)
- ) {
- override lazy val isAssistedDigital: Boolean = true
- }
+ )
givenTheUserIsAuthenticatedAndAuthorised()
givenADeclarationJourneyIsPersisted(journey)
@@ -191,8 +190,13 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
.thenReturn(Future.successful(Redirect("")))
}
- val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
- .withHeaders("authProviderId" -> "123")
+ val request =
+ buildPost(
+ routes.CheckYourAnswersController.onPageLoad.url,
+ sessionId,
+ journey,
+ headers = Seq("authProviderId" -> "123")
+ )
val result: Future[Result] = controller(declarationJourney = journey).onSubmit()(request)
@@ -210,7 +214,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
when(mockMibService.paymentCalculations(any[Seq[ImportGoods]], any[GoodsDestination])(any[HeaderCarrier]))
.thenReturn(Future.successful(CalculationResponse(aCalculationResults, WithinThreshold)))
- val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId, journey)
val result = controller(declarationJourney = journey).onSubmit()(request)
status(result) mustBe SEE_OTHER
@@ -233,7 +237,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec {
when(mockMibService.amendDeclaration(any[Declaration])(any[HeaderCarrier]))
.thenReturn(Future.successful(declarationWithResult.declarationId))
- val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId)
+ val request = buildPost(routes.CheckYourAnswersController.onPageLoad.url, sessionId, journey)
val result: Future[Result] = controller(declarationJourney = journey).onSubmit()(request)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala
index 113969f9e..38d7621a1 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala
@@ -88,7 +88,8 @@ class CheckYourAnswersNewHandlerSpec extends DeclarationJourneyControllerSpec {
givenADeclarationJourneyIsPersisted(journey)
- implicit val request: Request[_] = buildGet(CheckYourAnswersController.onPageLoad.url, sessionId)
+ implicit val request: DeclarationJourneyRequest[_] =
+ buildGet(CheckYourAnswersController.onPageLoad.url, sessionId)
val result = newHandler().onPageLoad(declaration, YesNo.Yes)
@@ -107,7 +108,8 @@ class CheckYourAnswersNewHandlerSpec extends DeclarationJourneyControllerSpec {
val overThresholdGoods = aCalculationResponse.copy(thresholdCheck = OverThreshold)
- implicit val request: Request[_] = buildGet(CheckYourAnswersController.onPageLoad.url, sessionId)
+ implicit val request: DeclarationJourneyRequest[_] =
+ buildGet(CheckYourAnswersController.onPageLoad.url, sessionId)
val result = newHandler(overThresholdGoods).onPageLoad(declaration, YesNo.Yes)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala
index bb0606d15..348494e75 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala
@@ -43,7 +43,8 @@ class CustomsAgentControllerSpec extends DeclarationJourneyControllerSpec {
mockNavigator
)
- private val journey: DeclarationJourney = DeclarationJourney(aSessionId, DeclarationType.Import)
+ private val journey: DeclarationJourney =
+ DeclarationJourney(aSessionId, DeclarationType.Import, isAssistedDigital = false)
//TODO move content test in UI
"onPageLoad" should {
@@ -62,8 +63,13 @@ class CustomsAgentControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
"delegate to Navigator" in {
- val request = buildGet(CustomsAgentController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val request =
+ buildPost(
+ CustomsAgentController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Yes")
+ )
when(mockNavigator.nextPage(any[CustomsAgentRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(AgentDetailsController.onPageLoad))
@@ -75,8 +81,13 @@ class CustomsAgentControllerSpec extends DeclarationJourneyControllerSpec {
}
"return 400 with any form errors" in {
- val request = buildGet(CustomsAgentController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ CustomsAgentController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala
index 536a82989..c787cdcdb 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala
@@ -59,7 +59,7 @@ class DeclarationConfirmationControllerSpec extends DeclarationJourneyController
status(eventualResult) mustBe OK
import exportJourney._
- val resetJourney = DeclarationJourney(sessionId, declarationType)
+ val resetJourney = DeclarationJourney(sessionId, declarationType, isAssistedDigital = false)
declarationJourneyRepository.findBySessionId(sessionId).futureValue.get.sessionId mustBe resetJourney.sessionId
declarationJourneyRepository
@@ -88,7 +88,7 @@ class DeclarationConfirmationControllerSpec extends DeclarationJourneyController
status(eventualResult) mustBe OK
import importJourney._
- val resetJourney = DeclarationJourney(sessionId, declarationType)
+ val resetJourney = DeclarationJourney(sessionId, declarationType, isAssistedDigital = false)
declarationJourneyRepository.findBySessionId(sessionId).futureValue.get.sessionId mustBe resetJourney.sessionId
declarationJourneyRepository
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProviderSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProviderSpec.scala
deleted file mode 100644
index adabfba64..000000000
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyActionProviderSpec.scala
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2024 HM Revenue & Customs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package uk.gov.hmrc.merchandiseinbaggage.controllers
-
-import play.api.Application
-import play.api.inject.guice.GuiceApplicationBuilder
-import play.api.mvc.{EssentialAction, Result}
-import play.api.test.Helpers._
-import uk.gov.hmrc.merchandiseinbaggage.BaseSpec
-import uk.gov.hmrc.merchandiseinbaggage.wiremock.MockStrideAuth._
-import uk.gov.hmrc.merchandiseinbaggage.wiremock.WireMockSupport
-
-import scala.concurrent.Future
-
-class DeclarationJourneyActionProviderSpec extends BaseSpec {
-
- "need to be stride authenticated if internal FE flag is set" in new DeclarationJourneyControllerSpec {
- override def fakeApplication(): Application =
- new GuiceApplicationBuilder()
- .configure(
- Map(
- "microservice.services.auth.port" -> WireMockSupport.port,
- "assistedDigital" -> true
- )
- )
- .build()
- val actionProvider: DeclarationJourneyActionProvider = injector.instanceOf[DeclarationJourneyActionProvider]
-
- givenTheUserIsAuthenticatedAndAuthorised()
-
- val action: EssentialAction = actionProvider.journeyAction { _ =>
- play.api.mvc.Results.Ok("authenticated")
- }
-
- val result: Future[Result] = call(action, buildGet("/", aSessionId))
- status(result) mustBe SEE_OTHER
- }
-
- "need not to be stride authenticated if internal FE flag is not set" in new DeclarationJourneyControllerSpec {
- val actionProvider: DeclarationJourneyActionProvider = injector.instanceOf[DeclarationJourneyActionProvider]
-
- val ess: EssentialAction = actionProvider.journeyAction { _ =>
- play.api.mvc.Results.Ok("authenticated")
- }
-
- val result: Future[Result] = call(ess, buildGet("/", aSessionId))
- status(result) mustBe SEE_OTHER
- }
-}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyControllerSpec.scala
index 9fd96aa57..462245384 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationJourneyControllerSpec.scala
@@ -23,6 +23,7 @@ import play.api.test.CSRFTokenHelper._
import play.api.test.FakeRequest
import play.api.test.Helpers._
import uk.gov.hmrc.http.SessionKeys
+import uk.gov.hmrc.merchandiseinbaggage.auth.AuthRequest
import uk.gov.hmrc.merchandiseinbaggage.model.api.SessionId
import uk.gov.hmrc.merchandiseinbaggage.model.core.DeclarationJourney
import uk.gov.hmrc.merchandiseinbaggage.{BaseSpecWithApplication, CoreTestData}
@@ -34,18 +35,64 @@ trait DeclarationJourneyControllerSpec extends BaseSpecWithApplication with Core
lazy val messageApi: MessagesApi = injector.instanceOf[MessagesApi]
implicit lazy val lang: Lang = Lang("en")
- def buildGet(url: String, sessionId: SessionId): FakeRequest[AnyContentAsEmpty.type] =
- FakeRequest(GET, url)
- .withSession((SessionKeys.sessionId, sessionId.value), (SessionKeys.authToken -> SessionKeys.authToken))
+ def buildGet(
+ url: String,
+ sessionId: SessionId,
+ journey: DeclarationJourney = startedImportJourney,
+ sessionData: Seq[(String, String)] = Seq.empty,
+ headers: Seq[(String, String)] = Seq.empty
+ ): DeclarationJourneyRequest[AnyContentAsEmpty.type] = {
+ val baseRequest = FakeRequest(GET, url)
+ .withSession(SessionKeys.sessionId -> sessionId.value)
+ .withHeaders(headers: _*)
+ .withSession(sessionData: _*)
.withCSRFToken
.asInstanceOf[FakeRequest[AnyContentAsEmpty.type]]
- def buildPost(url: String, sessionId: SessionId): FakeRequest[AnyContentAsEmpty.type] =
- FakeRequest(POST, url)
- .withSession((SessionKeys.sessionId, sessionId.value))
+ val request =
+ if (journey.isAssistedDigital) {
+ baseRequest
+ .withHeaders("x-forwarded-host" -> "admin.tax.service.gov.uk")
+ .withSession(SessionKeys.authToken -> SessionKeys.authToken)
+ } else {
+ baseRequest.withHeaders("x-forwarded-host" -> "tax.service.gov.uk")
+ }
+
+ new DeclarationJourneyRequest(
+ journey,
+ AuthRequest(request, None, isAssistedDigital = journey.isAssistedDigital)
+ )
+ }
+
+ def buildPost(
+ url: String,
+ sessionId: SessionId,
+ journey: DeclarationJourney = startedImportJourney,
+ headers: Seq[(String, String)] = Seq.empty,
+ formData: Seq[(String, String)] = Seq.empty
+ ): DeclarationJourneyRequest[AnyContentAsEmpty.type] = {
+ val baseRequest = FakeRequest(POST, url)
+ .withSession(SessionKeys.sessionId -> sessionId.value)
+ .withHeaders(headers: _*)
+ .withFormUrlEncodedBody(formData: _*)
.withCSRFToken
.asInstanceOf[FakeRequest[AnyContentAsEmpty.type]]
+ val request =
+ if (journey.isAssistedDigital) {
+ baseRequest
+ .withHeaders("x-forwarded-host" -> "admin.tax.service.gov.uk")
+ .withSession(SessionKeys.authToken -> SessionKeys.authToken)
+ } else {
+ baseRequest.withHeaders("x-forwarded-host" -> "tax.service.gov.uk")
+ }
+
+ new DeclarationJourneyRequest(
+ journey,
+ AuthRequest(request, None, isAssistedDigital = journey.isAssistedDigital)
+ )
+ }
+
def givenADeclarationJourneyIsPersistedWithStub(declarationJourney: DeclarationJourney): DeclarationJourney =
stubRepo(declarationJourney).findBySessionId(declarationJourney.sessionId).futureValue.get
}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailControllerSpec.scala
index 8626ae9c0..2ef2bc16a 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EnterEmailControllerSpec.scala
@@ -45,13 +45,13 @@ class EnterEmailControllerSpec extends DeclarationJourneyControllerSpec {
mockNavigator
)
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, Import)
+ val journey: DeclarationJourney = DeclarationJourney(aSessionId, Import, isAssistedDigital = false)
//TODO move content test in UI
"onPageLoad" should {
"return 200 with correct content" in {
- val request = buildGet(EnterEmailController.onPageLoad.url, aSessionId)
+ val request = buildGet(EnterEmailController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
@@ -65,8 +65,13 @@ class EnterEmailControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
"redirect to /journey-details after successful form submit" in {
- val request = buildPost(EnterEmailController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("email" -> "test@email.com")
+ val request =
+ buildPost(
+ EnterEmailController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("email" -> "test@email.com")
+ )
when(mockNavigator.nextPage(any[EnterEmailRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(JourneyDetailsController.onPageLoad))
@@ -79,8 +84,13 @@ class EnterEmailControllerSpec extends DeclarationJourneyControllerSpec {
}
"return 400 with any form errors" in {
- val request = buildPost(EnterEmailController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("email" -> "in valid")
+ val request =
+ buildPost(
+ EnterEmailController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("email" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EoriNumberControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EoriNumberControllerSpec.scala
index 97a03ce13..e8a1a340c 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EoriNumberControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/EoriNumberControllerSpec.scala
@@ -46,12 +46,16 @@ class EoriNumberControllerSpec extends DeclarationJourneyControllerSpec {
mockNavigator
)
- "return an error if API EROI validation fails" in {
+ "return an error if API EORI validation fails" in {
givenADeclarationJourneyIsPersisted(completedDeclarationJourney)
val result = controller.onSubmit()(
- buildPost(routes.EoriNumberController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody(("eori", "GB123467800022"))
+ buildPost(
+ routes.EoriNumberController.onSubmit.url,
+ aSessionId,
+ completedDeclarationJourney,
+ formData = Seq("eori" -> "GB123467800022")
+ )
)
status(result) mustBe BAD_REQUEST
@@ -77,8 +81,12 @@ class EoriNumberControllerSpec extends DeclarationJourneyControllerSpec {
)
val result: Future[Result] = controller.onSubmit()(
- buildPost(routes.EoriNumberController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody(("eori", "GB123467800000"))
+ buildPost(
+ routes.EoriNumberController.onSubmit.url,
+ aSessionId,
+ completedDeclarationJourney,
+ formData = Seq("eori" -> "GB123467800000")
+ )
)
status(result) mustBe BAD_REQUEST
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala
index 5611d7c8d..800f02adb 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala
@@ -44,11 +44,11 @@ class ExciseAndRestrictedGoodsControllerSpec extends DeclarationJourneyControlle
)
forAll(declarationTypesTable) { importOrExport: DeclarationType =>
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport)
+ val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(ExciseAndRestrictedGoodsController.onPageLoad.url, aSessionId)
+ val request = buildGet(ExciseAndRestrictedGoodsController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -61,8 +61,13 @@ class ExciseAndRestrictedGoodsControllerSpec extends DeclarationJourneyControlle
"onSubmit" should {
s"redirect by delegating to the Navigator for $importOrExport" in {
- val request = buildPost(ExciseAndRestrictedGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "No")
+ val request =
+ buildPost(
+ ExciseAndRestrictedGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "No")
+ )
when(mockNavigator.nextPage(any[ExciseAndRestrictedGoodsRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(ValueWeightOfGoodsController.onPageLoad))
@@ -75,8 +80,13 @@ class ExciseAndRestrictedGoodsControllerSpec extends DeclarationJourneyControlle
}
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(ExciseAndRestrictedGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ ExciseAndRestrictedGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala
index 1ba44ec49..3f68fd29b 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala
@@ -46,11 +46,11 @@ class GoodsDestinationControllerSpec extends DeclarationJourneyControllerSpec wi
)
forAll(declarationTypesTable) { importOrExport: DeclarationType =>
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport)
+ val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(GoodsDestinationController.onPageLoad.url, aSessionId)
+ val request = buildGet(GoodsDestinationController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -66,8 +66,13 @@ class GoodsDestinationControllerSpec extends DeclarationJourneyControllerSpec wi
"onSubmit" should {
s"redirect for $importOrExport using Navigator" in {
- val request = buildPost(GoodsDestinationController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "GreatBritain")
+ val request =
+ buildPost(
+ GoodsDestinationController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "GreatBritain")
+ )
when(mockNavigator.nextPage(any[GoodsDestinationRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(ExciseAndRestrictedGoodsController.onPageLoad))
@@ -80,8 +85,13 @@ class GoodsDestinationControllerSpec extends DeclarationJourneyControllerSpec wi
}
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(GoodsDestinationController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ GoodsDestinationController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala
index d508291c8..a42c1bd53 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala
@@ -44,12 +44,17 @@ class GoodsInVehicleControllerSpec extends DeclarationJourneyControllerSpec {
declarationTypes.foreach { importOrExport =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport, goodsEntries = completedGoodsEntries(importOrExport))
+ DeclarationJourney(
+ aSessionId,
+ importOrExport,
+ isAssistedDigital = false,
+ goodsEntries = completedGoodsEntries(importOrExport)
+ )
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(GoodsInVehicleController.onPageLoad.url, aSessionId)
+ val request = buildGet(GoodsInVehicleController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
@@ -61,8 +66,13 @@ class GoodsInVehicleControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect by delegating to navigator for $importOrExport" in {
- val request = buildPost(GoodsInVehicleController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val request =
+ buildPost(
+ GoodsInVehicleController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Yes")
+ )
when(mockNavigator.nextPage(any[GoodsInVehicleRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(VehicleSizeController.onPageLoad))
@@ -76,8 +86,13 @@ class GoodsInVehicleControllerSpec extends DeclarationJourneyControllerSpec {
s"return 400 with any form errors for $importOrExport" in {
- val request = buildGet(GoodsInVehicleController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ GoodsInVehicleController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala
index abe1cf77f..fa6f39804 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala
@@ -48,7 +48,7 @@ class GoodsOriginControllerSpec extends DeclarationJourneyControllerSpec {
"onPageLoad" should {
"return 200 with radio buttons" in {
- val request = buildGet(GoodsOriginController.onPageLoad(1).url, aSessionId)
+ val request = buildGet(GoodsOriginController.onPageLoad(1).url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(1)(request)
val result = contentAsString(eventualResult)
@@ -60,8 +60,13 @@ class GoodsOriginControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to /purchase-details/1 after successful form submit with Yes by delegating to Navigator" in {
- val request = buildPost(GoodsOriginController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val request =
+ buildPost(
+ GoodsOriginController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Yes")
+ )
when(mockNavigator.nextPage(any[GoodsOriginRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(PurchaseDetailsController.onPageLoad(1)))
@@ -74,8 +79,13 @@ class GoodsOriginControllerSpec extends DeclarationJourneyControllerSpec {
}
s"return 400 with any form errors" in {
- val request = buildPost(GoodsOriginController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ GoodsOriginController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(1)(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala
index 167f28ce8..5928f7b7d 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala
@@ -17,7 +17,6 @@
package uk.gov.hmrc.merchandiseinbaggage.controllers
import play.api.test.Helpers._
-import uk.gov.hmrc.merchandiseinbaggage.connectors.MibConnector
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType
import uk.gov.hmrc.merchandiseinbaggage.model.api.DeclarationType.Import
import uk.gov.hmrc.merchandiseinbaggage.model.api.GoodsDestinations.GreatBritain
@@ -32,27 +31,25 @@ class GoodsOverThresholdControllerSpec extends DeclarationJourneyControllerSpec
private val view = app.injector.instanceOf[GoodsOverThresholdView]
private val calculatorService = app.injector.instanceOf[MibService]
- private val mibConnector = app.injector.instanceOf[MibConnector]
def controller(declarationJourney: DeclarationJourney): GoodsOverThresholdController =
new GoodsOverThresholdController(
controllerComponents,
stubProvider(declarationJourney),
calculatorService,
- mibConnector,
view
)
declarationTypes.foreach { importOrExport: DeclarationType =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport)
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
.copy(maybeGoodsDestination = Some(GreatBritain), goodsEntries = completedGoodsEntries(importOrExport))
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
givenAPaymentCalculation(aCalculationResult)
- val request = buildGet(routes.GoodsOverThresholdController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.GoodsOverThresholdController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala
index 9fda60a3e..93983f2d3 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala
@@ -30,12 +30,12 @@ class GoodsRemovedControllerSpec extends DeclarationJourneyControllerSpec {
new GoodsRemovedController(controllerComponents, stubProvider(declarationJourney), view)
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, Import).copy(maybeGoodsDestination = Some(GreatBritain))
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false).copy(maybeGoodsDestination = Some(GreatBritain))
"onPageLoad" should {
s"return 200 with expected content" in {
- val request = buildGet(routes.GoodsRemovedController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.GoodsRemovedController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala
index b7ce587c5..46f827990 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala
@@ -46,11 +46,14 @@ class GoodsTypeControllerSpec extends DeclarationJourneyControllerSpec {
declarationTypes.foreach { importOrExport: DeclarationType =>
journeyTypes.foreach { journeyType =>
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport).copy(journeyType = journeyType)
+ val journey: DeclarationJourney =
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
+ .copy(journeyType = journeyType)
+
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport for journeyType $journeyType" in {
- val request = buildGet(GoodsTypeController.onPageLoad(1).url, aSessionId)
+ val request = buildGet(GoodsTypeController.onPageLoad(1).url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(1)(request)
val result = contentAsString(eventualResult)
@@ -63,8 +66,14 @@ class GoodsTypeControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to next page after successful form submit for $importOrExport for journeyType $journeyType" in {
- val request = buildPost(GoodsTypeController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("category" -> "clothes")
+ val request =
+ buildPost(
+ GoodsTypeController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("category" -> "clothes")
+ )
+
val page: Call = if (importOrExport == Import) {
GoodsVatRateController.onPageLoad(1)
} else {
@@ -84,8 +93,13 @@ class GoodsTypeControllerSpec extends DeclarationJourneyControllerSpec {
}
s"return 400 with any form errors for $importOrExport for journeyType $journeyType" in {
- val request = buildPost(GoodsTypeController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("xyz" -> "clothes", "abc" -> "1")
+ val request =
+ buildPost(
+ GoodsTypeController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("xyz" -> "clothes", "abc" -> "1")
+ )
val eventualResult = controller(journey).onSubmit(1)(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala
index a72b2a6f6..6b542ff47 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala
@@ -45,12 +45,13 @@ class GoodsVatRateControllerSpec extends DeclarationJourneyControllerSpec {
private val journey: DeclarationJourney = DeclarationJourney(
aSessionId,
DeclarationType.Import,
+ isAssistedDigital = false,
goodsEntries = GoodsEntries(Seq(ImportGoodsEntry(maybeCategory = Some("clothes"))))
)
"onPageLoad" should {
"return 200 with radio buttons" in {
- val request = buildPost(GoodsVatRateController.onPageLoad(1).url, aSessionId)
+ val request = buildPost(GoodsVatRateController.onPageLoad(1).url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(1)(request)
val result = contentAsString(eventualResult)
@@ -66,8 +67,13 @@ class GoodsVatRateControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
"redirect to next page after successful form submit" in {
- val request = buildPost(GoodsVatRateController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Zero")
+ val request =
+ buildPost(
+ GoodsVatRateController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Zero")
+ )
when(mockNavigator.nextPage(any[GoodsVatRateRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(SearchGoodsCountryController.onPageLoad(1)))
@@ -79,8 +85,13 @@ class GoodsVatRateControllerSpec extends DeclarationJourneyControllerSpec {
}
"return 400 with any form errors" in {
- val request = buildGet(GoodsVatRateController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ GoodsVatRateController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(1)(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala
index 14eb3b71c..4b7c75565 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala
@@ -21,6 +21,7 @@ import org.mockito.MockitoSugar.{mock, when}
import play.api.mvc.Result
import play.api.test.Helpers._
import uk.gov.hmrc.merchandiseinbaggage.controllers.routes._
+import uk.gov.hmrc.merchandiseinbaggage.model.core.DeclarationJourney
import uk.gov.hmrc.merchandiseinbaggage.model.core.ImportExportChoices.{AddToExisting, MakeExport}
import uk.gov.hmrc.merchandiseinbaggage.navigation.ImportExportChoiceRequest
import uk.gov.hmrc.merchandiseinbaggage.views.html.ImportExportChoice
@@ -33,12 +34,13 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec
val view: ImportExportChoice = injector.instanceOf[ImportExportChoice]
val mockNavigator: Navigator = mock[Navigator]
+ val journey: DeclarationJourney = startedImportJourney.copy(isAssistedDigital = true)
val controller: ImportExportChoiceController =
new ImportExportChoiceController(
controllerComponents,
view,
actionBuilder,
- stubRepo(startedImportJourney),
+ stubRepo(journey),
mockNavigator
)
@@ -46,7 +48,7 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec
"return 200 with radio button" in {
givenTheUserIsAuthenticatedAndAuthorised()
- val request = buildGet(ImportExportChoiceController.onPageLoad.url, aSessionId)
+ val request = buildGet(ImportExportChoiceController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller.onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -64,8 +66,13 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec
"redirect with navigator adding 'new' to header" in {
givenTheUserIsAuthenticatedAndAuthorised()
- val request = buildGet(ImportExportChoiceController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> MakeExport.toString)
+ val request =
+ buildPost(
+ ImportExportChoiceController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> MakeExport.toString)
+ )
when(mockNavigator.nextPage(any[ImportExportChoiceRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(GoodsDestinationController.onPageLoad))
@@ -80,8 +87,13 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec
"redirect with navigator adding 'amend' to header" in {
givenTheUserIsAuthenticatedAndAuthorised()
- val request = buildGet(routes.ImportExportChoiceController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> AddToExisting.toString)
+ val request =
+ buildPost(
+ routes.ImportExportChoiceController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> AddToExisting.toString)
+ )
when(mockNavigator.nextPage(any[ImportExportChoiceRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(GoodsDestinationController.onPageLoad))
@@ -96,8 +108,13 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec
"return 400 with required form error" in {
givenTheUserIsAuthenticatedAndAuthorised()
- val request = buildGet(ImportExportChoiceController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "")
+ val request =
+ buildPost(
+ ImportExportChoiceController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "")
+ )
givenTheUserIsAuthenticatedAndAuthorised()
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala
index 602bfbd9d..d53e8117a 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala
@@ -46,11 +46,12 @@ class JourneyDetailsControllerSpec extends DeclarationJourneyControllerSpec {
declarationTypes.foreach { importOrExport =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport).copy(maybeIsACustomsAgent = Some(YesNo.No))
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
+ .copy(maybeIsACustomsAgent = Some(YesNo.No))
"onPageLoad" should {
s"return 200 with correct content for $importOrExport" in {
- val request = buildGet(JourneyDetailsController.onPageLoad.url, aSessionId)
+ val request = buildGet(JourneyDetailsController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -66,12 +67,17 @@ class JourneyDetailsControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to next page after successful form submit for $importOrExport" in {
val today = LocalDate.now()
- val request = buildPost(JourneyDetailsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody(
- "port" -> "ABZ",
- "dateOfTravel.day" -> today.getDayOfMonth.toString,
- "dateOfTravel.month" -> today.getMonthValue.toString,
- "dateOfTravel.year" -> today.getYear.toString
+ val request =
+ buildPost(
+ JourneyDetailsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq(
+ "port" -> "ABZ",
+ "dateOfTravel.day" -> today.getDayOfMonth.toString,
+ "dateOfTravel.month" -> today.getMonthValue.toString,
+ "dateOfTravel.year" -> today.getYear.toString
+ )
)
when(mockNavigator.nextPage(any[JourneyDetailsRequest])(any[ExecutionContext]))
@@ -84,8 +90,13 @@ class JourneyDetailsControllerSpec extends DeclarationJourneyControllerSpec {
}
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(JourneyDetailsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("port111" -> "ABZ")
+ val request =
+ buildPost(
+ JourneyDetailsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("port111" -> "ABZ")
+ )
val eventualResult = controller(givenADeclarationJourneyIsPersisted(journey)).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala
index 0a4f160d4..e77510dea 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala
@@ -18,6 +18,7 @@ package uk.gov.hmrc.merchandiseinbaggage.controllers
import play.api.test.Helpers._
import uk.gov.hmrc.merchandiseinbaggage.CoreTestData
+import uk.gov.hmrc.merchandiseinbaggage.auth.StrideAuthAction
import uk.gov.hmrc.merchandiseinbaggage.model.api.SessionId
import uk.gov.hmrc.merchandiseinbaggage.repositories.DeclarationJourneyRepository
import uk.gov.hmrc.merchandiseinbaggage.views.html.{ProgressDeletedView, ServiceTimeoutView}
@@ -30,7 +31,9 @@ class KeepAliveControllerSpec extends DeclarationJourneyControllerSpec with Core
val repo = app.injector.instanceOf[DeclarationJourneyRepository]
val deletedView = app.injector.instanceOf[ProgressDeletedView]
val serviceTimeoutView = app.injector.instanceOf[ServiceTimeoutView]
- val controller = new KeepAliveController(controllerComponents, actionBuilder, repo, deletedView, serviceTimeoutView)
+ val strideAction = app.injector.instanceOf[StrideAuthAction]
+ val controller =
+ new KeepAliveController(controllerComponents, actionBuilder, strideAction, repo, deletedView, serviceTimeoutView)
"return NoContent with no changes to declaration journey" in {
val id = SessionId("unchanged")
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NavigatorSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NavigatorSpec.scala
index 976d9370e..191b60b21 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NavigatorSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NavigatorSpec.scala
@@ -300,7 +300,14 @@ class NavigatorSpec extends DeclarationJourneyControllerSpec with PropertyBaseTa
val journey: DeclarationJourney =
completedDeclarationJourney.copy(declarationType = importOrExport, journeyType = newOrAmend)
val result: Future[Call] =
- nextPage(PreviousDeclarationDetailsRequest(journey, journey.toDeclaration, _ => Future(journey)))
+ nextPage(
+ PreviousDeclarationDetailsRequest(
+ journey,
+ journey.toDeclaration,
+ _ => Future(journey),
+ isAssistedDigital = journey.isAssistedDigital
+ )
+ )
result.futureValue mustBe ExciseAndRestrictedGoodsController.onPageLoad
}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala
index e3305b101..23475e17e 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala
@@ -43,11 +43,11 @@ class NewOrExistingControllerSpec extends DeclarationJourneyControllerSpec {
)
declarationTypes.foreach { importOrExport: DeclarationType =>
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport)
+ val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(NewOrExistingController.onPageLoad.url, aSessionId)
+ val request = buildGet(NewOrExistingController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -60,8 +60,13 @@ class NewOrExistingControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to /goods-destination after successful form submit with New for $importOrExport" in {
- val request = buildPost(NewOrExistingController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "New")
+ val request =
+ buildPost(
+ NewOrExistingController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "New")
+ )
when(mockNavigator.nextPage(any[NewOrExistingRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(GoodsDestinationController.onPageLoad))
@@ -74,8 +79,13 @@ class NewOrExistingControllerSpec extends DeclarationJourneyControllerSpec {
}
s"redirect to /retrieve-declaration after successful form submit with 'Add goods to an existing declaration' for $importOrExport" in {
- val request = buildPost(NewOrExistingController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Amend")
+ val request =
+ buildPost(
+ NewOrExistingController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Amend")
+ )
when(mockNavigator.nextPage(any[NewOrExistingRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(RetrieveDeclarationController.onPageLoad))
@@ -89,8 +99,13 @@ class NewOrExistingControllerSpec extends DeclarationJourneyControllerSpec {
}
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(NewOrExistingController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ NewOrExistingController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala
index f1528c5ee..718389442 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala
@@ -33,9 +33,10 @@ class NoDeclarationNeededControllerSpec extends DeclarationJourneyControllerSpec
s"return 200 with correct content" in {
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, Import).copy(maybeGoodsDestination = Some(GreatBritain))
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false)
+ .copy(maybeGoodsDestination = Some(GreatBritain))
- val request = buildGet(routes.NoDeclarationNeededController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.NoDeclarationNeededController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PaymentCalculationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PaymentCalculationControllerSpec.scala
index 791d79d68..ee766914d 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PaymentCalculationControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PaymentCalculationControllerSpec.scala
@@ -62,11 +62,12 @@ class PaymentCalculationControllerSpec extends DeclarationJourneyControllerSpec
val journey = DeclarationJourney(
aSessionId,
importOrExport,
+ isAssistedDigital = false,
maybeGoodsDestination = Some(GoodsDestinations.GreatBritain),
goodsEntries = completedGoodsEntries(importOrExport)
)
- val request = buildGet(PaymentCalculationController.onPageLoad.url, aSessionId)
+ val request = buildGet(PaymentCalculationController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
@@ -98,11 +99,12 @@ class PaymentCalculationControllerSpec extends DeclarationJourneyControllerSpec
DeclarationJourney(
SessionId("123"),
importOrExport,
+ isAssistedDigital = false,
maybeGoodsDestination = Some(GoodsDestinations.GreatBritain),
goodsEntries = overThresholdGoods(importOrExport)
)
- val request = buildGet(PaymentCalculationController.onPageLoad.url, aSessionId)
+ val request = buildGet(PaymentCalculationController.onPageLoad.url, aSessionId, journey)
val eventualResult =
controller(givenADeclarationJourneyIsPersisted(journey), OverThreshold).onPageLoad()(request)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsControllerSpec.scala
index 8169fe89f..b309633a1 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PreviousDeclarationDetailsControllerSpec.scala
@@ -73,7 +73,7 @@ class PreviousDeclarationDetailsControllerSpec extends DeclarationJourneyControl
givenPersistedDeclarationIsFound(persistedDeclaration.get, aDeclarationId)
- val request = buildGet(PreviousDeclarationDetailsController.onPageLoad.url, aSessionId)
+ val request = buildGet(PreviousDeclarationDetailsController.onPageLoad.url, aSessionId, importJourney)
val eventualResult = controller.onPageLoad()(request)
status(eventualResult) mustBe OK
@@ -96,8 +96,14 @@ class PreviousDeclarationDetailsControllerSpec extends DeclarationJourneyControl
aDeclarationId
)
- val request =
- buildGet(PreviousDeclarationDetailsController.onPageLoad.url, SessionId()).withSession("declarationId" -> "987")
+ val request =
+ buildGet(
+ PreviousDeclarationDetailsController.onPageLoad.url,
+ SessionId(),
+ importJourney,
+ sessionData = Seq("declarationId" -> "987")
+ )
+
val eventualResult = controller.onPageLoad()(request)
status(eventualResult) mustBe SEE_OTHER
@@ -130,7 +136,7 @@ class PreviousDeclarationDetailsControllerSpec extends DeclarationJourneyControl
givenPersistedDeclarationIsFound(persistedDeclaration.get, aDeclarationId)
- val request = buildGet(PreviousDeclarationDetailsController.onPageLoad.url, aSessionId)
+ val request = buildGet(PreviousDeclarationDetailsController.onPageLoad.url, aSessionId, importJourney)
val eventualResult = controller.onPageLoad()(request)
status(eventualResult) mustBe OK
@@ -166,7 +172,7 @@ class PreviousDeclarationDetailsControllerSpec extends DeclarationJourneyControl
givenPersistedDeclarationIsFound(persistedDeclaration.get, aDeclarationId)
- val request = buildGet(PreviousDeclarationDetailsController.onPageLoad.url, aSessionId)
+ val request = buildGet(PreviousDeclarationDetailsController.onPageLoad.url, aSessionId, exportJourney)
val eventualResult = controller.onPageLoad()(request)
status(eventualResult) mustBe OK
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala
index ab8bf57df..249b2effb 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala
@@ -52,13 +52,14 @@ class PurchaseDetailsControllerSpec extends DeclarationJourneyControllerSpec {
val journey: DeclarationJourney = DeclarationJourney(
aSessionId,
importOrExport,
+ isAssistedDigital = false,
goodsEntries = GoodsEntries(Seq(ImportGoodsEntry(maybeCategory = Some("clothes"))))
)
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(PurchaseDetailsController.onPageLoad(1).url, aSessionId)
+ val request = buildGet(PurchaseDetailsController.onPageLoad(1).url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(1)(request)
val result = contentAsString(eventualResult)
@@ -79,8 +80,13 @@ class PurchaseDetailsControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to next page after successful form submit for $importOrExport" in {
- val request = buildPost(SearchGoodsCountryController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("price" -> "20", "currency" -> "EUR")
+ val request =
+ buildPost(
+ SearchGoodsCountryController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("price" -> "20", "currency" -> "EUR")
+ )
when(mockNavigator.nextPage(any[PurchaseDetailsRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(ReviewGoodsController.onPageLoad))
@@ -94,8 +100,13 @@ class PurchaseDetailsControllerSpec extends DeclarationJourneyControllerSpec {
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(SearchGoodsCountryController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("abcd" -> "in valid")
+ val request =
+ buildPost(
+ SearchGoodsCountryController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("abcd" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(1)(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RemoveGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RemoveGoodsControllerSpec.scala
index 70413a779..81af95a66 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RemoveGoodsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RemoveGoodsControllerSpec.scala
@@ -40,8 +40,13 @@ class RemoveGoodsControllerSpec extends DeclarationJourneyControllerSpec with Co
"delegate to navigator for navigation in" in {
givenADeclarationJourneyIsPersisted(completedDeclarationJourney)
- val postReq = buildPost(RemoveGoodsController.onPageLoad(1).url, completedDeclarationJourney.sessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val postReq =
+ buildPost(
+ RemoveGoodsController.onPageLoad(1).url,
+ completedDeclarationJourney.sessionId,
+ completedDeclarationJourney,
+ formData = Seq("value" -> "Yes")
+ )
when(mockNavigator.nextPage(any[RemoveGoodsRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(CheckYourAnswersController.onPageLoad))
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala
index daf619b3c..a2056d044 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala
@@ -49,15 +49,15 @@ class RetrieveDeclarationControllerSpec extends DeclarationJourneyControllerSpec
view
)
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, Import)
+ val journey: DeclarationJourney = DeclarationJourney(aSessionId, Import, isAssistedDigital = false)
//TODO create UI test for content
forAll(declarationTypesTable) { importOrExport: DeclarationType =>
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport)
+ val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
"onPageLoad" should {
s"return 200 with expected content for $importOrExport" in {
- val request = buildGet(RetrieveDeclarationController.onPageLoad.url, aSessionId)
+ val request = buildGet(RetrieveDeclarationController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -78,8 +78,13 @@ class RetrieveDeclarationControllerSpec extends DeclarationJourneyControllerSpec
"onSubmit" should {
"redirect by delegating to Navigator" in {
givenFindByDeclarationReturnStatus(mibReference, eori, NOT_FOUND)
- val request = buildPost(RetrieveDeclarationController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("mibReference" -> mibReference.value, "eori" -> eori.value)
+ val request =
+ buildPost(
+ RetrieveDeclarationController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("mibReference" -> mibReference.value, "eori" -> eori.value)
+ )
when(mockNavigator.nextPage(any[NavigationRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(DeclarationNotFoundController.onPageLoad))
@@ -92,8 +97,13 @@ class RetrieveDeclarationControllerSpec extends DeclarationJourneyControllerSpec
"redirect to /internal-server-error after successful form submit but some unexpected error is thrown from the BE" in {
givenFindByDeclarationReturnStatus(mibReference, eori, INTERNAL_SERVER_ERROR)
- val request = buildPost(RetrieveDeclarationController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("mibReference" -> mibReference.value, "eori" -> eori.value)
+ val request =
+ buildPost(
+ RetrieveDeclarationController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("mibReference" -> mibReference.value, "eori" -> eori.value)
+ )
val result: Future[Result] = controller(journey).onSubmit(request)
@@ -102,8 +112,14 @@ class RetrieveDeclarationControllerSpec extends DeclarationJourneyControllerSpec
}
"return 400 for invalid form data" in {
- val request = buildPost(RetrieveDeclarationController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("mibReference" -> "XAMB0000010", "eori" -> "GB12345")
+ val request =
+ buildPost(
+ RetrieveDeclarationController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("mibReference" -> "XAMB0000010", "eori" -> "GB12345")
+ )
+
val eventualResult = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala
index b93393671..630b354f2 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala
@@ -55,11 +55,11 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
forAll(declarationTypesTable) { importOrExport =>
val entries = completedGoodsEntries(importOrExport)
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport, goodsEntries = entries)
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false, goodsEntries = entries)
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(ReviewGoodsController.onPageLoad.url, aSessionId)
+ val request = buildGet(ReviewGoodsController.onPageLoad.url, aSessionId, journey)
val allowance =
if (importOrExport == Export) {
aThresholdAllowance.copy(currentGoods = entries.declarationGoodsIfComplete.get)
@@ -90,7 +90,7 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
}
s"redirect to CannotAccessPageController when no ThresholdAllowance is received from mibService for $importOrExport" in {
- val request = buildGet(ReviewGoodsController.onPageLoad.url, aSessionId)
+ val request = buildGet(ReviewGoodsController.onPageLoad.url, aSessionId, journey)
when(
mockMibService.thresholdAllowance(
@@ -112,8 +112,13 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
"onSubmit" should {
s"redirect to next page after successful form submit with Yes for $importOrExport by delegating to Navigator" in {
- val request = buildPost(ReviewGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val request =
+ buildPost(
+ ReviewGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Yes")
+ )
when(
mockMibService.thresholdAllowance(
@@ -136,8 +141,13 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
}
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(ReviewGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ ReviewGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
when(
mockMibService.thresholdAllowance(
@@ -180,7 +190,12 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
s"redirect to next page after successful form submit with No for $importOrExport" in {
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport, goodsEntries = completedGoodsEntries(importOrExport))
+ DeclarationJourney(
+ aSessionId,
+ importOrExport,
+ isAssistedDigital = false,
+ goodsEntries = completedGoodsEntries(importOrExport)
+ )
.copy(journeyType = Amend)
when(
@@ -196,8 +211,13 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
when(mockMibService.amendPlusOriginalCalculations(any[DeclarationJourney])(any[HeaderCarrier]))
.thenReturn(OptionT.pure[Future](CalculationResponse(CalculationResults(Seq.empty), WithinThreshold)))
- val request = buildPost(ReviewGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "No")
+ val request =
+ buildPost(
+ ReviewGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "No")
+ )
val expectedRedirect =
if (importOrExport == Export) {
@@ -235,7 +255,7 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr
when(mockNavigator.nextPage(any[ReviewGoodsRequest])(any[ExecutionContext]))
.thenReturn(Future.successful(GoodsOverThresholdController.onPageLoad))
- val request = buildPost(ReviewGoodsController.onSubmit.url, aSessionId)
+ val request = buildPost(ReviewGoodsController.onSubmit.url, aSessionId, journey)
val result: Future[Result] = controller(journey).onSubmit()(request)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala
index 9513c6df7..a7f075376 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala
@@ -43,12 +43,13 @@ class SearchGoodsCountryControllerSpec extends DeclarationJourneyControllerSpec
DeclarationJourney(
SessionId("123"),
Export,
+ isAssistedDigital = false,
goodsEntries = GoodsEntries(Seq(completedExportGoods.copy(maybePurchaseDetails = None)))
)
"onPageLoad" should {
s"return 200 with correct content Export" in {
- val request = buildGet(routes.SearchGoodsCountryController.onPageLoad(1).url, aSessionId)
+ val request = buildGet(routes.SearchGoodsCountryController.onPageLoad(1).url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(1)(request)
val result = contentAsString(eventualResult)
@@ -62,8 +63,13 @@ class SearchGoodsCountryControllerSpec extends DeclarationJourneyControllerSpec
"onSubmit" should {
s"redirect to next page after successful form submit for Export" in {
- val request = buildPost(routes.SearchGoodsCountryController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("country" -> "AF")
+ val request =
+ buildPost(
+ routes.SearchGoodsCountryController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("country" -> "AF")
+ )
val eventualResult = controller(journey).onSubmit(1)(request)
@@ -72,8 +78,13 @@ class SearchGoodsCountryControllerSpec extends DeclarationJourneyControllerSpec
}
s"return 400 with any form errors for Export" in {
- val request = buildPost(routes.SearchGoodsCountryController.onSubmit(1).url, aSessionId)
- .withFormUrlEncodedBody("country" -> "in valid")
+ val request =
+ buildPost(
+ routes.SearchGoodsCountryController.onSubmit(1).url,
+ aSessionId,
+ journey,
+ formData = Seq("country" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(1)(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartExportControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartExportControllerSpec.scala
index 750e7e2de..88433ba1c 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartExportControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartExportControllerSpec.scala
@@ -31,7 +31,7 @@ class StartExportControllerSpec extends DeclarationJourneyControllerSpec with Co
"onPageLoad" should {
"store redirect" in {
val url = routes.StartExportController.onPageLoad.url
- val request = buildGet(url, aSessionId)
+ val request = buildGet(url, aSessionId, startedExportJourney)
val result = controller().onPageLoad()(request)
status(result) mustBe Status.SEE_OTHER
@@ -42,7 +42,7 @@ class StartExportControllerSpec extends DeclarationJourneyControllerSpec with Co
"process-request" should {
"store the declaration type in mongo" in {
val url = routes.StartExportController.processRequest.url
- val request = buildPost(url, aSessionId)
+ val request = buildPost(url, aSessionId, startedExportJourney)
val result = controller().processRequest()(request)
status(result) mustBe Status.SEE_OTHER
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartImportControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartImportControllerSpec.scala
index 42abd955f..91b09ee10 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartImportControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/StartImportControllerSpec.scala
@@ -31,7 +31,7 @@ class StartImportControllerSpec extends DeclarationJourneyControllerSpec with Co
"onPageLoad" should {
"store redirect" in {
val url = routes.StartImportController.onPageLoad.url
- val request = buildGet(url, aSessionId)
+ val request = buildGet(url, aSessionId, startedImportJourney)
val result = controller().onPageLoad()(request)
status(result) mustBe Status.SEE_OTHER
@@ -42,7 +42,7 @@ class StartImportControllerSpec extends DeclarationJourneyControllerSpec with Co
"process-request" should {
"store the declaration type in mongo" in {
val url = routes.StartImportController.processRequest.url
- val request = buildPost(url, aSessionId)
+ val request = buildPost(url, aSessionId, startedImportJourney)
val result = controller().processRequest()(request)
status(result) mustBe Status.SEE_OTHER
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala
index 93d466498..45a7a8d88 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala
@@ -39,11 +39,12 @@ class TravellerDetailsControllerSpec extends DeclarationJourneyControllerSpec {
view
)
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, Import).copy(maybeIsACustomsAgent = Some(YesNo.No))
+ val journey: DeclarationJourney =
+ DeclarationJourney(aSessionId, Import, isAssistedDigital = false).copy(maybeIsACustomsAgent = Some(YesNo.No))
"onPageLoad" should {
s"return 200 with correct content for" in {
- val request = buildGet(routes.TravellerDetailsController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.TravellerDetailsController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -58,8 +59,13 @@ class TravellerDetailsControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to next page after successful form submit" in {
- val request = buildPost(routes.TravellerDetailsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("firstName" -> "Foo", "lastName" -> "Bar")
+ val request =
+ buildPost(
+ routes.TravellerDetailsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("firstName" -> "Foo", "lastName" -> "Bar")
+ )
val eventualResult = controller(journey).onSubmit(request)
status(eventualResult) mustBe SEE_OTHER
@@ -67,8 +73,13 @@ class TravellerDetailsControllerSpec extends DeclarationJourneyControllerSpec {
}
s"return 400 with required form errors" in {
- val request = buildPost(routes.EoriNumberController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("firstName" -> "", "lastName" -> "")
+ val request =
+ buildPost(
+ routes.EoriNumberController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("firstName" -> "", "lastName" -> "")
+ )
val eventualResult = controller(givenADeclarationJourneyIsPersisted(journey)).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala
index efa90886a..52b2c7ea0 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala
@@ -42,11 +42,12 @@ class ValueWeightOfGoodsControllerSpec extends DeclarationJourneyControllerSpec
declarationTypes.foreach { importOrExport: DeclarationType =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport).copy(maybeGoodsDestination = Some(GreatBritain))
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
+ .copy(maybeGoodsDestination = Some(GreatBritain))
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(routes.ValueWeightOfGoodsController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.ValueWeightOfGoodsController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad(request)
val result = contentAsString(eventualResult)
@@ -58,8 +59,13 @@ class ValueWeightOfGoodsControllerSpec extends DeclarationJourneyControllerSpec
"onSubmit" should {
s"redirect to /goods-type after successful form submit with Yes for $importOrExport" in {
- val request = buildPost(routes.ValueWeightOfGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val request =
+ buildPost(
+ routes.ValueWeightOfGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Yes")
+ )
val eventualResult = controller(journey).onSubmit(request)
@@ -69,8 +75,13 @@ class ValueWeightOfGoodsControllerSpec extends DeclarationJourneyControllerSpec
}
s"return 400 with any form errors for $importOrExport" in {
- val request = buildPost(routes.ValueWeightOfGoodsController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ routes.ValueWeightOfGoodsController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala
index 7b0f895d3..e1b44598d 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala
@@ -37,12 +37,13 @@ class VehicleRegistrationNumberControllerSpec extends DeclarationJourneyControll
)
declarationTypes.foreach { importOrExport =>
- val journey: DeclarationJourney = DeclarationJourney(aSessionId, importOrExport)
+ val journey: DeclarationJourney =
+ DeclarationJourney(aSessionId, importOrExport, isAssistedDigital = false)
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(routes.VehicleRegistrationNumberController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.VehicleRegistrationNumberController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
status(eventualResult) mustBe OK
@@ -55,8 +56,13 @@ class VehicleRegistrationNumberControllerSpec extends DeclarationJourneyControll
"onSubmit" should {
s"redirect to next page after successful form submit for $importOrExport" in {
- val request = buildPost(routes.VehicleRegistrationNumberController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "KM04 123")
+ val request =
+ buildPost(
+ routes.VehicleRegistrationNumberController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "KM04 123")
+ )
val eventualResult = controller(journey).onSubmit()(request)
@@ -66,8 +72,13 @@ class VehicleRegistrationNumberControllerSpec extends DeclarationJourneyControll
s"return 400 with required form error for $importOrExport" in {
- val request = buildGet(routes.VehicleRegistrationNumberController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value123" -> "")
+ val request =
+ buildPost(
+ routes.VehicleRegistrationNumberController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value123" -> "")
+ )
val eventualResult = controller(journey).onSubmit()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala
index 677770f2d..99745b18d 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala
@@ -38,12 +38,17 @@ class VehicleSizeControllerSpec extends DeclarationJourneyControllerSpec {
declarationTypes.foreach { importOrExport =>
val journey: DeclarationJourney =
- DeclarationJourney(aSessionId, importOrExport, goodsEntries = completedGoodsEntries(importOrExport))
+ DeclarationJourney(
+ aSessionId,
+ importOrExport,
+ isAssistedDigital = false,
+ goodsEntries = completedGoodsEntries(importOrExport)
+ )
"onPageLoad" should {
s"return 200 with radio buttons for $importOrExport" in {
- val request = buildGet(routes.VehicleSizeController.onPageLoad.url, aSessionId)
+ val request = buildGet(routes.VehicleSizeController.onPageLoad.url, aSessionId, journey)
val eventualResult = controller(journey).onPageLoad()(request)
val result = contentAsString(eventualResult)
@@ -56,8 +61,14 @@ class VehicleSizeControllerSpec extends DeclarationJourneyControllerSpec {
"onSubmit" should {
s"redirect to /vehicle-registration-number after successful form submit with Yes for $importOrExport" in {
- val request = buildPost(routes.VehicleSizeController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "Yes")
+ val request =
+ buildPost(
+ routes.VehicleSizeController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "Yes")
+ )
+
val eventualResult = controller(journey).onSubmit()(request)
status(eventualResult) mustBe SEE_OTHER
@@ -67,8 +78,13 @@ class VehicleSizeControllerSpec extends DeclarationJourneyControllerSpec {
s"return 400 with any form errors for $importOrExport" in {
- val request = buildGet(routes.VehicleSizeController.onSubmit.url, aSessionId)
- .withFormUrlEncodedBody("value" -> "in valid")
+ val request =
+ buildPost(
+ routes.VehicleSizeController.onSubmit.url,
+ aSessionId,
+ journey,
+ formData = Seq("value" -> "in valid")
+ )
val eventualResult = controller(journey).onSubmit()(request)
val result = contentAsString(eventualResult)
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/model/api/AmendmentSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/model/api/AmendmentSpec.scala
deleted file mode 100644
index e350c89a1..000000000
--- a/test/uk/gov/hmrc/merchandiseinbaggage/model/api/AmendmentSpec.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2024 HM Revenue & Customs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package uk.gov.hmrc.merchandiseinbaggage.model.api
-
-import uk.gov.hmrc.merchandiseinbaggage.{BaseSpec, CoreTestData}
-
-import java.time.LocalDateTime
-import java.time.temporal.ChronoUnit
-
-class AmendmentSpec extends BaseSpec with CoreTestData {
-
- "populate the source to AssistedDigital if internal frontend" in {
- val stub = new JourneySourceFinder {
- override def findSource: Option[String] = Some("AssistedDigital")
- }
- Amendment(
- 1,
- LocalDateTime.now.truncatedTo(ChronoUnit.MILLIS),
- aDeclarationGood,
- source = stub.findSource
- ).source mustBe Some("AssistedDigital")
- }
-
- "populate the source to Digital if public facing" in new JourneySourceFinder {
- override lazy val isAssistedDigital: Boolean = false
- Amendment(1, LocalDateTime.now.truncatedTo(ChronoUnit.MILLIS), aDeclarationGood).source mustBe Some("Digital")
- }
-}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinderSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinderSpec.scala
deleted file mode 100644
index ec32aad66..000000000
--- a/test/uk/gov/hmrc/merchandiseinbaggage/model/api/JourneySourceFinderSpec.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2024 HM Revenue & Customs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package uk.gov.hmrc.merchandiseinbaggage.model.api
-
-import uk.gov.hmrc.merchandiseinbaggage.BaseSpec
-
-class JourneySourceFinderSpec extends BaseSpec {
-
- "finds source AssistedDigital if internal frontend" in new JourneySourceFinder {
- override lazy val isAssistedDigital: Boolean = true
- findSource mustBe Some("AssistedDigital")
- }
-
- "finds source Digital if public facing" in new JourneySourceFinder {
- override lazy val isAssistedDigital: Boolean = false
- findSource mustBe Some("Digital")
- }
-}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourneySpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourneySpec.scala
index 9f9fbab72..7eefd7261 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourneySpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationJourneySpec.scala
@@ -31,7 +31,7 @@ class DeclarationJourneySpec extends BaseSpec with CoreTestData with PropertyBas
forAll(journeyTypesTable) { journeyType =>
s"instantiate a declaration journey for $declarationType $journeyType" in {
val sessionId = aSessionId
- val actual = DeclarationJourney(sessionId, declarationType, journeyType)
+ val actual = DeclarationJourney(sessionId, declarationType, isAssistedDigital = false, journeyType)
actual.sessionId mustBe sessionId
actual.declarationType mustBe declarationType
actual.journeyType mustBe journeyType
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationSpec.scala
index 192a71c68..5d5e74565 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/model/core/DeclarationSpec.scala
@@ -209,7 +209,8 @@ class DeclarationSpec extends BaseSpecWithApplication with CoreTestData {
completedDeclarationJourney.maybeRegistrationNumber.get
),
now,
- reference
+ reference,
+ source = Some("Digital")
)
)
}
@@ -405,31 +406,6 @@ class DeclarationSpec extends BaseSpecWithApplication with CoreTestData {
}
}
- "source is AssistedDigital if internal" in {
- val stub = new JourneySourceFinder {
- override def findSource: Option[String] = Some("AssistedDigital")
- }
- Declaration(
- aDeclarationId,
- aSessionId,
- Import,
- GreatBritain,
- aDeclarationGood,
- Name("xx", "yy"),
- None,
- None,
- Eori("GB123"),
- JourneyInSmallVehicle(
- journeyPort,
- JourneyDetailsEntry("BH", LocalDate.now).dateOfTravel,
- "Lx123"
- ),
- LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS),
- MibReference("xx"),
- source = stub.findSource
- ).source mustBe Some("AssistedDigital")
- }
-
"return the latest added goods" in {
val declarationWithGoods = Declaration(
aDeclarationId,
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/scheduler/ScheduledJobSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/scheduler/ScheduledJobSpec.scala
index 27df77c43..d7c84ecb3 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/scheduler/ScheduledJobSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/scheduler/ScheduledJobSpec.scala
@@ -148,15 +148,15 @@ class ScheduledJobSpec extends AnyWordSpecLike with Matchers with MockitoSugar {
|""".stripMargin
}
- "scheduler called if enabled and valid cron config" in new Setup("*/10_0_0-23_?_*_*_*", true) {
+ "scheduler called if enabled and valid cron config" in new Setup("*/10_0_0-23_?_*_*_*", enabled = true) {
job.schedule shouldBe true
}
- "scheduler NOT called if not enabled and cron config invalid" in new Setup("testInvalidCronString", false) {
+ "scheduler NOT called if not enabled and cron config invalid" in new Setup("testInvalidCronString", enabled = false) {
job.schedule shouldBe false
}
- "scheduler NOT called if enabled and cron config invalid" in new Setup("testInvalidCronString", true) {
+ "scheduler NOT called if enabled and cron config invalid" in new Setup("testInvalidCronString", enabled = true) {
job.schedule shouldBe false
}
}
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/utils/ObfuscateSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/utils/ObfuscateSpec.scala
index de18b971e..866f18213 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/utils/ObfuscateSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/utils/ObfuscateSpec.scala
@@ -55,6 +55,7 @@ class ObfuscateSpec extends BaseSpec with CoreTestData {
DeclarationJourney(
aSessionId,
Import,
+ isAssistedDigital = false,
New,
createdAt,
maybeExciseOrRestrictedGoods,
diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/view/ViewUtilsSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/view/ViewUtilsSpec.scala
index f4624e21e..634d326e5 100644
--- a/test/uk/gov/hmrc/merchandiseinbaggage/view/ViewUtilsSpec.scala
+++ b/test/uk/gov/hmrc/merchandiseinbaggage/view/ViewUtilsSpec.scala
@@ -30,7 +30,7 @@ class ViewUtilsSpec extends BaseSpec with CoreTestData {
maybeTotalCalculationResult = Some(calculationResultsOverLimit)
)
- proofOfOriginNeeded(decl) mustBe true
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe true
}
"false if Declaration < £1000 paid and no Amendments" in {
@@ -39,7 +39,7 @@ class ViewUtilsSpec extends BaseSpec with CoreTestData {
maybeTotalCalculationResult = Some(calculationResultsUnderLimit)
)
- proofOfOriginNeeded(decl) mustBe false
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe false
}
"true if Declaration and Amendments > £1000" in {
@@ -54,7 +54,7 @@ class ViewUtilsSpec extends BaseSpec with CoreTestData {
amendments = firstAmendmentModified +: declarationWithAmendment.amendments.tail
)
- proofOfOriginNeeded(decl) mustBe true
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe true
}
"false if Declaration paid and Amendments > £1000 but UNPAID" in {
@@ -69,7 +69,7 @@ class ViewUtilsSpec extends BaseSpec with CoreTestData {
amendments = firstAmendmentModified +: declarationWithAmendment.amendments.tail
)
- proofOfOriginNeeded(decl) mustBe false
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe false
}
"true if Declaration paid and 3 Amendments last > £1000" in {
@@ -106,7 +106,7 @@ class ViewUtilsSpec extends BaseSpec with CoreTestData {
amendments = amendmentsModified
)
- proofOfOriginNeeded(decl) mustBe true
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe true
}
"false if Declaration paid and 3 Amendments last No payment" in {
@@ -143,13 +143,13 @@ class ViewUtilsSpec extends BaseSpec with CoreTestData {
amendments = amendmentsModified
)
- proofOfOriginNeeded(decl) mustBe true
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe true
}
"false if Declaration is Export" in {
val decl = declaration.copy(declarationType = Export)
- proofOfOriginNeeded(decl) mustBe false
+ proofOfOriginNeeded(decl, isAssistedDigital = false) mustBe false
}
}
}