mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:36:54 +00:00
added the accountAttributes in create account
This commit is contained in:
parent
6b2c14707c
commit
39f5aea609
@ -3337,6 +3337,16 @@ object SwaggerDefinitionsJSON {
|
||||
customer_id = customerIdExample.value
|
||||
)
|
||||
|
||||
val createAccountJsonV310 = CreateAccountJsonV310(
|
||||
user_id = userIdExample.value,
|
||||
label = labelExample.value,
|
||||
`type` = accountTypeExample.value,
|
||||
balance = amountOfMoneyJsonV121,
|
||||
branch_id = branchIdExample.value,
|
||||
account_routing = accountRoutingJsonV121,
|
||||
account_attributes= List(accountAttributeResponseJson)
|
||||
)
|
||||
|
||||
val physicalCardsJsonV310 = PhysicalCardsJsonV310(List(physicalCardJsonV310))
|
||||
|
||||
//The common error or success format.
|
||||
|
||||
@ -4782,7 +4782,7 @@ trait APIMethods310 {
|
||||
|
|
||||
|Note: The Amount must be zero.""".stripMargin,
|
||||
createAccountJSONV220,
|
||||
createAccountJSONV220,
|
||||
createAccountJsonV310,
|
||||
List(
|
||||
InvalidJsonFormat,
|
||||
BankNotFound,
|
||||
@ -4859,7 +4859,7 @@ trait APIMethods310 {
|
||||
callContext
|
||||
)
|
||||
(productAttributes, callContext) <- NewStyle.function.getProductAttributesByBankAndCode(bankId, ProductCode(accountType), callContext)
|
||||
(_, callContext) <- NewStyle.function.createAccountAttributes(
|
||||
(accountAttributes, callContext) <- NewStyle.function.createAccountAttributes(
|
||||
bankId,
|
||||
accountId,
|
||||
ProductCode(accountType),
|
||||
@ -4871,7 +4871,7 @@ trait APIMethods310 {
|
||||
//2 Add permission to the user
|
||||
//3 Set the user as the account holder
|
||||
BankAccountCreation.setAsOwner(bankId, accountId, postedOrLoggedInUser)
|
||||
(JSONFactory220.createAccountJSON(userIdAccountOwner, bankAccount), HttpCode.`200`(callContext))
|
||||
(JSONFactory310.createAccountJSON(userIdAccountOwner, bankAccount, accountAttributes), HttpCode.`200`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ case class PhysicalCardWithAttributesJsonV310(
|
||||
case class PhysicalCardsJsonV310(
|
||||
cards : List[PhysicalCardJsonV310])
|
||||
|
||||
case class CreateAccountJSONV310(
|
||||
case class CreateAccountJsonV310(
|
||||
user_id : String,
|
||||
label : String,
|
||||
`type` : String,
|
||||
@ -1165,8 +1165,8 @@ object JSONFactory310{
|
||||
)
|
||||
}
|
||||
|
||||
def createAccountJSON(userId: String, account: BankAccount, accountAttributes: List[AccountAttribute]): CreateAccountJSONV310 = {
|
||||
CreateAccountJSONV310(
|
||||
def createAccountJSON(userId: String, account: BankAccount, accountAttributes: List[AccountAttribute]): CreateAccountJsonV310 = {
|
||||
CreateAccountJsonV310(
|
||||
user_id = userId,
|
||||
label = account.label,
|
||||
`type` = account.accountType,
|
||||
|
||||
@ -21,7 +21,7 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
object ApiEndpoint1 extends Tag(nameOf(Implementations3_1_0.updateAccount))
|
||||
object ApiEndpoint2 extends Tag(nameOf(Implementations3_1_0.createAccount))
|
||||
|
||||
lazy val testBankId = randomBankId
|
||||
lazy val testBankId = testBankId1
|
||||
lazy val putCreateAccountJSONV310 = SwaggerDefinitionsJSON.createAccountJSONV220.copy(user_id = resourceUser1.userId)
|
||||
lazy val putCreateAccountOtherUserJsonV310 = SwaggerDefinitionsJSON.createAccountJSONV220.copy(user_id = resourceUser2.userId)
|
||||
|
||||
@ -29,12 +29,11 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
feature("test Update Account") {
|
||||
scenario("We will test Update Account Api", ApiEndpoint1, VersionOfApi) {
|
||||
Given("The test bank and test account")
|
||||
val testBank = testBankId1
|
||||
val testAccount = testAccountId1
|
||||
val testPutJson = updateAccountRequestJsonV310
|
||||
|
||||
Then(s"We call the update api without proper role: ${ApiRole.canUpdateAccount}")
|
||||
val requestPut = (v3_1_0_Request / "management" / "banks" / testBank.value / "accounts" / testAccount.value).PUT <@ (user1)
|
||||
val requestPut = (v3_1_0_Request / "management" / "banks" / testBankId.value / "accounts" / testAccount.value).PUT <@ (user1)
|
||||
val responsePut = makePutRequest(requestPut, write(testPutJson))
|
||||
And("We should get 403 and the error message missing can CanUpdateAccount role")
|
||||
responsePut.code should equal(403)
|
||||
@ -53,7 +52,7 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
responsePut2.body.extract[UpdateAccountResponseJsonV310].account_routing.address should be (testPutJson.account_routing.address)
|
||||
|
||||
|
||||
val requestGet = (v3_1_0_Request /"my"/ "banks" / testBank.value / "accounts" / testAccount.value/"account").PUT <@ (user1)
|
||||
val requestGet = (v3_1_0_Request /"my"/ "banks" / testBankId.value / "accounts" / testAccount.value/"account").PUT <@ (user1)
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
And("We should get 200 and updated account data")
|
||||
responseGet.code should equal(200)
|
||||
@ -69,7 +68,7 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
feature("Create Account v3.1.0 - Unauthorized access") {
|
||||
scenario("We will call the endpoint without user credentials", ApiEndpoint2, VersionOfApi) {
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_1_0_Request / "banks" / testBankId / "accounts" / "ACCOUNT_ID" ).PUT
|
||||
val request310 = (v3_1_0_Request / "banks" / testBankId.value / "accounts" / "ACCOUNT_ID" ).PUT
|
||||
val response310 = makePutRequest(request310, write(putCreateAccountJSONV310))
|
||||
Then("We should get a 400")
|
||||
response310.code should equal(400)
|
||||
@ -80,7 +79,7 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
feature("Create Account v3.1.0 - Authorized access") {
|
||||
scenario("We will call the endpoint with user credentials", ApiEndpoint2, VersionOfApi) {
|
||||
When("We make a request v3.1.0")
|
||||
val request310 = (v3_1_0_Request / "banks" / testBankId / "accounts" / "TEST_ACCOUNT_ID" ).PUT <@(user1)
|
||||
val request310 = (v3_1_0_Request / "banks" / testBankId.value / "accounts" / "TEST_ACCOUNT_ID" ).PUT <@(user1)
|
||||
val response310 = makePutRequest(request310, write(putCreateAccountJSONV310))
|
||||
Then("We should get a 200")
|
||||
response310.code should equal(200)
|
||||
@ -95,7 +94,7 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
account.account_routing should be (putCreateAccountJSONV310.account_routing)
|
||||
|
||||
Then("We make a request v3.1.0 but with other user")
|
||||
val request310WithNewAccountId = (v3_1_0_Request / "banks" / testBankId / "accounts" / "TEST_ACCOUNT_ID2" ).PUT <@(user1)
|
||||
val request310WithNewAccountId = (v3_1_0_Request / "banks" / testBankId.value / "accounts" / "TEST_ACCOUNT_ID2" ).PUT <@(user1)
|
||||
val responseWithNoRole = makePutRequest(request310WithNewAccountId, write(putCreateAccountOtherUserJsonV310))
|
||||
Then("We should get a 403 and some error message")
|
||||
responseWithNoRole.code should equal(403)
|
||||
@ -103,10 +102,10 @@ class AccountTest extends V310ServerSetup with DefaultUsers {
|
||||
|
||||
|
||||
Then("We grant the roles and test it again")
|
||||
Entitlement.entitlement.vend.addEntitlement(testBankId1.value, resourceUser1.userId, ApiRole.canCreateAccount.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement(testBankId.value, resourceUser1.userId, ApiRole.canCreateAccount.toString)
|
||||
val responseWithOtherUesrV310 = makePutRequest(request310WithNewAccountId, write(putCreateAccountOtherUserJsonV310))
|
||||
|
||||
val account2 = responseWithOtherUesrV310.body.extract[CreateAccountJSONV220]
|
||||
val account2 = responseWithOtherUesrV310.body.extract[CreateAccountJsonV310]
|
||||
account2.`type` should be (putCreateAccountOtherUserJsonV310.`type`)
|
||||
account2.`label` should be (putCreateAccountOtherUserJsonV310.`label`)
|
||||
account2.balance.amount.toDouble should be (putCreateAccountOtherUserJsonV310.balance.amount.toDouble)
|
||||
|
||||
@ -67,6 +67,7 @@ case class ProductAttributeCommons(
|
||||
name :String,
|
||||
attributeType : ProductAttributeType.Value,
|
||||
value :String) extends ProductAttribute
|
||||
object ProductAttributeCommons extends Converter[ProductAttribute, ProductAttributeCommons]
|
||||
|
||||
|
||||
case class ProductCollectionCommons(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user