Skip to content

Commit

Permalink
Merge pull request #2246 from constantine2nd/develop
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
simonredfern authored Jul 19, 2023
2 parents 5fe4faf + 437e411 commit 2a353ee
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package code.api.berlin.group.v1_3

import code.api.BerlinGroup.ScaStatus
import code.api.Constant
import code.api.Constant.SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{CancellationJsonV13, InitiatePaymentResponseJson, StartPaymentAuthorisationJson}
import code.api.builder.PaymentInitiationServicePISApi.APIMethods_PaymentInitiationServicePISApi
import code.api.util.APIUtil.OAuth._
Expand All @@ -9,9 +11,10 @@ import code.api.util.ErrorMessages.{AuthorisationNotFound, InvalidJsonFormat, No
import code.model.dataAccess.{BankAccountRouting, MappedBankAccount}
import code.setup.{APIResponse, DefaultUsers}
import code.transactionrequests.TransactionRequests.{PaymentServiceTypes, TransactionRequestTypes}
import code.views.Views
import com.github.dwickern.macros.NameOf.nameOf
import com.openbankproject.commons.model.enums.AccountRoutingScheme
import com.openbankproject.commons.model.{ErrorMessage, SepaCreditTransfers, SepaCreditTransfersBerlinGroupV13}
import com.openbankproject.commons.model.{ErrorMessage, SepaCreditTransfers, SepaCreditTransfersBerlinGroupV13, ViewId}
import net.liftweb.json.Serialization.write
import net.liftweb.mapper.By
import org.scalatest.Tag
Expand Down Expand Up @@ -111,6 +114,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|},
|"creditorName": "70charname"
}""".stripMargin

grantAccountAccess(acountRoutingIbanFrom)

val requestPost = (V1_3_BG / PaymentServiceTypes.payments.toString / TransactionRequestTypes.SEPA_CREDIT_TRANSFERS.toString).POST <@ (user1)
val response: APIResponse = makePostRequest(requestPost, initiatePaymentJson)
Expand Down Expand Up @@ -163,6 +168,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|"creditorName": "70charname"
}""".stripMargin

grantAccountAccess(acountRoutingIbanFrom)

val requestPost = (V1_3_BG / PaymentServiceTypes.payments.toString / TransactionRequestTypes.SEPA_CREDIT_TRANSFERS.toString).POST <@ (user1)
val response: APIResponse = makePostRequest(requestPost, initiatePaymentJson)
Then("We should get a 201 ")
Expand All @@ -185,6 +192,18 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
afterPaymentToAccountBalacne-beforePaymentToAccountBalance should be (BigDecimal(0))
}
}

private def grantAccountAccess(acountRoutingIbanFrom: BankAccountRouting) = {
Views.views.vend.systemView(ViewId(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)).flatMap(view =>
// Grant account access
Views.views.vend.grantAccessToSystemView(acountRoutingIbanFrom.bankId,
acountRoutingIbanFrom.accountId,
view,
resourceUser1
)
)
}

feature(s"test the BG v1.3 -${getPaymentInformation.name}") {
scenario("Successful case ", BerlinGroupV1_3, PIS, initiatePayment) {
val accountsRoutingIban = BankAccountRouting.findAll(By(BankAccountRouting.AccountRoutingScheme, AccountRoutingScheme.IBAN.toString))
Expand All @@ -206,6 +225,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|"creditorName": "70charname"
}""".stripMargin

grantAccountAccess(accountsRoutingIban.head)

val requestPost = (V1_3_BG / PaymentServiceTypes.payments.toString / TransactionRequestTypes.SEPA_CREDIT_TRANSFERS.toString).POST <@ (user1)
val response: APIResponse = makePostRequest(requestPost, initiatePaymentJson)
Then("We should get a 201 ")
Expand Down Expand Up @@ -248,6 +269,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|"creditorName": "70charname"
}""".stripMargin

grantAccountAccess(accountsRoutingIban.head)

val requestPost = (V1_3_BG / PaymentServiceTypes.payments.toString / TransactionRequestTypes.SEPA_CREDIT_TRANSFERS.toString).POST <@ (user1)
val response: APIResponse = makePostRequest(requestPost, initiatePaymentJson)
Then("We should get a 201 ")
Expand Down Expand Up @@ -305,6 +328,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|"creditorName": "70charname"
}""".stripMargin

grantAccountAccess(accountsRoutingIban.head)

val requestInitiatePaymentJson = (V1_3_BG / PaymentServiceTypes.payments.toString / TransactionRequestTypes.SEPA_CREDIT_TRANSFERS.toString).POST <@ (user1)
val responseInitiatePaymentJson: APIResponse = makePostRequest(requestInitiatePaymentJson, initiatePaymentJson)
Then("We should get a 201 ")
Expand Down Expand Up @@ -405,6 +430,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|"creditorName": "70charname"
}""".stripMargin

grantAccountAccess(accountsRoutingIban.head)

val requestInitiatePaymentJson = (V1_3_BG / PaymentServiceTypes.payments.toString / TransactionRequestTypes.SEPA_CREDIT_TRANSFERS.toString).POST <@ (user1)
val responseInitiatePaymentJson: APIResponse = makePostRequest(requestInitiatePaymentJson, initiatePaymentJson)
Then("We should get a 201 ")
Expand Down

0 comments on commit 2a353ee

Please sign in to comment.