mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:07:02 +00:00
Merge branch 'OpenBankProject:develop' into develop
This commit is contained in:
commit
dd8d671526
@ -95,10 +95,11 @@ object MessageDocsSwaggerDefinitions
|
||||
|
||||
|
||||
val inboundStatusMessage = InboundStatusMessage(
|
||||
source ="String",
|
||||
status ="String",
|
||||
errorCode ="String",
|
||||
text= "String"
|
||||
source = sourceExample.value,
|
||||
status = statusExample.value,
|
||||
errorCode = errorCodeExample.value,
|
||||
text = textExample.value,
|
||||
duration= Some(durationExample.value),
|
||||
)
|
||||
|
||||
val inboundStatus = Status("Status errorCode", List(inboundStatusMessage))
|
||||
@ -109,8 +110,8 @@ object MessageDocsSwaggerDefinitions
|
||||
errorCode ="",
|
||||
backendMessages = List(inboundStatusMessage),
|
||||
name = usernameExample.value,
|
||||
version = "",
|
||||
git_commit = "String",
|
||||
version = versionExample.value,
|
||||
git_commit = gitCommitExample.value,
|
||||
date = DateWithMsExampleString
|
||||
)
|
||||
|
||||
|
||||
@ -964,7 +964,6 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
//Make a final string
|
||||
val definitions = "{\"definitions\":{" + particularDefinitionsPart + "}}"
|
||||
//Make a jsonAST from a string
|
||||
org.scalameta.logger.elem(definitions)
|
||||
parse(definitions)
|
||||
}
|
||||
|
||||
|
||||
@ -358,6 +358,12 @@ object ApiRole {
|
||||
case class CanGetConfig(requiresBankId: Boolean = false) extends ApiRole
|
||||
lazy val canGetConfig = CanGetConfig()
|
||||
|
||||
case class CanGetAdapterInfo(requiresBankId: Boolean = false) extends ApiRole
|
||||
lazy val canGetAdapterInfo = CanGetAdapterInfo()
|
||||
|
||||
case class CanGetAdapterInfoAtOneBank(requiresBankId: Boolean = false) extends ApiRole
|
||||
lazy val canGetAdapterInfoAtOneBank = CanGetAdapterInfoAtOneBank()
|
||||
|
||||
case class CanGetDatabaseInfo(requiresBankId: Boolean = false) extends ApiRole
|
||||
lazy val canGetDatabaseInfo = CanGetDatabaseInfo()
|
||||
|
||||
|
||||
@ -287,7 +287,7 @@ object ErrorMessages {
|
||||
val CreateCardError = "OBP-30032: Could not insert the Card"
|
||||
val UpdateCardError = "OBP-30033: Could not update the Card"
|
||||
|
||||
val ViewIdNotSupported = "OBP-30034: This ViewId is do not supported. Only support four now: Owner, Accountant, Auditor, StageOne, SmallPaymentVerified, _Public."
|
||||
val ViewIdNotSupported = "OBP-30034: This ViewId is not supported. Only support four now: Owner, Accountant, Auditor, StageOne, Standard, _Public."
|
||||
|
||||
val UserCustomerLinkNotFound = "OBP-30035: User Customer Link not found"
|
||||
|
||||
|
||||
@ -722,6 +722,12 @@ object ExampleValue {
|
||||
|
||||
lazy val statusExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
|
||||
glossaryItems += makeGlossaryItem("status", statusExample)
|
||||
|
||||
lazy val errorCodeExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
|
||||
glossaryItems += makeGlossaryItem("errorCode", errorCodeExample)
|
||||
|
||||
lazy val textExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
|
||||
glossaryItems += makeGlossaryItem("text", textExample)
|
||||
|
||||
lazy val canSeeTransactionBalanceExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
|
||||
glossaryItems += makeGlossaryItem("can_see_transaction_balance", canSeeTransactionBalanceExample)
|
||||
|
||||
@ -1007,16 +1007,19 @@ trait APIMethods300 {
|
||||
""".stripMargin,
|
||||
emptyObjectJson,
|
||||
adapterInfoJsonV300,
|
||||
List(UserNotLoggedIn, UnknownError),
|
||||
List(apiTagApi, apiTagNewStyle))
|
||||
List(UserNotLoggedIn, UserHasMissingRoles, UnknownError),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canGetAdapterInfoAtOneBank))
|
||||
)
|
||||
|
||||
|
||||
lazy val getAdapterInfoForBank: OBPEndpoint = {
|
||||
case "banks" :: BankId(bankId) :: "adapter" :: Nil JsonGet _ => {
|
||||
cc =>
|
||||
for {
|
||||
(_, callContext) <- anonymousAccess(cc)
|
||||
(Full(u), callContext) <- authenticatedAccess(cc)
|
||||
(_, callContext) <- NewStyle.function.getBank(bankId, callContext)
|
||||
_ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, ApiRole.canGetAdapterInfoAtOneBank, callContext)
|
||||
(ai, callContext) <- NewStyle.function.getAdapterInfo(callContext)
|
||||
} yield {
|
||||
(createAdapterInfoJson(ai), callContext)
|
||||
|
||||
@ -1055,15 +1055,18 @@ trait APIMethods310 {
|
||||
""".stripMargin,
|
||||
emptyObjectJson,
|
||||
adapterInfoJsonV300,
|
||||
List(UserNotLoggedIn, UnknownError),
|
||||
List(apiTagApi, apiTagNewStyle))
|
||||
List(UserNotLoggedIn,UserHasMissingRoles, UnknownError),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canGetAdapterInfo))
|
||||
)
|
||||
|
||||
|
||||
lazy val getAdapterInfo: OBPEndpoint = {
|
||||
case "adapter" :: Nil JsonGet _ => {
|
||||
cc =>
|
||||
for {
|
||||
(_, callContext) <- anonymousAccess(cc)
|
||||
(Full(u), callContext) <- authenticatedAccess(cc)
|
||||
_ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canGetAdapterInfo, callContext)
|
||||
(ai,_) <- NewStyle.function.getAdapterInfo(callContext)
|
||||
} yield {
|
||||
(createAdapterInfoJson(ai), HttpCode.`200`(callContext))
|
||||
|
||||
@ -39,7 +39,11 @@ import net.liftweb.http.rest.RestHelper
|
||||
import net.liftweb.json
|
||||
import net.liftweb.json.{Extraction, compactRender, prettyRender}
|
||||
import net.liftweb.util.Helpers.tryo
|
||||
import net.liftweb.util.Props
|
||||
import net.liftweb.util.{Helpers, Props}
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
|
||||
import code.accountattribute.AccountAttributeX
|
||||
import code.util.Helper.booleanToFuture
|
||||
|
||||
import scala.collection.immutable.{List, Nil}
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
@ -2031,6 +2035,36 @@ trait APIMethods500 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resourceDocs += ResourceDoc(
|
||||
getAdapterInfo,
|
||||
implementedInApiVersion,
|
||||
nameOf(getAdapterInfo),
|
||||
"GET",
|
||||
"/adapter",
|
||||
"Get Adapter Info",
|
||||
s"""Get basic information about the Adapter.
|
||||
|
|
||||
|${authenticationRequiredMessage(false)}
|
||||
|
|
||||
""".stripMargin,
|
||||
emptyObjectJson,
|
||||
adapterInfoJsonV300,
|
||||
List($UserNotLoggedIn, UserHasMissingRoles, UnknownError),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canGetAdapterInfo))
|
||||
)
|
||||
lazy val getAdapterInfo: OBPEndpoint = {
|
||||
case "adapter" :: Nil JsonGet _ => {
|
||||
cc =>
|
||||
for {
|
||||
(_, callContext) <- SS.user
|
||||
(adapterInfo,_) <- NewStyle.function.getAdapterInfo(callContext)
|
||||
} yield {
|
||||
(JSONFactory500.createAdapterInfoJson(adapterInfo,cc.startTime.getOrElse(Helpers.now).getTime), HttpCode.`200`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,13 +35,14 @@ import code.api.v1_3_0.JSONFactory1_3_0.{cardActionsToString, createAccountJson,
|
||||
import code.api.v1_3_0.{PinResetJSON, ReplacementJSON}
|
||||
import code.api.v1_4_0.JSONFactory1_4_0.{CustomerFaceImageJson, MetaJsonV140}
|
||||
import code.api.v2_1_0.CustomerCreditRatingJSON
|
||||
import code.api.v3_0_0.{CustomerAttributeResponseJsonV300, JSONFactory300}
|
||||
import code.api.v3_1_0.{AccountBasicV310, PostConsentEntitlementJsonV310}
|
||||
import code.api.v3_0_0.{AdapterInfoJsonV300, CustomerAttributeResponseJsonV300, JSONFactory300}
|
||||
import code.api.v3_1_0.{AccountAttributeResponseJson, AccountBasicV310, CustomerWithAttributesJsonV310, PhysicalCardWithAttributesJsonV310, PostConsentEntitlementJsonV310}
|
||||
import code.api.v4_0_0.BankAttributeBankResponseJsonV400
|
||||
import code.bankattribute.BankAttribute
|
||||
import code.customeraccountlinks.CustomerAccountLinkTrait
|
||||
import com.openbankproject.commons.model._
|
||||
import com.openbankproject.commons.model.{AccountAttribute, AccountRouting, AccountRoutingJsonV121, AmountOfMoneyJsonV121, Bank, BankAccount, CardAttribute, CreateViewJson, Customer, CustomerAttribute, InboundAdapterInfoInternal, InboundStatusMessage, PhysicalCardTrait, UpdateViewJSON, User, UserAuthContext, UserAuthContextUpdate, View, ViewBasic}
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.util.Helpers
|
||||
|
||||
import scala.collection.immutable.List
|
||||
|
||||
@ -369,6 +370,15 @@ case class CustomerAccountLinksJson(
|
||||
links:List[CustomerAccountLinkJson]
|
||||
)
|
||||
|
||||
case class AdapterInfoJsonV500(
|
||||
name: String,
|
||||
version: String,
|
||||
git_commit: String,
|
||||
date: String,
|
||||
total_duration: String,
|
||||
backend_messages: List[InboundStatusMessage],
|
||||
)
|
||||
|
||||
|
||||
case class CreateViewJsonV500(
|
||||
name: String,
|
||||
@ -845,5 +855,16 @@ object JSONFactory500 {
|
||||
ViewsIdsJsonV500(views.map(i => ViewIdJsonV500(i.viewId.value)))
|
||||
}
|
||||
|
||||
def createAdapterInfoJson(inboundAdapterInfoInternal: InboundAdapterInfoInternal, startTime: Long): AdapterInfoJsonV500 = {
|
||||
AdapterInfoJsonV500(
|
||||
name = inboundAdapterInfoInternal.name,
|
||||
version = inboundAdapterInfoInternal.version,
|
||||
git_commit = inboundAdapterInfoInternal.git_commit,
|
||||
date = inboundAdapterInfoInternal.date,
|
||||
total_duration = s"${Helpers.now.getTime - startTime} ms",
|
||||
backend_messages = inboundAdapterInfoInternal.backendMessages
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -87,14 +87,13 @@ import com.tesobe.model.UpdateBankAccount
|
||||
import com.twilio.Twilio
|
||||
import com.twilio.rest.api.v2010.account.Message
|
||||
import com.twilio.`type`.PhoneNumber
|
||||
|
||||
import net.liftweb.common._
|
||||
import net.liftweb.json
|
||||
import net.liftweb.json.JsonAST.JField
|
||||
import net.liftweb.json.{JArray, JBool, JInt, JObject, JString, JValue}
|
||||
import net.liftweb.mapper.{By, _}
|
||||
import net.liftweb.util.Helpers.{hours, now, time, tryo}
|
||||
import net.liftweb.util.Mailer
|
||||
import net.liftweb.util.{Helpers, Mailer}
|
||||
import net.liftweb.util.Mailer.{From, PlainMailBodyType, Subject, To}
|
||||
import org.iban4j
|
||||
import org.iban4j.{CountryCode, IbanFormat}
|
||||
@ -126,15 +125,26 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
implicit override val nameOfConnector = LocalMappedConnector.getClass.getSimpleName
|
||||
|
||||
//
|
||||
override def getAdapterInfo(callContext: Option[CallContext]): Future[Box[(InboundAdapterInfoInternal, Option[CallContext])]] = Future(
|
||||
override def getAdapterInfo(callContext: Option[CallContext]): Future[Box[(InboundAdapterInfoInternal, Option[CallContext])]] = Future {
|
||||
val startTime = Helpers.now.getTime
|
||||
val source = APIUtil.getPropsValue("db.driver","org.h2.Driver")
|
||||
Full(InboundAdapterInfoInternal(
|
||||
errorCode = "",
|
||||
backendMessages = Nil,
|
||||
backendMessages = List(
|
||||
InboundStatusMessage(
|
||||
source = source,
|
||||
status = "Success",
|
||||
errorCode = "",
|
||||
text =s"Get data from $source database",
|
||||
duration = Some(s"${Helpers.now.getTime - startTime} ms")
|
||||
)
|
||||
),
|
||||
name = "LocalMappedConnector",
|
||||
version = "mapped",
|
||||
git_commit = APIUtil.gitCommit,
|
||||
date = DateWithMsFormat.format(new Date())
|
||||
), callContext))
|
||||
), callContext)
|
||||
}
|
||||
|
||||
override def validateAndCheckIbanNumber(iban: String, callContext: Option[CallContext]): OBPReturnType[Box[IbanChecker]] = Future {
|
||||
import org.iban4j.CountryCode
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
/**
|
||||
Open Bank Project - API
|
||||
Copyright (C) 2011-2019, TESOBE GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Email: contact@tesobe.com
|
||||
TESOBE GmbH
|
||||
Osloerstrasse 16/17
|
||||
Berlin 13359, Germany
|
||||
|
||||
This product includes software developed at
|
||||
TESOBE (http://www.tesobe.com/)
|
||||
*/
|
||||
package code.api.v3_0_0
|
||||
|
||||
import code.api.util.ApiRole.canGetAdapterInfoAtOneBank
|
||||
import code.api.util.ErrorMessages.{UserHasMissingRoles, UserNotLoggedIn}
|
||||
import code.api.v3_0_0.OBPAPI3_0_0.Implementations3_0_0
|
||||
import code.api.util.APIUtil.OAuth._
|
||||
import code.entitlement.Entitlement
|
||||
import code.setup.DefaultUsers
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model.ErrorMessage
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import org.scalatest.Tag
|
||||
|
||||
class GetAdapterInfoTest extends V300ServerSetup with DefaultUsers {
|
||||
|
||||
/**
|
||||
* Test tags
|
||||
* Example: To run tests with tag "getPermissions":
|
||||
* mvn test -D tagsToInclude
|
||||
*
|
||||
* This is made possible by the scalatest maven plugin
|
||||
*/
|
||||
object VersionOfApi extends Tag(ApiVersion.v3_0_0.toString)
|
||||
object ApiEndpoint extends Tag(nameOf(Implementations3_0_0.getAdapterInfoForBank))
|
||||
|
||||
feature("Get Adapter Info v3.1.0")
|
||||
{
|
||||
scenario(s"$UserNotLoggedIn error case", ApiEndpoint, VersionOfApi) {
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_0Request /"banks"/testBankId1.value/ "adapter").GET
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 401")
|
||||
response310.code should equal(401)
|
||||
And("error should be " + UserNotLoggedIn)
|
||||
response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn)
|
||||
}
|
||||
scenario(s"$UserHasMissingRoles error case", ApiEndpoint, VersionOfApi) {
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_0Request / "banks"/testBankId1.value/ "adapter").GET <@ (user1)
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 403")
|
||||
response310.code should equal(403)
|
||||
And("error should be " + UserHasMissingRoles + canGetAdapterInfoAtOneBank)
|
||||
response310.body.extract[ErrorMessage].message contains (UserHasMissingRoles + canGetAdapterInfoAtOneBank) shouldBe (true)
|
||||
}
|
||||
scenario("We will try to get adapter info", ApiEndpoint, VersionOfApi) {
|
||||
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, canGetAdapterInfoAtOneBank.toString)
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_0Request / "banks"/testBankId1.value/ "adapter").GET <@ (user1)
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
response310.body.extract[AdapterInfoJsonV300].name should equal("LocalMappedConnector")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -27,11 +27,17 @@ package code.api.v3_1_0
|
||||
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import code.api.v3_0_0.AdapterInfoJsonV300
|
||||
import code.api.util.APIUtil.OAuth._
|
||||
import code.api.util.ApiRole.{CanCreateAccountAttributeAtOneBank, canGetAdapterInfo}
|
||||
import code.api.util.ErrorMessages.{UserHasMissingRoles, UserNotLoggedIn}
|
||||
import code.setup.{APIResponse, DefaultUsers}
|
||||
import code.api.v3_1_0.OBPAPI3_1_0.Implementations3_1_0
|
||||
import code.entitlement.Entitlement
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model.ErrorMessage
|
||||
import org.scalatest.Tag
|
||||
|
||||
class GetAdapterInfoTest extends V310ServerSetup {
|
||||
class GetAdapterInfoTest extends V310ServerSetup with DefaultUsers {
|
||||
|
||||
/**
|
||||
* Test tags
|
||||
@ -45,14 +51,34 @@ class GetAdapterInfoTest extends V310ServerSetup {
|
||||
|
||||
feature("Get Adapter Info v3.1.0")
|
||||
{
|
||||
scenario("We will try to get adapter info", ApiEndpoint, VersionOfApi) {
|
||||
scenario(s"$UserNotLoggedIn error case", ApiEndpoint, VersionOfApi) {
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_1_0_Request / "adapter").GET
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 401")
|
||||
response310.code should equal(401)
|
||||
And("error should be " + UserNotLoggedIn)
|
||||
response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn)
|
||||
}
|
||||
scenario(s"$UserHasMissingRoles error case", ApiEndpoint, VersionOfApi) {
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_1_0_Request / "adapter").GET <@ (user1)
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 403")
|
||||
response310.code should equal(403)
|
||||
And("error should be " + UserHasMissingRoles + canGetAdapterInfo)
|
||||
response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + canGetAdapterInfo)
|
||||
}
|
||||
scenario("We will try to get adapter info", ApiEndpoint, VersionOfApi) {
|
||||
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, canGetAdapterInfo.toString)
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_1_0_Request / "adapter").GET <@ (user1)
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
response310.body.extract[AdapterInfoJsonV300].name should equal("LocalMappedConnector")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
/**
|
||||
Open Bank Project - API
|
||||
Copyright (C) 2011-2019, TESOBE GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Email: contact@tesobe.com
|
||||
TESOBE GmbH
|
||||
Osloerstrasse 16/17
|
||||
Berlin 13359, Germany
|
||||
|
||||
This product includes software developed at
|
||||
TESOBE (http://www.tesobe.com/)
|
||||
*/
|
||||
package code.api.v5_0_0
|
||||
|
||||
import code.api.util.ApiRole.canGetAdapterInfo
|
||||
import code.api.util.ErrorMessages.{UserHasMissingRoles, UserNotLoggedIn}
|
||||
import code.api.v3_0_0.AdapterInfoJsonV300
|
||||
import code.api.v5_0_0.OBPAPI5_0_0.Implementations5_0_0
|
||||
import code.api.util.APIUtil.OAuth._
|
||||
import code.entitlement.Entitlement
|
||||
import code.setup.DefaultUsers
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model.ErrorMessage
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import org.scalatest.Tag
|
||||
|
||||
class GetAdapterInfoTest extends V500ServerSetup with DefaultUsers {
|
||||
|
||||
/**
|
||||
* Test tags
|
||||
* Example: To run tests with tag "getPermissions":
|
||||
* mvn test -D tagsToInclude
|
||||
*
|
||||
* This is made possible by the scalatest maven plugin
|
||||
*/
|
||||
object VersionOfApi extends Tag(ApiVersion.v5_0_0.toString)
|
||||
object ApiEndpoint extends Tag(nameOf(Implementations5_0_0.getAdapterInfo))
|
||||
|
||||
feature("Get Adapter Info v5.0.0")
|
||||
{
|
||||
scenario(s"$UserNotLoggedIn error case", ApiEndpoint, VersionOfApi) {
|
||||
When("We make a request v5.0.0")
|
||||
val request310 = (v5_0_0_Request / "adapter").GET
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 401")
|
||||
response310.code should equal(401)
|
||||
And("error should be " + UserNotLoggedIn)
|
||||
response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn)
|
||||
}
|
||||
scenario(s"$UserHasMissingRoles error case", ApiEndpoint, VersionOfApi) {
|
||||
When("We make a request v5.0.0")
|
||||
val request310 = (v5_0_0_Request / "adapter").GET <@ (user1)
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 403")
|
||||
response310.code should equal(403)
|
||||
And("error should be " + UserHasMissingRoles + canGetAdapterInfo)
|
||||
response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + canGetAdapterInfo)
|
||||
}
|
||||
scenario("We will try to get adapter info", ApiEndpoint, VersionOfApi) {
|
||||
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, canGetAdapterInfo.toString)
|
||||
When("We make a request v5.0.0")
|
||||
val request310 = (v5_0_0_Request / "adapter").GET <@ (user1)
|
||||
val response310 = makeGetRequest(request310)
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
response310.body.extract[AdapterInfoJsonV500].name should equal("LocalMappedConnector")
|
||||
response310.body.extract[AdapterInfoJsonV500].total_duration.length >0 shouldBe(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@ -65,7 +65,8 @@ case class InboundStatusMessage(
|
||||
source: String,
|
||||
status: String,
|
||||
errorCode: String,
|
||||
text: String
|
||||
text: String,
|
||||
duration: Option[String] = None //added from V500
|
||||
)
|
||||
|
||||
case class Status(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user