Skip to content

Commit a59547f

Browse files
authored
Merge pull request #16 from hmrc/version
Update versions and fix issue with parsing
2 parents b40db81 + 5215235 commit a59547f

11 files changed

+44
-21
lines changed

app/controllers/UserAllowListCheckController.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import play.api.i18n.{I18nSupport, Messages}
2424
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
2525
import uk.gov.hmrc.internalauth.client.*
2626
import uk.gov.hmrc.internalauth.client.Predicate.Permission
27-
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
27+
import uk.gov.hmrc.play.bootstrap.frontend.controller.{FrontendBaseController, FrontendController}
2828
import views.html.UserAllowListCheckView
2929

3030
import javax.inject.{Inject, Singleton}
@@ -37,7 +37,7 @@ class UserAllowListCheckController @Inject()(
3737
view: UserAllowListCheckView,
3838
formProvider: AllowListEntryFormProvider,
3939
connector: UserAllowListConnector
40-
)(implicit ec: ExecutionContext) extends FrontendBaseController with I18nSupport {
40+
)(implicit ec: ExecutionContext) extends FrontendController(controllerComponents) with I18nSupport {
4141

4242
private def form: Form[AllowListEntry] = formProvider()
4343

@@ -61,8 +61,8 @@ class UserAllowListCheckController @Inject()(
6161
Ok(view(form, service))
6262
}
6363

64-
def onSubmit(service: String): Action[AnyContent] =
65-
authorised(service).async { implicit request =>
64+
def onSubmit(service: String): Action[Map[String, Seq[String]]] =
65+
authorised(service).async(parse.formUrlEncoded) { implicit request =>
6666
form.bindFromRequest().fold(
6767
formWithErrors =>
6868
Future.successful(BadRequest(view(formWithErrors, service))),

app/controllers/UserAllowListClearController.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class UserAllowListClearController @Inject()(
6060
Ok(view(form, service))
6161
}
6262

63-
def onSubmit(service: String): Action[AnyContent] =
64-
authorised(service).async { implicit request =>
63+
def onSubmit(service: String): Action[Map[String, Seq[String]]] =
64+
authorised(service).async(parse.formUrlEncoded) { implicit request =>
6565
form.bindFromRequest().fold(
6666
formWithErrors =>
6767
Future.successful(BadRequest(view(formWithErrors, service))),

app/controllers/UserAllowListDeleteController.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class UserAllowListDeleteController @Inject()(
6161
Ok(view(form, service))
6262
}
6363

64-
def onSubmit(service: String): Action[AnyContent] =
65-
authorised(service).async { implicit request =>
64+
def onSubmit(service: String): Action[Map[String, Seq[String]]] =
65+
authorised(service).async(parse.formUrlEncoded) { implicit request =>
6666
form.bindFromRequest().fold(
6767
formWithErrors =>
6868
Future.successful(BadRequest(view(formWithErrors, service))),

app/controllers/UserAllowListSetController.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class UserAllowListSetController @Inject() (
6161
Ok(view(form, service))
6262
}
6363

64-
def onSubmit(service: String): Action[AnyContent] =
65-
authorised(service).async { implicit request =>
64+
def onSubmit(service: String): Action[Map[String, Seq[String]]] =
65+
authorised(service).async(parse.formUrlEncoded) { implicit request =>
6666
form.bindFromRequest().fold(
6767
formWithErrors =>
6868
Future.successful(BadRequest(view(formWithErrors, service))),

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import uk.gov.hmrc.DefaultBuildSettings
22

33
ThisBuild / majorVersion := 0
4-
ThisBuild / scalaVersion := "3.3.3"
4+
ThisBuild / scalaVersion := "3.3.6"
55

66
lazy val microservice = Project("user-allow-list-admin-frontend", file("."))
77
.enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin)

project/AppDependencies.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import sbt._
22

33
object AppDependencies {
44

5-
private val bootstrapVersion = "9.12.0"
5+
private val bootstrapVersion = "10.5.0"
66

77
val compile = Seq(
88
"uk.gov.hmrc" %% "bootstrap-frontend-play-30" % bootstrapVersion,
9-
"uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "12.1.0",
10-
"uk.gov.hmrc" %% "internal-auth-client-play-30" % "4.0.0"
9+
"uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "12.31.0",
10+
"uk.gov.hmrc" %% "internal-auth-client-play-30" % "4.3.0"
1111
)
1212

1313
val test = Seq(

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resolvers += Resolver.typesafeRepo("releases")
44

55
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.24.0")
66
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.6.0")
7-
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.7")
7+
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.9")
88
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.3.1")
9-
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.2")
9+
addSbtPlugin("com.github.sbt" % "sbt-gzip" % "2.0.0")
1010
addSbtPlugin("io.github.irundaia" % "sbt-sassify" % "1.5.2")

test/controllers/UserAllowListCheckControllerSpec.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import views.html.UserAllowListCheckView
3838
import scala.concurrent.ExecutionContext.global
3939
import scala.concurrent.Future
4040

41-
class UserAllowListCheckControllerSpec extends AnyFreeSpec with Matchers with ScalaFutures with MockitoSugar with BeforeAndAfterEach with OptionValues {
41+
class UserAllowListCheckControllerSpec extends AnyFreeSpec with Matchers with ScalaFutures with MockitoSugar with BeforeAndAfterEach with OptionValues
42+
{
4243

4344
override def beforeEach(): Unit = {
4445
super.beforeEach()
@@ -110,6 +111,7 @@ class UserAllowListCheckControllerSpec extends AnyFreeSpec with Matchers with Sc
110111
"feature" -> "feature",
111112
"value" -> "a"
112113
)
114+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
113115
val result = route(app, request).value
114116
status(result) mustBe SEE_OTHER
115117
redirectLocation(result).value mustEqual routes.UserAllowListCheckController.onPageLoad("service").url
@@ -127,6 +129,7 @@ class UserAllowListCheckControllerSpec extends AnyFreeSpec with Matchers with Sc
127129
"feature" -> "feature",
128130
"value" -> "a"
129131
)
132+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
130133
val result = route(app, request).value
131134
status(result) mustBe SEE_OTHER
132135
redirectLocation(result).value mustEqual routes.UserAllowListCheckController.onPageLoad("service").url
@@ -160,7 +163,9 @@ class UserAllowListCheckControllerSpec extends AnyFreeSpec with Matchers with Sc
160163
}
161164

162165
"must fail when the user is not authenticated" in {
163-
val request = FakeRequest(POST, routes.UserAllowListCheckController.onSubmit("service").url) // no auth token
166+
val request = FakeRequest(POST, routes.UserAllowListCheckController.onSubmit("service").url)
167+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
168+
// no auth token
164169
val result = route(app, request).value
165170
status(result) mustBe SEE_OTHER
166171
}
@@ -169,6 +174,7 @@ class UserAllowListCheckControllerSpec extends AnyFreeSpec with Matchers with Sc
169174
when(mockStubBehaviour.stubAuth[String](any(), any())).thenReturn(Future.failed(new RuntimeException()))
170175
val request = FakeRequest(POST, routes.UserAllowListCheckController.onSubmit("service").url)
171176
.withSession("authToken" -> "Token some-token")
177+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
172178
route(app, request).value.failed.futureValue
173179
}
174180
}

test/controllers/UserAllowListClearControllerSpec.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class UserAllowListClearControllerSpec extends AnyFreeSpec with Matchers with Sc
110110
.withFormUrlEncodedBody(
111111
"feature" -> "feature"
112112
)
113+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
113114
val result = route(app, request).value
114115
status(result) mustBe SEE_OTHER
115116
redirectLocation(result).value mustEqual routes.ServiceSummaryController.onPageLoad("service").url
@@ -124,6 +125,7 @@ class UserAllowListClearControllerSpec extends AnyFreeSpec with Matchers with Sc
124125
val request = FakeRequest(POST, routes.UserAllowListClearController.onSubmit("service").url)
125126
.withSession("authToken" -> "Token some-token")
126127
.withFormUrlEncodedBody()
128+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
127129
val result = route(app, request).value
128130
val view = app.injector.instanceOf[UserAllowListClearView]
129131
status(result) mustBe BAD_REQUEST
@@ -139,12 +141,14 @@ class UserAllowListClearControllerSpec extends AnyFreeSpec with Matchers with Sc
139141
.withFormUrlEncodedBody(
140142
"feature" -> "feature"
141143
)
144+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
142145
route(app, request).value.failed.futureValue
143146
}
144147
}
145148

146149
"must fail when the user is not authenticated" in {
147-
val request = FakeRequest(POST, routes.UserAllowListClearController.onSubmit("service").url) // no auth token
150+
val request = FakeRequest(POST, routes.UserAllowListClearController.onSubmit("service").url)
151+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded") // no auth token
148152
val result = route(app, request).value
149153
status(result) mustBe SEE_OTHER
150154
}
@@ -153,6 +157,7 @@ class UserAllowListClearControllerSpec extends AnyFreeSpec with Matchers with Sc
153157
when(mockStubBehaviour.stubAuth[String](any(), any())).thenReturn(Future.failed(new RuntimeException()))
154158
val request = FakeRequest(POST, routes.UserAllowListClearController.onSubmit("service").url)
155159
.withSession("authToken" -> "Token some-token")
160+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
156161
route(app, request).value.failed.futureValue
157162
}
158163
}

test/controllers/UserAllowListDeleteControllerSpec.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class UserAllowListDeleteControllerSpec extends AnyFreeSpec with Matchers with S
111111
"feature" -> "feature",
112112
"values" -> "a,b"
113113
)
114+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
114115
val result = route(app, request).value
115116
status(result) mustBe SEE_OTHER
116117
redirectLocation(result).value mustEqual routes.ServiceSummaryController.onPageLoad("service").url
@@ -128,6 +129,7 @@ class UserAllowListDeleteControllerSpec extends AnyFreeSpec with Matchers with S
128129
"feature" -> "feature",
129130
"values" -> "a"
130131
)
132+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
131133
val result = route(app, request).value
132134
status(result) mustBe SEE_OTHER
133135
redirectLocation(result).value mustEqual routes.ServiceSummaryController.onPageLoad("service").url
@@ -140,6 +142,7 @@ class UserAllowListDeleteControllerSpec extends AnyFreeSpec with Matchers with S
140142
val request = FakeRequest(POST, routes.UserAllowListDeleteController.onSubmit("service").url)
141143
.withSession("authToken" -> "Token some-token")
142144
.withFormUrlEncodedBody()
145+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
143146
val result = route(app, request).value
144147
val view = app.injector.instanceOf[UserAllowListDeleteView]
145148
status(result) mustBe BAD_REQUEST
@@ -156,12 +159,14 @@ class UserAllowListDeleteControllerSpec extends AnyFreeSpec with Matchers with S
156159
"feature" -> "feature",
157160
"values" -> "a,b"
158161
)
162+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
159163
route(app, request).value.failed.futureValue
160164
}
161165
}
162166

163167
"must fail when the user is not authenticated" in {
164-
val request = FakeRequest(POST, routes.UserAllowListDeleteController.onSubmit("service").url) // no auth token
168+
val request = FakeRequest(POST, routes.UserAllowListDeleteController.onSubmit("service").url)
169+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")// no auth token
165170
val result = route(app, request).value
166171
status(result) mustBe SEE_OTHER
167172
}
@@ -170,6 +175,7 @@ class UserAllowListDeleteControllerSpec extends AnyFreeSpec with Matchers with S
170175
when(mockStubBehaviour.stubAuth[String](any(), any())).thenReturn(Future.failed(new RuntimeException()))
171176
val request = FakeRequest(POST, routes.UserAllowListDeleteController.onSubmit("service").url)
172177
.withSession("authToken" -> "Token some-token")
178+
.withHeaders("Content-Type" -> "application/x-www-form-urlencoded")
173179
route(app, request).value.failed.futureValue
174180
}
175181
}

0 commit comments

Comments
 (0)