Merge pull request #801 from constantine2nd/develop

Tickets: #773, #765 and #623
This commit is contained in:
Simon Redfern 2017-11-01 11:50:06 +01:00 committed by GitHub
commit 679443c9df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 21 deletions

View File

@ -189,16 +189,16 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
val usr = getUser
usr match {
case Full(u) => fn(Full(u)) // Authentication is successful
case ParamFailure(_, _, _, apiFailure : APIFailure) => errorJsonResponse(apiFailure.msg, apiFailure.responseCode)
case Failure(msg, _, _) => errorJsonResponse(msg)
case _ => errorJsonResponse("oauth error")
case ParamFailure(a, b, c, apiFailure : APIFailure) => ParamFailure(a, b, c, apiFailure : APIFailure)
case Failure(msg, t, c) => Failure(msg, t, c)
case _ => Failure("oauth error")
}
} else if (Props.getBool("allow_direct_login", true) && hasDirectLoginHeader) {
DirectLogin.getUser match {
case Full(u) => fn(Full(u)) // Authentication is successful
case _ => {
var (httpCode, message, directLoginParameters) = DirectLogin.validator("protectedResource", DirectLogin.getHttpMethod)
errorJsonResponse(message, httpCode)
Full(errorJsonResponse(message, httpCode))
}
}
} else if (Props.getBool("allow_gateway_login", false) && hasGatewayHeader) {
@ -222,21 +222,25 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
setGatewayLoginUsername(s)(u.name)
setGatewayLoginCbsToken(s)(cbsAuthToken.get)
fn(Full(u))
case Failure(msg, _, _) => errorJsonResponse(msg)
case _ => errorJsonResponse(payload, httpCode)
case Failure(msg, t, c) => Failure(msg, t, c)
case _ => Full(errorJsonResponse(payload, httpCode))
}
case Failure(msg, _, _) =>
errorJsonResponse(msg)
case Failure(msg, t, c) =>
Failure(msg, t, c)
case _ =>
errorJsonResponse(ErrorMessages.GatewayLoginUnknownError)
Failure(ErrorMessages.GatewayLoginUnknownError)
}
case _ => errorJsonResponse(message, httpCode)
case _ =>
Failure(message)
}
case Full(h) if h.split(",").toList.exists(_.equalsIgnoreCase(getRemoteIpAddress()) == false) => // All other addresses will be rejected
errorJsonResponse(ErrorMessages.GatewayLoginWhiteListAddresses)
case Empty => errorJsonResponse(ErrorMessages.GatewayLoginHostPropertyMissing) // There is no gateway.host in props file
case Failure(msg, _, _) => errorJsonResponse(msg)
case _ => errorJsonResponse(ErrorMessages.GatewayLoginUnknownError)
Failure(ErrorMessages.GatewayLoginWhiteListAddresses)
case Empty =>
Failure(ErrorMessages.GatewayLoginHostPropertyMissing) // There is no gateway.host in props file
case Failure(msg, t, c) =>
Failure(msg, t, c)
case _ =>
Failure(ErrorMessages.GatewayLoginUnknownError)
}
} else {
fn(Empty)

View File

@ -3,7 +3,7 @@ package code.api.ResourceDocs1_4_0
import code.api.util.APIUtil
import code.api.util.APIUtil.{defaultJValue, _}
import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
import code.api.v3_0_0.{LobbyJsonV330, _}
import code.api.v3_0_0.{AdapterInfoJsonV300, LobbyJsonV330, _}
import code.bankconnectors.vMar2017.{MessageDocJson, MessageDocsJson}
import code.branches.Branches.{DriveUpString, _}
import code.common._
@ -1895,7 +1895,7 @@ object SwaggerDefinitionsJSON {
val connectorMetricJson = ConnectorMetricJson(
connector_name = "mapper",
function_name = "getBanks",
obp_api_request_id = "12345",
correlation_id = "12345",
date = exampleDate,
duration = 1000
)
@ -2000,6 +2000,14 @@ object SwaggerDefinitionsJSON {
account_routing = accountRoutingJsonV121
)
val coreAccountsJsonV300 = CoreAccountsJsonV300(accounts = List(coreAccountJsonV300))
val adapterInfoJsonV300 = AdapterInfoJsonV300(
name = "String",
version = "String",
git_commit = "String",
date = "String"
)
//The commont error or success format.
//Just some helper format to use in Json
case class NoSupportYet()

View File

@ -252,7 +252,7 @@ case class ConfigurationJSON(akka: AkkaJSON, elastic_search: ElasticSearchJSON,
case class ConnectorMetricJson(
connector_name: String,
function_name: String,
obp_api_request_id: String,
correlation_id: String,
date: Date,
duration: Long
)
@ -576,7 +576,7 @@ object JSONFactory220{
ConnectorMetricJson(
connector_name = metric.getConnectorName(),
function_name = metric.getFunctionName(),
obp_api_request_id = metric.getCorrelationId(),
correlation_id = metric.getCorrelationId(),
duration = metric.getDuration(),
date = metric.getDate()
)

View File

@ -708,7 +708,7 @@ trait APIMethods300 {
|
""".stripMargin,
emptyObjectJson,
usersJSONV200,
adapterInfoJsonV300,
List(UserNotLoggedIn, UnknownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagApi))
@ -716,13 +716,13 @@ trait APIMethods300 {
lazy val getAdapter: PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
case "banks" :: BankId(bankId) :: "adapter" :: Nil JsonGet _ => {
user =>
_ =>
for {
_ <- Bank(bankId) ?~! BankNotFound
ai: InboundAdapterInfoInternal <- Connector.connector.vend.getAdapterInfo() ?~ "Not implemented"
}
yield {
successJsonResponseFromCaseClass(ai)
successJsonResponseFromCaseClass(createAdapterInfoJson(ai))
}
}
}

View File

@ -32,6 +32,7 @@ import code.api.v1_2_1._
import code.api.v1_4_0.JSONFactory1_4_0.{BranchesJsonV300, _}
import code.api.v2_0_0.JSONFactory200.{UserJsonV200, UsersJSONV200}
import code.atms.Atms.{Atm, AtmId, AtmT}
import code.bankconnectors.vMar2017.InboundAdapterInfoInternal
import code.branches.Branches._
import code.entitlement.Entitlement
import code.model.dataAccess.ResourceUser
@ -341,6 +342,14 @@ case class AtmJsonV300 (
case class AtmsJsonV300(branches : List[AtmJsonV300])
case class AdapterInfoJsonV300(
name: String,
version: String,
git_commit: String,
date: String
)
object JSONFactory300{
//stated -- Transaction relevant methods /////
def createTransactionsJson(transactions: List[ModeratedTransaction]) : TransactionsJsonV300 = {
@ -904,5 +913,13 @@ object JSONFactory300{
}
def createAdapterInfoJson(ai: InboundAdapterInfoInternal): AdapterInfoJsonV300 = {
AdapterInfoJsonV300(
name = ai.name,
version = ai.version,
git_commit = ai.git_commit,
date = ai.date
)
}
}