gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated (f178af0 -> a4c7127)


From: gnunet
Subject: [libeufin] branch master updated (f178af0 -> a4c7127)
Date: Sat, 30 Jan 2021 13:35:47 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a change to branch master
in repository libeufin.

    from f178af0  Give db conn. str. examples upon failure
     new 6aeac38  test operation with new password
     new a4c7127  Fix integration tests.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 integration-tests/tests.py                         | 47 ++++++++++++++++------
 .../tech/libeufin/nexus/server/NexusServer.kt      | 10 ++++-
 2 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/integration-tests/tests.py b/integration-tests/tests.py
index 999ee4d..764dd48 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -66,17 +66,9 @@ def prepareSandbox():
         )
     )
 
+# most of the operations are run by the superuser.
 def prepareNexus():
     makeNexusSuperuser()
-    # make a new nexus user.
-    assertResponse(
-        post(
-            f"{PERSONA.nexus.base_url}/users",
-            auth=auth.HTTPBasicAuth("admin", "x"),
-            json=dict(username=PERSONA.nexus.username, 
password=PERSONA.nexus.password),
-        )
-    )
-    # make a ebics bank connection for the new user.
     assertResponse(
         post(
             f"{PERSONA.nexus.base_url}/bank-connections",
@@ -135,14 +127,45 @@ def teardown_function():
     dropSandboxTables()
     dropNexusTables()
 
-def test_change_password():
+def test_double_username():
     assertResponse(
-        post(f"{PERSONA.nexus.base_url}/users/password",
+        post(f"{PERSONA.nexus.base_url}/users",
+             auth=PERSONA.nexus.auth,
+             json=dict(username="admin", password="secret")
+        ),
+        acceptedResponses=[409]
+    )
+
+def test_change_nonadmin_password():
+    assertResponse(
+        post(f"{PERSONA.nexus.base_url}/users",
              auth=PERSONA.nexus.auth,
+             json=dict(username="nonadmin", password="secret")
+        )
+    )
+
+    resp = assertResponse(
+        get(
+            f"{PERSONA.nexus.base_url}/bank-accounts",
+            auth=auth.HTTPBasicAuth("nonadmin", "secret")
+        )
+    )
+
+    assertResponse(
+        post(f"{PERSONA.nexus.base_url}/users/password",
+             auth=auth.HTTPBasicAuth("nonadmin", "secret"),
              json=dict(newPassword="changed")
         )
     )
 
+    assertResponse(
+        get(
+            f"{PERSONA.nexus.base_url}/bank-accounts",
+            auth=auth.HTTPBasicAuth("nonadmin", "changed")
+        )
+    )
+
+
 def test_connection_deletion():
     resp = assertResponse(
         get(
@@ -445,7 +468,7 @@ def test_double_connection_name():
             ),
             auth=PERSONA.nexus.auth
         ),
-        [406] # expecting "406 Not acceptable"
+        [409] # Conflict
     )
 
 def test_ingestion_camt53_non_singleton():
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index fa2c274..a679d28 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -355,6 +355,14 @@ fun serverMain(dbName: String, host: String, port: Int) {
                 val requestedUsername = requireValidResourceName(body.username)
                 transaction {
                     requireSuperuser(call.request)
+                    // check if username is available
+                    val checkUsername = NexusUserEntity.find {
+                        NexusUsersTable.username eq requestedUsername
+                    }.firstOrNull()
+                    if (checkUsername != null) throw NexusError(
+                        HttpStatusCode.Conflict,
+                        "Username $requestedUsername unavailable"
+                    )
                     NexusUserEntity.new {
                         username = requestedUsername
                         passwordHash = CryptoUtil.hashpw(body.password)
@@ -720,7 +728,7 @@ fun serverMain(dbName: String, host: String, port: Int) {
                         NexusBankConnectionEntity.find { 
NexusBankConnectionsTable.connectionId eq body.name }
                             .firstOrNull()
                     if (existingConn != null) {
-                        throw NexusError(HttpStatusCode.NotAcceptable, 
"connection '${body.name}' exists already")
+                        throw NexusError(HttpStatusCode.Conflict, "connection 
'${body.name}' exists already")
                     }
                     when (body) {
                         is CreateBankConnectionFromBackupRequestJson -> {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]