-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'Creating new service income-tax-self-employment'
- Loading branch information
1 parent
9bbdf8f
commit 2a5ca2f
Showing
18 changed files
with
346 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
logs | ||
project/project | ||
project/target | ||
target | ||
lib_managed | ||
tmp | ||
.history | ||
.* | ||
|
||
!.gitignore | ||
!.scalafmt.conf | ||
bin | ||
.bloop/ | ||
.cache | ||
/.classpath | ||
db | ||
dist | ||
/.idea | ||
/*.iml | ||
/*.ipr | ||
/out | ||
.DS_Store | ||
**/*.DS_Store | ||
eclipse | ||
*.eml | ||
.history | ||
.idea | ||
.idea_modules | ||
/.idea_modules | ||
/.classpath | ||
*.iml | ||
lib | ||
lib_managed | ||
log | ||
logs | ||
.metals/ | ||
modules | ||
/out | ||
precompiled | ||
/.project | ||
project/metals.sbt | ||
project/project | ||
project/target | ||
/RUNNING_PID | ||
server.pid | ||
/.settings | ||
*.iws | ||
node_modules/ | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
target | ||
.target | ||
test-result | ||
tmp | ||
.vscode/ |
10 changes: 10 additions & 0 deletions
10
app/uk/gov/hmrc/incometaxselfemployment/config/AppConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package uk.gov.hmrc.incometaxselfemployment.config | ||
|
||
import javax.inject.{Inject, Singleton} | ||
import play.api.Configuration | ||
|
||
@Singleton | ||
class AppConfig @Inject()(config: Configuration) { | ||
|
||
val appName: String = config.get[String]("appName") | ||
} |
11 changes: 11 additions & 0 deletions
11
app/uk/gov/hmrc/incometaxselfemployment/config/Module.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package uk.gov.hmrc.incometaxselfemployment.config | ||
|
||
import com.google.inject.AbstractModule | ||
|
||
class Module extends AbstractModule { | ||
|
||
override def configure(): Unit = { | ||
|
||
bind(classOf[AppConfig]).asEagerSingleton() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/uk/gov/hmrc/incometaxselfemployment/controllers/MicroserviceHelloWorldController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package uk.gov.hmrc.incometaxselfemployment.controllers | ||
|
||
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController | ||
import play.api.mvc.{Action, AnyContent, ControllerComponents} | ||
import javax.inject.{Inject, Singleton} | ||
import scala.concurrent.Future | ||
|
||
@Singleton() | ||
class MicroserviceHelloWorldController @Inject()(cc: ControllerComponents) | ||
extends BackendController(cc) { | ||
|
||
def hello(): Action[AnyContent] = Action.async { implicit request => | ||
Future.successful(Ok("Hello world")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import uk.gov.hmrc.DefaultBuildSettings.integrationTestSettings | ||
|
||
lazy val microservice = Project("income-tax-self-employment", file(".")) | ||
.enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin) | ||
.settings( | ||
majorVersion := 0, | ||
scalaVersion := "2.13.8", | ||
libraryDependencies ++= AppDependencies.compile ++ AppDependencies.test, | ||
// https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html | ||
// suppress warnings in generated routes files | ||
scalacOptions += "-Wconf:src=routes/.*:s", | ||
) | ||
.configs(IntegrationTest) | ||
.settings(integrationTestSettings(): _*) | ||
.settings(resolvers += Resolver.jcenterRepo) | ||
.settings(CodeCoverageSettings.settings: _*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# microservice specific routes | ||
|
||
GET /hello-world uk.gov.hmrc.incometaxselfemployment.controllers.MicroserviceHelloWorldController.hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="uk.gov.hmrc.play.logging.JsonEncoder"/> | ||
</appender> | ||
|
||
<root level="WARN"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
include "backend.conf" | ||
|
||
# This is the main configuration file for the application. | ||
# ~~~~~ | ||
|
||
appName = income-tax-self-employment | ||
|
||
# Default http client | ||
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule" | ||
|
||
# Json error handler | ||
play.http.errorHandler = "uk.gov.hmrc.play.bootstrap.backend.http.JsonErrorHandler" | ||
|
||
# Play Modules | ||
play.modules.enabled += "uk.gov.hmrc.incometaxselfemployment.config.Module" | ||
|
||
|
||
# The application languages | ||
# ~~~~~ | ||
play.i18n.langs = ["en"] | ||
|
||
# Router | ||
# ~~~~~ | ||
# Define the Router object to use for this application. | ||
# This router will be looked up first when the application is starting up, | ||
# so make sure this is the entry point. | ||
# Furthermore, it's assumed your route file is named properly. | ||
# So for an application router like `my.application.Router`, | ||
# you may need to define a router file `conf/my.application.routes`. | ||
# Default to Routes in the root package (and conf/routes) | ||
# !!!WARNING!!! DO NOT CHANGE THIS ROUTER | ||
play.http.router = prod.Routes | ||
|
||
# Controller | ||
# ~~~~~ | ||
# By default all controllers will have authorisation, logging and | ||
# auditing (transaction monitoring) enabled. | ||
# The below controllers are the default exceptions to this rule. | ||
|
||
controllers { | ||
uk.gov.hmrc.incometaxselfemployment.controllers.MicroserviceHelloWorldController = { | ||
needsAuth = false | ||
needsLogging = false | ||
needsAuditing = false | ||
} | ||
} | ||
|
||
# Microservice specific config | ||
|
||
|
||
microservice { | ||
services { | ||
auth { | ||
host = localhost | ||
port = 8500 | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | ||
<file>logs/income-tax-self-employment.log</file> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] rid=[%X{X-Request-ID}] user=[%X{Authorization}] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="STDOUT_IGNORE_NETTY" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] rid=[not-available] user=[not-available] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="ACCESS_LOG_FILE" class="ch.qos.logback.core.FileAppender"> | ||
<file>logs/access.log</file> | ||
<encoder> | ||
<pattern>%message%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="CONNECTOR_LOG_FILE" class="ch.qos.logback.core.FileAppender"> | ||
<file>logs/connector.log</file> | ||
<encoder> | ||
<pattern>%message%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
|
||
<logger name="accesslog" level="INFO" additivity="false"> | ||
<appender-ref ref="ACCESS_LOG_FILE" /> | ||
</logger> | ||
|
||
<logger name="com.ning.http.client.providers.netty" additivity="false"> | ||
<appender-ref ref="STDOUT_IGNORE_NETTY" /> | ||
</logger> | ||
|
||
<logger name="com.google.inject" level="INFO"/> | ||
|
||
<logger name="uk.gov" level="INFO"/> | ||
|
||
<logger name="application" level="DEBUG"/> | ||
|
||
<logger name="connector" level="TRACE"> | ||
<appender-ref ref="STDOUT"/> | ||
</logger> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="FILE"/> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Add all the application routes to the app.routes file | ||
-> /income-tax-self-employment app.Routes | ||
-> / health.Routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# IF THE MICRO-SERVICE DOES NOT NEED ANY TEST-ONLY END-POINTS (ALWAYS PREFERRED) DELETE THIS FILE. | ||
|
||
# !!!WARNING!!! This file MUST NOT be referenced in the "application.conf" file to avoid risk of rolling test routes in the production environment. | ||
# If you need test routes when running tests in CI make sure that the profile for this micro-service (used by service-manager) defines this router as parameter. | ||
# To do so add the following line to the micro-service profile: "-Dapplication.router=testOnlyDoNotUseInAppConf.Routes" | ||
# To start the micro-service locally using the test routes run the following command: "sbt run -Dapplication.router=testOnlyDoNotUseInAppConf.Routes" | ||
|
||
# Any test-only end-point should be defined here. | ||
# !!!WARNING!!! Every route defined in this file MUST be prefixed with "/test-only/". This is because NGINX is blocking every uri containing the string "test-only" in production. | ||
# Failing to follow this rule may result in test routes deployed in production. | ||
|
||
# Add all the application routes to the prod.routes file | ||
-> / prod.Routes |
37 changes: 37 additions & 0 deletions
37
it/uk/gov/hmrc/incometaxselfemployment/HealthEndpointIntegrationSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package uk.gov.hmrc.incometaxselfemployment | ||
|
||
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures} | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
import org.scalatestplus.play.guice.GuiceOneServerPerSuite | ||
import play.api.Application | ||
import play.api.inject.guice.GuiceApplicationBuilder | ||
import play.api.libs.ws.WSClient | ||
|
||
class HealthEndpointIntegrationSpec | ||
extends AnyWordSpec | ||
with Matchers | ||
with ScalaFutures | ||
with IntegrationPatience | ||
with GuiceOneServerPerSuite { | ||
|
||
private val wsClient = app.injector.instanceOf[WSClient] | ||
private val baseUrl = s"http://localhost:$port" | ||
|
||
override def fakeApplication(): Application = | ||
GuiceApplicationBuilder() | ||
.configure("metrics.enabled" -> false) | ||
.build() | ||
|
||
"service health endpoint" should { | ||
"respond with 200 status" in { | ||
val response = | ||
wsClient | ||
.url(s"$baseUrl/ping/ping") | ||
.get() | ||
.futureValue | ||
|
||
response.status shouldBe 200 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import play.core.PlayVersion | ||
import play.sbt.PlayImport._ | ||
import sbt.Keys.libraryDependencies | ||
import sbt._ | ||
|
||
object AppDependencies { | ||
|
||
private val bootstrapVersion = "7.19.0" | ||
|
||
|
||
val compile = Seq( | ||
"uk.gov.hmrc" %% "bootstrap-backend-play-28" % bootstrapVersion | ||
) | ||
|
||
val test = Seq( | ||
"uk.gov.hmrc" %% "bootstrap-test-play-28" % bootstrapVersion % "test, it", | ||
|
||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sbt.Setting | ||
import scoverage.ScoverageKeys | ||
|
||
object CodeCoverageSettings { | ||
|
||
private val excludedPackages: Seq[String] = Seq( | ||
"<empty>", | ||
"Reverse.*", | ||
"uk.gov.hmrc.BuildInfo", | ||
"app.*", | ||
"prod.*", | ||
".*Routes.*", | ||
"testOnly.*", | ||
"testOnlyDoNotUseInAppConf.*" | ||
) | ||
|
||
val settings: Seq[Setting[_]] = Seq( | ||
ScoverageKeys.coverageExcludedPackages := excludedPackages.mkString(";"), | ||
ScoverageKeys.coverageMinimumStmtTotal := 100, | ||
ScoverageKeys.coverageFailOnMinimum := true, | ||
ScoverageKeys.coverageHighlighting := true | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.7.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2") | ||
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns) | ||
resolvers += Resolver.typesafeRepo("releases") | ||
|
||
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.9.0") | ||
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.2.0") | ||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19") | ||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
repoVisibility: public_0C3F0CE3E6E6448FAD341E7BFA50FCD333E06A20CFF05FCACE61154DDBBADF71 | ||
repoVisibility: public_0C3F0CE3E6E6448FAD341E7BFA50FCD333E06A20CFF05FCACE61154DDBBADF71 | ||
type: service |
20 changes: 20 additions & 0 deletions
20
...k/gov/hmrc/incometaxselfemployment/controllers/MicroserviceHelloWorldControllerSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package uk.gov.hmrc.incometaxselfemployment.controllers | ||
|
||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
import play.api.http.Status | ||
import play.api.test.Helpers._ | ||
import play.api.test.{FakeRequest, Helpers} | ||
|
||
class MicroserviceHelloWorldControllerSpec extends AnyWordSpec with Matchers { | ||
|
||
private val fakeRequest = FakeRequest("GET", "/") | ||
private val controller = new MicroserviceHelloWorldController(Helpers.stubControllerComponents()) | ||
|
||
"GET /" should { | ||
"return 200" in { | ||
val result = controller.hello()(fakeRequest) | ||
status(result) shouldBe Status.OK | ||
} | ||
} | ||
} |