commit 4edb7a093380f3909096141a8ac158f5bce0309e
parent 73672682cd5cce06a6e4132748132b77f3a3f50f
Author: MS <ms@taler.net>
Date: Tue, 19 Jan 2021 16:53:53 +0100
Revert (part of) #6646
Diffstat:
3 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
@@ -405,28 +405,6 @@ def test_double_connection_name():
[406] # expecting "406 Not acceptable"
)
- # Checking that _another_ user can pick the same connection name.
- assertResponse(
- post(
- f"{PERSONA.nexus.base_url}/users",
- auth=auth.HTTPBasicAuth("admin", "x"),
- json=dict(username="second-user", password="second-password"),
- )
- )
-
- assertResponse(
- post(
- f"{PERSONA.nexus.base_url}/bank-connections",
- json=dict(
- name=PERSONA.nexus.bank_connection, # same name from the previous creation.
- source="new",
- type="ebics",
- data=PERSONA.ebics.get_as_dict(with_url=True),
- ),
- auth=auth.HTTPBasicAuth("second-user", "second-password")
- ),
- )
-
def test_ingestion_camt53_non_singleton():
with open("camt53-gls-style-1.xml") as f:
camt = f.read()
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -302,7 +302,7 @@ class NexusUserEntity(id: EntityID<String>) : Entity<String>(id) {
}
object NexusBankConnectionsTable : IdTable<String>() {
- override val id = NexusBankConnectionsTable.text("id").entityId()
+ override val id = NexusBankConnectionsTable.text("id").entityId().uniqueIndex()
val type = text("type")
val owner = reference("user", NexusUsersTable)
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -718,9 +718,7 @@ fun serverMain(dbName: String, host: String, port: Int) {
val body = call.receive<CreateBankConnectionRequestJson>()
transaction {
val user = authenticateRequest(call.request)
- if (NexusBankConnectionEntity.find {
- NexusBankConnectionsTable.id eq body.name and (NexusBankConnectionsTable.owner eq user.id)
- }.firstOrNull() != null) {
+ if (NexusBankConnectionEntity.findById(body.name) != null) {
throw NexusError(HttpStatusCode.NotAcceptable, "connection '${body.name}' exists already")
}
when (body) {