diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 97754d0..68453e1 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -92,9 +92,9 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'app-insight-connection-string' - DEMAND_PAYMENT_SUBKEY: 'nodo-auth' - CART_SUBKEY: 'checkout-carts' - PAYMENT_RECEIPT_SUBKEY: 'gpd-payments-rest-aks' + DEMAND_PAYMENT_SUBKEY: 'apikey-node-for-psp' + CART_SUBKEY: 'apikey-checkout-carts' + PAYMENT_RECEIPT_SUBKEY: 'apikey-gpd-payments' keyvault: name: "pagopa-d-itn-ebollo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 6c2042c..3c7dc93 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -92,9 +92,9 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'app-insight-connection-string' - DEMAND_PAYMENT_SUBKEY: 'nodo-auth' - CART_SUBKEY: 'checkout-carts' - PAYMENT_RECEIPT_SUBKEY: 'gpd-payments-rest-aks' + DEMAND_PAYMENT_SUBKEY: 'apikey-node-for-psp' + CART_SUBKEY: 'apikey-checkout-carts' + PAYMENT_RECEIPT_SUBKEY: 'apikey-gpd-payments' keyvault: name: "pagopa-p-itn-ebollo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 26e4c26..093f1e4 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -92,9 +92,9 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'app-insight-connection-string' - DEMAND_PAYMENT_SUBKEY: 'nodo-auth' - CART_SUBKEY: 'checkout-carts' - PAYMENT_RECEIPT_SUBKEY: 'gpd-payments-rest-aks' + DEMAND_PAYMENT_SUBKEY: 'apikey-node-for-psp' + CART_SUBKEY: 'apikey-checkout-carts' + PAYMENT_RECEIPT_SUBKEY: 'apikey-gpd-payments' keyvault: name: "pagopa-u-itn-ebollo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" diff --git a/openapi/openapi.json b/openapi/openapi.json index 931d986..9b58f64 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,467 +1,487 @@ { - "openapi": "3.0.1", - "info": { - "title": "mbd-service", - "description": "MBD Service", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "1.0.1" + "openapi" : "3.0.1", + "info" : { + "title" : "mbd-service", + "description" : "MBD Service", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "0.0.2" }, - "servers": [ - { - "url": "", - "description": "Generated server url" - } - ], - "paths": { - "/organizations/{fiscalCodeEC}/mbd": { - "post": { - "tags": [ - "mbd-controller" - ], - "summary": "getMbd", - "description": "Return mbd data for payment on requirement ", - "operationId": "getMdb", - "parameters": [ - { - "name": "fiscalCodeEC", - "in": "path", - "required": true, - "schema": { - "type": "string" + "servers" : [ { + "url" : "", + "description" : "Generated server url" + } ], + "paths" : { + "/info" : { + "get" : { + "tags" : [ "Home" ], + "summary" : "health check", + "description" : "Return OK if application is started", + "operationId" : "healthCheck", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/AppInfo" + } + } } } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetMbdRequest" + }, + "security" : [ { + "ApiKey" : [ ] + } ] + }, + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" + } + } ] + }, + "/organizations/{fiscalCodeEC}/mbd" : { + "post" : { + "tags" : [ "mbd-controller" ], + "summary" : "getMbd", + "description" : "Return mbd data for payment on requirement ", + "operationId" : "getMdb", + "parameters" : [ { + "name" : "fiscalCodeEC", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/GetMbdRequest" } } }, - "required": true + "required" : true }, - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetCartResponse" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/GetCartResponse" } } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "403": { - "description": "Forbidden", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "403" : { + "description" : "Forbidden", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "404": { - "description": "ibans for the brokerCode not found", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "404" : { + "description" : "ibans for the brokerCode not found", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetCartErrorResponse" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/GetCartErrorResponse" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] }, - "/organizations/{fiscalCode}/receipt/{nav}": { - "get": { - "tags": [ - "mbd-controller" - ], - "summary": "getPaymentReceipt", - "description": "Return receipt of payment on requirement ", - "operationId": "getPaymentReceipts", - "parameters": [ - { - "name": "fiscalCode", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "nav", - "in": "path", - "required": true, - "schema": { - "type": "string" - } + "/organizations/{fiscalCode}/receipt/{nav}" : { + "get" : { + "tags" : [ "mbd-controller" ], + "summary" : "getPaymentReceipt", + "description" : "Return receipt of payment on requirement ", + "operationId" : "getPaymentReceipts", + "parameters" : [ { + "name" : "fiscalCode", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "nav", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + } ], + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetMdbReceipt" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/GetMdbReceipt" } } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/xml": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "403": { - "description": "Forbidden", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "403" : { + "description" : "Forbidden", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "404": { - "description": "ibans for the brokerCode not found", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "404" : { + "description" : "ibans for the brokerCode not found", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] } }, - "components": { - "schemas": { - "GetMbdRequest": { - "required": [ - "idCIService", - "returnUrls" - ], - "type": "object", - "properties": { - "paymentNotices": { - "maxItems": 1, - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/components/schemas/PaymentNotice" + "components" : { + "schemas" : { + "GetMbdRequest" : { + "required" : [ "idCIService", "returnUrls" ], + "type" : "object", + "properties" : { + "paymentNotices" : { + "maxItems" : 1, + "minItems" : 1, + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PaymentNotice" } }, - "idCIService": { - "type": "string" + "idCIService" : { + "type" : "string" }, - "returnUrls": { - "$ref": "#/components/schemas/ReturnUrls" + "returnUrls" : { + "$ref" : "#/components/schemas/ReturnUrls" } } }, - "PaymentNotice": { - "required": [ - "amount", - "email", - "firstName", - "fiscalCode", - "lastName", - "province" - ], - "type": "object", - "properties": { - "firstName": { - "type": "string" + "PaymentNotice" : { + "required" : [ "amount", "email", "firstName", "fiscalCode", "lastName", "province" ], + "type" : "object", + "properties" : { + "firstName" : { + "type" : "string" }, - "lastName": { - "type": "string" + "lastName" : { + "type" : "string" }, - "fiscalCode": { - "type": "string" + "fiscalCode" : { + "type" : "string" }, - "email": { - "type": "string" + "email" : { + "type" : "string" }, - "amount": { - "type": "integer", - "format": "int64" + "amount" : { + "type" : "integer", + "format" : "int64" }, - "province": { - "type": "string" + "province" : { + "type" : "string" }, - "documentHash": { - "maxLength": 44, - "minLength": 44, - "type": "string" + "documentHash" : { + "maxLength" : 44, + "minLength" : 44, + "type" : "string" } } }, - "ReturnUrls": { - "required": [ - "cancelUrl", - "errorUrl", - "successUrl" - ], - "type": "object", - "properties": { - "successUrl": { - "type": "string" + "ReturnUrls" : { + "required" : [ "cancelUrl", "errorUrl", "successUrl" ], + "type" : "object", + "properties" : { + "successUrl" : { + "type" : "string" }, - "cancelUrl": { - "type": "string" + "cancelUrl" : { + "type" : "string" }, - "errorUrl": { - "type": "string" + "errorUrl" : { + "type" : "string" } } }, - "ProblemJson": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "GetCartErrorResponse" : { + "type" : "object", + "properties" : { + "errorUrl" : { + "type" : "string" + } + } + }, + "ProblemJson" : { + "type" : "object", + "properties" : { + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 }, - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" } } }, - "GetCartErrorResponse": { - "type": "object", - "properties": { - "errorUrl": { - "type": "string" + "GetCartResponse" : { + "type" : "object", + "properties" : { + "checkoutRedirectUrl" : { + "type" : "string" } } }, - "GetCartResponse": { - "type": "object", - "properties": { - "checkoutRedirectUrl": { - "type": "string" + "GetMdbReceipt" : { + "type" : "object", + "properties" : { + "content" : { + "type" : "array", + "items" : { + "type" : "string", + "format" : "byte" + } } } }, - "GetMdbReceipt": { - "type": "object", - "properties": { - "content": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } + "AppInfo" : { + "type" : "object", + "properties" : { + "name" : { + "type" : "string" + }, + "version" : { + "type" : "string" + }, + "environment" : { + "type" : "string" } } } }, - "securitySchemes": { - "ApiKey": { - "type": "apiKey", - "description": "The API key to access this function app.", - "name": "Ocp-Apim-Subscription-Key", - "in": "header" + "securitySchemes" : { + "ApiKey" : { + "type" : "apiKey", + "description" : "The API key to access this function app.", + "name" : "Ocp-Apim-Subscription-Key", + "in" : "header" } } } -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/mbd/service/controller/HomeController.java b/src/main/java/it/gov/pagopa/mbd/service/controller/HomeController.java index 6d2daaf..cdcc363 100644 --- a/src/main/java/it/gov/pagopa/mbd/service/controller/HomeController.java +++ b/src/main/java/it/gov/pagopa/mbd/service/controller/HomeController.java @@ -1,16 +1,33 @@ package it.gov.pagopa.mbd.service.controller; import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import it.gov.pagopa.mbd.service.model.AppInfo; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.result.view.RedirectView; +import reactor.core.publisher.Mono; @RestController @Validated public class HomeController { + @Value("${info.application.name}") + private String name; + + @Value("${info.application.version}") + private String version; + + @Value("${info.properties.environment}") + private String environment; + + @Value("${server.servlet.context-path}") String basePath; @@ -25,4 +42,22 @@ public RedirectView home() { } return new RedirectView(basePath + "swagger-ui.html"); } + + /** + * Return app name, version and environment + * + * @return the app info + */ + @Operation( + summary = "health check", + description = "Return OK if application is started", + security = {@SecurityRequirement(name = "ApiKey")}, + tags = {"Home"}) + @GetMapping(value = "/info") + @ResponseStatus(HttpStatus.OK) + public Mono> healthCheck() { + AppInfo info = AppInfo.builder().name(name).version(version).environment(environment).build(); + return Mono.just(ResponseEntity.status(HttpStatus.OK).body(info)); + } + } diff --git a/src/test/java/it/gov/pagopa/mbd/service/controller/HomeControllerTest.java b/src/test/java/it/gov/pagopa/mbd/service/controller/HomeControllerTest.java new file mode 100644 index 0000000..04ac87c --- /dev/null +++ b/src/test/java/it/gov/pagopa/mbd/service/controller/HomeControllerTest.java @@ -0,0 +1,21 @@ +package it.gov.pagopa.mbd.service.controller; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.web.reactive.server.WebTestClient; + +class HomeControllerTest { + + @Autowired + private WebTestClient webClient; + + @Test + void healthCheckTestSuccess() throws Exception { + webClient.get().uri("/info").exchange().expectStatus().is2xxSuccessful(); + } + + @Test + void homeTestSuccess() throws Exception { + webClient.get().exchange().expectStatus().is3xxRedirection(); + } +} \ No newline at end of file