Lift version upgraded to 3.1.0

This commit is contained in:
constantine2nd 2017-08-04 09:00:59 +02:00
parent e14ba467d8
commit a73e28f4fd
57 changed files with 296 additions and 286 deletions

View File

@ -16,7 +16,7 @@
<akka.version>2.5.1</akka.version>
<akka-streams-kafka.version>0.16</akka-streams-kafka.version>
<avro.version>1.6.4</avro.version>
<lift.version>2.6.3</lift.version>
<lift.version>3.1.0</lift.version>
<obp-ri.version>2016.11-RC6-SNAPSHOT</obp-ri.version>
<!-- Common plugin settings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -344,7 +344,7 @@ class Boot extends MdcLoggable {
}
//for XSS vulnerability, set X-Frame-Options header as DENY
LiftRules.listOfSupplimentalHeaders.default.set(List(("X-Frame-Options", "DENY")))
LiftRules.supplementalHeaders.default.set(List(("X-Frame-Options", "DENY")))
// Make a transaction span the whole HTTP request
S.addAround(DB.buildLoanWrapper)

View File

@ -85,7 +85,7 @@ object MapperAccountHolders extends MapperAccountHolders with AccountHolders wit
//accountHolders --> user
accountHolders.flatMap { accHolder =>
ResourceUser.find(By(ResourceUser.id, accHolder.user))
ResourceUser.find(By(ResourceUser.id, accHolder.user.get))
}.toSet
}

View File

@ -312,7 +312,7 @@ object OBPAPI1_0 extends RestHelper with MdcLoggable {
//log the API call
logAPICall
JsonResponse("banks" -> Bank.toJson(Bank.all.get))
JsonResponse("banks" -> Bank.toJson(Bank.all.getOrElse(Nil)))
}
})

View File

@ -114,7 +114,7 @@ object OBPAPI1_1 extends RestHelper with MdcLoggable {
if(httpCode==200)
{
logger.debug("OAuth header correct ")
Tokens.tokens.vend.getTokenByKey(tokenID.get) match {
Tokens.tokens.vend.getTokenByKey(tokenID.openOrThrowException("Attempted to open an empty Box.")) match {
case Full(token) => {
logger.debug("access token: "+ token + " found")
val user = User.findByResourceUserId(token.userForeignKey.get)
@ -305,7 +305,7 @@ object OBPAPI1_1 extends RestHelper with MdcLoggable {
)
}
JsonResponse("banks" -> Bank.all.get.map(bankToJson _ ))
JsonResponse("banks" -> Bank.all.getOrElse(Nil).map(bankToJson _ ))
}
})

View File

@ -121,7 +121,7 @@ object BankMockAPI extends RestHelper with MdcLoggable {
tkn.consumerId.foreign match {
case Full(app) => {
val applicationInfo = ApplicationInformation(
name = app.name,
name = app.name.get,
callbackURL = tkn.callbackURL.get
)
JsonResponse(applicationInfo, Nil, Nil, 200)

View File

@ -92,7 +92,7 @@ object OAuthHandshake extends RestHelper with MdcLoggable {
//remove the request token so the application could not exchange it
//again to get an other access token
Tokens.tokens.vend.getTokenByKey(oAuthParameters.get("oauth_token").get) match {
case Full(requestToken) => Tokens.tokens.vend.deleteToken(requestToken.id) match {
case Full(requestToken) => Tokens.tokens.vend.deleteToken(requestToken.id.get) match {
case true =>
case false => logger.warn("Request token: " + requestToken + " is not deleted. The application could exchange it again to get an other access token!")
}
@ -158,7 +158,7 @@ object OAuthHandshake extends RestHelper with MdcLoggable {
//return true if the authorization header has a duplicated parameter
def duplicatedParameters = {
var output=false
val authorizationParameters = S.request.get.header("Authorization").get.split(",")
val authorizationParameters = S.request.openOrThrowException("Attempted to open an empty Box.").header("Authorization").openOrThrowException("Attempted to open an empty Box.").split(",")
//count the iterations of a parameter in the authorization header
def countPram(parameterName : String, parametersArray :Array[String] )={
@ -268,7 +268,7 @@ object OAuthHandshake extends RestHelper with MdcLoggable {
val encodeBaseString = URLEncoder.encode(baseString,"UTF-8")
//get the key to sign
val consumer = Consumers.consumers.vend.getConsumerByConsumerKey(OAuthparameters.get("oauth_consumer_key").get).get
val consumer = Consumers.consumers.vend.getConsumerByConsumerKey(OAuthparameters.get("oauth_consumer_key").get).openOrThrowException("Attempted to open an empty Box.")
var secret= consumer.secret.toString
OAuthparameters.get("oauth_token") match {
@ -552,7 +552,7 @@ object OAuthHandshake extends RestHelper with MdcLoggable {
if(httpCode==200)
{
//logger.debug("OAuth header correct ")
Tokens.tokens.vend.getTokenByKey(tokenID.get) match {
Tokens.tokens.vend.getTokenByKey(tokenID.openOrThrowException("Attempted to open an empty Box.")) match {
case Full(token) => {
//logger.debug("access token: "+ token + " found")
val user = token.user

View File

@ -335,7 +335,7 @@ object APIUtil extends MdcLoggable {
def registeredApplication(consumerKey: String): Boolean = {
Consumers.consumers.vend.getConsumerByConsumerKey(consumerKey) match {
case Full(application) => application.isActive
case Full(application) => application.isActive.get
case _ => false
}
}
@ -387,9 +387,9 @@ object APIUtil extends MdcLoggable {
case _ => ""
}
//name of version where the call is implemented) -- S.request.get.view
val implementedInVersion = S.request.get.view
val implementedInVersion = S.request.openOrThrowException("Attempted to open an empty Box.").view
//(GET, POST etc.) --S.request.get.requestType.method
val verb = S.request.get.requestType.method
val verb = S.request.openOrThrowException("Attempted to open an empty Box.").requestType.method
val url = S.uriAndQueryString.getOrElse("")
val correlationId = getCorrelationId()
@ -586,10 +586,10 @@ object APIUtil extends MdcLoggable {
}
if(parsedDate.isDefined){
Full(parsedDate.get)
Full(parsedDate.openOrThrowException("Attempted to open an empty Box."))
}
else if(fallBackParsedDate.isDefined){
Full(fallBackParsedDate.get)
Full(fallBackParsedDate.openOrThrowException("Attempted to open an empty Box."))
}
else{
Failure(FilterDateFormatError)

View File

@ -112,7 +112,7 @@ object OBPAPI1_2 extends OBPRestHelper with MdcLoggable {
Extraction.decompose(banks)
}
Full(successJsonResponse(banksToJson(Bank.all.get)))
Full(successJsonResponse(banksToJson(Bank.all.getOrElse(Nil))))
}
})

View File

@ -574,10 +574,10 @@ object JSONFactory200{
case _ => ("", List())
}
new UserJSONV200(user_id = userId,
email = user.email,
username = stringOrNull(user.username),
provider_id = stringOrNull(user.provider),
provider = stringOrNull(user.provider),
email = user.email.get,
username = stringOrNull(user.username.get),
provider_id = stringOrNull(user.provider.get),
provider = stringOrNull(user.provider.get),
entitlements = createEntitlementJSONs(entitlements)
)
}

View File

@ -378,7 +378,7 @@ trait APIMethods210 {
s"From Account Currency is ${fromAccount.currency}, but Requested Transaction Currency is: ${transDetailsJson.value.currency}"}
amountOfMoneyJSON <- Full(AmountOfMoneyJsonV121(transDetailsJson.value.currency, transDetailsJson.value.amount))
isMapped: Boolean <- Full((Props.get("connector").get.toString).equalsIgnoreCase("mapped"))
isMapped: Boolean <- Full((Props.get("connector").openOrThrowException("Attempted to open an empty Box.").toString).equalsIgnoreCase("mapped"))
createdTransactionRequest <- transactionRequestType.value match {
case "SANDBOX_TAN" => {
@ -828,7 +828,7 @@ trait APIMethods210 {
consumers <- Some(Consumer.findAll())
} yield {
// Format the data as json
val json = createConsumerJSONs(consumers.sortWith(_.id < _.id))
val json = createConsumerJSONs(consumers.sortWith(_.id.get < _.id.get))
// Return
successJsonResponse(Extraction.decompose(json))
}
@ -867,10 +867,10 @@ trait APIMethods210 {
case false => booleanToBox(hasEntitlement("", u.userId, ApiRole.CanDisableConsumers),UserHasMissingRoles + CanDisableConsumers )
}
consumer <- Consumers.consumers.vend.getConsumerByPrimaryId(consumerId.toLong)
updatedConsumer <- Consumers.consumers.vend.updateConsumer(consumer.id, None, None, Some(putData.enabled), None, None, None, None, None, None) ?~! "Cannot update Consumer"
updatedConsumer <- Consumers.consumers.vend.updateConsumer(consumer.id.get, None, None, Some(putData.enabled), None, None, None, None, None, None) ?~! "Cannot update Consumer"
} yield {
// Format the data as json
val json = PutEnabledJSON(updatedConsumer.isActive)
val json = PutEnabledJSON(updatedConsumer.isActive.get)
// Return
successJsonResponse(Extraction.decompose(json))
}
@ -1608,9 +1608,9 @@ trait APIMethods210 {
consumerIdToLong <- tryo{consumerId.toLong} ?~! InvalidConsumerId
consumer <- Consumers.consumers.vend.getConsumerByPrimaryId(consumerIdToLong) ?~! {ConsumerNotFoundByConsumerId}
//only the developer that created the Consumer should be able to edit it
isLoginUserCreatedTheConsumer <- tryo(assert(consumer.createdByUserId.equals(user.get.userId)))?~! UserNoPermissionUpdateConsumer
isLoginUserCreatedTheConsumer <- tryo(assert(consumer.createdByUserId.equals(user.openOrThrowException("Attempted to open an empty Box.").userId)))?~! UserNoPermissionUpdateConsumer
//update the redirectURL and isactive (set to false when change redirectUrl) field in consumer table
updatedConsumer <- Consumers.consumers.vend.updateConsumer(consumer.id, None, None, Some(false), None, None, None, None, Some(postJson.redirect_url), None) ?~! UpdateConsumerError
updatedConsumer <- Consumers.consumers.vend.updateConsumer(consumer.id.get, None, None, Some(false), None, None, None, None, Some(postJson.redirect_url), None) ?~! UpdateConsumerError
} yield {
val json = JSONFactory210.createConsumerJSON(updatedConsumer)
createdJsonResponse(Extraction.decompose(json))
@ -1728,19 +1728,19 @@ trait APIMethods210 {
setFilterPart1 <- Full(parameters += OBPLimit(limit) +=OBPOffset(offset) += OBPFromDate(startDate)+= OBPToDate(endDate))
setFilterPart2 <- if (!consumerId.isEmpty)
Full(parameters += OBPConsumerId(consumerId.get))
Full(parameters += OBPConsumerId(consumerId.openOrThrowException("Attempted to open an empty Box.")))
else if (!userId.isEmpty)
Full(parameters += OBPUserId(userId.get))
Full(parameters += OBPUserId(userId.openOrThrowException("Attempted to open an empty Box.")))
else if (!url.isEmpty)
Full(parameters += OBPUrl(url.get))
Full(parameters += OBPUrl(url.openOrThrowException("Attempted to open an empty Box.")))
else if (!appName.isEmpty)
Full(parameters += OBPAppName(appName.get))
Full(parameters += OBPAppName(appName.openOrThrowException("Attempted to open an empty Box.")))
else if (!implementedInVersion.isEmpty)
Full(parameters += OBPImplementedInVersion(implementedInVersion.get))
Full(parameters += OBPImplementedInVersion(implementedInVersion.openOrThrowException("Attempted to open an empty Box.")))
else if (!implementedByPartialFunction.isEmpty)
Full(parameters += OBPImplementedByPartialFunction(implementedByPartialFunction.get))
Full(parameters += OBPImplementedByPartialFunction(implementedByPartialFunction.openOrThrowException("Attempted to open an empty Box.")))
else if (!verb.isEmpty)
Full(parameters += OBPVerb(verb.get))
Full(parameters += OBPVerb(verb.openOrThrowException("Attempted to open an empty Box.")))
else
Full(parameters)

View File

@ -546,16 +546,16 @@ object JSONFactory210{
case _ => null
}
ConsumerJSON(consumer_id=c.id,
app_name=c.name,
ConsumerJSON(consumer_id=c.id.get,
app_name=c.name.get,
app_type=c.appType.toString(),
description=c.description,
developer_email=c.developerEmail,
redirect_url=c.redirectURL,
created_by_user_id =c.createdByUserId,
description=c.description.get,
developer_email=c.developerEmail.get,
redirect_url=c.redirectURL.get,
created_by_user_id =c.createdByUserId.get,
created_by_user =resourceUserJSON,
enabled=c.isActive,
created=c.createdAt
enabled=c.isActive.get,
created=c.createdAt.get
)
}
def createConsumerJSONs(l : List[Consumer]): ConsumersJson = {

View File

@ -254,7 +254,7 @@ trait APIMethods220 {
isValidCurrencyISOCodeFrom <- tryo(assert(isValidCurrencyISOCode(fromCurrencyCode))) ?~! ErrorMessages.InvalidISOCurrencyCode
isValidCurrencyISOCodeTo <- tryo(assert(isValidCurrencyISOCode(toCurrencyCode))) ?~! ErrorMessages.InvalidISOCurrencyCode
u <- user ?~! UserNotLoggedIn
fxRate <- tryo(Connector.connector.vend.getCurrentFxRate(bankId, fromCurrencyCode, toCurrencyCode).get) ?~! ErrorMessages.FXCurrencyCodeCombinationsNotSupported
fxRate <- tryo(Connector.connector.vend.getCurrentFxRate(bankId, fromCurrencyCode, toCurrencyCode).openOrThrowException("Attempted to open an empty Box.")) ?~! ErrorMessages.FXCurrencyCodeCombinationsNotSupported
} yield {
val viewJSON = JSONFactory220.createFXRateJSON(fxRate)
successJsonResponse(Extraction.decompose(viewJSON))

View File

@ -524,18 +524,18 @@ object JSONFactory220{
case _ => null
}
ConsumerJson(consumer_id=c.id,
key=c.key,
secret=c.secret,
app_name=c.name,
ConsumerJson(consumer_id=c.id.get,
key=c.key.get,
secret=c.secret.get,
app_name=c.name.get,
app_type=c.appType.toString(),
description=c.description,
developer_email=c.developerEmail,
redirect_url=c.redirectURL,
created_by_user_id =c.createdByUserId,
description=c.description.get,
developer_email=c.developerEmail.get,
redirect_url=c.redirectURL.get,
created_by_user_id =c.createdByUserId.get,
created_by_user =resourceUserJSON,
enabled=c.isActive,
created=c.createdAt
enabled=c.isActive.get,
created=c.createdAt.get
)
}

View File

@ -598,7 +598,7 @@ trait Connector extends MdcLoggable{
//save transaction_id into database
saveTransactionRequestTransaction(transactionRequest.id, createdTransactionId.openOrThrowException("Exception: Couldn't create transaction"))
//update transaction_id filed for varibale 'transactionRequest'
transactionRequest = transactionRequest.copy(transaction_ids = createdTransactionId.get.value)
transactionRequest = transactionRequest.copy(transaction_ids = createdTransactionId.openOrThrowException("Attempted to open an empty Box.").value)
case TransactionRequests.STATUS_PENDING =>
transactionRequest = transactionRequest

View File

@ -115,7 +115,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
}
override def updateUserAccountViewsOld( user: ResourceUser ) = {
val accounts: List[KafkaInboundAccount] = getBanks.get.flatMap { bank => {
val accounts: List[KafkaInboundAccount] = getBanks.openOrThrowException("Attempted to open an empty Box.").flatMap { bank => {
val bankId = bank.bankId.value
logger.info(s"ObpJvm updateUserAccountViews for user.email ${user.email} user.name ${user.name} at bank ${bankId}")
for {

View File

@ -197,7 +197,7 @@ object KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with Mdc
)
override def updateUserAccountViewsOld( user: ResourceUser ) = {
val accounts: List[InboundAccount] = getBanks.get.flatMap { bank => {
val accounts: List[InboundAccount] = getBanks.openOrThrowException("Attempted to open an empty Box.").flatMap { bank => {
val bankId = bank.bankId.value
logger.info(s"ObpJvm updateUserAccountViews for user.email ${user.email} user.name ${user.name} at bank ${bankId}")
for {

View File

@ -289,11 +289,11 @@ private object LocalConnector extends Connector with MdcLoggable {
val envelope: Box[OBPEnvelope] = OBPEnvelope.envelopesFromJValue(transactionJS)
if(envelope.isDefined) {
val e : OBPEnvelope = envelope.get
val e : OBPEnvelope = envelope.openOrThrowException("Attempted to open an empty Box.")
logger.debug(s"Updating current balance for ${thisAccount.bankName} / ${thisAccount.accountNumber} / ${thisAccount.accountType}")
thisAccount.accountBalance(e.obp_transaction.get.details.get.new_balance.get.amount.get).save
thisAccount.accountBalance(e.obp_transaction.get.details.get.new_balance.get.amount.get).save(true)
logger.debug("Saving new transaction")
Full(e.save)
Full(e.save(true))
} else {
Failure("couldn't save transaction")
}
@ -429,7 +429,7 @@ private object LocalConnector extends Connector with MdcLoggable {
import net.liftweb.mongodb.BsonDSL._
Account.find(
(Account.accountNumber.name -> accountNumber)~
(Account.bankID.name -> hostedBank.id.is)
(Account.bankID.name -> hostedBank.id.get)
) match {
case Full(bankAccount) => {
logger.debug(s"account with number ${bankAccount.accountNumber} at bank ${hostedBank.bankId} already exists. No need to create a new one.")
@ -447,11 +447,11 @@ private object LocalConnector extends Connector with MdcLoggable {
.accountLabel(accountLabel)
.accountName("")
.permalink(accountId.value)
.bankID(hostedBank.id.is)
.bankID(hostedBank.id.get)
.accountCurrency(currency)
.accountIban("")
.accountLastUpdate(now)
.save
.save(true)
bankAccount
}
}
@ -491,7 +491,7 @@ private object LocalConnector extends Connector with MdcLoggable {
.alias(bankName)
.permalink(Helper.generatePermalink(bankName))
.national_identifier(bankNationalIdentifier)
.save
.save(true)
}
}
}
@ -625,7 +625,7 @@ private object LocalConnector extends Connector with MdcLoggable {
override def setBankAccountLastUpdated(bankNationalIdentifier: String, accountNumber : String, updateDate: Date) : Boolean = {
Account.find(
(Account.accountNumber.name -> accountNumber)~
(Account.nationalIdentifier.name -> bankNationalIdentifier)
(Account.nationalIdentifier -> bankNationalIdentifier)
) match {
case Full(acc) => acc.accountLastUpdate(updateDate).saveTheRecord().isDefined
case _ => logger.warn("can't set bank account.lastUpdated because the account was not found"); false

View File

@ -322,10 +322,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
val list = code.cards.PhysicalCard.physicalCardProvider.vend.getPhysicalCards(user)
for (l <- list) yield
new PhysicalCard(
bankCardNumber = l.mBankCardNumber,
nameOnCard = l.mNameOnCard,
issueNumber = l.mIssueNumber,
serialNumber = l.mSerialNumber,
bankCardNumber = l.mBankCardNumber.get,
nameOnCard = l.mNameOnCard.get,
issueNumber = l.mIssueNumber.get,
serialNumber = l.mSerialNumber.get,
validFrom = l.validFrom,
expires = l.expires,
enabled = l.enabled,
@ -346,10 +346,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
val list = code.cards.PhysicalCard.physicalCardProvider.vend.getPhysicalCardsForBank(bank, user)
for (l <- list) yield
new PhysicalCard(
bankCardNumber = l.mBankCardNumber,
nameOnCard = l.mNameOnCard,
issueNumber = l.mIssueNumber,
serialNumber = l.mSerialNumber,
bankCardNumber = l.mBankCardNumber.get,
nameOnCard = l.mNameOnCard.get,
issueNumber = l.mIssueNumber.get,
serialNumber = l.mSerialNumber.get,
validFrom = l.validFrom,
expires = l.expires,
enabled = l.enabled,
@ -407,10 +407,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
)
for (l <- list) yield
new PhysicalCard(
bankCardNumber = l.mBankCardNumber,
nameOnCard = l.mNameOnCard,
issueNumber = l.mIssueNumber,
serialNumber = l.mSerialNumber,
bankCardNumber = l.mBankCardNumber.get,
nameOnCard = l.mNameOnCard.get,
issueNumber = l.mIssueNumber.get,
serialNumber = l.mSerialNumber.get,
validFrom = l.validFrom,
expires = l.expires,
enabled = l.enabled,
@ -447,7 +447,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
// Is it better to pass these into this function ?
val fromTransAmt = -amount//from fromAccount balance should decrease
val toTransAmt = fx.convert(amount, rate.get)
val toTransAmt = fx.convert(amount, rate.openOrThrowException("Attempted to open an empty Box."))
// From
val sentTransactionId = saveTransaction(fromAccount, toAccount, toCounterparty, fromTransAmt, description, transactionRequestType, chargePolicy)
@ -478,13 +478,13 @@ object LocalMappedConnector extends Connector with MdcLoggable {
//update the balance of the fromAccount for which a transaction is being created
val newAccountBalance: Long = fromAccountUpdate.get.accountBalance.get + Helper.convertToSmallestCurrencyUnits(amount, fromAccountUpdate.get.currency)
fromAccountUpdate.get.accountBalance(newAccountBalance).save()
val newAccountBalance: Long = fromAccountUpdate.openOrThrowException("Attempted to open an empty Box.").accountBalance.get + Helper.convertToSmallestCurrencyUnits(amount, fromAccountUpdate.openOrThrowException("Attempted to open an empty Box.").currency)
fromAccountUpdate.openOrThrowException("Attempted to open an empty Box.").accountBalance(newAccountBalance).save()
val mappedTransaction = MappedTransaction.create
//No matter which type (SANDBOX_TAN,SEPA,FREE_FORM,COUNTERPARTYE), always filled the following nine fields.
.bank(fromAccountUpdate.get.bankId.value)
.account(fromAccountUpdate.get.accountId.value)
.bank(fromAccountUpdate.openOrThrowException("Attempted to open an empty Box.").bankId.value)
.account(fromAccountUpdate.openOrThrowException("Attempted to open an empty Box.").accountId.value)
.transactionType(transactionRequestType.value)
.amount(Helper.convertToSmallestCurrencyUnits(amount, currency))
.newAccountBalance(newAccountBalance)
@ -1350,7 +1350,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
)
//If it is empty, return the default value : "0.0000000" and set the BankAccount currency
case _ =>
val fromAccountCurrency: String = getBankAccount(bankId, accountId).get.currency
val fromAccountCurrency: String = getBankAccount(bankId, accountId).openOrThrowException("Attempted to open an empty Box.").currency
TransactionRequestTypeChargeMock(transactionRequestType.value, bankId.value, fromAccountCurrency, "0.00", "Warning! Default value!")
}

View File

@ -133,7 +133,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
override def updateUserAccountViewsOld( user: ResourceUser ) = {
val accounts = getBanks.get.flatMap { bank => {
val accounts = getBanks.openOrThrowException("Attempted to open an empty Box.").flatMap { bank => {
val bankId = bank.bankId.value
logger.debug(s"ObpJvm updateUserAccountViews for user.email ${user.email} user.name ${user.name} at bank ${bankId}")
val parameters = new JHashMap

View File

@ -109,7 +109,7 @@ class MappedPhysicalCard extends PhysicalCardTrait with LongKeyedMapper[MappedPh
def expires: Date = mExpires.get
def enabled: Boolean = mEnabled.get
def cancelled: Boolean = mCancelled.get
def onHotList: Boolean = mOnHotList
def onHotList: Boolean = mOnHotList.get
def technology: String = mTechnology.get
def networks: List[String] = mNetworks.get.split(",").toList
def allows: List[code.model.CardAction] = Option(mAllows.get) match {
@ -127,7 +127,7 @@ class MappedPhysicalCard extends PhysicalCardTrait with LongKeyedMapper[MappedPh
}
case _ => None
}
def pinResets: List[code.model.PinResetInfo] = mPinResets.map(a => PinResetInfo(a.mReplacementDate, PinResetReason.valueOf(a.mReplacementReason))).toList
def pinResets: List[code.model.PinResetInfo] = mPinResets.map(a => PinResetInfo(a.mReplacementDate.get, PinResetReason.valueOf(a.mReplacementReason.get))).toList
def collected: Option[CardCollectionInfo] = Option(mCollected.get) match {
case Some(x) => Some(CardCollectionInfo(x))
case _ => None

View File

@ -68,7 +68,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: ResourceUser = Users.users.vend.getResourceUserByResourceUserId(mUserId.get).get
override def user: ResourceUser = Users.users.vend.getResourceUserByResourceUserId(mUserId.get).openOrThrowException("Attempted to open an empty Box.")
override def customerName : String = mCustomerName.get
override def customerNumber : String = mCustomerNumber.get
}

View File

@ -37,11 +37,11 @@ class MappedThing extends Thing with LongKeyedMapper[MappedThing] with IdPK {
override def foo: Foo = new Foo {
override def fooSomething: String = fooSomething_
override def fooSomething: String = fooSomething_.get
}
override def bar: Bar = new Bar {
override def barSomething: String = barSomething_
override def barSomething: String = barSomething_.get
}

View File

@ -49,7 +49,7 @@ private class OBPComment private() extends MongoRecord[OBPComment] with ObjectId
def viewId = ViewId(forView.get)
def text = textField.get
def datePosted = date.get
def id_ = id.is.toString
def id_ = id.get.toString
def replyToID = replyTo.get
object userId extends LongField(this)

View File

@ -191,11 +191,11 @@ object MapperCounterparties extends Counterparties with MdcLoggable {
}
override def getPublicAlias(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.publicAlias)
getCounterpartyMetadata(counterPartyId).map(_.publicAlias.get)
}
override def getPrivateAlias(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.privateAlias)
getCounterpartyMetadata(counterPartyId).map(_.privateAlias.get)
}
override def getPhysicalLocation(counterPartyId : String): Box[GeoTag] = {

View File

@ -60,7 +60,7 @@ object MongoCounterparties extends Counterparties with MdcLoggable {
.originalPartyAccountId(originalPartyAccountId.value)
.accountNumber(otherAccountNumber)
.holder("")
.save
.save(true)
} else {
Metadata.createRecord.
@ -68,7 +68,7 @@ object MongoCounterparties extends Counterparties with MdcLoggable {
originalPartyAccountId(originalPartyAccountId.value).
holder(otherAccountHolder).
accountNumber(otherAccountNumber).
publicAlias(newPublicAliasName(originalPartyBankId, originalPartyAccountId)).save
publicAlias(newPublicAliasName(originalPartyBankId, originalPartyAccountId)).save(true)
}
}

View File

@ -37,13 +37,13 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
date(datePosted).
geoLongitude(longitude).
geoLatitude(latitude)
corporateLocation(newTag).save
corporateLocation(newTag).saveTheRecord()
true
}
def deleteCorporateLocationFn : Boolean = {
corporateLocation.clear
this.save
this.saveTheRecord()
true
}
@ -53,13 +53,13 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
date(datePosted).
geoLongitude(longitude).
geoLatitude(latitude)
physicalLocation(newTag).save
physicalLocation(newTag).saveTheRecord()
true
}
def deletePhysicalLocationFn : Boolean = {
physicalLocation.clear
this.save
this.saveTheRecord()
true
}
@ -83,13 +83,13 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
override def getMoreInfo = moreInfo.get
override def getImageURL: String = imageUrl.get
override val addPrivateAlias: (String) => Boolean = (alias => {
privateAlias(alias).save
privateAlias(alias).saveTheRecord()
//the save method does not return a Boolean to inform about the saving state,
//so we a true
true
})
override val addURL: (String) => Boolean = (text => {
url(text).save
url(text).saveTheRecord()
//the save method does not return a Boolean to inform about the saving state,
//so we a true
true
@ -97,26 +97,26 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
override val addPhysicalLocation: (UserId, Date, Double, Double) => Boolean = addPhysicalLocationFn _
override val addCorporateLocation: (UserId, Date, Double, Double) => Boolean = addCorporateLocationFn _
override val addMoreInfo: (String) => Boolean = (text => {
moreInfo(text).save
moreInfo(text).saveTheRecord()
//the save method does not return a Boolean to inform about the saving state,
//so we a true
true
})
override def getOpenCorporatesURL: String = openCorporatesUrl.get
override val addPublicAlias: (String) => Boolean = (alias => {
publicAlias(alias).save
publicAlias(alias).saveTheRecord()
//the save method does not return a Boolean to inform about the saving state,
//so we a true
true
})
override val addOpenCorporatesURL: (String) => Boolean = (text => {
openCorporatesUrl(text).save
openCorporatesUrl(text).saveTheRecord()
//the save method does not return a Boolean to inform about the saving state,
//so we a true
true
})
override val addImageURL: (String) => Boolean = (text => {
imageUrl(text).save
imageUrl(text).saveTheRecord()
//the save method does not return a Boolean to inform about the saving state,
//so we a true
true

View File

@ -53,7 +53,7 @@ private class OBPTag private() extends MongoRecord[OBPTag] with ObjectIdPk[OBPTa
object tag extends StringField(this, 255)
object date extends DateField(this)
def id_ = id.is.toString
def id_ = id.get.toString
def datePosted = date.get
def postedBy = User.findByResourceUserId(userId.get)
def viewId = ViewId(forView.get)

View File

@ -62,7 +62,7 @@ with ObjectIdPk[OBPTransactionImage] with TransactionImage {
object date extends DateField(this)
object url extends StringField(this, 500)
def id_ = id.is.toString
def id_ = id.get.toString
def datePosted = date.get
def postedBy = User.findByResourceUserId(userId.get)
def viewId = ViewId(forView.get)

View File

@ -89,7 +89,7 @@ private object MongoAPIMetric extends MongoAPIMetric with MongoMetaRecord[MongoA
implementedInVersion(implementedInVersion).
verb(verb).
correlationId(correlationId)
save
saveTheRecord()
}
// def getAllGroupedByUrl() : Map[String, List[APIMetric]] = {

View File

@ -306,7 +306,7 @@ object Consumer extends Consumer with MdcLoggable with LongKeyedMetaMapper[Consu
//obscure primary key to avoid revealing information about, e.g. how many consumers are registered
// (by incrementing ids until receiving a "log in first" page instead of 404)
val obfuscator = new KeyObfuscator()
override def obscurePrimaryKey(in: TheCrudType): String = obfuscator(Consumer, in.id)
override def obscurePrimaryKey(in: TheCrudType): String = obfuscator(Consumer, in.id.get)
//I've disabled this method as it only looked to be called by the original implementation of obscurePrimaryKey(in: TheCrudType)
//and I don't want it affecting anything else
override def obscurePrimaryKey(in: String): String = ""
@ -545,9 +545,9 @@ class Token extends LongKeyedMapper[Token]{
def user = Users.users.vend.getResourceUserByResourceUserId(userForeignKey.get)
//The the consumer from Token by consumerId
def consumer = Consumers.consumers.vend.getConsumerByPrimaryId(consumerId.get)
def isValid : Boolean = expirationDate.is after now
def isValid : Boolean = expirationDate.get after now
def gernerateVerifier : String =
if (verifier.isEmpty){
if (verifier.get.isEmpty){
def fiveRandomNumbers() : String = {
def r() = randomInt(9).toString //from zero to 9
(1 to 5).map(x => r()).foldLeft("")(_ + _)
@ -557,7 +557,7 @@ class Token extends LongKeyedMapper[Token]{
generatedVerifier
}
else
verifier.is
verifier.get
// in the case of user authentication in a third party application
// (see authenticationURL in class Consumer).
@ -569,14 +569,14 @@ class Token extends LongKeyedMapper[Token]{
}
def generateThirdPartyApplicationSecret: String = {
if(thirdPartyApplicationSecret isEmpty){
if(thirdPartyApplicationSecret.get isEmpty){
def r() = randomInt(9).toString //from zero to 9
val generatedSecret = (1 to 10).map(x => r()).foldLeft("")(_ + _)
thirdPartyApplicationSecret(generatedSecret).save
generatedSecret
}
else
thirdPartyApplicationSecret
thirdPartyApplicationSecret.get
}
}
object Token extends Token with LongKeyedMetaMapper[Token]{

View File

@ -43,6 +43,7 @@ import net.liftweb.http._
import net.liftweb.mapper._
import net.liftweb.util.Mailer.{BCC, From, Subject, To}
import net.liftweb.util._
import net.liftweb.util.Bindable
import scala.xml.{NodeSeq, Text}
import code.loginattempts.LoginAttempt
@ -167,7 +168,7 @@ class AuthUser extends MegaProtoUser[AuthUser] with Logger {
}
def createUnsavedResourceUser() : ResourceUser = {
val user = Users.users.vend.createUnsavedResourceUser(getProvider(), Some(username), Some(username), Some(email), None).get
val user = Users.users.vend.createUnsavedResourceUser(getProvider(), Some(username.get), Some(username.get), Some(email.get), None).openOrThrowException("Attempted to open an empty Box.")
user
}
@ -200,9 +201,9 @@ class AuthUser extends MegaProtoUser[AuthUser] with Logger {
info("user reference is not null. Trying to update the ResourceUser")
Users.users.vend.getResourceUserByResourceUserId(user.get).map{ u =>{
info("API User found ")
u.name_(username)
.email(email)
.providerId(username)
u.name_(username.get)
.email(email.get)
.providerId(username.get)
.save
}
}
@ -211,7 +212,7 @@ class AuthUser extends MegaProtoUser[AuthUser] with Logger {
}
override def delete_!(): Boolean = {
user.obj.map(u => Users.users.vend.deleteResourceUser(u.id))
user.obj.map(u => Users.users.vend.deleteResourceUser(u.id.get))
super.delete_!
}
@ -288,7 +289,7 @@ import net.liftweb.util.Helpers._
for {
resourceUser <- if (AuthUser.currentUser.isDefined)
//AuthUser.currentUser.get.user.foreign // this will be issue when the resource user is in remote side
Users.users.vend.getUserByUserName(AuthUser.currentUser.get.username)
Users.users.vend.getUserByUserName(AuthUser.currentUser.openOrThrowException("Attempted to open an empty Box.").username.get)
else if (hasDirectLoginHeader)
DirectLogin.getUser
else if (hasAnOAuthHeader) {
@ -381,9 +382,11 @@ import net.liftweb.util.Helpers._
}
override def lostPassword = {
bind("user", lostPasswordXhtml,
"email" -> SHtml.text("", sendPasswordReset _),
"submit" -> lostPasswordSubmitButton(S.?("submit")))
val bind =
".email" #> SHtml.text("", sendPasswordReset _) &
"type=submit" #> lostPasswordSubmitButton(S.?("submit"))
bind(lostPasswordXhtml)
}
//override def def passwordResetMailBody(user: TheUserType, resetLink: String): Elem = { }
@ -480,7 +483,7 @@ import net.liftweb.util.Helpers._
{
// We logged in correctly, so reset badLoginAttempts counter (if it exists)
LoginAttempt.resetBadLoginAttempts(username)
Full(user.user) // Return the user.
Full(user.user.get) // Return the user.
}
// User is unlocked AND password is bad
else if (
@ -512,7 +515,7 @@ import net.liftweb.util.Helpers._
val userId = for { kafkaUser <- getUserFromConnector(username, password)
kafkaUserId <- tryo{kafkaUser.user} } yield {
LoginAttempt.resetBadLoginAttempts(username)
kafkaUserId.toLong
kafkaUserId.get
}
userId match {
case Full(l:Long) => Full(l)
@ -525,7 +528,7 @@ import net.liftweb.util.Helpers._
val userId = for { obpjvmUser <- getUserFromConnector(username, password)
obpjvmUserId <- tryo{obpjvmUser.user} } yield {
LoginAttempt.resetBadLoginAttempts(username)
obpjvmUserId.toLong
obpjvmUserId.get
}
userId match {
case Full(l:Long) => Full(l)
@ -676,7 +679,7 @@ import net.liftweb.util.Helpers._
}
//This method is used for connector = kafka* || obpjvm*
//It will update the views and createAccountHolder ....
registeredUserHelper(user.username)
registeredUserHelper(user.username.get)
//Check the internal redirect, in case for open redirect issue.
// variable redir is from loginRedirect, it is set-up in OAuthAuthorisation.scala as following code:
// val currentUrl = S.uriAndQueryString.getOrElse("/")
@ -744,7 +747,7 @@ import net.liftweb.util.Helpers._
info(ErrorMessages.InvalidInternalRedirectUrl + loginRedirect.get)
}
case _ =>
LoginAttempt.incrementBadLoginAttempts(username)
LoginAttempt.incrementBadLoginAttempts(username.get)
Empty
}
@ -765,8 +768,9 @@ import net.liftweb.util.Helpers._
scala.xml.XML.loadString(loginSubmitButton(S.?("Login"), loginAction _).toString().replace("type=\"submit\"","class=\"submit\" type=\"submit\""))
}
bind("user", loginXhtml,
"submit" -> insertSubmitButton)
val bind =
"submit" #> insertSubmitButton
bind(loginXhtml)
}
@ -823,7 +827,7 @@ import net.liftweb.util.Helpers._
*/
def updateUserAccountViews(user: ResourceUser): Unit = {
//get all accounts from Kafka
val accounts = Connector.connector.vend.getBankAccounts(user.name).get
val accounts = Connector.connector.vend.getBankAccounts(user.name).openOrThrowException("Attempted to open an empty Box.")
debug(s"-->AuthUser.updateUserAccountViews.accounts : ${accounts} ")
for {
@ -884,9 +888,10 @@ import net.liftweb.util.Helpers._
}
}
def innerSignup = bind("user",
signupXhtml(theUser),
"submit" -> signupSubmitButton(S.?("sign.up"), testSignup _))
//TODO not supported in lift3, find another way
def innerSignup = //bind("user",
signupXhtml(theUser)//,
// "submit" -> signupSubmitButton(S.?("sign.up"), testSignup _))
innerSignup
}

View File

@ -33,6 +33,7 @@ package code.model.dataAccess
import code.metadata.narrative.OBPNarrativeInit
import code.metadata.wheretags.OBPWhereTagInit
import com.mongodb.MongoClient
import net.liftweb.util.ConnectionIdentifier
object AdminDb extends ConnectionIdentifier {
@ -55,8 +56,8 @@ object MongoConfig {
case _ => "OBP006"
}
MongoDB.defineDb(DefaultConnectionIdentifier, new Mongo(srvr), Props.get("mongo.dbName", defaultDatabase))
MongoDB.defineDb(AdminDb, new Mongo(srvr), "admin")
MongoDB.defineDb(DefaultConnectionIdentifier, new MongoClient(srvr), Props.get("mongo.dbName", defaultDatabase))
MongoDB.defineDb(AdminDb, new MongoClient(srvr), "admin")
HostedBank.init

View File

@ -34,7 +34,7 @@ object CreateTestAccountForm{
}
}
val banks = Connector.connector.vend.getBanks.get
val banks = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
val bankOptions = banks.map{b =>
val id = b.bankId.value
(id, id)

View File

@ -90,34 +90,34 @@ object OAuthAuthorisation {
if (AuthUser.loggedIn_? && shouldNotLogUserOut()) {
var verifier = ""
// if the user is logged in and no verifier have been generated
if (appToken.verifier.isEmpty) {
val randomVerifier = Tokens.tokens.vend.gernerateVerifier(appToken.id)
if (appToken.verifier.get.isEmpty) {
val randomVerifier = Tokens.tokens.vend.gernerateVerifier(appToken.id.get)
//the user is logged in so we have the current user
val authUser = AuthUser.currentUser.get
val authUser = AuthUser.currentUser.openOrThrowException("Attempted to open an empty Box.")
//link the token with the concrete API User
val saved = Users.users.vend.getResourceUserByResourceUserId(authUser.user.get).map {
u => {
//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"
Tokens.tokens.vend.updateToken(appToken.id, u.id.get)
Tokens.tokens.vend.updateToken(appToken.id.get, u.id.get)
}
}
if (saved.getOrElse(false))
verifier = randomVerifier
} else
verifier = appToken.verifier
verifier = appToken.verifier.get
// show the verifier if the application does not support
// redirection
if (appToken.callbackURL.is == "oob")
if (appToken.callbackURL.get == "oob")
"#verifier *" #> verifier &
ErrorMessageSel #> "" &
"#account" #> ""
else {
//send the user to another obp page that handles the redirect
val oauthQueryParams: List[(String, String)] = ("oauth_token", unencodedTokenParam) ::("oauth_verifier", verifier) :: Nil
val applicationRedirectionUrl = appendParams(appToken.callbackURL, oauthQueryParams)
val applicationRedirectionUrl = appendParams(appToken.callbackURL.get, oauthQueryParams)
val encodedApplicationRedirectionUrl = urlEncode(applicationRedirectionUrl)
val redirectionUrl = Props.get("hostname", "") + OAuthWorkedThanks.menu.loc.calcDefaultHref
val redirectionParam = List(("redirectUrl", encodedApplicationRedirectionUrl))
@ -139,7 +139,7 @@ object OAuthAuthorisation {
//if login fails, just reload the page with the login form visible
AuthUser.failedLoginRedirect.set(Full(Helpers.appendParams(currentUrl, List((FailedLoginParam, "true")))))
//the user is not logged in so we show a login form
Consumers.consumers.vend.getConsumerByPrimaryId(appToken.consumerId) match {
Consumers.consumers.vend.getConsumerByPrimaryId(appToken.consumerId.get) match {
case Full(consumer) => {
hideFailedLoginMessageIfNeeded &
"#applicationName" #> consumer.name &

View File

@ -232,14 +232,14 @@ class MappedTransactionRequest extends LongKeyedMapper[MappedTransactionRequest]
)
val t_challenge = TransactionRequestChallenge (
id = mChallenge_Id,
allowed_attempts = mChallenge_AllowedAttempts,
challenge_type = mChallenge_ChallengeType
id = mChallenge_Id.get,
allowed_attempts = mChallenge_AllowedAttempts.get,
challenge_type = mChallenge_ChallengeType.get
)
val t_charge = TransactionRequestCharge (
summary = mCharge_Summary,
value = AmountOfMoney(currency = mCharge_Currency, amount = mCharge_Amount)
summary = mCharge_Summary.get,
value = AmountOfMoney(currency = mCharge_Currency.get, amount = mCharge_Amount.get)
)
@ -261,7 +261,7 @@ class MappedTransactionRequest extends LongKeyedMapper[MappedTransactionRequest]
end_date = mEndDate.get,
challenge = t_challenge,
charge = t_charge,
charge_policy =mcharge_Policy,
charge_policy =mcharge_Policy.get,
counterparty_id = CounterpartyId(mCounterpartyId.get),
name = mName.get,
this_bank_id = BankId(mThisBankId.get),

View File

@ -95,13 +95,13 @@ class MappedTransactionType extends LongKeyedMapper[MappedTransactionType] with
}
def updateAllFields(mappedTransactionType: MappedTransactionType): Box[MappedTransactionType] = {
mTransactionTypeId.set(mappedTransactionType.mTransactionTypeId)
mBankId.set(mappedTransactionType.mBankId)
mShortCode.set(mappedTransactionType.mShortCode)
mSummary.set(mappedTransactionType.mSummary)
mDescription.set(mappedTransactionType.mDescription)
mCustomerFee_Currency.set(mappedTransactionType.mCustomerFee_Currency)
mCustomerFee_Amount.set(mappedTransactionType.mCustomerFee_Amount)
mTransactionTypeId.set(mappedTransactionType.mTransactionTypeId.get)
mBankId.set(mappedTransactionType.mBankId.get)
mShortCode.set(mappedTransactionType.mShortCode.get)
mSummary.set(mappedTransactionType.mSummary.get)
mDescription.set(mappedTransactionType.mDescription.get)
mCustomerFee_Currency.set(mappedTransactionType.mCustomerFee_Currency.get)
mCustomerFee_Amount.set(mappedTransactionType.mCustomerFee_Amount.get)
Some(this)
}
}

View File

@ -29,7 +29,7 @@ object MappedUserCustomerLinkProvider extends UserCustomerLinkProvider {
override def getUserCustomerLinkByUserId(userId: String): List[UserCustomerLink] = {
MappedUserCustomerLink.findAll(
By(MappedUserCustomerLink.mUserId, userId)).sortWith(_.id < _.id)
By(MappedUserCustomerLink.mUserId, userId)).sortWith(_.id.get < _.id.get)
}
override def getUserCustomerLink(userId : String, customerId: String): Box[UserCustomerLink] = {
@ -63,7 +63,7 @@ class MappedUserCustomerLink extends UserCustomerLink with LongKeyedMapper[Mappe
override def customerId: String = mCustomerId.get // id.toString
override def userId: String = mUserId.get
override def dateInserted: Date = mDateInserted.get
override def isActive: Boolean = mIsActive
override def isActive: Boolean = mIsActive.get
}
object MappedUserCustomerLink extends MappedUserCustomerLink with LongKeyedMetaMapper[MappedUserCustomerLink] {

View File

@ -206,7 +206,7 @@ object MapperViews extends Views with MdcLoggable {
def view(viewId : ViewId, account: BankIdAccountId) : Box[View] = {
val view = ViewImpl.find(ViewIdBankIdAccountId(viewId, account.bankId, account.accountId))
if(view.isDefined && view.get.isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
if(view.isDefined && view.openOrThrowException("Attempted to open an empty Box.").isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
view
}
@ -214,7 +214,7 @@ object MapperViews extends Views with MdcLoggable {
def view(viewUID : ViewIdBankIdAccountId) : Box[View] = {
val view=ViewImpl.find(viewUID)
if(view.isDefined && view.get.isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
if(view.isDefined && view.openOrThrowException("Attempted to open an empty Box.").isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
view
}
@ -672,7 +672,7 @@ object MapperViews extends Views with MdcLoggable {
By(ViewImpl.accountPermalink, accountId.value),
By(ViewImpl.name_, name)
)
if(res.isDefined && res.get.isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
if(res.isDefined && res.openOrThrowException("Attempted to open an empty Box.").isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
res
}
@ -683,7 +683,7 @@ object MapperViews extends Views with MdcLoggable {
)
var privilegesDeleted = true
views.map (x => {
privilegesDeleted &&= ViewPrivileges.bulkDelete_!!(By(ViewPrivileges.view, x.id_))
privilegesDeleted &&= ViewPrivileges.bulkDelete_!!(By(ViewPrivileges.view, x.id_.get))
} )
privilegesDeleted
}

View File

@ -39,7 +39,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
saveMe
if (Consumers.consumers.vend.getConsumerByConsumerKey(KEY).isEmpty)
Consumers.consumers.vend.createConsumer(Some(KEY), Some(SECRET), Some(true), Some("test application"), None, None, None, None, None).get
Consumers.consumers.vend.createConsumer(Some(KEY), Some(SECRET), Some(true), Some("test application"), None, None, None, None, None).openOrThrowException("Attempted to open an empty Box.")
if (AuthUser.find(By(AuthUser.username, USERNAME_DISABLED)).isEmpty)
@ -53,7 +53,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
saveMe
if (Consumers.consumers.vend.getConsumerByConsumerKey(KEY_DISABLED).isEmpty)
Consumers.consumers.vend.createConsumer(Some(KEY_DISABLED), Some(SECRET_DISABLED), Some(false), Some("test application disabled"), None, None, None, None, None).get
Consumers.consumers.vend.createConsumer(Some(KEY_DISABLED), Some(SECRET_DISABLED), Some(false), Some("test application disabled"), None, None, None, None, None).openOrThrowException("Attempted to open an empty Box.")
}
val accessControlOriginHeader = ("Access-Control-Allow-Origin", "*")

View File

@ -57,12 +57,12 @@ class gateWayloginTest extends FeatureSpec
feature("Unit Tests for two getCbsToken and getErrors: ") {
scenario("test the getErrors") {
val reply: List[String] = GatewayLogin.getErrors(compact(render(Extraction.decompose(fakeResultFromAdapter.get))))
val reply: List[String] = GatewayLogin.getErrors(compact(render(Extraction.decompose(fakeResultFromAdapter.openOrThrowException("Attempted to open an empty Box.")))))
reply.forall(_.equalsIgnoreCase("")) should equal(true)
}
scenario("test the getCbsToken") {
val reply: List[String] = GatewayLogin.getCbsTokens(compact(render(Extraction.decompose(fakeResultFromAdapter.get))))
val reply: List[String] = GatewayLogin.getCbsTokens(compact(render(Extraction.decompose(fakeResultFromAdapter.openOrThrowException("Attempted to open an empty Box.")))))
reply(0) should equal("cbsToken1")
reply(1) should equal("cbsToken2")

View File

@ -68,9 +68,9 @@ class OAuthTest extends ServerSetup {
val accountValidationError = ResourceBundle.getBundle(LiftRules.liftCoreResourceName).getObject("account.validation.error").toString
lazy val testConsumer = Consumers.consumers.vend.createConsumer(Some(randomString(40).toLowerCase), Some(randomString(40).toLowerCase), Some(true), Some("test application"), None, None, None, Some(selfCallback), None).get
lazy val testConsumer = Consumers.consumers.vend.createConsumer(Some(randomString(40).toLowerCase), Some(randomString(40).toLowerCase), Some(true), Some("test application"), None, None, None, Some(selfCallback), None).openOrThrowException("Attempted to open an empty Box.")
lazy val disabledTestConsumer = Consumers.consumers.vend.createConsumer(Some(randomString(40).toLowerCase), Some(randomString(40).toLowerCase), Some(false), Some("test application disabled"), None, None, None, Some(selfCallback), None).get
lazy val disabledTestConsumer = Consumers.consumers.vend.createConsumer(Some(randomString(40).toLowerCase), Some(randomString(40).toLowerCase), Some(false), Some("test application disabled"), None, None, None, Some(selfCallback), None).openOrThrowException("Attempted to open an empty Box.")
lazy val user1Password = randomString(10)
lazy val user1 =
@ -94,8 +94,8 @@ class OAuthTest extends ServerSetup {
lastName(randomString(10)).
saveMe
lazy val consumer = new Consumer (testConsumer.key,testConsumer.secret)
lazy val disabledConsumer = new Consumer (disabledTestConsumer.key, disabledTestConsumer.secret)
lazy val consumer = new Consumer (testConsumer.key.get,testConsumer.secret.get)
lazy val disabledConsumer = new Consumer (disabledTestConsumer.key.get, disabledTestConsumer.secret.get)
lazy val notRegisteredConsumer = new Consumer (randomString(5),randomString(5))
private def getAPIResponse(req : Req) : OAuthResponse = {
@ -239,7 +239,7 @@ class OAuthTest extends ServerSetup {
When("the browser is launched to login")
val verifier = getVerifier(requestToken.value, user1.username.get, user1Password)
Then("we should get a verifier")
verifier.get.nonEmpty should equal (true)
verifier.openOrThrowException("Attempted to open an empty Box.").nonEmpty should equal (true)
}
scenario("the user login and is asked to enter the verifier manually", Verifier, Oauth){
Given("we will use a valid request token")
@ -272,7 +272,7 @@ class OAuthTest extends ServerSetup {
val requestToken = extractToken(reply.body)
val verifier = getVerifier(requestToken.value, user1.username.get, user1Password)
When("when we ask for an access token")
val accessToken = getAccessToken(consumer, requestToken, verifier.get)
val accessToken = getAccessToken(consumer, requestToken, verifier.openOrThrowException("Attempted to open an empty Box."))
Then("we should get an access token")
extractToken(accessToken.body)
}
@ -282,7 +282,7 @@ class OAuthTest extends ServerSetup {
val requestToken = extractToken(reply.body)
val verifier = getVerifier(requestToken.value, user1.username.get, user1Password)
When("when we ask for an access token")
val accessToken = getAccessToken(consumer, requestToken, verifier.get)
val accessToken = getAccessToken(consumer, requestToken, verifier.openOrThrowException("Attempted to open an empty Box."))
Then("we should get an access token")
extractToken(accessToken.body)
}
@ -302,7 +302,7 @@ class OAuthTest extends ServerSetup {
val verifier = getVerifier(requestToken.value, user1.username.get, user1Password)
When("when we ask for an access token with a request token")
val randomRequestToken = Token(randomString(5), randomString(5))
val accessTokenReply = getAccessToken(consumer, randomRequestToken, verifier.get)
val accessTokenReply = getAccessToken(consumer, randomRequestToken, verifier.openOrThrowException("Attempted to open an empty Box."))
Then("we should get a 401")
accessTokenReply.code should equal (401)
}

View File

@ -1396,7 +1396,7 @@ class API1_2Test extends User1AllPrivileges with DefaultUsers {
val bankId = randomBank
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
val viewId = ViewId("owner")
val view = Views.views.vend.view(ViewIdBankIdAccountId(viewId, BankId(bankId), AccountId(bankAccount.id))).get
val view = Views.views.vend.view(ViewIdBankIdAccountId(viewId, BankId(bankId), AccountId(bankAccount.id))).openOrThrowException("Attempted to open an empty Box.")
if(Views.views.vend.getOwners(view).toList.length == 0){
val userId = resourceUser2.idGivenByProvider
grantUserAccessToView(bankId, bankAccount.id, userId, viewId.value, user1)

View File

@ -655,7 +655,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
accounts.foldLeft(0)((accumulator, account) => {
//TODO: might be nice to avoid direct use of the connector, but if we use an api call we need to do
//it with the correct account owners, and be sure that we don't even run into pagination problems
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).get.size
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).openOrThrowException("Attempted to open an empty Box.").size
})
}
@ -1956,7 +1956,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
val bankId = randomBank
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
val viewId = ViewId("owner")
val view = Views.views.vend.view(ViewIdBankIdAccountId(viewId, BankId(bankId), AccountId(bankAccount.id))).get
val view = Views.views.vend.view(ViewIdBankIdAccountId(viewId, BankId(bankId), AccountId(bankAccount.id))).openOrThrowException("Attempted to open an empty Box.")
if(Views.views.vend.getOwners(view).toList.length == 0){
val userId = resourceUser2.idGivenByProvider
grantUserAccessToView(bankId, bankAccount.id, userId, viewId.value, user1)
@ -2000,7 +2000,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
reply.code should equal (400)
And("The account holder should still have access to the owner view")
val view = Views.views.vend.view(ViewIdBankIdAccountId(ownerViewId, BankId(bankId), AccountId(bankAccount.id))).get
val view = Views.views.vend.view(ViewIdBankIdAccountId(ownerViewId, BankId(bankId), AccountId(bankAccount.id))).openOrThrowException("Attempted to open an empty Box.")
Views.views.vend.getOwners(view).toList should contain (resourceUser3)
}
@ -2082,7 +2082,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
val bankId = randomBank
val bankAccount : AccountJSON = randomPrivateAccount(bankId)
val viewId = ViewId("owner")
val view = Views.views.vend.view(ViewIdBankIdAccountId(viewId, BankId(bankId), AccountId(bankAccount.id))).get
val view = Views.views.vend.view(ViewIdBankIdAccountId(viewId, BankId(bankId), AccountId(bankAccount.id))).openOrThrowException("Attempted to open an empty Box.")
val userId = resourceUser1.idGivenByProvider
Views.views.vend.getOwners(view).toList.length should equal(1)
@ -2116,7 +2116,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
reply.code should equal (400)
And("The user should not have had his access revoked")
val view = Views.views.vend.view(ViewIdBankIdAccountId(ViewId("owner"), BankId(bankId), AccountId(bankAccount.id))).get
val view = Views.views.vend.view(ViewIdBankIdAccountId(ViewId("owner"), BankId(bankId), AccountId(bankAccount.id))).openOrThrowException("Attempted to open an empty Box.")
Views.views.vend.getOwners(view).toList should contain (resourceUser3)
}
}

View File

@ -23,7 +23,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
accounts.foldLeft(0)((accumulator, account) => {
//TODO: might be nice to avoid direct use of the connector, but if we use an api call we need to do
//it with the correct account owners, and be sure that we don't even run into pagination problems
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).get.size
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).openOrThrowException("Attempted to open an empty Box.").size
})
}

View File

@ -26,7 +26,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
accounts.foldLeft(0)((accumulator, account) => {
//TODO: might be nice to avoid direct use of the connector, but if we use an api call we need to do
//it with the correct account owners, and be sure that we don't even run into pagination problems
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).get.size
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).openOrThrowException("Attempted to open an empty Box.").size
})
}

View File

@ -24,7 +24,7 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
def transactionCount(accounts: BankAccount*): Int = {
accounts.foldLeft(0)((accumulator, account) => {
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).get.size
accumulator + Connector.connector.vend.getTransactions(account.bankId, account.accountId).openOrThrowException("Attempted to open an empty Box.").size
})
}
@ -70,7 +70,11 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
var beforeToBalance = toAccount.balance
//we expected transfer amount
var expectedAmtTo = amt * fx.exchangeRate(fromCurrency, toCurrency).get
val zero: BigDecimal = BigDecimal(0)
var expectedAmtTo = fx.exchangeRate(fromCurrency, toCurrency) match {
case Some(exchangeRate) => amt * exchangeRate
case _ => amt * BigDecimal("0")
}
// We debit the From
var expectedFromNewBalance = beforeFromBalance - amt
// We credit the To

View File

@ -35,7 +35,7 @@ class BankAccountCreationListenerTest extends ServerSetup with DefaultConnectorT
//need to create the user for the bank accout creation process to work
def getTestUser() =
Users.users.vend.getUserByProviderId(userProvider, userId).getOrElse {
Users.users.vend.createResourceUser(userProvider, Some(userId), None, None, None).get
Users.users.vend.createResourceUser(userProvider, Some(userId), None, None, None).openOrThrowException("Attempted to open an empty Box.")
}
val expectedBankId = "quxbank"
@ -88,7 +88,7 @@ class BankAccountCreationListenerTest extends ServerSetup with DefaultConnectorT
And("A bank should be created")
val createdBankBox = Connector.connector.vend.getBank(BankId(expectedBankId))
createdBankBox.isDefined should equal(true)
val createdBank = createdBankBox.get
val createdBank = createdBankBox.openOrThrowException("Attempted to open an empty Box.")
createdBank.nationalIdentifier should equal(bankIdentifier)
}

View File

@ -57,7 +57,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
val bankNationalIdentifier = "bank-identifier"
val bankName = "A Bank"
Given("A bank that does not exist")
Connector.connector.vend.getBanks.get.size should equal(0)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.").size should equal(0)
When("We create an account at that bank")
val (_, returnedAccount) = Connector.connector.vend.createBankAndAccount(
@ -67,7 +67,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
)
Then("A bank should now exist, with the correct parameters")
val allBanks = Connector.connector.vend.getBanks.get
val allBanks = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
allBanks.size should equal(1)
val newBank = allBanks(0)
newBank.fullName should equal(bankName)
@ -76,7 +76,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
And("An account should now exist, with the correct parameters")
val foundAccountBox = Connector.connector.vend.getBankAccount(newBank.bankId, returnedAccount.accountId)
foundAccountBox.isDefined should equal(true)
val foundAccount = foundAccountBox.get
val foundAccount = foundAccountBox.openOrThrowException("Attempted to open an empty Box.")
foundAccount.number should equal(accountNumber)
foundAccount.accountHolder should equal(accountHolderName)
@ -86,7 +86,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
val existingBank = createBank("some-bank")
Given("A bank that does exist")
val allBanksBefore = Connector.connector.vend.getBanks.get
val allBanksBefore = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
allBanksBefore.size should equal(1)
allBanksBefore(0).bankId should equal(existingBank.bankId)
@ -102,7 +102,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
)
Then("No new bank should be created")
val allBanksAfter = Connector.connector.vend.getBanks.get
val allBanksAfter = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
allBanksAfter.size should equal(1)
allBanksAfter(0).fullName should equal(existingBank.fullName)
allBanksAfter(0).nationalIdentifier should equal(existingBank.nationalIdentifier)
@ -110,7 +110,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
And("An account should now exist, with the correct parameters")
val foundAccountBox = Connector.connector.vend.getBankAccount(existingBank.bankId, returnedAccount.accountId)
foundAccountBox.isDefined should equal(true)
val foundAccount = foundAccountBox.get
val foundAccount = foundAccountBox.openOrThrowException("Attempted to open an empty Box.")
foundAccount.number should equal(accountNumber)
foundAccount.accountHolder should equal(accountHolderName)
@ -158,7 +158,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
Then("An account with the proper parameters should be created")
val createdAccBox = Connector.connector.vend.getBankAccount(bankId, accountId)
createdAccBox.isDefined should be(true)
val createdAcc = createdAccBox.get
val createdAcc = createdAccBox.openOrThrowException("Attempted to open an empty Box.")
createdAcc.bankId should equal(bankId)
createdAcc.accountId should equal(accountId)
@ -180,7 +180,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
Then("An account with the proper parameters should be created")
val createdAccBox = Connector.connector.vend.getBankAccount(bankId, accountId)
createdAccBox.isDefined should be(true)
val createdAcc = createdAccBox.get
val createdAcc = createdAccBox.openOrThrowException("Attempted to open an empty Box.")
createdAcc.bankId should equal(bankId)
createdAcc.accountId should equal(accountId)

View File

@ -148,7 +148,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
val f = defaultFixture()
Given("An account with no transactions")
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(0)
When("We try to import transactions without using a secret key")
@ -158,7 +158,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(400)
And("No transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(0)
}
@ -166,7 +166,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
val f = defaultFixture()
Given("An account with no transactions")
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(0)
When("We try to import transactions with the incorrect secret key")
@ -176,7 +176,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(401)
And("No transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(0)
}
@ -184,7 +184,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
val f = defaultFixture()
Given("An account with no transactions")
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(0)
When("We try to import transactions with the correct secret key")
@ -194,7 +194,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(200)
And("Transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(2)
And("The transactions should have the correct parameters")
@ -206,7 +206,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
And("The account should have its balance set to the 'new_balance' value of the most recently completed transaction")
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).get
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
account.balance.toString should equal(f.t2NewBalance) //t2 has a later completed date than t1
And("The account should have accountLastUpdate set to the current time")
@ -220,7 +220,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
def checkTransactionOkay(t : Transaction) = checkOkay(t, f.t1Value, f.t1NewBalance, f.t1StartDate, f.t1EndDate, f.dummyLabel)
Given("An account with no transactions")
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(0)
When("We try to import two identical transactions with the correct secret key")
@ -234,14 +234,14 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(200)
And("Transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(2)
And("The transactions should have the correct parameters")
tsAfter.foreach(checkTransactionOkay)
And("The account should have its balance set to the 'new_balance' value of the most recently completed transaction")
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).get
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
account.balance.toString should equal(f.t1NewBalance)
And("The account should have accountLastUpdate set to the current time")
@ -258,13 +258,13 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
Given("Two 'identical' existing transactions")
addTransactions(importJson, Some(secretKeyValue))
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(2)
tsBefore.foreach(checkTransactionOkay)
//remember lastUpdate time
var account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).get
var account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
val oldTime = if(account.lastUpdate != null) account.lastUpdate.getTime else 0
When("We try to add those transactions again")
@ -274,13 +274,13 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(200)
And("There should still only be two transactions")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(2)
tsAfter.foreach(checkTransactionOkay)
And("The account should have accountLastUpdate set to the current time (different from first insertion)")
account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).get
account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
val dt = (account.lastUpdate.getTime - oldTime)
dt > 0 should equal(true)
}
@ -295,7 +295,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
Given("Two 'identical' existing transactions")
addTransactions(initialImportJson, Some(secretKeyValue))
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(2)
checkTransactionOkay(tsBefore(0))
@ -308,7 +308,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(200)
And("There should now be 5 transactions")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(5)
tsAfter.foreach(checkTransactionOkay)
@ -330,7 +330,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
Given("Two 'identical' existing transactions at a different account")
addTransactions(t1F1ImportJson, Some(secretKeyValue))
val f1TsBefore = Connector.connector.vend.getTransactions(f1.account.bankId, f1.account.accountId).get
val f1TsBefore = Connector.connector.vend.getTransactions(f1.account.bankId, f1.account.accountId).openOrThrowException("Attempted to open an empty Box.")
f1TsBefore.size should equal(2)
f1TsBefore.foreach(checkF1TransactionOkay)
@ -338,11 +338,11 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
addTransactions(t1F2ImportJson, Some(secretKeyValue))
Then("There should be two transactions for each account")
val f1TsAfter = Connector.connector.vend.getTransactions(f1.account.bankId, f1.account.accountId).get
val f1TsAfter = Connector.connector.vend.getTransactions(f1.account.bankId, f1.account.accountId).openOrThrowException("Attempted to open an empty Box.")
f1TsAfter.size should equal(2)
f1TsAfter.foreach(checkF1TransactionOkay)
val f2Ts = Connector.connector.vend.getTransactions(f2.account.bankId, f2.account.accountId).get
val f2Ts = Connector.connector.vend.getTransactions(f2.account.bankId, f2.account.accountId).openOrThrowException("Attempted to open an empty Box.")
f2Ts.size should equal(2)
f2Ts.foreach(checkF2TransactionOkay)
@ -351,7 +351,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
scenario("Attempting to import transactions using an incorrect json format") {
val f = defaultFixture()
Given("An account with no transactions")
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsBefore = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsBefore.size should equal(0)
When("We try to import transactions with the correct secret key")
@ -361,7 +361,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
response.code should equal(200)
And("No transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).get
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId).openOrThrowException("Attempted to open an empty Box.")
tsAfter.size should equal(0)
}

View File

@ -151,7 +151,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundBankBox.isDefined should equal(true)
val foundBank = foundBankBox.get
val foundBank = foundBankBox.openOrThrowException("Attempted to open an empty Box.")
foundBank.bankId should equal(bankId)
foundBank.shortName should equal(bank.short_name)
@ -267,7 +267,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
val foundUserBox = Users.users.vend.getUserByProviderId(defaultProvider, user.user_name)
foundUserBox.isDefined should equal(true)
val foundUser = foundUserBox.get
val foundUser = foundUserBox.openOrThrowException("Attempted to open an empty Box.")
foundUser.provider should equal(defaultProvider)
foundUser.idGivenByProvider should equal(user.user_name)
@ -281,7 +281,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
val foundAccountBox = Connector.connector.vend.getBankAccount(bankId, accId)
foundAccountBox.isDefined should equal(true)
val foundAccount = foundAccountBox.get
val foundAccount = foundAccountBox.openOrThrowException("Attempted to open an empty Box.")
foundAccount.bankId should equal(bankId)
foundAccount.accountId should equal(accId)
@ -300,7 +300,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundAccount.publicViews.size should equal(0)
}
val owner = Users.users.vend.getUserByProviderId(defaultProvider, foundAccount.owners.toList.head.name).get
val owner = Users.users.vend.getUserByProviderId(defaultProvider, foundAccount.owners.toList.head.name).openOrThrowException("Attempted to open an empty Box.")
//there should be an owner view
val views = Views.views.vend.permittedViews(owner, BankIdAccountId(foundAccount.bankId, foundAccount.accountId))
val ownerView = views.find(v => v.viewId.value == "owner")
@ -318,7 +318,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransactionBox.isDefined should equal(true)
val foundTransaction = foundTransactionBox.get
val foundTransaction = foundTransactionBox.openOrThrowException("Attempted to open an empty Box.")
foundTransaction.id should equal(transactionId)
foundTransaction.bankId should equal(bankId)
@ -328,7 +328,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransaction.amount.toString should equal(transaction.details.value)
def toDate(dateString : String) : Date = {
DateParser.parse(dateString).get
DateParser.parse(dateString).openOrThrowException("Attempted to open an empty Box.")
}
foundTransaction.startDate.getTime should equal(toDate(transaction.details.posted).getTime)
@ -611,7 +611,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
response.code should equal(403)
//nothing should be created
Connector.connector.vend.getBanks.get should equal(Nil)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.") should equal(Nil)
}
it should "not allow data to be imported with an invalid secret token" in {
@ -623,13 +623,13 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
response.code should equal(403)
//nothing should be created
Connector.connector.vend.getBanks.get should equal(Nil)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.") should equal(Nil)
}
it should "require banks to have non-empty ids" in {
//no banks should exist initially
Connector.connector.vend.getBanks.get.size should equal(0)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.").size should equal(0)
val bank1Json = Extraction.decompose(bank1)
@ -643,13 +643,13 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
getResponse(bankWithoutId).code should equal(FAILED)
//no banks should have been created
Connector.connector.vend.getBanks.get.size should equal(0)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.").size should equal(0)
val bankWithEmptyId = addIdField(bankWithoutId, "")
getResponse(bankWithEmptyId).code should equal(FAILED)
//no banks should have been created
Connector.connector.vend.getBanks.get.size should equal(0)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.").size should equal(0)
//Check that the same json becomes valid when a non-empty id is added
val validId = "foo"
@ -658,7 +658,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
response.code should equal(SUCCESS)
//Check the bank was created
val banks = Connector.connector.vend.getBanks.get
val banks = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
banks.size should equal(1)
val createdBank = banks(0)
@ -671,7 +671,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
it should "not allow multiple banks with the same id" in {
//no banks should exist initially
Connector.connector.vend.getBanks.get.size should equal(0)
Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.").size should equal(0)
val bank1AsJValue = Extraction.decompose(bank1)
@ -697,7 +697,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
getResponse(List(bank1AsJValue, validOtherBank)).code should equal(SUCCESS)
//check that two banks were created
val banks = Connector.connector.vend.getBanks.get
val banks = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
banks.size should equal(2)
}
@ -773,9 +773,9 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
//a user should now have been created
val createdUser = Users.users.vend.getUserByProviderId(defaultProvider, user1.user_name)
createdUser.isDefined should equal(true)
createdUser.get.provider should equal(defaultProvider)
createdUser.get.idGivenByProvider should equal(user1.user_name)
createdUser.get.name should equal(user1.user_name)
createdUser.openOrThrowException("Attempted to open an empty Box.").provider should equal(defaultProvider)
createdUser.openOrThrowException("Attempted to open an empty Box.").idGivenByProvider should equal(user1.user_name)
createdUser.openOrThrowException("Attempted to open an empty Box.").name should equal(user1.user_name)
}
@ -828,11 +828,11 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
firstUser.isDefined should equal(true)
secondUser.isDefined should equal(true)
firstUser.get.idGivenByProvider should equal(user1.user_name)
secondUser.get.idGivenByProvider should equal(secondUserName)
firstUser.openOrThrowException("Attempted to open an empty Box.").idGivenByProvider should equal(user1.user_name)
secondUser.openOrThrowException("Attempted to open an empty Box.").idGivenByProvider should equal(secondUserName)
firstUser.get.name should equal(user1.user_name)
secondUser.get.name should equal(secondUserName)
firstUser.openOrThrowException("Attempted to open an empty Box.").name should equal(user1.user_name)
secondUser.openOrThrowException("Attempted to open an empty Box.").name should equal(secondUserName)
}
it should "fail if a specified user already exists" in {
@ -891,7 +891,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
val createdAuthUserBox = AuthUser.find(By(AuthUser.username, user1.user_name))
createdAuthUserBox.isDefined should equal(true)
val createdAuthUser = createdAuthUserBox.get
val createdAuthUser = createdAuthUserBox.openOrThrowException("Attempted to open an empty Box.")
createdAuthUser.password.match_?(user1.password) should equal(true)
}
@ -1246,7 +1246,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
TransactionId(t.id))
createdTransaction.isDefined should equal(true)
val created = createdTransaction.get
val created = createdTransaction.openOrThrowException("Attempted to open an empty Box.")
created.otherAccount.label.nonEmpty should equal(true)
created.otherAccount.thisAccountId.value should equal(t.counterparty.get.account_number.get)
@ -1274,7 +1274,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
TransactionId(t.id))
createdTransaction.isDefined should equal(true)
val created = createdTransaction.get
val created = createdTransaction.openOrThrowException("Attempted to open an empty Box.")
created.otherAccount.label.nonEmpty should equal(true)
created.otherAccount.thisAccountId.value should equal(t.counterparty.get.account_number.get)
@ -1302,7 +1302,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
TransactionId(t.id))
createdTransaction.isDefined should equal(true)
val created = createdTransaction.get
val created = createdTransaction.openOrThrowException("Attempted to open an empty Box.")
created.otherAccount.label should equal(t.counterparty.get.name.get)
created.otherAccount.thisAccountId.value should equal("")
@ -1329,7 +1329,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
TransactionId(t.id))
createdTransaction.isDefined should equal(true)
val created = createdTransaction.get
val created = createdTransaction.openOrThrowException("Attempted to open an empty Box.")
created.otherAccount.label should equal(t.counterparty.get.name.get)
created.otherAccount.thisAccountId.value should equal("")
@ -1395,8 +1395,8 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransaction1Box.isDefined should equal(true)
foundTransaction2Box.isDefined should equal(true)
val counter1 = foundTransaction1Box.get.otherAccount
val counter2 = foundTransaction2Box.get.otherAccount
val counter1 = foundTransaction1Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
val counter2 = foundTransaction2Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
counter1.counterPartyId should equal(counter2.counterPartyId)
counter1.metadata.getPublicAlias should equal(counter2.metadata.getPublicAlias)
@ -1429,8 +1429,8 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransaction1Box.isDefined should equal(true)
foundTransaction2Box.isDefined should equal(true)
val counter1 = foundTransaction1Box.get.otherAccount
val counter2 = foundTransaction2Box.get.otherAccount
val counter1 = foundTransaction1Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
val counter2 = foundTransaction2Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
counter1.counterPartyId should not equal(counter2.counterPartyId)
counter1.metadata.getPublicAlias should not equal(counter2.metadata.getPublicAlias)
@ -1463,8 +1463,8 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransaction1Box.isDefined should equal(true)
foundTransaction2Box.isDefined should equal(true)
val counter1 = foundTransaction1Box.get.otherAccount
val counter2 = foundTransaction2Box.get.otherAccount
val counter1 = foundTransaction1Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
val counter2 = foundTransaction2Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
counter1.counterPartyId should equal(counter2.counterPartyId)
counter1.metadata.getPublicAlias should equal(counter2.metadata.getPublicAlias)
@ -1502,8 +1502,8 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransaction1Box.isDefined should equal(true)
foundTransaction2Box.isDefined should equal(true)
val counter1 = foundTransaction1Box.get.otherAccount
val counter2 = foundTransaction2Box.get.otherAccount
val counter1 = foundTransaction1Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
val counter2 = foundTransaction2Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
//transactions should have the same counterparty
counter1.counterPartyId should not equal(counter2.counterPartyId)
@ -1549,9 +1549,9 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
foundTransaction2Box.isDefined should equal(true)
foundTransaction3Box.isDefined should equal(true)
val counter1 = foundTransaction1Box.get.otherAccount
val counter2 = foundTransaction2Box.get.otherAccount
val counter3 = foundTransaction3Box.get.otherAccount
val counter1 = foundTransaction1Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
val counter2 = foundTransaction2Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
val counter3 = foundTransaction3Box.openOrThrowException("Attempted to open an empty Box.").otherAccount
counter1.counterPartyId should not equal(counter2.counterPartyId)
counter1.counterPartyId should not equal(counter3.counterPartyId)
@ -1689,7 +1689,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Shoul
def getCreatedTransaction(id : String) =
Connector.connector.vend.getTransaction(BankId(t.this_account.bank),
AccountId(t.this_account.id),
TransactionId(id)).get
TransactionId(id)).openOrThrowException("Attempted to open an empty Box.")
val t1 = getCreatedTransaction(t.id)
val t2 = getCreatedTransaction(newTransId)

View File

@ -27,8 +27,8 @@ trait DefaultUsers {
developerEmail = None,
redirectURL = None,
createdByUserId = None //Internally, the consumer is not relevant to UserId.
).get
lazy val consumer = Consumer(testConsumer.key, testConsumer.secret)
).openOrThrowException("Attempted to open an empty Box.")
lazy val consumer = Consumer(testConsumer.key.get, testConsumer.secret.get)
// create the access token
val expiration = Props.getInt("token_expiration_weeks", 4)
@ -38,50 +38,50 @@ trait DefaultUsers {
val defaultProvider = Props.get("hostname", "")
// create some resource user for test purposes
lazy val resourceUser1 = User.createResourceUser(defaultProvider, None, None, None, None).get
lazy val resourceUser2 = User.createResourceUser(defaultProvider, None, None, None, None).get
lazy val resourceUser3 = User.createResourceUser(defaultProvider, None, None, None, None).get
lazy val resourceUser1 = User.createResourceUser(defaultProvider, None, None, None, None).openOrThrowException("Attempted to open an empty Box.")
lazy val resourceUser2 = User.createResourceUser(defaultProvider, None, None, None, None).openOrThrowException("Attempted to open an empty Box.")
lazy val resourceUser3 = User.createResourceUser(defaultProvider, None, None, None, None).openOrThrowException("Attempted to open an empty Box.")
// create the tokens in database, we only need token-key and token-secret
lazy val testToken1 = Tokens.tokens.vend.createToken(
Access,
Some(testConsumer.id),
Some(resourceUser1.id.toLong),
Some(testConsumer.id.get),
Some(resourceUser1.id.get),
Some(randomString(40).toLowerCase),
Some(randomString(40).toLowerCase),
Some(tokenDuration),
Some({ (now: TimeSpan) + tokenDuration }),
Some(now),
None
).get
).openOrThrowException("Attempted to open an empty Box.")
lazy val testToken2 = Tokens.tokens.vend.createToken(
Access,
Some(testConsumer.id),
Some(resourceUser2.id.toLong),
Some(testConsumer.id.get),
Some(resourceUser2.id.get),
Some(randomString(40).toLowerCase),
Some(randomString(40).toLowerCase),
Some(tokenDuration),
Some({ (now: TimeSpan) + tokenDuration }),
Some(now),
None
).get
).openOrThrowException("Attempted to open an empty Box.")
lazy val testToken3 = Tokens.tokens.vend.createToken(Access,
Some(testConsumer.id),
Some(resourceUser3.id.toLong),
Some(testConsumer.id.get),
Some(resourceUser3.id.get),
Some(randomString(40).toLowerCase),
Some(randomString(40).toLowerCase),
Some(tokenDuration),
Some({ (now: TimeSpan) + tokenDuration }),
Some(now),
None
).get
).openOrThrowException("Attempted to open an empty Box.")
// prepare the tokens
lazy val token1 = Token(testToken1.key, testToken1.secret)
lazy val token2 = Token(testToken2.key, testToken2.secret)
lazy val token3 = Token(testToken3.key, testToken3.secret)
lazy val token1 = Token(testToken1.key.get, testToken1.secret.get)
lazy val token2 = Token(testToken2.key.get, testToken2.secret.get)
lazy val token3 = Token(testToken3.key.get, testToken3.secret.get)
// prepare the OAuth users to login
lazy val user1 = Some(consumer, token1)

View File

@ -47,7 +47,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
otherBranchRoutingScheme ="OBP",
otherBranchRoutingAddress ="Berlin",
isBeneficiary = isBeneficiary
).get
).openOrThrowException("Attempted to open an empty Box.")
}
// TODO: Should return an option or box so can test if the insert succeeded
@ -84,7 +84,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
}
override protected def updateAccountCurrency(bankId: BankId, accountId : AccountId, currency : String) : BankAccount = {
MappedBankAccount.find(By(MappedBankAccount.bank, bankId.value), By(MappedBankAccount.theAccountId, accountId.value)).get.accountCurrency(currency).saveMe()
MappedBankAccount.find(By(MappedBankAccount.bank, bankId.value), By(MappedBankAccount.theAccountId, accountId.value)).openOrThrowException("Attempted to open an empty Box.").accountCurrency(currency).saveMe()
}
def addEntitlement(bankId: String, userId: String, roleName: String): Box[Entitlement] = {

View File

@ -22,12 +22,12 @@ trait LocalRecordConnectorTestSetup extends TestConnectorSetupWithStandardPermis
alias(randomString(5)).
permalink(id).
national_identifier(randomString(5)).
save
save(true)
}
override protected def createAccount(bankId: BankId, accountId : AccountId, currency : String) : BankAccount = {
val q = QueryBuilder.start(HostedBank.permalink.name).is(bankId.value).get()
val hostedBank = HostedBank.find(q).get
val hostedBank = HostedBank.find(q).openOrThrowException("Attempted to open an empty Box.")
Account.createRecord.
accountBalance(900000000).
@ -39,7 +39,7 @@ trait LocalRecordConnectorTestSetup extends TestConnectorSetupWithStandardPermis
bankID(hostedBank.id.get).
accountLabel(randomString(4)).
accountCurrency(currency).
save
save(true)
}
override protected def createTransaction(account: BankAccount, startDate: Date, finishDate: Date) = {
@ -92,12 +92,12 @@ trait LocalRecordConnectorTestSetup extends TestConnectorSetupWithStandardPermis
details(details)
val env = OBPEnvelope.createRecord.
obp_transaction(transaction).save
obp_transaction(transaction).save(true)
//slightly ugly
account.asInstanceOf[Account].accountBalance(newBalance.amount.get).accountLastUpdate(now).save
account.asInstanceOf[Account].accountBalance(newBalance.amount.get).accountLastUpdate(now).save(true)
env.save
env.save(true)
}
}

View File

@ -18,7 +18,7 @@ trait PrivateUser2Accounts {
*/
def accountTestsSpecificDBSetup() {
val banks = Connector.connector.vend.getBanks.get
val banks = Connector.connector.vend.getBanks.openOrThrowException("Attempted to open an empty Box.")
def generateAccounts(owner: User) = banks.flatMap(bank => {
for { i <- 0 until 2 } yield {

View File

@ -128,14 +128,14 @@ trait SendServerRequests {
def getConsumerSecret(consumerKey : String ) : String = {
Consumers.consumers.vend.getConsumerByConsumerKey(consumerKey) match {
case Full(c) => c.secret
case Full(c) => c.secret.get
case _ => ""
}
}
def getTokenSecret(token : String ) : String = {
Tokens.tokens.vend.getTokenByKey(token) match {
case Full(t) => t.secret
case Full(t) => t.secret.get
case _ => ""
}
}

View File

@ -8,7 +8,7 @@ import code.views.Views
import net.liftweb.mapper.MetaMapper
import net.liftweb.mongodb._
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
import net.liftweb.util.{DefaultConnectionIdentifier, Props}
/**
* Handles setting up views and permissions and account holders using ViewImpls, ViewPrivileges,
@ -29,22 +29,22 @@ trait TestConnectorSetupWithStandardPermissions extends TestConnectorSetup {
}
protected def createOwnerView(bankId: BankId, accountId: AccountId ) : View = {
Views.views.vend.getOrCreateOwnerView(bankId, accountId, randomString(3)).get
Views.views.vend.getOrCreateOwnerView(bankId, accountId, randomString(3)).openOrThrowException("Attempted to open an empty Box.")
}
protected def createPublicView(bankId: BankId, accountId: AccountId) : View = {
Views.views.vend.getOrCreatePublicView(bankId, accountId, randomString(3)).get
Views.views.vend.getOrCreatePublicView(bankId, accountId, randomString(3)).openOrThrowException("Attempted to open an empty Box.")
}
protected def createRandomView(bankId: BankId, accountId: AccountId) : View = {
Views.views.vend.createRandomView(bankId, accountId).get
Views.views.vend.createRandomView(bankId, accountId).openOrThrowException("Attempted to open an empty Box.")
}
protected def wipeTestData(): Unit = {
//drop the mongo Database after each test
MongoDB.getDb(DefaultMongoIdentifier).foreach(_.dropDatabase())
MongoDB.getDb(DefaultConnectionIdentifier).foreach(_.dropDatabase())
//returns true if the model should not be wiped after each test
def exclusion(m : MetaMapper[_]) = {