Skip to content

Commit

Permalink
Merge pull request #19 from hmrc/APIS-4348
Browse files Browse the repository at this point in the history
APIS-4348 Removed service-locator registration.
  • Loading branch information
adampridmore authored May 8, 2019
2 parents ad6f656 + 12cd4b5 commit 4c80dde
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class ConfigurationModule extends Module {

override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
Seq(
bind[ServiceLocatorRegistrationConfig].toProvider[ServiceLocatorRegistrationConfigProvider],
bind[ServiceLocatorConfig].toProvider[ServiceLocatorConfigProvider],
bind[DocumentationConfig].toProvider[DocumentationConfigProvider],
bind[RefreshSubscriptionsJobConfig].toProvider[RefreshSubscriptionsJobConfigProvider],
bind[UpliftVerificationExpiryJobConfig].toProvider[UpliftVerificationExpiryJobConfigProvider],
Expand All @@ -63,32 +61,6 @@ object ConfigHelper {
}
}

@Singleton
class ServiceLocatorRegistrationConfigProvider @Inject()(val runModeConfiguration: Configuration, environment: Environment)
extends Provider[ServiceLocatorRegistrationConfig] with ServicesConfig {

override protected def mode = environment.mode

override def get() = {
val registrationEnabled = getConfBool("service-locator.enabled", defBool = true)
ServiceLocatorRegistrationConfig(registrationEnabled)
}
}

@Singleton
class ServiceLocatorConfigProvider @Inject()(val runModeConfiguration: Configuration, environment: Environment)
extends Provider[ServiceLocatorConfig] with ServicesConfig {

override protected def mode = environment.mode

override def get() = {
val appName = getString("appName")
val appUrl = getString("appUrl")
val serviceLocatorBaseUrl = baseUrl("service-locator")
ServiceLocatorConfig(appName, appUrl, serviceLocatorBaseUrl)
}
}

@Singleton
class DocumentationConfigProvider @Inject()(val runModeConfiguration: Configuration, environment: Environment)
extends Provider[DocumentationConfig] with ServicesConfig {
Expand Down

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions app/uk/gov/hmrc/thirdpartyapplication/models/Registration.scala

This file was deleted.

13 changes: 6 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ lazy val appName = "third-party-application"
lazy val appDependencies: Seq[ModuleID] = compile ++ test

lazy val compile = Seq(
"uk.gov.hmrc" %% "bootstrap-play-25" % "4.9.0",
"uk.gov.hmrc" %% "bootstrap-play-25" % "4.11.0",
"uk.gov.hmrc" %% "mongo-lock" % "6.12.0-play-25",
"uk.gov.hmrc" %% "simple-reactivemongo" % "7.16.0-play-25",
"uk.gov.hmrc" %% "play-scheduling" % "5.4.0",
"uk.gov.hmrc" %% "play-json-union-formatter" % "1.4.0",
"uk.gov.hmrc" %% "play-scheduling" % "6.0.0",
"uk.gov.hmrc" %% "play-json-union-formatter" % "1.5.0",
"uk.gov.hmrc" %% "play-hmrc-api" % "3.4.0-play-25"
)
lazy val test = Seq(
"uk.gov.hmrc" %% "reactivemongo-test" % "4.10.0-play-25" % "test,it",
"uk.gov.hmrc" %% "hmrctest" % "3.6.0-play-25" % "test,it",
"uk.gov.hmrc" %% "reactivemongo-test" % "4.13.0-play-25" % "test,it",
"uk.gov.hmrc" %% "hmrctest" % "3.8.0-play-25" % "test,it",
"org.pegdown" % "pegdown" % "1.6.0" % "test,it",
"org.scalaj" %% "scalaj-http" % "2.3.0" % "test,it",
"org.scalatest" %% "scalatest" % "2.2.6" % "test,it",
Expand Down Expand Up @@ -60,7 +59,7 @@ lazy val microservice = (project in file("."))
.settings(inConfig(TemplateItTest)(Defaults.itSettings): _*)
.settings(
Keys.fork in IntegrationTest := false,
unmanagedSourceDirectories in IntegrationTest <<= (baseDirectory in IntegrationTest) (base => Seq(base / "test")),
unmanagedSourceDirectories in IntegrationTest := (baseDirectory in IntegrationTest) (base => Seq(base / "test")).value,
addTestReportOption(IntegrationTest, "int-test-reports"),
testGrouping in IntegrationTest := oneForkedJvmPerTest((definedTests in IntegrationTest).value),
testOptions in IntegrationTest := Seq(Tests.Filter(itFilter), Tests.Argument(TestFrameworks.ScalaTest, "-eT")),
Expand Down
13 changes: 0 additions & 13 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
include "backend.conf"

appName = third-party-application
appUrl = "http://localhost:9607"

# An ApplicationLoader that uses Guice to bootstrap the application.
play.application.loader = "uk.gov.hmrc.play.bootstrap.ApplicationLoader"
Expand All @@ -42,7 +41,6 @@ play.http.errorHandler = "uk.gov.hmrc.play.bootstrap.http.JsonErrorHandler"
play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoHmrcModule"
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule"
play.modules.enabled += "uk.gov.hmrc.thirdpartyapplication.config.ConfigurationModule"
play.modules.enabled += "uk.gov.hmrc.thirdpartyapplication.config.ServiceLocatorRegistrationModule"
play.modules.enabled += "uk.gov.hmrc.thirdpartyapplication.config.SchedulerModule"
play.modules.enabled += "uk.gov.hmrc.thirdpartyapplication.config.ApiStorageModule"

Expand Down Expand Up @@ -221,11 +219,6 @@ Dev {
port = 9988
}

service-locator {
host = localhost
port = 9602
}

third-party-delegated-authority {
protocol = https
host = localhost
Expand Down Expand Up @@ -309,12 +302,6 @@ Test {
port = 22226
}

service-locator {
enabled = false
host = localhost
port = 9602
}

third-party-delegated-authority {
host = localhost
port = 22228
Expand Down
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksam

resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.14.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "1.16.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.17.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.3.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.16.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "1.19.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.19.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.5.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.19")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
39 changes: 5 additions & 34 deletions test/it/uk/gov/hmrc/PlatformIntegrationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@

package it.uk.gov.hmrc.thirdpartyapplication

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.client.WireMock._
import com.github.tomakehurst.wiremock.core.WireMockConfiguration._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{BeforeAndAfterEach, TestData}
import org.scalatestplus.play.guice.GuiceOneAppPerTest
import play.api.http.Status
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.test.FakeRequest
import play.api.{Application, Mode}
Expand All @@ -34,50 +29,26 @@ import uk.gov.hmrc.thirdpartyapplication.controllers.DocumentationController
/**
* Testcase to verify the capability of integration with the API platform.
*
* 1, To integrate with API platform the service needs to register itself to the service locator by calling the /registration endpoint and providing
* - application name
* - application url
*
* 2a, To expose API's to Third Party Developers, the service needs to make the API definition available under api/definition GET endpoint
* 2b, The endpoints need to be defined in an application.raml file for all versions For all of the endpoints defined documentation will be provided and be
* available under api/documentation/[version]/[endpoint name] GET endpoint
* 1a, To expose API's to Third Party Developers, the service needs to make the API definition available under api/definition GET endpoint
* 1b, The endpoints need to be defined in an application.raml file for all versions For all of the endpoints defined documentation will be provided and
* be available under api/documentation/[version]/[endpoint name] GET endpoint
* Example: api/documentation/1.0/Fetch-Some-Data
*
* See: https://confluence.tools.tax.service.gov.uk/display/ApiPlatform/API+Platform+Architecture+with+Flows
*/


trait PlatformIntegrationSpec extends UnitSpec with MockitoSugar with ScalaFutures with BeforeAndAfterEach with GuiceOneAppPerTest {

implicit def mat: akka.stream.Materializer = app.injector.instanceOf[akka.stream.Materializer]

val publishApiDefinition: Boolean
val stubHost = "localhost"
val stubPort = sys.env.getOrElse("WIREMOCK_SERVICE_LOCATOR_PORT", "11111").toInt
val wireMockServer = new WireMockServer(wireMockConfig().port(stubPort))

override def newAppForTest(testData: TestData): Application = GuiceApplicationBuilder()
.configure("run.mode" -> "Stub")
.configure(Map(
"appName" -> "application-name",
"appUrl" -> "http://microservice-name.example.local",
"publishApiDefinition" -> publishApiDefinition,
"api.context" -> "test-api-context",
"Test.microservice.services.service-locator.host" -> stubHost,
"Test.microservice.services.service-locator.port" -> stubPort,
"Test.microservice.services.service-locator.enabled" -> true
"api.context" -> "test-api-context"
)).in(Mode.Test).build()

override def beforeEach() {
wireMockServer.start()
WireMock.configureFor(stubHost, stubPort)
stubFor(post(urlMatching("/registration")).willReturn(aResponse().withStatus(Status.NO_CONTENT)))
}

override protected def afterEach(): Unit = {
wireMockServer.stop()
wireMockServer.resetMappings()
}

trait Setup {
val documentationController = app.injector.instanceOf[DocumentationController]
val request = FakeRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import scala.concurrent.{ExecutionContext, Future}

object AuthSpecHelpers {
def givenUserIsAuthenticated(underTest: AuthorisationWrapper) = {
when(underTest.authConnector.authorise(any, any[Retrieval[Any]])(any[HeaderCarrier], any[ExecutionContext])).thenReturn(Future.successful())
when(underTest.authConnector.authorise(any, any[Retrieval[Any]])(any[HeaderCarrier], any[ExecutionContext])).thenReturn(Future.successful(()))
}

def givenUserIsNotAuthenticated(underTest: AuthorisationWrapper) = {
Expand Down

0 comments on commit 4c80dde

Please sign in to comment.