test/fixed the failed view test

This commit is contained in:
hongwei 2023-06-13 17:46:00 +08:00
parent 992c643369
commit 855b50f176
4 changed files with 20 additions and 13 deletions

View File

@ -90,7 +90,6 @@ class CreateCounterpartyTest extends V220ServerSetup with DefaultUsers {
val bankId = testBank.bankId
val accountId = AccountId("notExistingAccountId")
val viewId =ViewId(SYSTEM_OWNER_VIEW_ID)
val ownerView = createOwnerView(bankId, accountId)
Views.views.vend.grantAccessToCustomView(ViewIdBankIdAccountId(viewId, bankId, accountId), resourceUser1)
val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value)

View File

@ -273,13 +273,19 @@ class SystemViewsTests extends V310ServerSetup {
}
feature(s"test $ApiEndpoint4 version $VersionOfApi - Authorized access with proper Role in order to delete owner view") {
scenario("We will call the endpoint without user credentials", ApiEndpoint4, VersionOfApi) {
When(s"We make a request $ApiEndpoint2")
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateSystemView.toString)
val responseCreate400 = postSystemView(postBodySystemViewJson, user1)
Then("We should get a 201")
responseCreate400.code should equal(201)
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanDeleteSystemView.toString)
When(s"We make a request $ApiEndpoint4")
AccountAccess.findAll(
By(AccountAccess.view_id, SYSTEM_OWNER_VIEW_ID),
By(AccountAccess.view_id, randomSystemViewId),
By(AccountAccess.user_fk, resourceUser1.id.get)
).forall(_.delete_!) // Remove all rows assigned to the system owner view in order to delete it
val response400 = deleteSystemView(SYSTEM_OWNER_VIEW_ID, user1)
).forall(_.delete_!) // Remove all rows assigned to the system view in order to delete it
val response400 = deleteSystemView(randomSystemViewId, user1)
Then("We should get a 200")
response400.code should equal(200)
}

View File

@ -75,7 +75,6 @@ class SystemViewsTests extends V500ServerSetup {
val postBodySystemViewJson = createSystemViewJsonV500
.copy(name=randomSystemViewId)
.copy(metadata_view = randomSystemViewId).toCreateViewJson
val systemViewId = MapperViews.createViewIdByName(postBodySystemViewJson.name)
def getSystemView(viewId : String, consumerAndToken: Option[(Consumer, Token)]): APIResponse = {
val request = v5_0_0_Request / "system-views" / viewId <@(consumerAndToken)
@ -266,15 +265,21 @@ class SystemViewsTests extends V500ServerSetup {
response400.code should equal(200)
}
}
feature(s"test $ApiEndpoint4 version $VersionOfApi - Authorized access with proper Role in order to delete owner view") {
feature(s"test $ApiEndpoint4 version $VersionOfApi - Authorized access with proper Role in order to delete system view") {
scenario("We will call the endpoint without user credentials", ApiEndpoint4, VersionOfApi) {
When(s"We make a request $ApiEndpoint2")
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateSystemView.toString)
val responseCreate400 = postSystemView(postBodySystemViewJson, user1)
Then("We should get a 201")
responseCreate400.code should equal(201)
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanDeleteSystemView.toString)
When(s"We make a request $ApiEndpoint4")
AccountAccess.findAll(
By(AccountAccess.view_id, SYSTEM_OWNER_VIEW_ID),
By(AccountAccess.view_id, randomSystemViewId),
By(AccountAccess.user_fk, resourceUser1.id.get)
).forall(_.delete_!) // Remove all rows assigned to the system owner view in order to delete it
val response400 = deleteSystemView(SYSTEM_OWNER_VIEW_ID, user1)
).forall(_.delete_!) // Remove all rows assigned to the system view in order to delete it
val response400 = deleteSystemView(randomSystemViewId, user1)
Then("We should get a 200")
response400.code should equal(200)
}

View File

@ -28,10 +28,7 @@ trait TestConnectorSetupWithStandardPermissions extends TestConnectorSetup {
protected def getOrCreateSystemView(name: String) : View = {
Views.views.vend.getOrCreateSystemView(name).openOrThrowException(attemptedToOpenAnEmptyBox)
}
protected def createOwnerView(bankId: BankId, accountId: AccountId ) : View = {
Views.views.vend.getOrCreateSystemView(SYSTEM_OWNER_VIEW_ID).openOrThrowException(attemptedToOpenAnEmptyBox)
}
protected def createPublicView(bankId: BankId, accountId: AccountId) : View = {
Views.views.vend.getOrCreateCustomPublicView(bankId: BankId, accountId: AccountId, CUSTOM_PUBLIC_VIEW_ID).openOrThrowException(attemptedToOpenAnEmptyBox)
}