mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:56:57 +00:00
Simplify User model #187 - Refactored APIUser -> ResourceUser and OBPUser -> AuthUser. added sql migration script for apiuser table
This commit is contained in:
parent
a22176ea2e
commit
3d0e1dd293
@ -255,7 +255,7 @@ class Boot extends Loggable{
|
||||
if(Props.getBool("allow_sandbox_account_creation", false)){
|
||||
//user must be logged in, as a created account needs an owner
|
||||
// Not mentioning test and sandbox for App store purposes right now.
|
||||
List(Menu("Sandbox Account Creation", "Create Bank Account") / "create-sandbox-account" >> OBPUser.loginFirst)
|
||||
List(Menu("Sandbox Account Creation", "Create Bank Account") / "create-sandbox-account" >> AuthUser.loginFirst)
|
||||
} else {
|
||||
Nil
|
||||
}
|
||||
@ -275,13 +275,13 @@ class Boot extends Loggable{
|
||||
Menu.i("Home") / "index",
|
||||
Menu.i("Consumer Admin") / "admin" / "consumers" >> Admin.loginFirst >> LocGroup("admin")
|
||||
submenus(Consumer.menus : _*),
|
||||
Menu("Consumer Registration", "Get API Key") / "consumer-registration" >> OBPUser.loginFirst,
|
||||
Menu("Consumer Registration", "Get API Key") / "consumer-registration" >> AuthUser.loginFirst,
|
||||
// Menu.i("Metrics") / "metrics", //TODO: allow this page once we can make the account number anonymous in the URL
|
||||
Menu.i("OAuth") / "oauth" / "authorize", //OAuth authorization page
|
||||
OAuthWorkedThanks.menu //OAuth thanks page that will do the redirect
|
||||
) ++ accountCreation ++ Admin.menus
|
||||
|
||||
def sitemapMutators = OBPUser.sitemapMutator
|
||||
def sitemapMutators = AuthUser.sitemapMutator
|
||||
|
||||
// set the sitemap. Note if you don't want access control for
|
||||
// each page, just comment this line out.
|
||||
@ -301,7 +301,7 @@ class Boot extends Loggable{
|
||||
LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
|
||||
|
||||
// What is the function to test if a user is logged in?
|
||||
LiftRules.loggedInTest = Full(() => OBPUser.loggedIn_?)
|
||||
LiftRules.loggedInTest = Full(() => AuthUser.loggedIn_?)
|
||||
|
||||
// Template(/Response?) encoding
|
||||
LiftRules.early.append(_.setCharacterEncoding("utf-8"))
|
||||
@ -428,12 +428,12 @@ object ToSchemify {
|
||||
ViewPrivileges)
|
||||
|
||||
val models = List(
|
||||
OBPUser,
|
||||
AuthUser,
|
||||
Admin,
|
||||
Nonce,
|
||||
Token,
|
||||
Consumer,
|
||||
APIUser,
|
||||
ResourceUser,
|
||||
MappedAccountHolder,
|
||||
MappedComment,
|
||||
MappedNarrative,
|
||||
|
||||
@ -29,7 +29,7 @@ package code.api
|
||||
import java.util.Date
|
||||
|
||||
import authentikat.jwt.{JsonWebToken, JwtClaimsSet, JwtHeader}
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.model.{Consumer, Token, TokenType, User}
|
||||
import net.liftweb.common._
|
||||
import net.liftweb.http._
|
||||
@ -101,7 +101,7 @@ object DirectLogin extends RestHelper with Loggable {
|
||||
if (userId == 0) {
|
||||
message = ErrorMessages.InvalidLoginCredentials
|
||||
httpCode = 401
|
||||
} else if (userId == OBPUser.usernameLockedStateCode) {
|
||||
} else if (userId == AuthUser.usernameLockedStateCode) {
|
||||
message = ErrorMessages.UsernameHasBeenLocked
|
||||
httpCode = 401
|
||||
} else {
|
||||
@ -318,11 +318,11 @@ object DirectLogin extends RestHelper with Loggable {
|
||||
val username = directLoginParameters.getOrElse("username", "")
|
||||
val password = directLoginParameters.getOrElse("password", "")
|
||||
|
||||
var userId = for {id <- OBPUser.getAPIUserId(username, password)} yield id
|
||||
var userId = for {id <- AuthUser.getResourceUserId(username, password)} yield id
|
||||
|
||||
if (userId.isEmpty) {
|
||||
if ( ! OBPUser.externalUserHelper(username, password).isEmpty)
|
||||
userId = for {id <- OBPUser.getAPIUserId(username, password)} yield id
|
||||
if ( ! AuthUser.externalUserHelper(username, password).isEmpty)
|
||||
userId = for {id <- AuthUser.getResourceUserId(username, password)} yield id
|
||||
}
|
||||
|
||||
userId
|
||||
|
||||
@ -34,7 +34,7 @@ import javax.security.cert.Certificate
|
||||
|
||||
import authentikat.jwt.{JsonWebToken, JwtClaimsSet, JwtHeader}
|
||||
import code.api.util.APIUtil._
|
||||
import code.model.dataAccess.{APIUser, OBPUser}
|
||||
import code.model.dataAccess.{ResourceUser, AuthUser}
|
||||
import code.model.{Consumer, Token, TokenType, User}
|
||||
import net.liftweb.common._
|
||||
import net.liftweb.http._
|
||||
@ -103,17 +103,17 @@ object OpenIdConnect extends OBPRestHelper with Loggable {
|
||||
for {
|
||||
emailVerified <- tryo{(json_user \ "email_verified").extractOrElse[Boolean](false)}
|
||||
userEmail <- tryo{(json_user \ "email").extractOrElse[String]("")}
|
||||
obp_user: OBPUser <- OBPUser.find(By(OBPUser.email, userEmail))
|
||||
api_user: APIUser <- obp_user.user.foreign
|
||||
obp_user: AuthUser <- AuthUser.find(By(AuthUser.email, userEmail))
|
||||
api_user: ResourceUser <- obp_user.user.foreign
|
||||
if emailVerified && api_user.apiId.value > 0
|
||||
} yield {
|
||||
saveAuthorizationToken(accessToken, accessToken, api_user.apiId.value)
|
||||
httpCode = 200
|
||||
message= String.format("oauth_token=%s&oauth_token_secret=%s", accessToken, accessToken)
|
||||
val headers = ("Content-type" -> "application/x-www-form-urlencoded") :: Nil
|
||||
OBPUser.logUserIn(obp_user, () => {
|
||||
AuthUser.logUserIn(obp_user, () => {
|
||||
S.notice(S.?("logged.in"))
|
||||
S.redirectTo(OBPUser.homePage)
|
||||
S.redirectTo(AuthUser.homePage)
|
||||
})
|
||||
}
|
||||
case _ => message=String.format("Could not find user with token %s", accessToken)
|
||||
|
||||
@ -126,7 +126,7 @@ trait APIMethods140 extends Loggable with APIMethods130 with APIMethods121{
|
||||
for {
|
||||
u <- user ?~! ErrorMessages.UserNotLoggedIn
|
||||
bank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
|
||||
//au <- APIUser.find(By(APIUser.id, u.apiId))
|
||||
//au <- ResourceUser.find(By(ResourceUser.id, u.apiId))
|
||||
//role <- au.isCustomerMessageAdmin ~> APIFailure("User does not have sufficient permissions", 401)
|
||||
} yield {
|
||||
val messages = CustomerMessages.customerMessageProvider.vend.getMessages(u, bankId)
|
||||
|
||||
@ -27,7 +27,7 @@ import net.liftweb.http.CurrentReq
|
||||
|
||||
|
||||
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import net.liftweb.mapper.By
|
||||
|
||||
|
||||
@ -1389,8 +1389,8 @@ trait APIMethods200 {
|
||||
postedData <- tryo {json.extract[CreateUserJSON]} ?~! ErrorMessages.InvalidJsonFormat
|
||||
isValidStrongPassword <- tryo(assert(isValidStrongPassword(postedData.password))) ?~! ErrorMessages.InvalidStrongPasswordFormat
|
||||
} yield {
|
||||
if (OBPUser.find(By(OBPUser.username, postedData.username)).isEmpty) {
|
||||
val userCreated = OBPUser.create
|
||||
if (AuthUser.find(By(AuthUser.username, postedData.username)).isEmpty) {
|
||||
val userCreated = AuthUser.create
|
||||
.firstName(postedData.first_name)
|
||||
.lastName(postedData.last_name)
|
||||
.username(postedData.username)
|
||||
@ -1404,7 +1404,7 @@ trait APIMethods200 {
|
||||
{
|
||||
userCreated.saveMe()
|
||||
if (userCreated.saved_?) {
|
||||
val json = JSONFactory200.createUserJSONfromOBPUser(userCreated)
|
||||
val json = JSONFactory200.createUserJSONfromAuthUser(userCreated)
|
||||
successJsonResponse(Extraction.decompose(json), 201)
|
||||
}
|
||||
else
|
||||
@ -1721,7 +1721,7 @@ trait APIMethods200 {
|
||||
l <- user ?~ ErrorMessages.UserNotLoggedIn
|
||||
canGetAnyUser <- booleanToBox(hasEntitlement("", l.userId, ApiRole.CanGetAnyUser), "CanGetAnyUser entitlement required")
|
||||
// Workaround to get userEmail address directly from URI without needing to URL-encode it
|
||||
users <- tryo{OBPUser.getApiUsersByEmail(CurrentReq.value.uri.split("/").last)} ?~! {ErrorMessages.UserNotFoundByEmail}
|
||||
users <- tryo{AuthUser.getResourceUsersByEmail(CurrentReq.value.uri.split("/").last)} ?~! {ErrorMessages.UserNotFoundByEmail}
|
||||
}
|
||||
yield {
|
||||
// Format the data as V2.0.0 json
|
||||
|
||||
@ -39,7 +39,7 @@ import code.api.v1_2_1.ViewJSON
|
||||
import code.api.v2_2_0.{AccountsJSON, AccountJSON}
|
||||
import code.entitlement.Entitlement
|
||||
import code.meetings.Meeting
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import net.liftweb.common.{Box, Full}
|
||||
import net.liftweb.json
|
||||
@ -571,7 +571,7 @@ object JSONFactory200{
|
||||
)
|
||||
|
||||
|
||||
def createUserJSONfromOBPUser(user : OBPUser) : UserJSON = new UserJSON(
|
||||
def createUserJSONfromAuthUser(user : AuthUser) : UserJSON = new UserJSON(
|
||||
user_id = user.user.foreign.get.userId,
|
||||
email = user.email,
|
||||
username = stringOrNull(user.username),
|
||||
@ -605,9 +605,9 @@ object JSONFactory200{
|
||||
|
||||
|
||||
|
||||
def createUserJSONfromOBPUser(user : Box[OBPUser]) : UserJSON = {
|
||||
def createUserJSONfromAuthUser(user : Box[AuthUser]) : UserJSON = {
|
||||
user match {
|
||||
case Full(u) => createUserJSONfromOBPUser(u)
|
||||
case Full(u) => createUserJSONfromAuthUser(u)
|
||||
case _ => null
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import code.customer.{Customer, MockCreditLimit, MockCreditRating, MockCustomerF
|
||||
import code.entitlement.Entitlement
|
||||
import code.fx.fx
|
||||
import code.metadata.counterparties.{Counterparties}
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.model.{BankId, ViewId, _}
|
||||
import code.products.Products.ProductCode
|
||||
import code.usercustomerlinks.UserCustomerLink
|
||||
@ -755,7 +755,7 @@ trait APIMethods210 {
|
||||
for {
|
||||
l <- user ?~ ErrorMessages.UserNotLoggedIn
|
||||
canGetAnyUser <- booleanToBox(hasEntitlement("", l.userId, ApiRole.CanGetAnyUser), "CanGetAnyUser entitlement required")
|
||||
users <- tryo{OBPUser.getApiUsers()}
|
||||
users <- tryo{AuthUser.getResourceUsers()}
|
||||
} yield {
|
||||
// Format the data as V2.0.0 json
|
||||
val json = JSONFactory200.createUserJSONs(users)
|
||||
|
||||
@ -22,7 +22,7 @@ import code.customer.{Customer, MockCreditLimit, MockCreditRating, MockCustomerF
|
||||
import code.entitlement.Entitlement
|
||||
import code.fx.{MappedFXRate, fx}
|
||||
import code.metadata.counterparties.Counterparties
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.model.{BankId, ViewId, _}
|
||||
import code.products.Products.ProductCode
|
||||
import code.usercustomerlinks.UserCustomerLink
|
||||
|
||||
@ -11,7 +11,7 @@ import code.fx.{FXRate, fx}
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.metadata.counterparties.{CounterpartyTrait, MappedCounterparty}
|
||||
import code.model.{Transaction, TransactionRequestType, User, _}
|
||||
import code.model.dataAccess.{APIUser, MappedAccountHolder}
|
||||
import code.model.dataAccess.{ResourceUser, MappedAccountHolder}
|
||||
import code.transactionrequests.{TransactionRequestTypeCharge, TransactionRequests}
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import code.util.Helper._
|
||||
@ -114,7 +114,7 @@ trait Connector {
|
||||
|
||||
def getUser(name: String, password: String): Box[InboundUser]
|
||||
|
||||
def updateUserAccountViews(user: APIUser)
|
||||
def updateUserAccountViews(user: ResourceUser)
|
||||
|
||||
def getBankAccount(bankId : BankId, accountId : AccountId) : Box[AccountType]
|
||||
|
||||
@ -764,7 +764,7 @@ trait Connector {
|
||||
|
||||
def getBranch(bankId : BankId, branchId: BranchId) : Box[Branch]
|
||||
|
||||
def accountOwnerExists(user: APIUser, bankId: BankId, accountId: AccountId): Boolean = {
|
||||
def accountOwnerExists(user: ResourceUser, bankId: BankId, accountId: AccountId): Boolean = {
|
||||
val res =
|
||||
MappedAccountHolder.findAll(
|
||||
By(MappedAccountHolder.user, user),
|
||||
@ -778,15 +778,15 @@ trait Connector {
|
||||
//def setAccountOwner(owner : String, account: KafkaInboundAccount) : Unit = {
|
||||
def setAccountOwner(owner : String, bankId: BankId, accountId: AccountId, account_owners: List[String]) : Unit = {
|
||||
if (account_owners.contains(owner)) {
|
||||
val apiUserOwner = APIUser.findAll.find(user => owner == user.name)
|
||||
apiUserOwner match {
|
||||
val resourceUserOwner = ResourceUser.findAll.find(user => owner == user.name)
|
||||
resourceUserOwner match {
|
||||
case Some(o) => {
|
||||
if ( ! accountOwnerExists(o, bankId, accountId)) {
|
||||
MappedAccountHolder.createMappedAccountHolder(o.apiId.value, bankId.value, accountId.value, "KafkaMappedConnector")
|
||||
}
|
||||
}
|
||||
case None => {
|
||||
//This shouldn't happen as OBPUser should generate the APIUsers when saved
|
||||
//This shouldn't happen as AuthUser should generate the ResourceUsers when saved
|
||||
//logger.error(s"api user(s) $owner not found.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
}
|
||||
}
|
||||
|
||||
def updateUserAccountViews( user: APIUser ) = {
|
||||
def updateUserAccountViews( user: ResourceUser ) = {
|
||||
val accounts: List[KafkaInboundAccount] = getBanks.flatMap { bank => {
|
||||
val bankId = bank.bankId.value
|
||||
logger.info(s"ObpJvm updateUserAccountViews for user.email ${user.email} user.name ${user.name} at bank ${bankId}")
|
||||
@ -135,11 +135,11 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
setAccountOwner(username, BankId(acc.bank), AccountId(acc.id), acc.owners)
|
||||
views.foreach(v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> updated view ${v.uid} for apiuser ${user} and account ${acc}")
|
||||
logger.info(s"------------> updated view ${v.uid} for resourceuser ${user} and account ${acc}")
|
||||
})
|
||||
existing_views.filterNot(_.users.contains(user.apiId)).foreach (v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> added apiuser ${user} to view ${v.uid} for account ${acc}")
|
||||
logger.info(s"------------> added resourceuser ${user} to view ${v.uid} for account ${acc}")
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -152,7 +152,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
"version" -> formatVersion,
|
||||
"name" -> "get",
|
||||
"target" -> "banks",
|
||||
"userId" -> OBPUser.getCurrentUserUsername
|
||||
"userId" -> AuthUser.getCurrentUserUsername
|
||||
)
|
||||
|
||||
logger.debug(s"Kafka getBanks says: req is: $req")
|
||||
@ -181,7 +181,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getChallengeThreshold",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"userId" -> userId,
|
||||
"accountId" -> accountId,
|
||||
"transactionRequestType" -> transactionRequestType,
|
||||
@ -206,7 +206,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "createChallenge",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"userId" -> userId,
|
||||
"transactionRequestType" -> transactionRequestType.value,
|
||||
"transactionRequestId" -> transactionRequestId,
|
||||
@ -227,7 +227,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "validateChallengeAnswer",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"challengeId" -> challengeId,
|
||||
"hashOfSuppliedAnswer" -> hashOfSuppliedAnswer
|
||||
)
|
||||
@ -249,7 +249,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
"bankId" -> id.toString,
|
||||
"name" -> "get",
|
||||
"target" -> "bank",
|
||||
"userId" -> OBPUser.getCurrentUserUsername
|
||||
"userId" -> AuthUser.getCurrentUserUsername
|
||||
)
|
||||
val r = {
|
||||
cachedBank.getOrElseUpdate( req.toString, () => process(req).extract[KafkaInboundBank])
|
||||
@ -263,7 +263,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getTransaction",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"bankId" -> bankId.toString,
|
||||
"accountId" -> accountId.toString,
|
||||
"transactionId" -> transactionId.toString
|
||||
@ -298,7 +298,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getTransactions",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"bankId" -> bankId.toString,
|
||||
"accountId" -> accountId.toString,
|
||||
"queryParams" -> queryParams.toString
|
||||
@ -324,7 +324,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getBankAccount",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"bankId" -> bankId.toString,
|
||||
"accountId" -> accountId.value
|
||||
)
|
||||
@ -348,7 +348,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getBankAccounts",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"bankIds" -> accts.map(a => a._1).mkString(","),
|
||||
"accountIds" -> accts.map(a => a._2).mkString(",")
|
||||
)
|
||||
@ -373,7 +373,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getBankAccount",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"bankId" -> bankId.toString,
|
||||
"number" -> number
|
||||
)
|
||||
@ -478,7 +478,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getCounterpartyByCounterpartyId",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"counterpartyId" -> counterpartyId.toString
|
||||
)
|
||||
// Since result is single account, we need only first list entry
|
||||
@ -493,7 +493,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getCounterpartyByIban",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"otherAccountRoutingAddress" -> iban,
|
||||
"otherAccountRoutingScheme" -> "IBAN"
|
||||
)
|
||||
@ -555,7 +555,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req: Map[String, String] = Map(
|
||||
"north" -> "saveTransaction",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
// for both toAccount and toCounterparty
|
||||
"accountId" -> fromAccount.accountId.value,
|
||||
"transactionType" -> transactionRequestType.value,
|
||||
@ -1012,7 +1012,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getCurrentFxRate",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"fromCurrencyCode" -> fromCurrencyCode,
|
||||
"toCurrencyCode" -> toCurrencyCode
|
||||
)
|
||||
@ -1030,7 +1030,7 @@ object KafkaMappedConnector extends Connector with Loggable {
|
||||
val req = Map(
|
||||
"north" -> "getTransactionRequestTypeCharge",
|
||||
"version" -> formatVersion,
|
||||
"name" -> OBPUser.getCurrentUserUsername,
|
||||
"name" -> AuthUser.getCurrentUserUsername,
|
||||
"bankId" -> bankId.value,
|
||||
"accountId" -> accountId.value,
|
||||
"viewId" -> viewId.value,
|
||||
|
||||
@ -48,7 +48,7 @@ private object LocalConnector extends Connector with Loggable {
|
||||
override def validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String): Box[Boolean] = ???
|
||||
|
||||
def getUser(name: String, password: String): Box[InboundUser] = ???
|
||||
def updateUserAccountViews(user: APIUser): Unit = ???
|
||||
def updateUserAccountViews(user: ResourceUser): Unit = ???
|
||||
|
||||
override def getBank(bankId : BankId): Box[Bank] =
|
||||
getHostedBank(bankId)
|
||||
|
||||
@ -93,7 +93,7 @@ object LocalMappedConnector extends Connector with Loggable {
|
||||
|
||||
|
||||
def getUser(name: String, password: String): Box[InboundUser] = ???
|
||||
def updateUserAccountViews(user: APIUser): Unit = ???
|
||||
def updateUserAccountViews(user: ResourceUser): Unit = ???
|
||||
|
||||
//gets a particular bank handled by this connector
|
||||
override def getBank(bankId: BankId): Box[Bank] =
|
||||
|
||||
@ -103,7 +103,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
|
||||
}
|
||||
|
||||
def updateUserAccountViews( user: APIUser ) = {
|
||||
def updateUserAccountViews( user: ResourceUser ) = {
|
||||
|
||||
val accounts = getBanks.flatMap { bank => {
|
||||
val bankId = bank.bankId.value
|
||||
@ -146,11 +146,11 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
setAccountOwner(username, BankId(acc.bank), AccountId(acc.id), acc.owners)
|
||||
views.foreach(v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> updated view ${v.uid} for apiuser ${user} and account ${acc}")
|
||||
logger.info(s"------------> updated view ${v.uid} for resourceuser ${user} and account ${acc}")
|
||||
})
|
||||
existing_views.filterNot(_.users.contains(user.apiId)).foreach (v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> added apiuser ${user} to view ${v.uid} for account ${acc}")
|
||||
logger.info(s"------------> added resourceuser ${user} to view ${v.uid} for account ${acc}")
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
|
||||
// Gets transaction identified by bankid, accountid and transactionId
|
||||
def getTransaction(bankId: BankId, accountId: AccountId, transactionId: TransactionId): Box[Transaction] = {
|
||||
val primaryUserIdentifier = OBPUser.getCurrentUserUsername
|
||||
val primaryUserIdentifier = AuthUser.getCurrentUserUsername
|
||||
val invalid = ZonedDateTime.of(1970, 1, 1, 0, 0, 0, 0, UTC)
|
||||
val parameters = new JHashMap
|
||||
|
||||
@ -262,7 +262,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
}
|
||||
|
||||
override def getTransactions(bankId: BankId, accountId: AccountId, queryParams: OBPQueryParam*): Box[List[Transaction]] = {
|
||||
val primaryUserIdentifier = OBPUser.getCurrentUserUsername
|
||||
val primaryUserIdentifier = AuthUser.getCurrentUserUsername
|
||||
|
||||
val limit = queryParams.collect { case OBPLimit(value) => MaxRows[MappedTransaction](value) }.headOption
|
||||
val offset = queryParams.collect { case OBPOffset(value) => StartAt[MappedTransaction](value) }.headOption
|
||||
@ -332,7 +332,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
override def getBankAccount(bankId: BankId, accountId: AccountId): Box[ObpJvmBankAccount] = {
|
||||
val parameters = new JHashMap
|
||||
|
||||
val primaryUserIdentifier = OBPUser.getCurrentUserUsername
|
||||
val primaryUserIdentifier = AuthUser.getCurrentUserUsername
|
||||
|
||||
parameters.put("accountId", accountId.value)
|
||||
parameters.put("bankId", bankId.value)
|
||||
@ -365,7 +365,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
|
||||
logger.info(s"hello from ObpJvmMappedConnnector.getBankAccounts accts is $accts")
|
||||
|
||||
val primaryUserIdentifier = OBPUser.getCurrentUserUsername
|
||||
val primaryUserIdentifier = AuthUser.getCurrentUserUsername
|
||||
|
||||
val r:List[ObpJvmInboundAccount] = accts.flatMap { a => {
|
||||
|
||||
@ -413,7 +413,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
}
|
||||
|
||||
private def getAccountByNumber(bankId : BankId, number : String) : Box[AccountType] = {
|
||||
val primaryUserIdentifier = OBPUser.getCurrentUserUsername
|
||||
val primaryUserIdentifier = AuthUser.getCurrentUserUsername
|
||||
val parameters = new JHashMap
|
||||
|
||||
parameters.put("accountId", number)
|
||||
@ -579,8 +579,8 @@ object ObpJvmMappedConnector extends Connector with Loggable {
|
||||
// TODO: Extend jvmNorth function with parameters transactionRequestId and description
|
||||
private def saveTransaction(fromAccount: AccountType, toAccount: AccountType, amt: BigDecimal, description : String): Box[TransactionId] = {
|
||||
|
||||
val name = OBPUser.getCurrentUserUsername
|
||||
val user = OBPUser.getApiUserByUsername(name)
|
||||
val name = AuthUser.getCurrentUserUsername
|
||||
val user = AuthUser.getResourceUserByUsername(name)
|
||||
val userId = for (u <- user) yield u.userId
|
||||
val accountId = fromAccount.accountId.value
|
||||
val accountName = fromAccount.name
|
||||
@ -1169,7 +1169,6 @@ private def saveTransaction(fromAccount: AccountType, toAccount: AccountType, am
|
||||
}
|
||||
|
||||
case class ObpJvmBankAccount(r: ObpJvmInboundAccount) extends BankAccount {
|
||||
logger.info(s"--- ObpJvmBankAccount ---> amount=${r.balance.amount}")
|
||||
def accountId : AccountId = AccountId(r.id)
|
||||
def accountType : String = r.`type`
|
||||
def balance : BigDecimal = BigDecimal(if (r.balance.amount.isEmpty) "-0.00" else r.balance.amount)
|
||||
|
||||
@ -7,8 +7,8 @@ package code.crm
|
||||
import code.crm.CrmEvent.{CrmEvent, CrmEventId}
|
||||
import code.model.BankId
|
||||
import code.common.{Address, Location, Meta}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import net.liftweb.common.Logger
|
||||
import net.liftweb.util
|
||||
import net.liftweb.util.SimpleInjector
|
||||
@ -23,9 +23,9 @@ object CrmEvent extends util.SimpleInjector {
|
||||
trait CrmEvent {
|
||||
def crmEventId: CrmEventId
|
||||
def bankId: BankId
|
||||
def user: APIUser
|
||||
def user: ResourceUser
|
||||
def customerName : String
|
||||
def customerNumber : String // Is this duplicate of APIUser?
|
||||
def customerNumber : String // Is this duplicate of ResourceUser?
|
||||
def category : String
|
||||
def detail : String
|
||||
def channel : String
|
||||
@ -73,7 +73,7 @@ trait CrmEventProvider {
|
||||
/*
|
||||
Common logic for returning crmEvents at a bank for one user
|
||||
*/
|
||||
final def getCrmEvents(bankId : BankId, user : APIUser) : Option[List[CrmEvent]] = {
|
||||
final def getCrmEvents(bankId : BankId, user : ResourceUser) : Option[List[CrmEvent]] = {
|
||||
getEventsFromProvider(bankId, user) // No filter required
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ trait CrmEventProvider {
|
||||
protected def getEventsFromProvider(bank : BankId) : Option[List[CrmEvent]]
|
||||
|
||||
// For a user
|
||||
protected def getEventsFromProvider(bank : BankId, user : APIUser) : Option[List[CrmEvent]]
|
||||
protected def getEventsFromProvider(bank : BankId, user : ResourceUser) : Option[List[CrmEvent]]
|
||||
|
||||
// One event
|
||||
protected def getEventFromProvider(crmEventId: CrmEventId) : Option[CrmEvent]
|
||||
|
||||
@ -9,7 +9,7 @@ import code.customer.CustomerMessage
|
||||
import code.model.BankId
|
||||
|
||||
import code.common.{Address, License, Location, Meta}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
|
||||
import code.util.{MappedUUID, DefaultStringField}
|
||||
import net.liftweb.common.Box
|
||||
@ -29,7 +29,7 @@ object MappedCrmEventProvider extends CrmEventProvider {
|
||||
}
|
||||
|
||||
// Get events at a bank for one user
|
||||
override protected def getEventsFromProvider(bankId: BankId, user: APIUser): Option[List[CrmEvent]] =
|
||||
override protected def getEventsFromProvider(bankId: BankId, user: ResourceUser): Option[List[CrmEvent]] =
|
||||
Some(MappedCrmEvent.findAll(
|
||||
By(MappedCrmEvent.mBankId, bankId.toString),
|
||||
By(MappedCrmEvent.mUserId, user)
|
||||
@ -51,7 +51,7 @@ class MappedCrmEvent extends CrmEvent with LongKeyedMapper[MappedCrmEvent] with
|
||||
override def getSingleton = MappedCrmEvent
|
||||
|
||||
object mBankId extends DefaultStringField(this) // Should be a foreign key
|
||||
object mUserId extends MappedLongForeignKey(this, APIUser) // The customer
|
||||
object mUserId extends MappedLongForeignKey(this, ResourceUser) // The customer
|
||||
object mCrmEventId extends MappedUUID(this)
|
||||
object mCategory extends DefaultStringField(this)
|
||||
object mDetail extends DefaultStringField(this)
|
||||
@ -70,7 +70,7 @@ class MappedCrmEvent extends CrmEvent with LongKeyedMapper[MappedCrmEvent] with
|
||||
override def scheduledDate: Date = mScheduledDate.get
|
||||
override def actualDate: Date = mActualDate.get
|
||||
override def result: String = mResult.get
|
||||
override def user: APIUser = mUserId.obj.get
|
||||
override def user: ResourceUser = mUserId.obj.get
|
||||
override def customerName : String = mCustomerName.get
|
||||
override def customerNumber : String = mCustomerNumber.get
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package code.customer
|
||||
import java.util.Date
|
||||
|
||||
import code.model.{BankId, User}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField, MappedUUID}
|
||||
import net.liftweb.mapper._
|
||||
|
||||
@ -32,7 +32,7 @@ class MappedCustomerMessage extends CustomerMessage
|
||||
|
||||
def getSingleton = MappedCustomerMessage
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object bank extends DefaultStringField(this)
|
||||
|
||||
object mFromPerson extends DefaultStringField(this)
|
||||
|
||||
@ -3,7 +3,7 @@ package code.customer
|
||||
import java.util.Date
|
||||
|
||||
import code.model.{BankId, User}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{MappedUUID, DefaultStringField}
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper._
|
||||
@ -120,7 +120,7 @@ class MappedCustomer extends Customer with LongKeyedMapper[MappedCustomer] with
|
||||
|
||||
object mCustomerId extends MappedUUID(this)
|
||||
|
||||
object mUser extends MappedLongForeignKey(this, APIUser)
|
||||
object mUser extends MappedLongForeignKey(this, ResourceUser)
|
||||
object mBank extends DefaultStringField(this)
|
||||
|
||||
object mNumber extends DefaultStringField(this)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package code.kycchecks
|
||||
|
||||
import java.util.Date
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.DefaultStringField
|
||||
import net.liftweb.common.{Box, Full}
|
||||
import net.liftweb.mapper._
|
||||
@ -51,7 +51,7 @@ with LongKeyedMapper[MappedKycCheck] with IdPK with CreatedUpdated {
|
||||
|
||||
def getSingleton = MappedKycCheck
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object mBankId extends MappedString(this, 255)
|
||||
object mCustomerId extends MappedString(this, 255)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package code.kycdocuments
|
||||
import java.util.Date
|
||||
|
||||
import net.liftweb.common.{Box, Full}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField}
|
||||
import net.liftweb.mapper._
|
||||
|
||||
@ -51,7 +51,7 @@ with LongKeyedMapper[MappedKycDocument] with IdPK with CreatedUpdated {
|
||||
|
||||
def getSingleton = MappedKycDocument
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object mBankId extends MappedString(this, 255)
|
||||
object mCustomerId extends MappedString(this, 255)
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package code.kycstatuses
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.DefaultStringField
|
||||
import net.liftweb.common.{Box, Full}
|
||||
import net.liftweb.mapper.{By, _}
|
||||
@ -42,7 +42,7 @@ with LongKeyedMapper[MappedKycStatus] with IdPK with CreatedUpdated {
|
||||
|
||||
def getSingleton = MappedKycStatus
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object mBankId extends MappedString(this, 255)
|
||||
object mCustomerId extends MappedString(this, 255)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package code.meetings
|
||||
import java.util.Date
|
||||
|
||||
import code.model.{BankId, User}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{MappedUUID, DefaultStringField}
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper._
|
||||
@ -66,8 +66,8 @@ class MappedMeeting extends Meeting with LongKeyedMapper[MappedMeeting] with IdP
|
||||
|
||||
// With
|
||||
object mBankId extends DefaultStringField(this)
|
||||
object mCustomerUserId extends MappedLongForeignKey(this, APIUser)
|
||||
object mStaffUserId extends MappedLongForeignKey(this, APIUser)
|
||||
object mCustomerUserId extends MappedLongForeignKey(this, ResourceUser)
|
||||
object mStaffUserId extends MappedLongForeignKey(this, ResourceUser)
|
||||
|
||||
// What
|
||||
object mProviderId extends DefaultStringField(this)
|
||||
|
||||
@ -3,7 +3,7 @@ package code.metadata.comments
|
||||
import java.util.{UUID, Date}
|
||||
|
||||
import code.model._
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField, MappedUUID}
|
||||
import net.liftweb.common.{Failure, Full, Box}
|
||||
import net.liftweb.mapper._
|
||||
@ -53,7 +53,7 @@ class MappedComment extends Comment with LongKeyedMapper[MappedComment] with IdP
|
||||
object apiId extends MappedUUID(this)
|
||||
|
||||
object text_ extends DefaultStringField(this)
|
||||
object poster extends MappedLongForeignKey(this, APIUser)
|
||||
object poster extends MappedLongForeignKey(this, ResourceUser)
|
||||
object replyTo extends MappedUUID(this) {
|
||||
override def defaultValue = ""
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package code.metadata.counterparties
|
||||
import java.util.{Date, UUID}
|
||||
|
||||
import code.model._
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField, MappedAccountNumber, MappedUUID}
|
||||
import net.liftweb.common.{Box, Full, Loggable}
|
||||
import net.liftweb.mapper.{By, _}
|
||||
@ -288,7 +288,7 @@ class MappedCounterpartyWhereTag extends GeoTag with LongKeyedMapper[MappedCount
|
||||
|
||||
def getSingleton = MappedCounterpartyWhereTag
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object date extends MappedDateTime(this)
|
||||
|
||||
//TODO: require these to be valid latitude/longitudes
|
||||
|
||||
@ -3,7 +3,7 @@ package code.metadata.tags
|
||||
import java.util.Date
|
||||
|
||||
import code.model._
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField, MappedUUID}
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.util.Helpers.tryo
|
||||
@ -44,7 +44,7 @@ class MappedTag extends TransactionTag with LongKeyedMapper[MappedTag] with IdPK
|
||||
|
||||
object tagId extends MappedUUID(this)
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object tag extends DefaultStringField(this)
|
||||
object date extends MappedDateTime(this)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package code.metadata.transactionimages
|
||||
import java.net.URL
|
||||
import java.util.Date
|
||||
import code.model._
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField, MappedUUID}
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper._
|
||||
@ -51,7 +51,7 @@ class MappedTransactionImage extends TransactionImage with LongKeyedMapper[Mappe
|
||||
object view extends MappedString(this, 255)
|
||||
|
||||
object imageId extends MappedUUID(this)
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object date extends MappedDateTime(this)
|
||||
|
||||
object url extends DefaultStringField(this)
|
||||
|
||||
@ -3,7 +3,7 @@ package code.metadata.wheretags
|
||||
import java.util.Date
|
||||
|
||||
import code.model._
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import net.liftweb.util.Helpers.tryo
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper._
|
||||
@ -61,7 +61,7 @@ class MappedWhereTag extends GeoTag with LongKeyedMapper[MappedWhereTag] with Id
|
||||
object transaction extends MappedString(this, 255)
|
||||
object view extends MappedString(this, 255)
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object date extends MappedDateTime(this)
|
||||
|
||||
//TODO: require these to be valid latitude/longitudes
|
||||
|
||||
@ -35,7 +35,7 @@ import net.liftweb.mapper.{LongKeyedMetaMapper, _}
|
||||
import net.liftweb.util.{Props, FieldError, Helpers, SecurityHelpers}
|
||||
import net.liftweb.common.{Full,Failure,Box,Empty}
|
||||
import Helpers.now
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import net.liftweb.http.S
|
||||
import net.liftweb.util.Helpers._
|
||||
|
||||
@ -211,7 +211,7 @@ class Token extends LongKeyedMapper[Token]{
|
||||
object id extends MappedLongIndex(this)
|
||||
object tokenType extends MappedEnum(this, TokenType)
|
||||
object consumerId extends MappedLongForeignKey(this, Consumer)
|
||||
object userForeignKey extends MappedLongForeignKey(this, APIUser)
|
||||
object userForeignKey extends MappedLongForeignKey(this, ResourceUser)
|
||||
object key extends MappedString(this,250)
|
||||
object secret extends MappedString(this,250)
|
||||
object callbackURL extends MappedString(this,250)
|
||||
|
||||
@ -46,7 +46,7 @@ case class UserId(val value : Long) {
|
||||
}
|
||||
|
||||
|
||||
// TODO Document clearly the difference between this and OBPUser
|
||||
// TODO Document clearly the difference between this and AuthUser
|
||||
|
||||
trait User {
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ object Admin extends Admin with MetaMegaProtoUser[Admin]{
|
||||
|
||||
override def dbTableName = "admins" // define the DB table name
|
||||
|
||||
//override some MetaMegaProtoUser fields to avoid conflicting urls/menus with OBPUser
|
||||
//override some MetaMegaProtoUser fields to avoid conflicting urls/menus with AuthUser
|
||||
override def basePath = "admin_mgt" :: Nil
|
||||
override def menuNameSuffix = "Admin"
|
||||
|
||||
|
||||
@ -50,13 +50,13 @@ import code.loginattempts.LoginAttempt
|
||||
* An O-R mapped "User" class that includes first name, last name, password
|
||||
*
|
||||
*
|
||||
* // TODO Document the difference between this and User / APIUser
|
||||
* // TODO Document the difference between this and User / ResourceUser
|
||||
*
|
||||
*/
|
||||
class OBPUser extends MegaProtoUser[OBPUser] with Logger {
|
||||
def getSingleton = OBPUser // what's the "meta" server
|
||||
class AuthUser extends MegaProtoUser[AuthUser] with Logger {
|
||||
def getSingleton = AuthUser // what's the "meta" server
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
|
||||
/**
|
||||
* The username field for the User.
|
||||
@ -90,32 +90,32 @@ class OBPUser extends MegaProtoUser[OBPUser] with Logger {
|
||||
}
|
||||
}
|
||||
|
||||
def createUnsavedApiUser() : APIUser = {
|
||||
APIUser.create
|
||||
def createUnsavedResourceUser() : ResourceUser = {
|
||||
ResourceUser.create
|
||||
.name_(username)
|
||||
.email(email)
|
||||
.provider_(getProvider())
|
||||
.providerId(username)
|
||||
}
|
||||
|
||||
def getApiUsersByEmail(userEmail: String) : List[APIUser] = {
|
||||
APIUser.findAll(By(APIUser.email, userEmail))
|
||||
def getResourceUsersByEmail(userEmail: String) : List[ResourceUser] = {
|
||||
ResourceUser.findAll(By(ResourceUser.email, userEmail))
|
||||
}
|
||||
|
||||
def getApiUsers(): List[APIUser] = {
|
||||
APIUser.findAll()
|
||||
def getResourceUsers(): List[ResourceUser] = {
|
||||
ResourceUser.findAll()
|
||||
}
|
||||
|
||||
def getApiUserByUsername(username: String) : Box[APIUser] = {
|
||||
APIUser.find(By(APIUser.name_, username))
|
||||
def getResourceUserByUsername(username: String) : Box[ResourceUser] = {
|
||||
ResourceUser.find(By(ResourceUser.name_, username))
|
||||
}
|
||||
|
||||
override def save(): Boolean = {
|
||||
if(! (user defined_?)){
|
||||
info("user reference is null. We will create an API User")
|
||||
val apiUser = createUnsavedApiUser()
|
||||
apiUser.save()
|
||||
user(apiUser) //is this saving apiUser into a user field?
|
||||
val resourceUser = createUnsavedResourceUser()
|
||||
resourceUser.save()
|
||||
user(resourceUser) //is this saving resourceUser into a user field?
|
||||
}
|
||||
else {
|
||||
info("user reference is not null. Trying to update the API User")
|
||||
@ -158,7 +158,7 @@ class OBPUser extends MegaProtoUser[OBPUser] with Logger {
|
||||
/**
|
||||
* The singleton that has methods for accessing the database
|
||||
*/
|
||||
object OBPUser extends OBPUser with MetaMegaProtoUser[OBPUser]{
|
||||
object AuthUser extends AuthUser with MetaMegaProtoUser[AuthUser]{
|
||||
import net.liftweb.util.Helpers._
|
||||
|
||||
/**Marking the locked state to show different error message */
|
||||
@ -190,7 +190,7 @@ import net.liftweb.util.Helpers._
|
||||
"a *" #> {S.?("recover.password")}
|
||||
} &
|
||||
"#SignUpLink * " #> {
|
||||
"a [href]" #> {OBPUser.signUpPath.foldLeft("")(_ + "/" + _)} &
|
||||
"a [href]" #> {AuthUser.signUpPath.foldLeft("")(_ + "/" + _)} &
|
||||
"a *" #> {S.?("sign.up")}
|
||||
}
|
||||
})
|
||||
@ -202,8 +202,8 @@ import net.liftweb.util.Helpers._
|
||||
* Find current user
|
||||
*/
|
||||
def getCurrentUserUsername: String = {
|
||||
for {
|
||||
current <- OBPUser.currentUser
|
||||
for {
|
||||
current <- AuthUser.currentUser
|
||||
username <- tryo{current.username.get}
|
||||
if (username.nonEmpty)
|
||||
} yield {
|
||||
@ -229,12 +229,12 @@ import net.liftweb.util.Helpers._
|
||||
return ""
|
||||
}
|
||||
/**
|
||||
* Find current APIUser_UserId from OBPUser, it is only used for Consumer registration form to save the USER_ID when register new consumer.
|
||||
* Find current ResourceUser_UserId from AuthUser, it is only used for Consumer registration form to save the USER_ID when register new consumer.
|
||||
*/
|
||||
//TODO may not be a good idea, need modify after refactoring User Models.
|
||||
def getCurrentAPIUserUserId: String = {
|
||||
//TODO may not be a good idea, need modify after refactoring User Models.
|
||||
def getCurrentResourceUserUserId: String = {
|
||||
for {
|
||||
current <- OBPUser.currentUser
|
||||
current <- AuthUser.currentUser
|
||||
userId <- tryo{current.user.foreign.get.userId}
|
||||
if (userId.nonEmpty)
|
||||
} yield {
|
||||
@ -359,7 +359,7 @@ import net.liftweb.util.Helpers._
|
||||
}
|
||||
|
||||
|
||||
override def signupXhtml (user:OBPUser) = {
|
||||
override def signupXhtml (user:AuthUser) = {
|
||||
<div id="authorizeSection" class="signupSection">
|
||||
<div class="signup-error"><span class="lift:Msg?id=signup"/></div>
|
||||
<div>
|
||||
@ -389,7 +389,7 @@ import net.liftweb.util.Helpers._
|
||||
|
||||
|
||||
|
||||
def getAPIUserId(username: String, password: String): Box[Long] = {
|
||||
def getResourceUserId(username: String, password: String): Box[Long] = {
|
||||
findUserByUsername(username) match {
|
||||
case Full(user) if (user.getProvider() == Props.get("hostname","")) =>
|
||||
if (
|
||||
@ -417,10 +417,10 @@ import net.liftweb.util.Helpers._
|
||||
LoginAttempt.incrementBadLoginAttempts(username)
|
||||
info(ErrorMessages.UsernameHasBeenLocked)
|
||||
//TODO need to fix, use Failure instead, it is used to show the error message to the GUI
|
||||
Full(usernameLockedStateCode)
|
||||
Full(usernameLockedStateCode)
|
||||
}
|
||||
else {
|
||||
// Nothing worked, so just increment bad login attempts
|
||||
// Nothing worked, so just increment bad login attempts
|
||||
LoginAttempt.incrementBadLoginAttempts(username)
|
||||
Empty
|
||||
}
|
||||
@ -433,27 +433,27 @@ import net.liftweb.util.Helpers._
|
||||
kafkaUserId <- tryo{kafkaUser.user} } yield {
|
||||
LoginAttempt.resetBadLoginAttempts(username)
|
||||
kafkaUserId.toLong
|
||||
}
|
||||
}
|
||||
userId match {
|
||||
case Full(l:Long) => Full(l)
|
||||
case _ =>
|
||||
LoginAttempt.incrementBadLoginAttempts(username)
|
||||
Empty
|
||||
Empty
|
||||
}
|
||||
case "obpjvm" if ( Props.getBool("obpjvm.user.authentication", false) &&
|
||||
! LoginAttempt.userIsLocked(username) ) =>
|
||||
val userId = for { obpjvmUser <- getUserFromConnector(username, password)
|
||||
obpjvmUserId <- tryo{obpjvmUser.user} } yield {
|
||||
obpjvmUserId <- tryo{obpjvmUser.user} } yield {
|
||||
LoginAttempt.resetBadLoginAttempts(username)
|
||||
obpjvmUserId.toLong
|
||||
}
|
||||
userId match {
|
||||
case Full(l:Long) => Full(l)
|
||||
case _ =>
|
||||
case _ =>
|
||||
LoginAttempt.incrementBadLoginAttempts(username)
|
||||
Empty
|
||||
Empty
|
||||
}
|
||||
case _ =>
|
||||
case _ =>
|
||||
LoginAttempt.incrementBadLoginAttempts(username)
|
||||
Empty
|
||||
}
|
||||
@ -465,7 +465,7 @@ import net.liftweb.util.Helpers._
|
||||
}
|
||||
|
||||
|
||||
def getUserFromConnector(name: String, password: String):Box[OBPUser] = {
|
||||
def getUserFromConnector(name: String, password: String):Box[AuthUser] = {
|
||||
Connector.connector.vend.getUser(name, password) match {
|
||||
case Full(Connector.connector.vend.InboundUser(extEmail, extPassword, extUsername)) => {
|
||||
info("external user authenticated. login redir: " + loginRedirect.get)
|
||||
@ -491,10 +491,10 @@ import net.liftweb.util.Helpers._
|
||||
|
||||
// If not found, create new user
|
||||
case _ => {
|
||||
// Create OBPUser using fetched data from Kafka
|
||||
// Create AuthUser using fetched data from Kafka
|
||||
// assuming that user's email is always validated
|
||||
info("external user "+ extEmail +" does not exist locally, creating one")
|
||||
val newUser = OBPUser.create
|
||||
val newUser = AuthUser.create
|
||||
.firstName(extUsername)
|
||||
.email(extEmail)
|
||||
.username(extUsername)
|
||||
@ -553,7 +553,7 @@ import net.liftweb.util.Helpers._
|
||||
case Full(user) if user.validated_? &&
|
||||
user.getProvider() == Props.get("hostname","") &&
|
||||
! LoginAttempt.userIsLocked(usernameFromGui) &&
|
||||
! user.testPassword(Full(passwordFromGui)) =>
|
||||
! user.testPassword(Full(passwordFromGui)) =>
|
||||
LoginAttempt.incrementBadLoginAttempts(usernameFromGui)
|
||||
S.error(S.?("Invalid Login Credentials")) // TODO constant / i18n for this string
|
||||
|
||||
@ -568,7 +568,7 @@ import net.liftweb.util.Helpers._
|
||||
// If not found locally, try to authenticate user via Kafka, if enabled in props
|
||||
case Empty if ((connector == "kafka" || connector == "obpjvm") &&
|
||||
(Props.getBool("kafka.user.authentication", false) ||
|
||||
Props.getBool("obpjvm.user.authentication", false))) =>
|
||||
Props.getBool("obpjvm.user.authentication", false))) =>
|
||||
val preLoginState = capturePreLoginState()
|
||||
info("login redir: " + loginRedirect.get)
|
||||
val redir = loginRedirect.get match {
|
||||
@ -581,9 +581,9 @@ import net.liftweb.util.Helpers._
|
||||
for {
|
||||
user_ <- externalUserHelper(usernameFromGui, passwordFromGui)
|
||||
} yield {
|
||||
user_
|
||||
user_
|
||||
} match {
|
||||
case u:OBPUser =>
|
||||
case u:AuthUser =>
|
||||
LoginAttempt.resetBadLoginAttempts(usernameFromGui)
|
||||
logUserIn(u, () => {
|
||||
S.notice(S.?("logged.in"))
|
||||
@ -613,11 +613,11 @@ import net.liftweb.util.Helpers._
|
||||
}
|
||||
|
||||
|
||||
def externalUserHelper(name: String, password: String): Box[OBPUser] = {
|
||||
def externalUserHelper(name: String, password: String): Box[AuthUser] = {
|
||||
if (connector == "kafka" || connector == "obpjvm") {
|
||||
for {
|
||||
user <- getUserFromConnector(name, password)
|
||||
u <- APIUser.find(By(APIUser.name_, user.username))
|
||||
u <- ResourceUser.find(By(ResourceUser.name_, user.username))
|
||||
v <- tryo {Connector.connector.vend.updateUserAccountViews(u)}
|
||||
} yield {
|
||||
user
|
||||
@ -629,7 +629,7 @@ import net.liftweb.util.Helpers._
|
||||
def registeredUserHelper(username: String) = {
|
||||
if (connector == "kafka" || connector == "obpjvm") {
|
||||
for {
|
||||
u <- APIUser.find(By(APIUser.name_, username))
|
||||
u <- ResourceUser.find(By(ResourceUser.name_, username))
|
||||
v <- tryo {Connector.connector.vend.updateUserAccountViews(u)}
|
||||
} yield v
|
||||
}
|
||||
@ -7,7 +7,7 @@ class MappedAccountHolder extends LongKeyedMapper[MappedAccountHolder] with IdPK
|
||||
|
||||
def getSingleton = MappedAccountHolder
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
|
||||
object accountBankPermalink extends MappedString(this, 255)
|
||||
object accountPermalink extends MappedString(this, 255)
|
||||
|
||||
@ -37,8 +37,8 @@ import net.liftweb.util.Props
|
||||
|
||||
import code.model.{UserId, User, View}
|
||||
|
||||
class APIUser extends LongKeyedMapper[APIUser] with User with ManyToMany with OneToMany[Long, APIUser]{
|
||||
def getSingleton = APIUser
|
||||
class ResourceUser extends LongKeyedMapper[ResourceUser] with User with ManyToMany with OneToMany[Long, ResourceUser]{
|
||||
def getSingleton = ResourceUser
|
||||
def primaryKeyField = id
|
||||
|
||||
object id extends MappedLongIndex(this)
|
||||
@ -78,6 +78,6 @@ class APIUser extends LongKeyedMapper[APIUser] with User with ManyToMany with On
|
||||
|
||||
}
|
||||
|
||||
object APIUser extends APIUser with LongKeyedMetaMapper[APIUser]{
|
||||
object ResourceUser extends ResourceUser with LongKeyedMetaMapper[ResourceUser]{
|
||||
override def dbIndexes = UniqueIndex(provider_, providerId) ::super.dbIndexes
|
||||
}
|
||||
@ -46,7 +46,7 @@ A User can't use a View unless it is listed here.
|
||||
*/
|
||||
class ViewPrivileges extends LongKeyedMapper[ViewPrivileges] with IdPK with CreatedUpdated {
|
||||
def getSingleton = ViewPrivileges
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object view extends MappedLongForeignKey(this, ViewImpl)
|
||||
}
|
||||
object ViewPrivileges extends ViewPrivileges with LongKeyedMetaMapper[ViewPrivileges]
|
||||
@ -55,7 +55,7 @@ class ViewImpl extends View with LongKeyedMapper[ViewImpl] with ManyToMany with
|
||||
def getSingleton = ViewImpl
|
||||
|
||||
def primaryKeyField = id_
|
||||
object users_ extends MappedManyToMany(ViewPrivileges, ViewPrivileges.view, ViewPrivileges.user, APIUser)
|
||||
object users_ extends MappedManyToMany(ViewPrivileges, ViewPrivileges.view, ViewPrivileges.user, ResourceUser)
|
||||
|
||||
object bankPermalink extends MappedString(this, 255)
|
||||
object accountPermalink extends MappedString(this, 255)
|
||||
|
||||
@ -1,39 +1,39 @@
|
||||
package code.sandbox
|
||||
|
||||
import code.model.dataAccess.{OBPUser, APIUser}
|
||||
import code.model.dataAccess.{AuthUser, ResourceUser}
|
||||
import net.liftweb.common.{Full, Failure, Box}
|
||||
import net.liftweb.mapper.By
|
||||
|
||||
trait CreateOBPUsers {
|
||||
trait CreateAuthUsers {
|
||||
|
||||
self : OBPDataImport =>
|
||||
|
||||
override protected def createSaveableUser(u : SandboxUserImport) : Box[Saveable[APIUser]] = {
|
||||
override protected def createSaveableUser(u : SandboxUserImport) : Box[Saveable[ResourceUser]] = {
|
||||
|
||||
def asSaveable(u : OBPUser) = new Saveable[APIUser] {
|
||||
val value = u.createUnsavedApiUser()
|
||||
def asSaveable(u : AuthUser) = new Saveable[ResourceUser] {
|
||||
val value = u.createUnsavedResourceUser()
|
||||
def save() = {
|
||||
value.save()
|
||||
u.user(value).save()
|
||||
}
|
||||
}
|
||||
|
||||
val existingObpUser = OBPUser.find(By(OBPUser.username, u.user_name))
|
||||
val existingAuthUser = AuthUser.find(By(AuthUser.username, u.user_name))
|
||||
|
||||
if(existingObpUser.isDefined) {
|
||||
logger.warn(s"Existing OBPUser with email ${u.email} detected in data import where no APIUser was found")
|
||||
if(existingAuthUser.isDefined) {
|
||||
logger.warn(s"Existing AuthUser with email ${u.email} detected in data import where no ResourceUser was found")
|
||||
Failure(s"User with email ${u.email} already exist (and may be different (e.g. different display_name)")
|
||||
} else {
|
||||
val obpUser = OBPUser.create
|
||||
val authUser = AuthUser.create
|
||||
.email(u.email)
|
||||
.lastName(u.user_name)
|
||||
.username(u.user_name)
|
||||
.password(u.password)
|
||||
.validated(true)
|
||||
|
||||
val validationErrors = obpUser.validate
|
||||
val validationErrors = authUser.validate
|
||||
if(!validationErrors.isEmpty) Failure(s"Errors: ${validationErrors.map(_.msg)}")
|
||||
else Full(asSaveable(obpUser))
|
||||
else Full(asSaveable(authUser))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ case class SaveableMongoObj[T <: MongoRecord[_]](value : T) extends Saveable[T]
|
||||
|
||||
Not currently using this connector so not updating it at the moment.
|
||||
|
||||
object LocalConnectorDataImport extends OBPDataImport with CreateOBPUsers {
|
||||
object LocalConnectorDataImport extends OBPDataImport with CreateAuthUsers {
|
||||
|
||||
type BankType = HostedBank
|
||||
type AccountType = Account
|
||||
|
||||
@ -20,7 +20,7 @@ case class MappedSaveable[T <: Mapper[_]](value : T) extends Saveable[T] {
|
||||
def save() = value.save()
|
||||
}
|
||||
|
||||
object LocalMappedConnectorDataImport extends OBPDataImport with CreateOBPUsers {
|
||||
object LocalMappedConnectorDataImport extends OBPDataImport with CreateAuthUsers {
|
||||
|
||||
// Rename these types as MappedCrmEventType etc? Else can get confused with other types of same name
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import code.metadata.counterparties.{Counterparties, MapperCounterparties}
|
||||
import code.products.Products
|
||||
import code.products.Products.{Product, ProductCode}
|
||||
import code.bankconnectors.{Connector, OBPLimit, OBPOffset}
|
||||
import code.model.dataAccess.{APIUser, MappedAccountHolder}
|
||||
import code.model.dataAccess.{ResourceUser, MappedAccountHolder}
|
||||
import code.model._
|
||||
import code.branches.Branches.Branch
|
||||
import code.atms.Atms.Atm
|
||||
@ -130,45 +130,45 @@ trait OBPDataImport extends Loggable {
|
||||
|
||||
|
||||
/**
|
||||
* Creates an APIUser that can be saved. This method assumes there is no existing user with an email
|
||||
* Creates an ResourceUser that can be saved. This method assumes there is no existing user with an email
|
||||
* equal to @u.email
|
||||
*/
|
||||
protected def createSaveableUser(u : SandboxUserImport) : Box[Saveable[APIUser]]
|
||||
protected def createSaveableUser(u : SandboxUserImport) : Box[Saveable[ResourceUser]]
|
||||
|
||||
protected def createUsers(toImport : List[SandboxUserImport]) : Box[List[Saveable[APIUser]]] = {
|
||||
val existingApiUsers = toImport.flatMap(u => APIUser.find(By(APIUser.name_, u.user_name)))
|
||||
protected def createUsers(toImport : List[SandboxUserImport]) : Box[List[Saveable[ResourceUser]]] = {
|
||||
val existingResourceUsers = toImport.flatMap(u => ResourceUser.find(By(ResourceUser.name_, u.user_name)))
|
||||
val allUsernames = toImport.map(_.user_name)
|
||||
val duplicateUsernames = allUsernames diff allUsernames.distinct
|
||||
|
||||
def usersExist(existingEmails : List[String]) =
|
||||
Failure(s"User(s) with email(s) $existingEmails already exist (and may be different (e.g. different display_name)")
|
||||
|
||||
if(!existingApiUsers.isEmpty) {
|
||||
usersExist(existingApiUsers.map(_.name))
|
||||
if(!existingResourceUsers.isEmpty) {
|
||||
usersExist(existingResourceUsers.map(_.name))
|
||||
} else if(!duplicateUsernames.isEmpty) {
|
||||
Failure(s"Users must have unique usernames: Duplicates found: $duplicateUsernames")
|
||||
}else {
|
||||
|
||||
val apiUsers = toImport.map(createSaveableUser(_))
|
||||
val resourceUsers = toImport.map(createSaveableUser(_))
|
||||
|
||||
dataOrFirstFailure(apiUsers)
|
||||
dataOrFirstFailure(resourceUsers)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user with email @owner as the owner of @account
|
||||
*
|
||||
* TODO: this only works after createdUsers have been saved (and thus an APIUser has been created
|
||||
* TODO: this only works after createdUsers have been saved (and thus an ResourceUser has been created
|
||||
*/
|
||||
protected def setAccountOwner(owner : AccountOwnerUsername, account: BankAccount, createdUsers: List[APIUser]): AnyVal = {
|
||||
val apiUserOwner = createdUsers.find(user => owner == user.name)
|
||||
protected def setAccountOwner(owner : AccountOwnerUsername, account: BankAccount, createdUsers: List[ResourceUser]): AnyVal = {
|
||||
val resourceUserOwner = createdUsers.find(user => owner == user.name)
|
||||
|
||||
apiUserOwner match {
|
||||
resourceUserOwner match {
|
||||
case Some(o) => {
|
||||
MappedAccountHolder.createMappedAccountHolder(o.apiId.value, account.bankId.value, account.accountId.value, "OBPDataImport")
|
||||
}
|
||||
case None => {
|
||||
//This shouldn't happen as OBPUser should generate the APIUsers when saved
|
||||
//This shouldn't happen as AuthUser should generate the ResourceUsers when saved
|
||||
logger.error(s"api user $owner not found.")
|
||||
logger.error("Data import completed with errors.")
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ Berlin 13359, Germany
|
||||
package code.snippet
|
||||
|
||||
import code.model._
|
||||
import code.model.dataAccess.{OBPUser}
|
||||
import code.model.dataAccess.{AuthUser}
|
||||
import net.liftweb.http.{RequestVar, S}
|
||||
import net.liftweb.util.FieldError
|
||||
import net.liftweb.util.Helpers
|
||||
@ -147,7 +147,7 @@ class ConsumerRegistration extends Loggable {
|
||||
description(descriptionVar.is).
|
||||
developerEmail(devEmailVar.is).
|
||||
redirectURL(redirectionURLVar.is).
|
||||
createdByUserId(OBPUser.getCurrentAPIUserUserId)
|
||||
createdByUserId(AuthUser.getCurrentResourceUserUserId)
|
||||
|
||||
val errors = consumer.validate
|
||||
nameVar.set(nameVar.is)
|
||||
|
||||
@ -10,7 +10,7 @@ import net.liftweb.http.js.JsCmds.SetHtml
|
||||
import net.liftweb.http.js.JsCmd
|
||||
import scala.xml.NodeSeq
|
||||
import net.liftweb.http.js.jquery.JqJsCmds.{Show, Hide}
|
||||
import code.model.dataAccess.{OBPUser, BankAccountCreation}
|
||||
import code.model.dataAccess.{AuthUser, BankAccountCreation}
|
||||
|
||||
object CreateTestAccountForm{
|
||||
|
||||
@ -80,8 +80,8 @@ object CreateTestAccountForm{
|
||||
else {
|
||||
for {
|
||||
initialBalanceAsNumber <- tryo {BigDecimal(initialBalance)} ?~! "Initial balance must be a number, e.g 1000.00"
|
||||
currentObpUser <- OBPUser.currentUser ?~! "You need to be logged in to create an account"
|
||||
user <- currentObpUser.user.obj ?~ "Server error: could not identify user"
|
||||
currentAuthUser <- AuthUser.currentUser ?~! "You need to be logged in to create an account"
|
||||
user <- currentAuthUser.user.obj ?~ "Server error: could not identify user"
|
||||
bank <- Bank(bankId) ?~ s"Bank $bankId not found"
|
||||
accountDoesNotExist <- booleanToBox(BankAccount(bankId, accountId).isEmpty,
|
||||
s"Account with id $accountId already exists at bank $bankId")
|
||||
|
||||
@ -33,7 +33,7 @@ Berlin 13359, Germany
|
||||
package code.snippet
|
||||
|
||||
import code.api.OpenIdConnectConfig
|
||||
import code.model.dataAccess.{Admin, OBPUser}
|
||||
import code.model.dataAccess.{Admin, AuthUser}
|
||||
import net.liftweb.http.{S, SHtml}
|
||||
import net.liftweb.util.Helpers._
|
||||
import net.liftweb.util.{CssSel, Props}
|
||||
@ -43,29 +43,29 @@ import scala.xml.NodeSeq
|
||||
class Login {
|
||||
|
||||
def loggedIn = {
|
||||
if(!OBPUser.loggedIn_?){
|
||||
if(!AuthUser.loggedIn_?){
|
||||
"*" #> NodeSeq.Empty
|
||||
}else{
|
||||
".logout [href]" #> {
|
||||
OBPUser.logoutPath.foldLeft("")(_ + "/" + _)
|
||||
AuthUser.logoutPath.foldLeft("")(_ + "/" + _)
|
||||
} &
|
||||
".username *" #> OBPUser.getCurrentUserUsername
|
||||
".username *" #> AuthUser.getCurrentUserUsername
|
||||
}
|
||||
}
|
||||
|
||||
def loggedOut = {
|
||||
if(OBPUser.loggedIn_?){
|
||||
if(AuthUser.loggedIn_?){
|
||||
"*" #> NodeSeq.Empty
|
||||
} else {
|
||||
".login [href]" #> OBPUser.loginPageURL &
|
||||
".login [href]" #> AuthUser.loginPageURL &
|
||||
".forgot [href]" #> {
|
||||
val href = for {
|
||||
menu <- OBPUser.lostPasswordMenuLoc
|
||||
menu <- AuthUser.lostPasswordMenuLoc
|
||||
} yield menu.loc.calcDefaultHref
|
||||
href getOrElse "#"
|
||||
} & {
|
||||
".signup [href]" #> {
|
||||
OBPUser.signUpPath.foldLeft("")(_ + "/" + _)
|
||||
AuthUser.signUpPath.foldLeft("")(_ + "/" + _)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ import java.util.Date
|
||||
import code.api.util.APIUtil
|
||||
import net.liftweb.util.{CssSel, Helpers, Props}
|
||||
import code.model.TokenType
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import scala.xml.NodeSeq
|
||||
import net.liftweb.util.Helpers._
|
||||
import code.util.Helper.NOOP_SELECTOR
|
||||
@ -83,18 +83,18 @@ object OAuthAuthorisation {
|
||||
|
||||
//TODO: refactor into something nicer / more readable
|
||||
def validTokenCase(appToken: Token, unencodedTokenParam: String): CssSel = {
|
||||
if (OBPUser.loggedIn_? && shouldNotLogUserOut()) {
|
||||
if (AuthUser.loggedIn_? && shouldNotLogUserOut()) {
|
||||
var verifier = ""
|
||||
// if the user is logged in and no verifier have been generated
|
||||
if (appToken.verifier.isEmpty) {
|
||||
val randomVerifier = appToken.gernerateVerifier
|
||||
//the user is logged in so we have the current user
|
||||
val obpUser = OBPUser.currentUser.get
|
||||
val authUser = AuthUser.currentUser.get
|
||||
|
||||
//link the token with the concrete API User
|
||||
obpUser.user.obj.map {
|
||||
authUser.user.obj.map {
|
||||
u => {
|
||||
//We want ApiUser.id because it is unique, unlike the id given by a provider
|
||||
//We want ResourceUser.id because it is unique, unlike the id given by a provider
|
||||
// i.e. two different providers can have a user with id "bob"
|
||||
appToken.userForeignKey(u.id.get)
|
||||
}
|
||||
@ -121,18 +121,18 @@ object OAuthAuthorisation {
|
||||
}
|
||||
} else {
|
||||
val currentUrl = S.uriAndQueryString.getOrElse("/")
|
||||
/*if (OBPUser.loggedIn_?) {
|
||||
OBPUser.logUserOut()
|
||||
/*if (AuthUser.loggedIn_?) {
|
||||
AuthUser.logUserOut()
|
||||
//Bit of a hack here, but for reasons I haven't had time to discover, if this page doesn't get
|
||||
//refreshed here the session vars OBPUser.loginRedirect and OBPUser.failedLoginRedirect don't get set
|
||||
//refreshed here the session vars AuthUser.loginRedirect and AuthUser.failedLoginRedirect don't get set
|
||||
//properly and the redirect after login gets messed up. -E.S.
|
||||
S.redirectTo(currentUrl)
|
||||
}*/
|
||||
|
||||
//if login succeeds, reload the page with logUserOut=false to process it
|
||||
OBPUser.loginRedirect.set(Full(Helpers.appendParams(currentUrl, List((LogUserOutParam, "false")))))
|
||||
AuthUser.loginRedirect.set(Full(Helpers.appendParams(currentUrl, List((LogUserOutParam, "false")))))
|
||||
//if login fails, just reload the page with the login form visible
|
||||
OBPUser.failedLoginRedirect.set(Full(Helpers.appendParams(currentUrl, List((FailedLoginParam, "true")))))
|
||||
AuthUser.failedLoginRedirect.set(Full(Helpers.appendParams(currentUrl, List((FailedLoginParam, "true")))))
|
||||
//the user is not logged in so we show a login form
|
||||
Consumer.find(By(Consumer.id, appToken.consumerId)) match {
|
||||
case Full(consumer) => {
|
||||
@ -140,16 +140,16 @@ object OAuthAuthorisation {
|
||||
"#applicationName" #> consumer.name &
|
||||
VerifierBlocSel #> NodeSeq.Empty &
|
||||
ErrorMessageSel #> NodeSeq.Empty & {
|
||||
".login [action]" #> OBPUser.loginPageURL &
|
||||
".login [action]" #> AuthUser.loginPageURL &
|
||||
".forgot [href]" #> {
|
||||
val href = for {
|
||||
menu <- OBPUser.resetPasswordMenuLoc
|
||||
menu <- AuthUser.resetPasswordMenuLoc
|
||||
} yield menu.loc.calcDefaultHref
|
||||
|
||||
href getOrElse "#"
|
||||
} &
|
||||
".signup [href]" #>
|
||||
OBPUser.signUpPath.foldLeft("")(_ + "/" + _)
|
||||
AuthUser.signUpPath.foldLeft("")(_ + "/" + _)
|
||||
}
|
||||
}
|
||||
case _ => error("Application not found")
|
||||
@ -168,9 +168,9 @@ object OAuthAuthorisation {
|
||||
|
||||
// In this function we bind submit button to loginAction function.
|
||||
// In case that unique token of submit button cannot be paired submit action will be omitted.
|
||||
// Please note that unique token is obtained by responce from OBPUser.login function.
|
||||
// Please note that unique token is obtained by responce from AuthUser.login function.
|
||||
def getSubmitButtonWithValidLoginToken = {
|
||||
val allInputFields = (OBPUser.login \\ "input")
|
||||
val allInputFields = (AuthUser.login \\ "input")
|
||||
val submitFields = allInputFields.filter(e => e.\@("type").equalsIgnoreCase("submit"))
|
||||
val extractToken = submitFields.map(e => e.\@("name"))
|
||||
val submitElem = """<input class="submit" type="submit" value="Login" tabindex="4" name="submitButton"/>""".replace("submitButton", extractToken.headOption.getOrElse(""))
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package code.socialmedia
|
||||
|
||||
import java.util.Date
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.util.{DefaultStringField}
|
||||
import net.liftweb.mapper._
|
||||
|
||||
@ -30,7 +30,7 @@ with LongKeyedMapper[MappedSocialMedia] with IdPK with CreatedUpdated {
|
||||
|
||||
def getSingleton = MappedSocialMedia
|
||||
|
||||
object user extends MappedLongForeignKey(this, APIUser)
|
||||
object user extends MappedLongForeignKey(this, ResourceUser)
|
||||
object bank extends DefaultStringField(this)
|
||||
|
||||
object mCustomerNumber extends DefaultStringField(this)
|
||||
|
||||
@ -3,21 +3,21 @@ package code.users
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.util.Helpers._
|
||||
import code.model.User
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import net.liftweb.mapper.By
|
||||
|
||||
private object LiftUsers extends Users {
|
||||
|
||||
def getUserByApiId(id : Long) : Box[User] = {
|
||||
APIUser.find(id) ?~ { s"user $id not found"}
|
||||
ResourceUser.find(id) ?~ { s"user $id not found"}
|
||||
}
|
||||
|
||||
def getUserByProviderId(provider : String, idGivenByProvider : String) : Box[User] = {
|
||||
APIUser.find(By(APIUser.provider_, provider), By(APIUser.providerId, idGivenByProvider))
|
||||
ResourceUser.find(By(ResourceUser.provider_, provider), By(ResourceUser.providerId, idGivenByProvider))
|
||||
}
|
||||
|
||||
def getUserByUserId(userId : String) : Box[User] = {
|
||||
APIUser.find(By(APIUser.userId_, userId))
|
||||
ResourceUser.find(By(ResourceUser.userId_, userId))
|
||||
}
|
||||
|
||||
}
|
||||
4
src/main/scripts/migrate/migrate_0000004.sql
Normal file
4
src/main/scripts/migrate/migrate_0000004.sql
Normal file
@ -0,0 +1,4 @@
|
||||
-- Rename apiuser to resourceuser
|
||||
alter table apiuser RENAME TO resourceuser;
|
||||
alter table apiuser RENAME COLUMN apiuser_pk TO resourceuser_pk;
|
||||
alter table apiuser RENAME COLUMN apiuser_provider__providerid TO resourceuser_provider__providerid;
|
||||
@ -675,8 +675,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -748,8 +748,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -788,8 +788,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -830,8 +830,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -871,8 +871,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
When("we try to make a payment with amount < 0")
|
||||
|
||||
@ -913,7 +913,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val testBank = createPaymentTestBank()
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
When("we try to make a payment to an account that doesn't exist")
|
||||
|
||||
@ -948,8 +948,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "GBP")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "GBP")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1779,7 +1779,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user1)
|
||||
@ -1808,7 +1808,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomString(5), user1)
|
||||
@ -1824,7 +1824,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user3)
|
||||
@ -1842,7 +1842,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant = randomViewsIdsToGrant(bankId, bankAccount.id)
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
@ -1878,7 +1878,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant= List(randomString(3),randomString(3))
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1892,7 +1892,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) ++ List(randomString(3),randomString(3))
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
@ -1909,7 +1909,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) ++ List(randomString(3),randomString(3))
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
@ -1928,7 +1928,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewId = randomViewPermalinkButNotOwner(bankId, bankAccount)
|
||||
val viewsIdsToGrant = viewId :: Nil
|
||||
grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1946,8 +1946,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val viewId = "owner"
|
||||
val userId1 = obpuser2.idGivenByProvider
|
||||
val userId2 = obpuser2.idGivenByProvider
|
||||
val userId1 = authuser2.idGivenByProvider
|
||||
val userId2 = authuser2.idGivenByProvider
|
||||
grantUserAccessToView(bankId, bankAccount.id, userId1, viewId, user1)
|
||||
grantUserAccessToView(bankId, bankAccount.id, userId2, viewId, user1)
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId1, user1).body.extract[ViewsJSON].views.length
|
||||
@ -1966,7 +1966,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val viewId = ViewId("owner")
|
||||
val view = Views.views.vend.view(ViewUID(viewId, BankId(bankId), AccountId(bankAccount.id))).get
|
||||
if(view.users.length == 0){
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
grantUserAccessToView(bankId, bankAccount.id, userId, viewId.value, user1)
|
||||
}
|
||||
while(view.users.length > 1){
|
||||
@ -1997,26 +1997,26 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val ownerViewId = ViewId("owner")
|
||||
|
||||
//set up: make obpuser3 the account holder and make sure they have access to the owner view
|
||||
grantUserAccessToView(bankId, bankAccount.id, obpuser3.idGivenByProvider, ownerViewId.value, user1)
|
||||
setAccountHolder(obpuser3, BankId(bankId), AccountId(bankAccount.id))
|
||||
//set up: make authuser3 the account holder and make sure they have access to the owner view
|
||||
grantUserAccessToView(bankId, bankAccount.id, authuser3.idGivenByProvider, ownerViewId.value, user1)
|
||||
setAccountHolder(authuser3, BankId(bankId), AccountId(bankAccount.id))
|
||||
|
||||
When("We try to revoke this user's access to the owner view")
|
||||
val reply = revokeUserAccessToView(bankId, bankAccount.id, obpuser3.idGivenByProvider, ownerViewId.value, user1)
|
||||
val reply = revokeUserAccessToView(bankId, bankAccount.id, authuser3.idGivenByProvider, ownerViewId.value, user1)
|
||||
|
||||
Then("We will get a 400 response code")
|
||||
reply.code should equal (400)
|
||||
|
||||
And("The account holder should still have access to the owner view")
|
||||
val view = Views.views.vend.view(ViewUID(ownerViewId, BankId(bankId), AccountId(bankAccount.id))).get
|
||||
view.users should contain (obpuser3)
|
||||
view.users should contain (authuser3)
|
||||
}
|
||||
|
||||
scenario("we cannot revoke a user access to a view on an bank account because the view does not exist", API1_2, DeletePermission) {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId =obpuser2.idGivenByProvider
|
||||
val userId =authuser2.idGivenByProvider
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomString(5), user1)
|
||||
@ -2030,7 +2030,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSON].views.length
|
||||
When("the request is sent")
|
||||
val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user3)
|
||||
@ -2045,7 +2045,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewId = randomViewPermalink(bankId, bankAccount)
|
||||
val viewsIdsToGrant = viewId :: Nil
|
||||
grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -2071,7 +2071,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewId = randomViewPermalink(bankId, bankAccount)
|
||||
val viewsIdsToGrant = viewId :: Nil
|
||||
grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -2091,7 +2091,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val viewId = ViewId("owner")
|
||||
val view = Views.views.vend.view(ViewUID(viewId, BankId(bankId), AccountId(bankAccount.id))).get
|
||||
val userId = obpuser1.idGivenByProvider
|
||||
val userId = authuser1.idGivenByProvider
|
||||
|
||||
view.users.length should equal(1)
|
||||
view.users(0).idGivenByProvider should equal(userId)
|
||||
@ -2113,19 +2113,19 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val ownerViewId = "owner"
|
||||
|
||||
//set up: make obpuser3 the account holder and make sure they have access to the owner view
|
||||
grantUserAccessToView(bankId, bankAccount.id, obpuser3.idGivenByProvider, ownerViewId, user1)
|
||||
setAccountHolder(obpuser3, BankId(bankId), AccountId(bankAccount.id))
|
||||
//set up: make authuser3 the account holder and make sure they have access to the owner view
|
||||
grantUserAccessToView(bankId, bankAccount.id, authuser3.idGivenByProvider, ownerViewId, user1)
|
||||
setAccountHolder(authuser3, BankId(bankId), AccountId(bankAccount.id))
|
||||
|
||||
When("We try to revoke this user's access to all views")
|
||||
val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, obpuser3.idGivenByProvider, user1)
|
||||
val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, authuser3.idGivenByProvider, user1)
|
||||
|
||||
Then("we should get a 400 code")
|
||||
reply.code should equal (400)
|
||||
|
||||
And("The user should not have had his access revoked")
|
||||
val view = Views.views.vend.view(ViewUID(ViewId("owner"), BankId(bankId), AccountId(bankAccount.id))).get
|
||||
view.users should contain (obpuser3)
|
||||
view.users should contain (authuser3)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1234,7 +1234,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
When("the request is sent")
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user1)
|
||||
Then("we should get a 201 ok code")
|
||||
reply.code should equal (201)
|
||||
@ -1259,7 +1259,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomString(5), user1)
|
||||
Then("we should get a 404 code")
|
||||
@ -1272,7 +1272,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user3)
|
||||
Then("we should get a 400 ok code")
|
||||
@ -1287,7 +1287,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant = randomViewsIdsToGrant(bankId, bankAccount.id)
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1320,7 +1320,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant= List(randomString(3),randomString(3))
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1334,7 +1334,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) ++ List(randomString(3),randomString(3))
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1348,7 +1348,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser3.idGivenByProvider
|
||||
val userId = authuser3.idGivenByProvider
|
||||
val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) ++ List(randomString(3),randomString(3))
|
||||
When("the request is sent")
|
||||
val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user3)
|
||||
@ -1364,7 +1364,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewId = randomViewPermalinkButNotOwner(bankId, bankAccount)
|
||||
val viewsIdsToGrant = viewId :: Nil
|
||||
grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1382,8 +1382,8 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val viewId = "owner"
|
||||
val userId1 = obpuser2.idGivenByProvider
|
||||
val userId2 = obpuser2.idGivenByProvider
|
||||
val userId1 = authuser2.idGivenByProvider
|
||||
val userId2 = authuser2.idGivenByProvider
|
||||
grantUserAccessToView(bankId, bankAccount.id, userId1, viewId, user1)
|
||||
grantUserAccessToView(bankId, bankAccount.id, userId2, viewId, user1)
|
||||
val viewsBefore = getUserAccountPermission(bankId, bankAccount.id, userId1, user1).body.extract[ViewsJSON].views.length
|
||||
@ -1402,7 +1402,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
val viewId = ViewId("owner")
|
||||
val view = Views.views.vend.view(ViewUID(viewId, BankId(bankId), AccountId(bankAccount.id))).get
|
||||
if(view.users.length == 0){
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
grantUserAccessToView(bankId, bankAccount.id, userId, viewId.value, user1)
|
||||
}
|
||||
while(view.users.length > 1){
|
||||
@ -1431,7 +1431,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId =obpuser2.idGivenByProvider
|
||||
val userId =authuser2.idGivenByProvider
|
||||
When("the request is sent")
|
||||
val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomString(5), user1)
|
||||
Then("we should get a 404 code")
|
||||
@ -1442,7 +1442,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
When("the request is sent")
|
||||
val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user3)
|
||||
Then("we should get a 400 ok code")
|
||||
@ -1454,7 +1454,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewId = randomViewPermalink(bankId, bankAccount)
|
||||
val viewsIdsToGrant = viewId :: Nil
|
||||
grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
@ -1478,7 +1478,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
|
||||
Given("We will use an access token")
|
||||
val bankId = randomBank
|
||||
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
|
||||
val userId = obpuser2.idGivenByProvider
|
||||
val userId = authuser2.idGivenByProvider
|
||||
val viewId = randomViewPermalink(bankId, bankAccount)
|
||||
val viewsIdsToGrant = viewId :: Nil
|
||||
grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1)
|
||||
|
||||
@ -3,7 +3,7 @@ package code.api
|
||||
import code.api.util.APIUtil
|
||||
import code.model.TokenType._
|
||||
import code.model.{Consumer => OBPConsumer, Token => OBPToken}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import APIUtil.OAuth.{Token, Consumer}
|
||||
import net.liftweb.util.Helpers._
|
||||
import net.liftweb.util.Props
|
||||
@ -28,15 +28,15 @@ trait DefaultUsers {
|
||||
val expiration = Props.getInt("token_expiration_weeks", 4)
|
||||
lazy val tokenDuration = weeks(expiration)
|
||||
|
||||
lazy val obpuser1 =
|
||||
APIUser.create.provider_(defaultProvider).
|
||||
lazy val authuser1 =
|
||||
ResourceUser.create.provider_(defaultProvider).
|
||||
saveMe
|
||||
|
||||
lazy val testToken =
|
||||
OBPToken.create.
|
||||
tokenType(Access).
|
||||
consumerId(testConsumer.id).
|
||||
userForeignKey(obpuser1.id.toLong).
|
||||
userForeignKey(authuser1.id.toLong).
|
||||
key(randomString(40).toLowerCase).
|
||||
secret(randomString(40).toLowerCase).
|
||||
duration(tokenDuration).
|
||||
@ -47,8 +47,8 @@ trait DefaultUsers {
|
||||
lazy val token = new Token(testToken.key, testToken.secret)
|
||||
|
||||
// create a user for test purposes
|
||||
lazy val obpuser2 =
|
||||
APIUser.create.provider_(defaultProvider).
|
||||
lazy val authuser2 =
|
||||
ResourceUser.create.provider_(defaultProvider).
|
||||
saveMe
|
||||
|
||||
//we create an access token for the other user
|
||||
@ -56,7 +56,7 @@ trait DefaultUsers {
|
||||
OBPToken.create.
|
||||
tokenType(Access).
|
||||
consumerId(testConsumer.id).
|
||||
userForeignKey(obpuser2.id.toLong).
|
||||
userForeignKey(authuser2.id.toLong).
|
||||
key(randomString(40).toLowerCase).
|
||||
secret(randomString(40).toLowerCase).
|
||||
duration(tokenDuration).
|
||||
@ -67,8 +67,8 @@ trait DefaultUsers {
|
||||
lazy val token2 = new Token(testToken2.key, testToken2.secret)
|
||||
|
||||
// create a user for test purposes
|
||||
lazy val obpuser3 =
|
||||
APIUser.create.provider_(defaultProvider).
|
||||
lazy val authuser3 =
|
||||
ResourceUser.create.provider_(defaultProvider).
|
||||
saveMe
|
||||
|
||||
//we create an access token for the other user
|
||||
@ -76,7 +76,7 @@ trait DefaultUsers {
|
||||
OBPToken.create.
|
||||
tokenType(Access).
|
||||
consumerId(testConsumer.id).
|
||||
userForeignKey(obpuser3.id.toLong).
|
||||
userForeignKey(authuser3.id.toLong).
|
||||
key(randomString(40).toLowerCase).
|
||||
secret(randomString(40).toLowerCase).
|
||||
duration(tokenDuration).
|
||||
|
||||
@ -111,7 +111,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
override protected def wipeTestData() = {
|
||||
//returns true if the model should not be wiped after each test
|
||||
def exclusion(m : MetaMapper[_]) = {
|
||||
m == Nonce || m == Token || m == Consumer || m == OBPUser || m == APIUser
|
||||
m == Nonce || m == Token || m == Consumer || m == AuthUser || m == ResourceUser
|
||||
}
|
||||
|
||||
//empty the relational db tables after each test
|
||||
|
||||
@ -9,7 +9,7 @@ trait PrivateUser2Accounts {
|
||||
self: ServerSetupWithTestData with DefaultUsers =>
|
||||
|
||||
/**
|
||||
* Adds some private accounts for obpuser2 to the DB so that not all accounts in the DB are public
|
||||
* Adds some private accounts for authuser2 to the DB so that not all accounts in the DB are public
|
||||
* (which is at the time of writing, the default created in ServerSetup)
|
||||
*
|
||||
* Also adds some public accounts to which user1 does not have owner access
|
||||
@ -28,14 +28,14 @@ trait PrivateUser2Accounts {
|
||||
|
||||
//fake bank accounts
|
||||
|
||||
//private accounts for obpuser1 (visible to obpuser1)
|
||||
generateAccounts(obpuser1)
|
||||
//private accounts for obpuser2 (not visible to obpuser1)
|
||||
generateAccounts(obpuser2)
|
||||
//private accounts for authuser1 (visible to authuser1)
|
||||
generateAccounts(authuser1)
|
||||
//private accounts for authuser2 (not visible to authuser1)
|
||||
generateAccounts(authuser2)
|
||||
|
||||
//public accounts owned by obpuser2 (visible to obpuser1)
|
||||
//public accounts owned by authuser2 (visible to authuser1)
|
||||
//create accounts
|
||||
val accounts = generateAccounts(obpuser2)
|
||||
val accounts = generateAccounts(authuser2)
|
||||
//add public views
|
||||
accounts.foreach(acc => createPublicView(acc.bankId, acc.accountId))
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ trait TestConnectorSetupWithStandardPermissions extends TestConnectorSetup {
|
||||
|
||||
//returns true if the model should not be wiped after each test
|
||||
def exclusion(m : MetaMapper[_]) = {
|
||||
m == Nonce || m == Token || m == Consumer || m == OBPUser || m == APIUser
|
||||
m == Nonce || m == Token || m == Consumer || m == AuthUser || m == ResourceUser
|
||||
}
|
||||
|
||||
//empty the relational db tables after each test
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package code.api
|
||||
|
||||
//a trait that grants obpuser1 from DefaultUsers access to all views before each test
|
||||
//a trait that grants authuser1 from DefaultUsers access to all views before each test
|
||||
trait User1AllPrivileges extends ServerSetupWithTestData {
|
||||
self : DefaultUsers =>
|
||||
|
||||
override def beforeEach(): Unit = {
|
||||
super.beforeEach()
|
||||
super.grantAccessToAllExistingViews(obpuser1)
|
||||
super.grantAccessToAllExistingViews(authuser1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package code.api
|
||||
|
||||
import code.api.util.ErrorMessages
|
||||
import code.loginattempts.LoginAttempt
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.model.{Consumer => OBPConsumer, Token => OBPToken}
|
||||
import net.liftweb.json.JsonAST.{JArray, JField, JObject, JString}
|
||||
import net.liftweb.mapper.By
|
||||
@ -27,8 +27,8 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
|
||||
val PASSWORD_DISABLED = randomString(20)
|
||||
|
||||
before {
|
||||
if (OBPUser.find(By(OBPUser.username, USERNAME)).isEmpty)
|
||||
OBPUser.create.
|
||||
if (AuthUser.find(By(AuthUser.username, USERNAME)).isEmpty)
|
||||
AuthUser.create.
|
||||
email(EMAIL).
|
||||
username(USERNAME).
|
||||
password(PASSWORD).
|
||||
@ -46,8 +46,8 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
|
||||
saveMe
|
||||
|
||||
|
||||
if (OBPUser.find(By(OBPUser.username, USERNAME_DISABLED)).isEmpty)
|
||||
OBPUser.create.
|
||||
if (AuthUser.find(By(AuthUser.username, USERNAME_DISABLED)).isEmpty)
|
||||
AuthUser.create.
|
||||
email(EMAIL_DISABLED).
|
||||
username(USERNAME_DISABLED).
|
||||
password(PASSWORD_DISABLED).
|
||||
|
||||
@ -37,7 +37,7 @@ import java.util.ResourceBundle
|
||||
import code.api.util.APIUtil.OAuth._
|
||||
import code.api.util.ErrorMessages
|
||||
import code.loginattempts.LoginAttempt
|
||||
import code.model.dataAccess.OBPUser
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.model.{Consumer => OBPConsumer, Token => OBPToken}
|
||||
import dispatch.Defaults._
|
||||
import dispatch._
|
||||
@ -85,7 +85,7 @@ class OAuthTest extends ServerSetup {
|
||||
|
||||
lazy val user1Password = randomString(10)
|
||||
lazy val user1 =
|
||||
OBPUser.create.
|
||||
AuthUser.create.
|
||||
email(randomString(3)+"@example.com").
|
||||
username(randomString(9)).
|
||||
password(user1Password).
|
||||
@ -96,7 +96,7 @@ class OAuthTest extends ServerSetup {
|
||||
|
||||
lazy val user2Password = randomString(10)
|
||||
lazy val user2 =
|
||||
OBPUser.create.
|
||||
AuthUser.create.
|
||||
email(randomString(3)+"@example.com").
|
||||
username(randomString(9)).
|
||||
password(user2Password).
|
||||
|
||||
@ -12,7 +12,7 @@ import code.fx.FXRate
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.metadata.counterparties.CounterpartyTrait
|
||||
import code.model.{Consumer, PhysicalCard, _}
|
||||
import code.model.dataAccess.APIUser
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import net.liftweb.common.{Box, Empty, Failure, Full, Loggable}
|
||||
import code.products.Products.{Product, ProductCode}
|
||||
@ -66,7 +66,7 @@ class PhysicalCardsTest extends ServerSetup with DefaultUsers with DefaultConne
|
||||
override def getTransactionRequestStatusesImpl() : Box[Map[String, String]] = ???
|
||||
|
||||
def getUser(name: String, password: String): Box[InboundUser] = ???
|
||||
def updateUserAccountViews(user: APIUser): Unit = ???
|
||||
def updateUserAccountViews(user: ResourceUser): Unit = ???
|
||||
|
||||
//these methods aren't required by our test
|
||||
override def getChallengeThreshold(userId: String, accountId: String, transactionRequestType: String, currency: String): (BigDecimal, String) = (0, "EUR")
|
||||
@ -87,9 +87,9 @@ class PhysicalCardsTest extends ServerSetup with DefaultUsers with DefaultConne
|
||||
|
||||
//these methods are required
|
||||
override def getPhysicalCards(user : User) : List[PhysicalCard] = {
|
||||
if(user == obpuser1) {
|
||||
if(user == authuser1) {
|
||||
user1AllCards
|
||||
} else if (user == obpuser2) {
|
||||
} else if (user == authuser2) {
|
||||
user2AllCards
|
||||
} else {
|
||||
List()
|
||||
@ -97,9 +97,9 @@ class PhysicalCardsTest extends ServerSetup with DefaultUsers with DefaultConne
|
||||
}
|
||||
|
||||
override def getPhysicalCardsForBank(bank : Bank, user : User) : List[PhysicalCard] = {
|
||||
if(user == obpuser1) {
|
||||
if(user == authuser1) {
|
||||
user1CardsForOneBank
|
||||
} else if (user == obpuser2) {
|
||||
} else if (user == authuser2) {
|
||||
user2CardsForOneBank
|
||||
} else {
|
||||
List()
|
||||
|
||||
@ -39,7 +39,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
|
||||
val testBank = mockBankId
|
||||
|
||||
val customerPostJSON = CreateCustomerJson(
|
||||
user_id = obpuser1.userId,
|
||||
user_id = authuser1.userId,
|
||||
customer_number = mockCustomerNumber,
|
||||
legal_name = "Someone",
|
||||
mobile_phone_number = "125245",
|
||||
@ -77,14 +77,14 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
|
||||
}
|
||||
|
||||
When("We link user to customer")
|
||||
val uclJSON = CreateUserCustomerLinkJSON(user_id = obpuser1.userId, customer_id = customerId)
|
||||
val uclJSON = CreateUserCustomerLinkJSON(user_id = authuser1.userId, customer_id = customerId)
|
||||
val requestPostUcl = (v2_0Request / "banks" / testBank.value / "user_customer_links").POST <@ (user1)
|
||||
val responsePostUcl = makePostRequest(requestPostUcl, write(uclJSON))
|
||||
Then("We should get a 400")
|
||||
responsePostUcl.code should equal(400)
|
||||
|
||||
When("We add required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, obpuser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, authuser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
|
||||
val responsePostUclSec = makePostRequest(requestPostUcl, write(uclJSON))
|
||||
Then("We should get a 201")
|
||||
responsePostUclSec.code should equal(201)
|
||||
|
||||
@ -76,7 +76,7 @@ class MappedCustomerMessagesTest extends V140ServerSetup with DefaultUsers {
|
||||
case Empty => "Empty"
|
||||
case _ => "Failure"
|
||||
}
|
||||
MappedUserCustomerLink.createUserCustomerLink(obpuser1.userId, customerId, exampleDate, true)
|
||||
MappedUserCustomerLink.createUserCustomerLink(authuser1.userId, customerId, exampleDate, true)
|
||||
|
||||
When("We add a message")
|
||||
request = (v1_4Request / "banks" / mockBankId.value / "customer" / customerId / "messages").POST <@ user1
|
||||
@ -107,7 +107,7 @@ class MappedCustomerMessagesTest extends V140ServerSetup with DefaultUsers {
|
||||
//need to create a customer info obj since the customer messages call needs to find user by customer number
|
||||
MappedCustomer.create
|
||||
.mBank(mockBankId.value)
|
||||
.mUser(obpuser1)
|
||||
.mUser(authuser1)
|
||||
.mNumber(mockCustomerNumber).save()
|
||||
}
|
||||
|
||||
|
||||
@ -35,8 +35,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -166,8 +166,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -330,8 +330,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -370,8 +370,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -412,8 +412,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -453,8 +453,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
When("we try to make a payment with amount < 0")
|
||||
|
||||
@ -495,7 +495,7 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val testBank = createPaymentTestBank()
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
When("we try to make a payment to an account that doesn't exist")
|
||||
|
||||
@ -530,8 +530,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "GBP")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "GBP")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
|
||||
@ -38,7 +38,7 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
|
||||
val testBank = mockBankId
|
||||
|
||||
Then("We create an private account at the bank")
|
||||
val accountPutJSON = CreateAccountJSON(obpuser1.userId, "CURRENT", newAccountLabel1, AmountOfMoneyJSON121("EUR", "0"))
|
||||
val accountPutJSON = CreateAccountJSON(authuser1.userId, "CURRENT", newAccountLabel1, AmountOfMoneyJSON121("EUR", "0"))
|
||||
val requestPut = (v2_0Request / "banks" / testBank.value / "accounts" / newAccountId1).PUT <@ (user1)
|
||||
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
|
||||
|
||||
@ -86,7 +86,7 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
|
||||
val testBank = mockBankId
|
||||
|
||||
Then("We create an private account at the bank")
|
||||
val accountPutJSON = CreateAccountJSON(obpuser1.userId,"CURRENT", newAccountLabel1, AmountOfMoneyJSON121("EUR", "0"))
|
||||
val accountPutJSON = CreateAccountJSON(authuser1.userId,"CURRENT", newAccountLabel1, AmountOfMoneyJSON121("EUR", "0"))
|
||||
val requestPut = (v2_0Request / "banks" / testBank.value / "accounts" / newAccountId1).PUT <@ (user1)
|
||||
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
|
||||
|
||||
@ -135,7 +135,7 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
|
||||
val newAccountIdWithSpaces = "account%20with%20spaces"
|
||||
|
||||
Then("We create an private account at the bank")
|
||||
val accountPutJSON = CreateAccountJSON(obpuser1.userId, "CURRENT", newAccountLabel1, AmountOfMoneyJSON121("EUR", "0"))
|
||||
val accountPutJSON = CreateAccountJSON(authuser1.userId, "CURRENT", newAccountLabel1, AmountOfMoneyJSON121("EUR", "0"))
|
||||
val requestPut = (v2_0Request / "banks" / testBank.value / "accounts" / newAccountIdWithSpaces).PUT <@ (user1)
|
||||
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
|
||||
val testBank = mockBankId
|
||||
|
||||
val customerPostJSON = CreateCustomerJson(
|
||||
user_id = obpuser1.userId,
|
||||
user_id = authuser1.userId,
|
||||
customer_number = mockCustomerNumber,
|
||||
legal_name = "Someone",
|
||||
mobile_phone_number = "125245",
|
||||
@ -59,13 +59,13 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
|
||||
responsePost.code should equal(400)
|
||||
|
||||
When("We add one required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, obpuser1.userId, ApiRole.CanCreateCustomer.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, authuser1.userId, ApiRole.CanCreateCustomer.toString)
|
||||
val responsePost1 = makePostRequest(requestPost, write(customerPostJSON))
|
||||
Then("We should get a 400")
|
||||
responsePost1.code should equal(400)
|
||||
|
||||
When("We add all required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, obpuser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, authuser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
|
||||
val responsePost2 = makePostRequest(requestPost, write(customerPostJSON))
|
||||
Then("We should get a 201")
|
||||
responsePost2.code should equal(201)
|
||||
|
||||
@ -25,7 +25,7 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("We try to get entitlements without login - getEntitlements") {
|
||||
When("We make the request")
|
||||
val requestGet = (v2_0Request / "users" / obpuser1.userId / "entitlements").GET
|
||||
val requestGet = (v2_0Request / "users" / authuser1.userId / "entitlements").GET
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
Then("We should get a 400")
|
||||
responseGet.code should equal(400)
|
||||
@ -37,7 +37,7 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("We try to get entitlements without credentials - getEntitlements") {
|
||||
When("We make the request")
|
||||
val requestGet = (v2_0Request / "users" / obpuser1.userId / "entitlements").GET <@ (user1)
|
||||
val requestGet = (v2_0Request / "users" / authuser1.userId / "entitlements").GET <@ (user1)
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
Then("We should get a 400")
|
||||
responseGet.code should equal(400)
|
||||
@ -48,9 +48,9 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("We try to get entitlements with credentials - getEntitlements") {
|
||||
When("We add required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement("", obpuser1.userId, ApiRole.CanGetEntitlementsForAnyUserAtAnyBank.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement("", authuser1.userId, ApiRole.CanGetEntitlementsForAnyUserAtAnyBank.toString)
|
||||
And("We make the request")
|
||||
val requestGet = (v2_0Request / "users" / obpuser1.userId / "entitlements").GET <@ (user1)
|
||||
val requestGet = (v2_0Request / "users" / authuser1.userId / "entitlements").GET <@ (user1)
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
Then("We should get a 200")
|
||||
responseGet.code should equal(200)
|
||||
|
||||
@ -38,12 +38,12 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
addEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
addEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -187,8 +187,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -325,8 +325,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -374,12 +374,12 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId2 = testBank2.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -442,8 +442,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -646,8 +646,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -826,8 +826,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1080,8 +1080,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1120,8 +1120,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1162,8 +1162,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1203,8 +1203,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
When("we try to make a payment with amount < 0")
|
||||
|
||||
@ -1245,7 +1245,7 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val testBank = createPaymentTestBank()
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
When("we try to make a payment to an account that doesn't exist")
|
||||
|
||||
@ -1280,8 +1280,8 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "GBP")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "GBP")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
|
||||
@ -37,8 +37,8 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
|
||||
val branchId = BranchId("1234")
|
||||
|
||||
Then("We add entitlement to user1")
|
||||
addEntitlement(bankId.value, obpuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser1.userId, CanCreateBranch)
|
||||
addEntitlement(bankId.value, authuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser1.userId, CanCreateBranch)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
When("We make the request Update Branch for an account")
|
||||
@ -62,8 +62,8 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
|
||||
val branchId = BranchId("1234")
|
||||
|
||||
Then("We add entitlement to user1")
|
||||
addEntitlement(bankId.value, obpuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser1.userId, CanCreateBranch)
|
||||
addEntitlement(bankId.value, authuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser1.userId, CanCreateBranch)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
When("We make the request Update Branch for an account")
|
||||
@ -105,11 +105,11 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
|
||||
val accountId = AccountId("__acc1")
|
||||
val branchId = BranchId("1234")
|
||||
val viewId =ViewId("owner")
|
||||
val bankAccount = createAccountAndOwnerView(Some(obpuser1), bankId, accountId, "EUR")
|
||||
val bankAccount = createAccountAndOwnerView(Some(authuser1), bankId, accountId, "EUR")
|
||||
|
||||
Then("We add entitlement to user1")
|
||||
addEntitlement(bankId.value, obpuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser1.userId, CanCreateBranch)
|
||||
addEntitlement(bankId.value, authuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser1.userId, CanCreateBranch)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
|
||||
@ -135,12 +135,12 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
|
||||
val accountId = AccountId("__acc1")
|
||||
val branchId = BranchId("1234")
|
||||
val viewId =ViewId("owner")
|
||||
val bankAccount = createAccountAndOwnerView(Some(obpuser1), bankId, accountId, "EUR")
|
||||
val bankAccount = createAccountAndOwnerView(Some(authuser1), bankId, accountId, "EUR")
|
||||
|
||||
|
||||
Then("We add entitlement to user1")
|
||||
addEntitlement(bankId.value, obpuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser1.userId, CanCreateBranch)
|
||||
addEntitlement(bankId.value, authuser1.userId, CanCreateBranch.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser1.userId, CanCreateBranch)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
When("We make the request Update Branch for an account")
|
||||
|
||||
@ -39,7 +39,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
|
||||
val bankId = testBank.bankId
|
||||
val accountId = AccountId("__acc1")
|
||||
val viewId =ViewId("owner")
|
||||
val bankAccount = createAccountAndOwnerView(Some(obpuser1), bankId, accountId, "EUR")
|
||||
val bankAccount = createAccountAndOwnerView(Some(authuser1), bankId, accountId, "EUR")
|
||||
|
||||
When("We make the request Create counterparty for an account")
|
||||
val requestPost = (v2_1Request / "banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1)
|
||||
@ -75,7 +75,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
|
||||
val accountId = AccountId("__acc1")
|
||||
val viewId =ViewId("owner")
|
||||
val ownerView = createOwnerView(bankId, accountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
val requestPost = (v2_1Request / "banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1)
|
||||
val responsePost = makePostRequest(requestPost, write(customerPostJSON))
|
||||
@ -92,7 +92,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
|
||||
val bankId = testBank.bankId
|
||||
val accountId = AccountId("__acc1")
|
||||
val viewId =ViewId("owner")
|
||||
val bankAccount = createAccountAndOwnerView(Some(obpuser1), bankId, accountId, "EUR")
|
||||
val bankAccount = createAccountAndOwnerView(Some(authuser1), bankId, accountId, "EUR")
|
||||
|
||||
When("We make the request Create counterparty for an account")
|
||||
val requestPost = (v2_1Request / "banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1)
|
||||
|
||||
@ -146,9 +146,9 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
|
||||
* set CanCreateTransactionType Entitlements to user1
|
||||
*/
|
||||
def setCanCreateTransactionType: Unit = {
|
||||
addEntitlement(mockBankId, obpuser1.userId, CanCreateTransactionType.toString)
|
||||
addEntitlement(mockBankId, authuser1.userId, CanCreateTransactionType.toString)
|
||||
Then("We add entitlement to user1")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(mockBankId, obpuser1.userId, CanCreateTransactionType)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(mockBankId, authuser1.userId, CanCreateTransactionType)
|
||||
hasEntitlement should equal(true)
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ class CustomerTest extends V210ServerSetup with DefaultUsers {
|
||||
val testBank = mockBankId
|
||||
|
||||
val customerPostJSON = PostCustomerJson(
|
||||
user_id = obpuser1.userId,
|
||||
user_id = authuser1.userId,
|
||||
customer_number = mockCustomerNumber,
|
||||
legal_name = "Someone",
|
||||
mobile_phone_number = "125245",
|
||||
@ -62,13 +62,13 @@ class CustomerTest extends V210ServerSetup with DefaultUsers {
|
||||
responsePost.code should equal(400)
|
||||
|
||||
When("We add one required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, obpuser1.userId, ApiRole.CanCreateCustomer.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, authuser1.userId, ApiRole.CanCreateCustomer.toString)
|
||||
val responsePost1 = makePostRequest(requestPost, write(customerPostJSON))
|
||||
Then("We should get a 400")
|
||||
responsePost1.code should equal(400)
|
||||
|
||||
When("We add all required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, obpuser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement(testBank.value, authuser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
|
||||
val responsePost2 = makePostRequest(requestPost, write(customerPostJSON))
|
||||
Then("We should get a 201")
|
||||
responsePost2.code should equal(201)
|
||||
|
||||
@ -53,7 +53,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("We try to get entitlements without login - getEntitlementsByBankAndUser") {
|
||||
When("We make the request")
|
||||
val requestGet = (v2_1Request / "banks" / mockBankId.value / "users" / obpuser1.userId / "entitlements").GET
|
||||
val requestGet = (v2_1Request / "banks" / mockBankId.value / "users" / authuser1.userId / "entitlements").GET
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
Then("We should get a 400")
|
||||
responseGet.code should equal(400)
|
||||
@ -65,7 +65,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("We try to get entitlements without credentials - getEntitlementsByBankAndUser") {
|
||||
When("We make the request")
|
||||
val requestGet = (v2_1Request / "banks" / mockBankId.value / "users" / obpuser1.userId / "entitlements").GET <@ (user1)
|
||||
val requestGet = (v2_1Request / "banks" / mockBankId.value / "users" / authuser1.userId / "entitlements").GET <@ (user1)
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
Then("We should get a 400")
|
||||
responseGet.code should equal(400)
|
||||
@ -80,9 +80,9 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("We try to get entitlements with credentials - getEntitlementsByBankAndUser") {
|
||||
When("We add required entitlement")
|
||||
Entitlement.entitlement.vend.addEntitlement("", obpuser1.userId, ApiRole.CanGetEntitlementsForAnyUserAtAnyBank.toString)
|
||||
Entitlement.entitlement.vend.addEntitlement("", authuser1.userId, ApiRole.CanGetEntitlementsForAnyUserAtAnyBank.toString)
|
||||
And("We make the request")
|
||||
val requestGet = (v2_1Request / "banks" / mockBankId.value / "users" / obpuser1.userId / "entitlements").GET <@ (user1)
|
||||
val requestGet = (v2_1Request / "banks" / mockBankId.value / "users" / authuser1.userId / "entitlements").GET <@ (user1)
|
||||
val responseGet = makeGetRequest(requestGet)
|
||||
Then("We should get a 200")
|
||||
responseGet.code should equal(200)
|
||||
|
||||
@ -40,16 +40,16 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
val isBeneficiary = true
|
||||
val counterpartyId = CounterpartyIdJson("123");
|
||||
val counterParty = createCounterparty(bankId.value, accountId2.value, "", true, counterpartyId.counterparty_id);
|
||||
|
||||
addEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
addEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -180,8 +180,8 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
val counterpartyId = CounterpartyIdJson("123");
|
||||
val counterParty = createCounterparty(bankId.value, accountId2.value, "", true, counterpartyId.counterparty_id);
|
||||
@ -321,8 +321,8 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
val counterpartyId = CounterpartyIdJson("123");
|
||||
val counterParty = createCounterparty(bankId.value, accountId2.value, "", true, counterpartyId.counterparty_id);
|
||||
@ -373,15 +373,15 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
val bankId2 = testBank2.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
|
||||
val counterpartyId = CounterpartyIdJson("123");
|
||||
val counterParty = createCounterparty(bankId.value, accountId2.value, "", true, counterpartyId.counterparty_id);
|
||||
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -446,8 +446,8 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -650,8 +650,8 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
val counterpartyId = CounterpartyIdJson("123");
|
||||
val counterParty = createCounterparty(bankId.value, accountId2.value, "", true, counterpartyId.counterparty_id);
|
||||
@ -834,8 +834,8 @@ class TransactionRequestsCounterpartyTest extends ServerSetupWithTestData with D
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
|
||||
@ -41,11 +41,11 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc1")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
addEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
addEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -186,7 +186,7 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc1")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -316,7 +316,7 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc1")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -364,12 +364,12 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId2 = testBank2.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -432,7 +432,7 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -623,7 +623,7 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc1")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -803,7 +803,7 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1045,8 +1045,8 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1085,8 +1085,8 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1127,8 +1127,8 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1168,8 +1168,8 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
When("we try to make a payment with amount < 0")
|
||||
|
||||
@ -1210,7 +1210,7 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val testBank = createPaymentTestBank()
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
When("we try to make a payment to an account that doesn't exist")
|
||||
|
||||
@ -1245,8 +1245,8 @@ class TransactionRequestsFreeFormTest extends ServerSetupWithTestData with Defau
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "GBP")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "GBP")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
|
||||
@ -40,12 +40,12 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
addEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
addEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -186,8 +186,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -324,8 +324,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -373,12 +373,12 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId2 = testBank2.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -441,8 +441,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -646,8 +646,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -828,8 +828,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1083,8 +1083,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1123,8 +1123,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1165,8 +1165,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1206,8 +1206,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
When("we try to make a payment with amount < 0")
|
||||
|
||||
@ -1248,7 +1248,7 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val testBank = createPaymentTestBank()
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
When("we try to make a payment to an account that doesn't exist")
|
||||
|
||||
@ -1283,8 +1283,8 @@ class TransactionRequestsSandboxTanTest extends ServerSetupWithTestData with Def
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "GBP")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "GBP")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
|
||||
@ -63,11 +63,11 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
Then("Create the view and grant the owner view to use1")
|
||||
// ownerView is 'view = "owner"', we made it before
|
||||
val ownerView = createOwnerView(fromBankId, fromAccountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
Then("Add the CanCreateAnyTransactionRequest entitlement to user1")
|
||||
addEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
Then("We prepare for the request Json")
|
||||
@ -101,8 +101,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -157,12 +157,12 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId2 = testBank2.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
addEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
|
||||
Then("We add entitlement to user3")
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId2.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
@ -234,11 +234,11 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
Then("Create the view and grant the owner view to use1")
|
||||
// ownerView is 'view = "owner"', we made it before
|
||||
val ownerView = createOwnerView(fromBankId, fromAccountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
Then("Add the CanCreateAnyTransactionRequest entitlement to user1")
|
||||
addEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
Then("We prepare for the request Json")
|
||||
@ -288,11 +288,11 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
Then("Create the view and grant the owner view to use1")
|
||||
// ownerView is 'view = "owner"', we made it before
|
||||
val ownerView = createOwnerView(fromBankId, fromAccountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
Then("Add the CanCreateAnyTransactionRequest entitlement to user1")
|
||||
addEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
Then("We prepare for the request Json")
|
||||
@ -339,11 +339,11 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
Then("Create the view and grant the owner view to use1")
|
||||
// ownerView is 'view = "owner"', we made it before
|
||||
val ownerView = createOwnerView(fromBankId, fromAccountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
Then("Add the CanCreateAnyTransactionRequest entitlement to user1")
|
||||
addEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
Then("We prepare for the request Json")
|
||||
@ -391,11 +391,11 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
Then("Create the view and grant the owner view to use1")
|
||||
// ownerView is 'view = "owner"', we made it before
|
||||
val ownerView = createOwnerView(fromBankId, fromAccountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
Then("Add the CanCreateAnyTransactionRequest entitlement to user1")
|
||||
addEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
Then("We prepare for the request Json")
|
||||
@ -441,11 +441,11 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
Then("Create the view and grant the owner view to use1")
|
||||
// ownerView is 'view = "owner"', we made it before
|
||||
val ownerView = createOwnerView(fromBankId, fromAccountId)
|
||||
grantAccessToView(obpuser1, ownerView)
|
||||
grantAccessToView(authuser1, ownerView)
|
||||
|
||||
Then("Add the CanCreateAnyTransactionRequest entitlement to user1")
|
||||
addEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, obpuser1.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(fromBankId.value, authuser1.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
Then("We prepare for the request Json, but the amount is not a number")
|
||||
@ -494,8 +494,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
val accountRoutingAddress1 = AccountRoutingAddress("IBAN1");
|
||||
val accountRoutingAddress2 = AccountRoutingAddress("IBAN2");
|
||||
@ -520,8 +520,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
|
||||
|
||||
Then("We add entitlement to user3")
|
||||
addEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, obpuser3.userId, CanCreateAnyTransactionRequest)
|
||||
addEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
|
||||
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest)
|
||||
hasEntitlement should equal(true)
|
||||
|
||||
|
||||
@ -614,8 +614,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
val accountRoutingAddress1 = AccountRoutingAddress("IBAN1");
|
||||
val accountRoutingAddress2 = AccountRoutingAddress("IBAN2");
|
||||
@ -728,8 +728,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val amt = BigDecimal("10.00") // This is money going out. We want to transfer this away from the From account.
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
val accountRoutingAddress1 = AccountRoutingAddress("IBAN1");
|
||||
val accountRoutingAddress2 = AccountRoutingAddress("IBAN2");
|
||||
@ -919,8 +919,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1103,8 +1103,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
|
||||
val expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
|
||||
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, toCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, fromCurrency)
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, toCurrency)
|
||||
|
||||
def getFromAccount: BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1365,8 +1365,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1405,8 +1405,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1447,8 +1447,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
@ -1488,8 +1488,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
val acc2 = createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
|
||||
|
||||
When("we try to make a payment with amount < 0")
|
||||
|
||||
@ -1530,7 +1530,7 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val testBank = createPaymentTestBank()
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val acc1 = createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
val acc1 = createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
|
||||
When("we try to make a payment to an account that doesn't exist")
|
||||
|
||||
@ -1565,8 +1565,8 @@ class TransactionRequestsSepaTest extends ServerSetupWithTestData with DefaultUs
|
||||
val bankId = testBank.bankId
|
||||
val accountId1 = AccountId("__acc1")
|
||||
val accountId2 = AccountId("__acc2")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(obpuser1), bankId, accountId2, "GBP")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
|
||||
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "GBP")
|
||||
|
||||
def getFromAccount : BankAccount = {
|
||||
BankAccount(bankId, accountId1).getOrElse(fail("couldn't get from account"))
|
||||
|
||||
@ -9,7 +9,7 @@ import net.liftweb.mapper.By
|
||||
import net.liftweb.util.Props
|
||||
import org.scalatest.Tag
|
||||
import com.tesobe.model.CreateBankAccount
|
||||
import code.model.dataAccess.{APIUser, BankAccountCreationListener}
|
||||
import code.model.dataAccess.{ResourceUser, BankAccountCreationListener}
|
||||
import net.liftmodules.amqp.AMQPMessage
|
||||
import code.bankconnectors.Connector
|
||||
|
||||
@ -34,8 +34,8 @@ class BankAccountCreationListenerTest extends ServerSetup with DefaultConnectorT
|
||||
|
||||
//need to create the user for the bank accout creation process to work
|
||||
def getTestUser() =
|
||||
APIUser.find(By(APIUser.provider_, userProvider), By(APIUser.providerId, userId)).getOrElse {
|
||||
APIUser.create.
|
||||
ResourceUser.find(By(ResourceUser.provider_, userProvider), By(ResourceUser.providerId, userId)).getOrElse {
|
||||
ResourceUser.create.
|
||||
provider_(userProvider).
|
||||
providerId(userId).
|
||||
saveMe
|
||||
|
||||
@ -26,7 +26,7 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
def createCrmEvent1() = MappedCrmEvent.create
|
||||
.mCrmEventId("ASDFIUHUIUYFD444")
|
||||
.mBankId(testBankId1.value)
|
||||
.mUserId(obpuser1)
|
||||
.mUserId(authuser1)
|
||||
.mScheduledDate(new Date(12340000))
|
||||
.mActualDate(new Date(12340000))
|
||||
.mChannel("PHONE")
|
||||
@ -39,7 +39,7 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
def createCrmEvent2() = MappedCrmEvent.create
|
||||
.mCrmEventId("YYASDFYYGYHUIURR")
|
||||
.mBankId(testBankId2.value)
|
||||
.mUserId(obpuser2)
|
||||
.mUserId(authuser2)
|
||||
.mScheduledDate(new Date(12340000))
|
||||
.mActualDate(new Date(12340000))
|
||||
.mChannel("PHONE")
|
||||
@ -51,7 +51,7 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
def createCrmEvent3() = MappedCrmEvent.create
|
||||
.mCrmEventId("HY677SRDD")
|
||||
.mBankId(testBankId2.value)
|
||||
.mUserId(obpuser2)
|
||||
.mUserId(authuser2)
|
||||
.mScheduledDate(new Date(12340000))
|
||||
.mActualDate(new Date(12340000))
|
||||
.mChannel("PHONE")
|
||||
@ -64,10 +64,10 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
|
||||
scenario("No crm events exist for user and we try to get them") {
|
||||
Given("No MappedCrmEvent exists for a user (any bank)")
|
||||
MappedCrmEvent.find(By(MappedCrmEvent.mUserId, obpuser2)).isDefined should equal(false) // (Would find on any bank)
|
||||
MappedCrmEvent.find(By(MappedCrmEvent.mUserId, authuser2)).isDefined should equal(false) // (Would find on any bank)
|
||||
|
||||
When("We try to get it by bank and user")
|
||||
val foundOpt = MappedCrmEventProvider.getCrmEvents(testBankId1, obpuser2)
|
||||
val foundOpt = MappedCrmEventProvider.getCrmEvents(testBankId1, authuser2)
|
||||
val foundList = foundOpt.get
|
||||
|
||||
Then("We don't")
|
||||
@ -79,11 +79,11 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
Given("MappedCrmEvent exists for a user on a bank")
|
||||
MappedCrmEvent.find(
|
||||
By(MappedCrmEvent.mBankId, testBankId1.toString),
|
||||
By(MappedCrmEvent.mUserId, obpuser1.apiId.value)
|
||||
By(MappedCrmEvent.mUserId, authuser1.apiId.value)
|
||||
).isDefined should equal(true)
|
||||
|
||||
When("We try to get it by bank and user")
|
||||
val foundOpt = MappedCrmEventProvider.getCrmEvents(testBankId1, obpuser1)
|
||||
val foundOpt = MappedCrmEventProvider.getCrmEvents(testBankId1, authuser1)
|
||||
|
||||
Then("We do")
|
||||
foundOpt.isDefined should equal(true)
|
||||
@ -117,11 +117,11 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
Given("MappedCrmEvent exists for a user")
|
||||
MappedCrmEvent.find(
|
||||
By(MappedCrmEvent.mBankId, testBankId2.toString),
|
||||
By(MappedCrmEvent.mUserId, obpuser2.apiId.value)
|
||||
By(MappedCrmEvent.mUserId, authuser2.apiId.value)
|
||||
).isDefined should equal(true)
|
||||
|
||||
When("We try to get them")
|
||||
val foundOpt = MappedCrmEventProvider.getCrmEvents(testBankId2, obpuser2)
|
||||
val foundOpt = MappedCrmEventProvider.getCrmEvents(testBankId2, authuser2)
|
||||
|
||||
Then("We do")
|
||||
foundOpt.isDefined should equal(true)
|
||||
|
||||
@ -14,16 +14,16 @@ class MappedCustomerProviderTest extends ServerSetup with DefaultUsers {
|
||||
def createCustomer1() = MappedCustomer.create
|
||||
.mBank(testBankId.value).mEmail("bob@example.com").mFaceImageTime(new Date(12340000))
|
||||
.mFaceImageUrl("http://example.com/image.jpg").mLegalName("John Johnson")
|
||||
.mMobileNumber("12343434").mNumber("343").mUser(obpuser1).saveMe()
|
||||
.mMobileNumber("12343434").mNumber("343").mUser(authuser1).saveMe()
|
||||
|
||||
feature("Getting customer info") {
|
||||
|
||||
scenario("No customer info exists for user and we try to get it") {
|
||||
Given("No MappedCustomer exists for a user")
|
||||
MappedCustomer.find(By(MappedCustomer.mUser, obpuser2)).isDefined should equal(false)
|
||||
MappedCustomer.find(By(MappedCustomer.mUser, authuser2)).isDefined should equal(false)
|
||||
|
||||
When("We try to get it")
|
||||
val found = MappedCustomerProvider.getCustomer(testBankId, obpuser2)
|
||||
val found = MappedCustomerProvider.getCustomer(testBankId, authuser2)
|
||||
|
||||
Then("We don't")
|
||||
found.isDefined should equal(false)
|
||||
@ -32,10 +32,10 @@ class MappedCustomerProviderTest extends ServerSetup with DefaultUsers {
|
||||
scenario("Customer exists and we try to get it") {
|
||||
val customer1 = createCustomer1()
|
||||
Given("MappedCustomer exists for a user")
|
||||
MappedCustomer.find(By(MappedCustomer.mUser, obpuser1.apiId.value)).isDefined should equal(true)
|
||||
MappedCustomer.find(By(MappedCustomer.mUser, authuser1.apiId.value)).isDefined should equal(true)
|
||||
|
||||
When("We try to get it")
|
||||
val foundOpt = MappedCustomerProvider.getCustomer(testBankId, obpuser1)
|
||||
val foundOpt = MappedCustomerProvider.getCustomer(testBankId, authuser1)
|
||||
|
||||
Then("We do")
|
||||
foundOpt.isDefined should equal(true)
|
||||
@ -66,7 +66,7 @@ class MappedCustomerProviderTest extends ServerSetup with DefaultUsers {
|
||||
val bankId = BankId("a-bank")
|
||||
|
||||
Given("Customer info exists for a different bank")
|
||||
MappedCustomer.create.mNumber(customerNumber).mBank(bankId.value).mUser(obpuser1).saveMe()
|
||||
MappedCustomer.create.mNumber(customerNumber).mBank(bankId.value).mUser(authuser1).saveMe()
|
||||
MappedCustomer.count(By(MappedCustomer.mNumber, customerNumber),
|
||||
By(MappedCustomer.mBank, bankId.value)) should equal({
|
||||
MappedCustomer.count(By(MappedCustomer.mNumber, customerNumber))
|
||||
@ -84,7 +84,7 @@ class MappedCustomerProviderTest extends ServerSetup with DefaultUsers {
|
||||
val bankId = BankId("a-bank")
|
||||
|
||||
Given("Customer info exists for that bank")
|
||||
MappedCustomer.create.mNumber(customerNumber).mBank(bankId.value).mUser(obpuser1).saveMe()
|
||||
MappedCustomer.create.mNumber(customerNumber).mBank(bankId.value).mUser(authuser1).saveMe()
|
||||
MappedCustomer.count(By(MappedCustomer.mNumber, customerNumber),
|
||||
By(MappedCustomer.mBank, bankId.value)) should equal(1)
|
||||
|
||||
|
||||
@ -855,13 +855,13 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
|
||||
|
||||
getResponse(List(Extraction.decompose(user1))).code should equal(SUCCESS)
|
||||
|
||||
//TODO: we shouldn't reference OBPUser here as it is an implementation, but for now there
|
||||
//TODO: we shouldn't reference AuthUser here as it is an implementation, but for now there
|
||||
//is no way to check User (the trait) passwords
|
||||
val createdOBPUserBox = OBPUser.find(By(OBPUser.username, user1.user_name))
|
||||
createdOBPUserBox.isDefined should equal(true)
|
||||
val createdAuthUserBox = AuthUser.find(By(AuthUser.username, user1.user_name))
|
||||
createdAuthUserBox.isDefined should equal(true)
|
||||
|
||||
val createdOBPUser = createdOBPUserBox.get
|
||||
createdOBPUser.password.match_?(user1.password) should equal(true)
|
||||
val createdAuthUser = createdAuthUserBox.get
|
||||
createdAuthUser.password.match_?(user1.password) should equal(true)
|
||||
}
|
||||
|
||||
it should "require accounts to have non-empty ids" in {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user