[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: integration test
From: |
gnunet |
Subject: |
[libeufin] branch master updated: integration test |
Date: |
Tue, 12 May 2020 18:55:53 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 545ebac integration test
545ebac is described below
commit 545ebacc71734b3b6f9a491f7cddf1450fbda5fd
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue May 12 18:55:31 2020 +0200
integration test
Admin gets password accepted.
---
integration-tests/test-ebics-new.py | 33 +++++++++++++++++++---
.../src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 8 ++++--
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/integration-tests/test-ebics-new.py
b/integration-tests/test-ebics-new.py
index c1b02a8..3f89f77 100755
--- a/integration-tests/test-ebics-new.py
+++ b/integration-tests/test-ebics-new.py
@@ -5,6 +5,9 @@ from subprocess import call, Popen, PIPE
from time import sleep
import os
import socket
+import sqlite3
+import hashlib
+import base64
# Steps implemented in this test.
#
@@ -32,6 +35,11 @@ import socket
# Nexus user details
USERNAME="person"
+PASSWORD="y"
+USER_AUTHORIZATION_HEADER = "basic
{}".format(base64.b64encode(b"person:y").decode("utf-8"))
+
+# Admin authentication
+ADMIN_AUTHORIZATION_HEADER = "basic
{}".format(base64.b64encode(b"admin:x").decode("utf-8"))
# EBICS details
EBICS_URL="http://localhost:5000/ebicsweb"
@@ -89,7 +97,7 @@ for i in range(10):
sleep(1)
continue
break
-
+# Start sandbox
checkPorts([5000])
sandbox = Popen(["./gradlew", "sandbox:run"], stdout=PIPE, stderr=PIPE)
for i in range(10):
@@ -147,16 +155,33 @@ assertResponse(
)
)
-#1.a
+#1.a, make a new nexus user.
+
+# "Create" the admin user first.
+dbconn = sqlite3.connect("nexus/libeufin-nexus.sqlite3")
+dbconn.execute(
+ "INSERT INTO NexusUsers (id, password) VALUES (?, ?)",
+ ("admin", sqlite3.Binary(hashlib.sha256(b"x").digest()))
+)
+dbconn.commit()
+dbconn.close()
+
assertResponse(
post(
- "http://localhost:5001/users/{}".format(USERNAME),
+ "http://localhost:5001/users",
+ headers=dict(authorization=ADMIN_AUTHORIZATION_HEADER),
json=dict(
- password="secret"
+ username=USERNAME,
+ password=PASSWORD
)
)
)
+nexus.terminate()
+sandbox.terminate()
+print("All done!")
+exit(44)
+
#1.b
assertResponse(
post(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index 4258b84..93e5eb9 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -423,13 +423,15 @@ fun extractNexusUser(param: String?): NexusUserEntity {
* will then be compared with the one kept into the database.
*/
fun extractUserAndHashedPassword(authorizationHeader: String): Pair<String,
ByteArray> {
+ logger.debug("Authenticating: $authorizationHeader")
val (username, password) = try {
val split = authorizationHeader.split(" ")
- val valueUtf8 = String(base64ToBytes(split[1]), Charsets.UTF_8) //
newline introduced here: BUG!
- valueUtf8.split(":")
+ val plainUserAndPass = String(base64ToBytes(split[1]), Charsets.UTF_8)
+ plainUserAndPass.split(":")
} catch (e: java.lang.Exception) {
throw NexusError(
- HttpStatusCode.BadRequest, "invalid Authorization:-header received"
+ HttpStatusCode.BadRequest,
+ "invalid Authorization:-header received"
)
}
return Pair(username, CryptoUtil.hashStringSHA256(password))
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [libeufin] branch master updated: integration test,
gnunet <=