Skip to content

Commit

Permalink
Merge pull request #107 from hmrc/DC-7025
Browse files Browse the repository at this point in the history
DC-7025 Update two-way-messages endpoint url
  • Loading branch information
chandankumarray authored Jan 7, 2025
2 parents de6748c + 0126ad6 commit 42aa5fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/connectors/RendererConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class RendererConnector @Inject() (

val deprecateRenderer = servicesConfig.getBoolean("deprecate.message-renderer")
val url =
if (
(rendererUrl.service == "ats-message-renderer" || rendererUrl.service == "two-way-message") && deprecateRenderer
) {
if (rendererUrl.service == "ats-message-renderer" && deprecateRenderer) {
s"${servicesConfig.baseUrl("secure-message")}/secure-messaging${rendererUrl.url}"
} else if (rendererUrl.service == "two-way-message" && deprecateRenderer) {
s"${servicesConfig.baseUrl("secure-message")}/secure-messaging/two-way-message${rendererUrl.url}"
} else {
s"${servicesConfig.baseUrl(rendererUrl.service)}${rendererUrl.url}"
}
Expand Down
6 changes: 5 additions & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ microservice {
host = localhost
port = 8093
}


two-way-message {
host = localhost
port = 8970
}
}
}

Expand Down
21 changes: 19 additions & 2 deletions test/connectors/RendererConnectorSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class RendererConnectorSpec extends PlaySpec with ScalaFutures with MockitoSugar
}

"render two-way secure-messages from secure-message service when deprecate flag is enabled" in new TestCase {
val expectedUrl: URL = URI("http://localhost:9051/secure-messaging/message/messageId/content").toURL
val expectedUrl: URL =
URI("http://localhost:9051/secure-messaging/two-way-message/messages/messageId/content").toURL
when(mockServicesConfig.getBoolean(ArgumentMatchers.eq("deprecate.message-renderer"))).thenReturn(true)
when(mockServicesConfig.baseUrl(ArgumentMatchers.eq("secure-message"))).thenReturn("http://localhost:9051")
when(mockHttp.get(ArgumentMatchers.eq(expectedUrl))(any[HeaderCarrier])).thenReturn(mockRequestBuilder)
Expand All @@ -82,7 +83,7 @@ class RendererConnectorSpec extends PlaySpec with ScalaFutures with MockitoSugar
Future.successful(HtmlPartial.Success(Some("two-way-message"), Html("<p>Secure message from advisor</p>")))
)

val serviceUrl: ServiceUrl = ServiceUrl("two-way-message", "/message/messageId/content")
val serviceUrl: ServiceUrl = ServiceUrl("two-way-message", "/messages/messageId/content")
val response: Future[HtmlPartial] = renderer.getRenderedMessage(serviceUrl, Map.empty)(FakeRequest())

response.futureValue.toString must include("<p>Secure message from advisor</p>")
Expand All @@ -102,6 +103,22 @@ class RendererConnectorSpec extends PlaySpec with ScalaFutures with MockitoSugar
response.futureValue.toString must include("<p>Annual Tax Summary</p>")
}

"render 2WSM messages from two-way-message renderer service when deprecate flag is disabled" in new TestCase {
val expectedUrl: URL = URI("http://localhost:8970/messages/messageId/content").toURL
when(mockServicesConfig.getBoolean(ArgumentMatchers.eq("deprecate.message-renderer"))).thenReturn(false)
when(mockServicesConfig.baseUrl(ArgumentMatchers.eq("two-way-message"))).thenReturn("http://localhost:8970")
when(mockHttp.get(ArgumentMatchers.eq(expectedUrl))(any[HeaderCarrier])).thenReturn(mockRequestBuilder)
when(mockRequestBuilder.execute(any(), any()))
.thenReturn(
Future.successful(HtmlPartial.Success(Some("two-way-message"), Html("<p>Secure message from advisor</p>")))
)

val serviceUrl: ServiceUrl = ServiceUrl("two-way-message", "/messages/messageId/content")
val response: Future[HtmlPartial] = renderer.getRenderedMessage(serviceUrl, Map.empty)(FakeRequest())

response.futureValue.toString must include("<p>Secure message from advisor</p>")
}

"render non-ats messages from other services even if deprecate flag is enabled" in new TestCase {
val expectedUrl: URL = URI("http://localhost:8910/message/messageId/content").toURL
when(mockServicesConfig.getBoolean(ArgumentMatchers.eq("deprecate.message-renderer"))).thenReturn(true)
Expand Down

0 comments on commit 42aa5fa

Please sign in to comment.