diff --git a/obp-api/src/test/scala/code/api/v5_1_0/SystemIntegrityTest.scala b/obp-api/src/test/scala/code/api/v5_1_0/SystemIntegrityTest.scala index e670b40ca..de2e41e5e 100644 --- a/obp-api/src/test/scala/code/api/v5_1_0/SystemIntegrityTest.scala +++ b/obp-api/src/test/scala/code/api/v5_1_0/SystemIntegrityTest.scala @@ -22,6 +22,7 @@ class SystemIntegrityTest extends V510ServerSetup { object ApiEndpoint1 extends Tag(nameOf(Implementations5_1_0.customViewNamesCheck)) object ApiEndpoint2 extends Tag(nameOf(Implementations5_1_0.systemViewNamesCheck)) object ApiEndpoint3 extends Tag(nameOf(Implementations5_1_0.accountAccessUniqueIndexCheck)) + object ApiEndpoint4 extends Tag(nameOf(Implementations5_1_0.accountCurrencyCheck)) feature(s"test $ApiEndpoint1 version $VersionOfApi - Unauthorized access") { scenario("We will call the endpoint without user credentials", ApiEndpoint1, VersionOfApi) { @@ -128,5 +129,41 @@ class SystemIntegrityTest extends V510ServerSetup { response510.body.extract[CheckSystemIntegrityJsonV510] } } + + + feature(s"test $ApiEndpoint4 version $VersionOfApi - Unauthorized access") { + scenario("We will call the endpoint without user credentials", ApiEndpoint1, VersionOfApi) { + When("We make a request v5.1.0") + val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "account-currency-check").GET + val response510 = makeGetRequest(request510) + Then("We should get a 401") + response510.code should equal(401) + response510.body.extract[ErrorMessage].message should equal(UserNotLoggedIn) + } + } + + feature(s"test $ApiEndpoint4 version $VersionOfApi - Authorized access") { + scenario("We will call the endpoint with user credentials but without a proper entitlement", ApiEndpoint1, VersionOfApi) { + When("We make a request v5.1.0") + val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "account-currency-check").GET <@(user1) + val response510 = makeGetRequest(request510) + Then("error should be " + UserHasMissingRoles + CanGetSystemIntegrity) + response510.code should equal(403) + response510.body.extract[ErrorMessage].message should be (UserHasMissingRoles + CanGetSystemIntegrity) + } + } + + feature(s"test $ApiEndpoint4 version $VersionOfApi - Authorized access") { + scenario("We will call the endpoint with user credentials and a proper entitlement", ApiEndpoint1, VersionOfApi) { + Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanGetSystemIntegrity.toString) + When("We make a request v5.1.0") + val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "account-currency-check").GET <@(user1) + val response510 = makeGetRequest(request510) + Then("We get successful response") + response510.code should equal(200) + response510.body.extract[CheckSystemIntegrityJsonV510] + } + } + }