Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 6a2b691

Browse files
authored
Merge pull request #13 from hmrc/hipp-1429
HIPP-1429: Add egressPrefix & prefixesToRemove fields to Update form
2 parents b29b7ba + a125bf3 commit 6a2b691

File tree

6 files changed

+81
-11
lines changed

6 files changed

+81
-11
lines changed

app/uk/gov/hmrc/simpleapideploymentstubs/controllers/SimpleAPiDeploymentController.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import play.api.libs.Files
2424
import play.api.libs.json.{JsValue, Json}
2525
import play.api.mvc.{Action, AnyContent, ControllerComponents, MultipartFormData}
2626
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController
27-
import uk.gov.hmrc.simpleapideploymentstubs.models.{CreateMetadata, DeploymentFrom, DeploymentResponse, DeploymentsResponse, FailuresResponse, UpdateMetadata}
27+
import uk.gov.hmrc.simpleapideploymentstubs.models.{CreateMetadata, DeploymentFrom, DeploymentResponse, DeploymentsResponse, DetailsResponse, FailuresResponse, UpdateMetadata}
2828

2929
@Singleton
3030
class SimpleAPiDeploymentController @Inject()(cc: ControllerComponents) extends BackendController(cc) with Logging {
@@ -100,4 +100,8 @@ class SimpleAPiDeploymentController @Inject()(cc: ControllerComponents) extends
100100
)
101101
}
102102

103+
def getDeploymentDetails(serviceId: String): Action[AnyContent] = Action {
104+
Ok(Json.toJson(DetailsResponse.cannedResponse))
105+
}
106+
103107
}

app/uk/gov/hmrc/simpleapideploymentstubs/models/CreateMetadata.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ case class CreateMetadata(
2828
domain: Option[String] = None,
2929
subdomain: Option[String] = None,
3030
backends: Seq[String] = Seq.empty,
31-
prefixesToRemove: Seq[String],
32-
egressPrefix: String
31+
prefixestoremove: Seq[String],
32+
egressprefix: String
3333
)
3434

3535
object CreateMetadata {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2024 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package uk.gov.hmrc.simpleapideploymentstubs.models
18+
19+
import play.api.libs.json.{Format, Json}
20+
21+
case class DetailsResponse(
22+
description: String,
23+
status: String,
24+
domain: String,
25+
subdomain: String,
26+
backends: Seq[String],
27+
egressprefix: String,
28+
prefixestoremove: Seq[String]
29+
)
30+
31+
object DetailsResponse {
32+
33+
val cannedResponse: DetailsResponse = DetailsResponse(
34+
description = "A short description of the API",
35+
status = "ALPHA",
36+
domain = "8",
37+
subdomain = "8.1",
38+
backends = Seq("NPS"),
39+
egressprefix = "/prefix",
40+
prefixestoremove = Seq("/v1")
41+
)
42+
43+
implicit val formatDetailsResponse: Format[DetailsResponse] = Json.format[DetailsResponse]
44+
45+
}

app/uk/gov/hmrc/simpleapideploymentstubs/models/UpdateMetadata.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ case class UpdateMetadata(
2323
status: String,
2424
domain: Option[String] = None,
2525
subdomain: Option[String] = None,
26-
backends: Seq[String] = Seq.empty
26+
backends: Seq[String] = Seq.empty,
27+
prefixestoremove: Seq[String],
28+
egressprefix: String
2729
)
2830

2931
object UpdateMetadata {

conf/app.routes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
POST /v1/simple-api-deployment/validate uk.gov.hmrc.simpleapideploymentstubs.controllers.SimpleAPiDeploymentController.validate()
44
POST /v1/simple-api-deployment/deployments uk.gov.hmrc.simpleapideploymentstubs.controllers.SimpleAPiDeploymentController.create()
5+
GET /v1/simple-api-deployment/deployments/:serviceId uk.gov.hmrc.simpleapideploymentstubs.controllers.SimpleAPiDeploymentController.getDeploymentDetails(serviceId: String)
56
PUT /v1/simple-api-deployment/deployments/:serviceId uk.gov.hmrc.simpleapideploymentstubs.controllers.SimpleAPiDeploymentController.update(serviceId: String)
67
PUT /v1/simple-api-deployment/deployment-from uk.gov.hmrc.simpleapideploymentstubs.controllers.SimpleAPiDeploymentController.deploymentFrom()
78
GET /v1/oas-deployments/:publisherReference uk.gov.hmrc.simpleapideploymentstubs.controllers.SimpleAPiDeploymentController.deployment(publisherReference: String)

test/uk/gov/hmrc/simpleapideploymentstubs/controllers/SimpleAPiDeploymentControllerSpec.scala

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import play.api.libs.json.Json
2525
import play.api.mvc.MultipartFormData
2626
import play.api.test.FakeRequest
2727
import play.api.test.Helpers._
28-
import uk.gov.hmrc.simpleapideploymentstubs.models.{CreateMetadata, DeploymentFrom, DeploymentsResponse, FailuresResponse, UpdateMetadata}
28+
import uk.gov.hmrc.simpleapideploymentstubs.models.{CreateMetadata, DeploymentFrom, DeploymentsResponse, DetailsResponse, FailuresResponse, UpdateMetadata}
2929

3030
class SimpleAPiDeploymentControllerSpec extends AnyFreeSpec with Matchers with OptionValues {
3131

@@ -69,8 +69,8 @@ class SimpleAPiDeploymentControllerSpec extends AnyFreeSpec with Matchers with O
6969
name = "test-name",
7070
description = "test-description",
7171
egress = "test-egress",
72-
prefixesToRemove = Seq("test-prefix-1"),
73-
egressPrefix = ""
72+
prefixestoremove = Seq("test-prefix-1"),
73+
egressprefix = ""
7474
)
7575

7676
running(application) {
@@ -101,8 +101,8 @@ class SimpleAPiDeploymentControllerSpec extends AnyFreeSpec with Matchers with O
101101
name = "test-name",
102102
description = "test-description",
103103
egress = "test-egress",
104-
prefixesToRemove = Seq("test-prefix-1"),
105-
egressPrefix = ""
104+
prefixestoremove = Seq("test-prefix-1"),
105+
egressprefix = ""
106106
)
107107

108108
running(application) {
@@ -156,7 +156,9 @@ class SimpleAPiDeploymentControllerSpec extends AnyFreeSpec with Matchers with O
156156

157157
val metadata = UpdateMetadata(
158158
description = "test-description",
159-
status = "test-status"
159+
status = "test-status",
160+
prefixestoremove = Seq("test-prefix-1", "test-prefix-2"),
161+
egressprefix = "test-egress-prefix"
160162
)
161163

162164
running(application) {
@@ -186,7 +188,9 @@ class SimpleAPiDeploymentControllerSpec extends AnyFreeSpec with Matchers with O
186188

187189
val metadata = UpdateMetadata(
188190
description = "test-description",
189-
status = "test-status"
191+
status = "test-status",
192+
prefixestoremove = Seq("test-prefix-1", "test-prefix-2"),
193+
egressprefix = "test-egress-prefix"
190194
)
191195

192196
running(application) {
@@ -280,6 +284,20 @@ class SimpleAPiDeploymentControllerSpec extends AnyFreeSpec with Matchers with O
280284
}
281285
}
282286

287+
"getDeploymentDetails" - {
288+
"must return 200 Ok can a DetailsResponse" in {
289+
val application = buildApplication()
290+
291+
running(application) {
292+
val request = FakeRequest(routes.SimpleAPiDeploymentController.getDeploymentDetails("test-service-id"))
293+
val result = route(application, request).value
294+
295+
status(result) mustBe OK
296+
contentAsJson(result) mustBe Json.toJson(DetailsResponse.cannedResponse)
297+
}
298+
}
299+
}
300+
283301
private def buildApplication(): Application = {
284302
GuiceApplicationBuilder()
285303
.build()

0 commit comments

Comments
 (0)