From 804a800d8adc80cb3625fd065c230565335eb8fb Mon Sep 17 00:00:00 2001 From: JoPintoPaul Date: Tue, 28 May 2024 16:56:55 +0100 Subject: [PATCH] PLATUI-3061: Use an integration test to compare Github main service files with local --- conf/application.conf | 2 +- conf/services/example-chgv.yml | 13 ------------- test/it/ServicesISpec.scala | 28 +++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 15 deletions(-) delete mode 100644 conf/services/example-chgv.yml diff --git a/conf/application.conf b/conf/application.conf index 6d9c33c30..b23e27f9d 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -20,7 +20,7 @@ play.http.router = prod.Routes play.filters.enabled += play.filters.csp.CSPFilter # Default http client -play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule" +play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientV2Module" # Custom error handler play.http.errorHandler = "uk.gov.hmrc.accessibilitystatementfrontend.handlers.ErrorHandler" diff --git a/conf/services/example-chgv.yml b/conf/services/example-chgv.yml deleted file mode 100644 index 4c6c166c3..000000000 --- a/conf/services/example-chgv.yml +++ /dev/null @@ -1,13 +0,0 @@ -serviceName: Discounted Pies for C-HGV -serviceDescription: | - Use this paragraph to describe your service. It can go over multiple lines - like this. -serviceDomain: www.tax.service.gov.uk -serviceUrl: /chgv-pies -contactFrontendServiceId: chgv-pies -complianceStatus: full -serviceLastTestedDate: 2022-02-01 -statementVisibility: draft -statementCreatedDate: 2022-02-24 -statementLastUpdatedDate: 2022-02-24 -statementType: C-HGV diff --git a/test/it/ServicesISpec.scala b/test/it/ServicesISpec.scala index 3bae76441..8f53135d7 100644 --- a/test/it/ServicesISpec.scala +++ b/test/it/ServicesISpec.scala @@ -27,9 +27,17 @@ import org.scalatestplus.play.guice.GuiceOneAppPerSuite import uk.gov.hmrc.accessibilitystatementfrontend.config.{AppConfig, ServicesFinder, SourceConfig} import uk.gov.hmrc.accessibilitystatementfrontend.models._ import uk.gov.hmrc.accessibilitystatementfrontend.parsers.AccessibilityStatementParser +import org.scalatest.AppendedClues.convertToClueful +import play.api.libs.json.JsValue +import play.api.test.WsTestClient +import uk.gov.hmrc.http.HeaderCarrier +import uk.gov.hmrc.http.client.HttpClientV2 import java.io.File -import java.net.URLDecoder +import java.net.{URL, URLDecoder} +import scala.concurrent.Await +import scala.concurrent.duration._ +import java.util.concurrent.TimeUnit.SECONDS import scala.util.Try class ServicesISpec extends AnyWordSpec with Matchers with GuiceOneAppPerSuite with TryValues { @@ -280,5 +288,23 @@ class ServicesISpec extends AnyWordSpec with Matchers with GuiceOneAppPerSuite w services.contains(serviceName) should be(true) } } + + "match the files in Github" in { + import scala.concurrent.ExecutionContext.Implicits.global + + val client = app.injector.instanceOf[HttpClientV2] + val url: URL = + new URL("https://api.github.com/repos/hmrc/accessibility-statement-frontend/contents/conf/services") + val files = + Await.result(client.get(url)(HeaderCarrier()).execute[Seq[JsValue]], Duration(2, SECONDS)) + + val fileNamesFromGithub = files.map(file => (file \ "name").as[String]) + + val maybeDeletedFiles = fileNamesFromGithub.diff(fileNames) + maybeDeletedFiles.isEmpty should be( + true + ) withClue (s", The following files from the Github are not found in the services directory: $maybeDeletedFiles") + + } } }