diff options
author | MS <ms@taler.net> | 2020-09-03 14:36:51 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2020-09-03 14:36:51 +0200 |
commit | 66a817389b41ccc301d11b6da862fa45a7f03c48 (patch) | |
tree | 8b8f54586277571150189965e8745c21d0c3ae99 | |
parent | a6375e5da848323ad0b04d608b0b124c282ea4e1 (diff) | |
download | libeufin-66a817389b41ccc301d11b6da862fa45a7f03c48.tar.gz libeufin-66a817389b41ccc301d11b6da862fa45a7f03c48.tar.bz2 libeufin-66a817389b41ccc301d11b6da862fa45a7f03c48.zip |
fixing tests
-rwxr-xr-x | integration-tests/all.sh | 1 | ||||
-rwxr-xr-x | integration-tests/test-ebics-backup.py | 4 | ||||
-rwxr-xr-x | integration-tests/test-ebics-double-payment-submission.py | 12 | ||||
-rw-r--r-- | integration-tests/util.py | 2 | ||||
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 6 | ||||
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt | 6 | ||||
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt | 12 |
7 files changed, 29 insertions, 14 deletions
diff --git a/integration-tests/all.sh b/integration-tests/all.sh index 6bbb7ae6..c8dd2152 100755 --- a/integration-tests/all.sh +++ b/integration-tests/all.sh @@ -9,3 +9,4 @@ set -e ./test-taler-facade.py ./test-bankConnection.py ./test-ebics-double-payment-submission.py +echo "All tests passed." diff --git a/integration-tests/test-ebics-backup.py b/integration-tests/test-ebics-backup.py index 5725c0ed..7b4b126e 100755 --- a/integration-tests/test-ebics-backup.py +++ b/integration-tests/test-ebics-backup.py @@ -153,7 +153,7 @@ print("send ini & hia with restored connection") assertResponse( post( - "http://localhost:5001/bank-connections/my-ebics-restored/send-ini", + "http://localhost:5001/bank-connections/my-ebics-restored/ebics/send-ini", json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) @@ -161,7 +161,7 @@ assertResponse( assertResponse( post( - "http://localhost:5001/bank-connections/my-ebics-restored/send-hia", + "http://localhost:5001/bank-connections/my-ebics-restored/ebics/send-hia", json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) diff --git a/integration-tests/test-ebics-double-payment-submission.py b/integration-tests/test-ebics-double-payment-submission.py index de111556..32493a20 100755 --- a/integration-tests/test-ebics-double-payment-submission.py +++ b/integration-tests/test-ebics-double-payment-submission.py @@ -45,12 +45,9 @@ def fail(msg): def assertResponse(response, acceptedResponses=[200]): if response.status_code not in acceptedResponses: - print("Test failed on URL: {}".format(response.url)) - # stdout/stderr from both services is A LOT of text. - # Confusing to dump all that to console. - print("Check nexus.log and sandbox.log, probably under /tmp") + print("Test failed on URL: {}, status: {}/{}".format( + response.url, response.status_code, acceptedResponses)) exit(1) - # Allows for finer grained checks. return response startNexus(NEXUS_DB) @@ -143,6 +140,7 @@ assertResponse( headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) +print("First payment done") # mark the payment as not submitted directly # into the database. check_call(["sqlite3", NEXUS_DB, f"UPDATE PaymentInitiations SET submitted = false WHERE id = '{PREPARED_PAYMENT_UUID}'"]) @@ -154,9 +152,9 @@ assertResponse( post( f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{PREPARED_PAYMENT_UUID}/submit", json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER) ), - [500] + acceptedResponses = [500] ) print("Test passed!") diff --git a/integration-tests/util.py b/integration-tests/util.py index fa933e63..129ce0e0 100644 --- a/integration-tests/util.py +++ b/integration-tests/util.py @@ -63,7 +63,7 @@ def startSandbox(dbname="sandbox-test.sqlite3"): get("http://localhost:5000/") except: if i == 9: - stdout, stderr = nexus.communicate() + stdout, stderr = sandbox.communicate() print("Sandbox timed out") print("{}\n{}".format(stdout.decode(), stderr.decode())) exit(77) diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt index eb98a18c..2a340393 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt @@ -246,7 +246,7 @@ class EbicsUploadTransactionChunkEntity(id: EntityID<String>) : Entity<String>(i /** * Table that keeps all the payments initiated by PAIN.001. */ -object BankAccountTransactionsTable : IntIdTable() { +object BankAccountTransactionsTable : Table() { val creditorIban = text("creditorIban") val creditorBic = text("creditorBic").nullable() val creditorName = text("creditorName") @@ -260,8 +260,11 @@ object BankAccountTransactionsTable : IntIdTable() { val pmtInfId = text("pmtInfId") val msgId = text("msgId") val account = reference("account", BankAccountsTable) + + override val primaryKey = PrimaryKey(pmtInfId, msgId) } +/* class BankAccountTransactionsEntity(id: EntityID<Int>) : IntEntity(id) { companion object : IntEntityClass<BankAccountTransactionsEntity>(BankAccountTransactionsTable) @@ -279,6 +282,7 @@ class BankAccountTransactionsEntity(id: EntityID<Int>) : IntEntity(id) { var msgId by BankAccountTransactionsTable.msgId var account by BankAccountEntity referencedOn BankAccountTransactionsTable.account } +*/ /** * Table that keeps information about which bank accounts (iban+bic+name) diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt index a07405d1..2996c856 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -572,6 +572,7 @@ private fun handleCct(paymentRequest: String, initiatorName: String, ctx: Reques transaction { try { BankAccountTransactionsTable.insert { + it[account] = getBankAccountFromPain(parseResult).id it[creditorIban] = parseResult.creditorIban it[creditorName] = parseResult.creditorName it[debitorIban] = parseResult.debitorIban @@ -1069,7 +1070,6 @@ private fun handleEbicsUploadTransactionTransmission(requestContext: RequestCont signedData, requestContext.clientSigPub ) - if (!res1) { throw EbicsInvalidRequestError() } @@ -1094,7 +1094,7 @@ private fun handleEbicsUploadTransactionTransmission(requestContext: RequestCont } } // req.header.static.hostID. -private fun makeReqestContext(requestObject: EbicsRequest): RequestContext { +private fun makeRequestContext(requestObject: EbicsRequest): RequestContext { val staticHeader = requestObject.header.static val requestedHostId = staticHeader.hostID val ebicsHost = @@ -1203,7 +1203,7 @@ suspend fun ApplicationCall.ebicsweb() { val requestObject = requestDocument.toObject<EbicsRequest>() val responseXmlStr = transaction { // Step 1 of 3: Get information about the host and subscriber - val requestContext = makeReqestContext(requestObject) + val requestContext = makeRequestContext(requestObject) // Step 2 of 3: Validate the signature val verifyResult = XMLUtil.verifyEbicsDocument(requestDocument, requestContext.clientAuthPub) if (!verifyResult) { diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt index 3a5b895c..9e7040a1 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt @@ -38,6 +38,18 @@ fun getOrderTypeFromTransactionId(transactionID: String): String { return uploadTransaction.orderType } +fun getBankAccountFromPain(painParseResult: PainParseResult): BankAccountEntity { + return transaction { + BankAccountEntity.find( + BankAccountsTable.iban eq + painParseResult.debitorIban + ) + }.firstOrNull() ?: throw SandboxError( + HttpStatusCode.NotFound, + "Did not find a bank account for ${painParseResult.debitorIban}" + ) +} + fun getBankAccountFromSubscriber(subscriber: EbicsSubscriberEntity): BankAccountEntity { return transaction { BankAccountEntity.find(BankAccountsTable.subscriber eq subscriber.id) |