Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few tweaks #2420

Merged
merged 12 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions obp-api/src/main/scala/code/api/util/ErrorMessages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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", "[email protected]")
Expand Down
15 changes: 8 additions & 7 deletions obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading