diff --git a/obp-api/src/main/resources/props/sample.props.template b/obp-api/src/main/resources/props/sample.props.template index a9a3fd1cdd..5b1810460d 100644 --- a/obp-api/src/main/resources/props/sample.props.template +++ b/obp-api/src/main/resources/props/sample.props.template @@ -1180,6 +1180,11 @@ personal_data_collection_consent_country_waiver_list = Austria, Belgium, Bulgari # local_identity_provider=strongly recommended to use top level domain name so that all nodes in the cluster share same provider name +# User Invitation Link Base URL +# it defaults to the "portal_hostname" as a 1st choise and to the "hostname" props value as a 2nd choise +# user_invitation_link_base_URL=strongly recommended to use top level domain name so that all nodes in the cluster share same URL + + # enable dynamic code sandbox, default is false, this will make sandbox works for code running in Future, will make performance lower than disable dynamic_code_sandbox_enable=false # Here is the default permissions if you set the dynamic_code_sandbox_enable = true. If you need more permission need to add it manually here. diff --git a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala index 096de0a477..c26cbe6291 100644 --- a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala +++ b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala @@ -442,22 +442,6 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { ) } - private def extractAccountData(scheme: String, address: String): (String, String, String, String, String) = { - val (iban: String, bban: String, pan: String, maskedPan: String, currency: String) = Connector.connector.vend.getBankAccountByRoutingLegacy( - None, - scheme, - address, - None - ) match { - case Full((account, _)) => - val (iban: String, bban: String) = getIbanAndBban(account) - val (pan, maskedPan) = (account.number, getMaskedPrimaryAccountNumber(accountNumber = account.number)) - (iban, bban, pan, maskedPan, account.currency) - case _ => ("", "", "", "", "") - } - (iban, bban, pan, maskedPan, currency) - } - def createTransactionsJson(bankAccount: BankAccount, transactions: List[ModeratedTransaction], transactionRequests: List[TransactionRequest]) : TransactionsJsonV13 = { val accountId = bankAccount.accountId.value val (iban: String, bban: String) = getIbanAndBban(bankAccount) diff --git a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala index d69d4907b8..322302c948 100644 --- a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala +++ b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala @@ -385,6 +385,7 @@ object ErrorMessages { val BankAccountNotFoundByAccountRouting = "OBP-30073: Bank Account not found. Please specify valid values for account routing scheme and address." val BankAccountNotFoundByIban = "OBP-30074: Bank Account not found. Please specify a valid value for iban." val AccountRoutingNotFound = "OBP-30075: Account routing not found, Please specify valid values for account routing scheme and address" + val AccountRoutingNotUnique = "OBP-31075: Routing is not unique at this instance" val BankAccountNotFoundByAccountId = "OBP-30076: Bank Account not found. Please specify a valid value for ACCOUNT_ID." val TransactionRequestAttributeNotFound = "OBP-30078: Transaction Request Attribute not found. Please specify a valid value for TRANSACTION_REQUEST_ATTRIBUTE_ID." diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 56f25e11a9..fcf804f28d 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -3822,7 +3822,7 @@ trait APIMethods400 extends MdcLoggable { postedData.purpose, cc.callContext) } yield { - val link = s"${APIUtil.getPropsValue("portal_hostname", Constant.HostName)}/user-invitation?id=${invitation.secretKey}" + val link = s"${APIUtil.getPropsValue("user_invitation_link_base_URL", APIUtil.getPropsValue("portal_hostname", Constant.HostName))}/user-invitation?id=${invitation.secretKey}" if (postedData.purpose == UserInvitationPurpose.DEVELOPER.toString){ val subject = getWebUiPropsValue("webui_developer_user_invitation_email_subject", "Welcome to the API Playground") val from = getWebUiPropsValue("webui_developer_user_invitation_email_from", "do-not-reply@openbankproject.com") diff --git a/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala b/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala index 022cfc9100..8d973c2d8b 100644 --- a/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala +++ b/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala @@ -951,7 +951,8 @@ trait APIMethods500 { val vrpViewId = s"_VRP-${UUID.randomUUID.toString}".dropRight(5)// to make sure the length of the viewId is 36. val targetPermissions = List(//may need getTransactionRequest .. so far only this payments. - "can_add_transaction_request_to_beneficiary" + "can_add_transaction_request_to_beneficiary", + "can_get_counterparty" ) val targetCreateCustomViewJson = CreateCustomViewJson( @@ -990,13 +991,13 @@ trait APIMethods500 { description = postConsentRequestJsonV510.to_account.counterparty_name, currency = postConsentRequestJsonV510.to_account.limit.currency, other_account_routing_scheme = postConsentRequestJsonV510.to_account.account_routing.scheme, - other_account_routing_address = postConsentRequestJsonV510.to_account.account_routing.scheme, + other_account_routing_address = postConsentRequestJsonV510.to_account.account_routing.address, other_account_secondary_routing_scheme = "", other_account_secondary_routing_address = "", - other_bank_routing_scheme = postConsentRequestJsonV510.to_account.account_routing.scheme, - other_bank_routing_address = postConsentRequestJsonV510.to_account.account_routing.scheme, - other_branch_routing_scheme = postConsentRequestJsonV510.to_account.account_routing.scheme, - other_branch_routing_address = postConsentRequestJsonV510.to_account.account_routing.scheme, + other_bank_routing_scheme = postConsentRequestJsonV510.to_account.bank_routing.scheme, + other_bank_routing_address = postConsentRequestJsonV510.to_account.bank_routing.address, + other_branch_routing_scheme = postConsentRequestJsonV510.to_account.branch_routing.scheme, + other_branch_routing_address = postConsentRequestJsonV510.to_account.branch_routing.address, is_beneficiary = true, bespoke = Nil ) @@ -1113,7 +1114,7 @@ trait APIMethods500 { Future.sequence( consentRequestJson.account_access.map( access => - NewStyle.function.getBankAccountByRouting(None,access.account_routing.scheme, access.account_routing.address, cc.callContext) + NewStyle.function.getBankAccountByRouting(consentRequestJson.bank_id.map(BankId(_)),access.account_routing.scheme, access.account_routing.address, cc.callContext) .map(result =>PostConsentViewJsonV310( result._1.bankId.value, result._1.accountId.value, diff --git a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala index b6ea170f10..b35a61f648 100644 --- a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala @@ -846,15 +846,25 @@ object LocalMappedConnector extends Connector with MdcLoggable { } override def getBankAccountByRoutingLegacy(bankId: Option[BankId], scheme: String, address: String, callContext: Option[CallContext]): Box[(BankAccount, Option[CallContext])] = { + def handleRouting(routing: List[BankAccountRouting]): Box[(MappedBankAccount, Option[CallContext])] = { + if (routing.size > 1) { // Handle more than 1 occurrence + // Routing MUST be unique + val errorMessage = s"$AccountRoutingNotUnique (scheme: $scheme, address: $address)" + Failure(errorMessage) + } else { // Handle 0 and 1 occurrence + Box(routing.headOption).flatMap(accountRouting => getBankAccountCommon(accountRouting.bankId, accountRouting.accountId, callContext)) + } + } + bankId match { - case Some(bankId) => - BankAccountRouting - .find(By(BankAccountRouting.BankId, bankId.value), By(BankAccountRouting.AccountRoutingScheme, scheme), By(BankAccountRouting.AccountRoutingAddress, address)) - .flatMap(accountRouting => getBankAccountCommon(accountRouting.bankId, accountRouting.accountId, callContext)) - case None => - BankAccountRouting - .find(By(BankAccountRouting.AccountRoutingScheme, scheme), By(BankAccountRouting.AccountRoutingAddress, address)) - .flatMap(accountRouting => getBankAccountCommon(accountRouting.bankId, accountRouting.accountId, callContext)) + case Some(bankId) => // Bank specific routing + val routing = BankAccountRouting + .findAll(By(BankAccountRouting.BankId, bankId.value), By(BankAccountRouting.AccountRoutingScheme, scheme), By(BankAccountRouting.AccountRoutingAddress, address)) + handleRouting(routing) + case None => // World wide specific routing (IBAN etc.) + val routing = BankAccountRouting + .findAll(By(BankAccountRouting.AccountRoutingScheme, scheme), By(BankAccountRouting.AccountRoutingAddress, address)) + handleRouting(routing) } } diff --git a/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala b/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala index af98a24033..1d2a18b6ca 100644 --- a/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala +++ b/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala @@ -64,6 +64,7 @@ class ConsentRequestTest extends V500ServerSetupAsync with PropsReset{ object ApiEndpoint6 extends Tag(nameOf(Implementations5_0_0.getConsentRequest)) lazy val entitlements = List(PostConsentEntitlementJsonV310("", CanGetAnyUser.toString())) + lazy val bankId = testBankId1.value lazy val forbiddenEntitlementOneBank = List(PostConsentEntitlementJsonV310(testBankId1.value, CanCreateEntitlementAtOneBank.toString())) lazy val forbiddenEntitlementAnyBank = List(PostConsentEntitlementJsonV310("", CanCreateEntitlementAtAnyBank.toString())) lazy val accountAccess = List(AccountAccessV500( @@ -73,6 +74,7 @@ class ConsentRequestTest extends V500ServerSetupAsync with PropsReset{ lazy val postConsentRequestJson = SwaggerDefinitionsJSON.postConsentRequestJsonV500 .copy(entitlements=Some(entitlements)) .copy(consumer_id=None) + .copy(bank_id=Some(bankId)) .copy(account_access=accountAccess) val createConsentRequestWithoutLoginUrl = (v5_0_0_Request / "consumer" / "consent-requests") diff --git a/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala b/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala index e6b3aeaa05..b1955d6ddb 100644 --- a/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala +++ b/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala @@ -75,8 +75,9 @@ class ConsentsTest extends V510ServerSetup with PropsReset{ lazy val postConsentRequestJsonV310 = SwaggerDefinitionsJSON.postConsentRequestJsonV500 .copy(entitlements=Some(entitlements)) .copy(consumer_id=None) + .copy(bank_id=Some(bankId)) .copy(account_access=accountAccess) - + val createConsentRequestWithoutLoginUrl = (v5_1_0_Request / "consumer" / "consent-requests") val createConsentRequestUrl = (v5_1_0_Request / "consumer"/ "consent-requests").POST<@(user1) def getConsentRequestUrl(requestId:String) = (v5_1_0_Request / "consumer"/ "consent-requests"/requestId).GET<@(user1)