mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Include name/alias of already existing (pending) contact in error
This commit is contained in:
@@ -118,6 +118,14 @@ Until it is completed, a pending contact is returned as JSON:
|
||||
|
||||
Possible errors when adding a pending contact are:
|
||||
|
||||
#### 400: Pending contact's link is invalid
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "INVALID_LINK"
|
||||
}
|
||||
```
|
||||
|
||||
#### 400: Pending contact's handshake public key is invalid
|
||||
|
||||
```json
|
||||
@@ -147,7 +155,8 @@ when this happens:
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "CONTACT_EXISTS"
|
||||
"error": "CONTACT_EXISTS",
|
||||
"remoteAuthorName": "Bob"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -165,7 +174,8 @@ possible attack.
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "PENDING_EXISTS"
|
||||
"error": "PENDING_EXISTS",
|
||||
"pendingContactAlias": "Alice"
|
||||
}
|
||||
```
|
||||
-----------
|
||||
|
||||
@@ -112,11 +112,13 @@ constructor(
|
||||
return ctx.json(details)
|
||||
} catch (e: ContactExistsException) {
|
||||
ctx.status(FORBIDDEN_403)
|
||||
val details = mapOf("error" to "CONTACT_EXISTS")
|
||||
val details =
|
||||
mapOf("error" to "CONTACT_EXISTS", "remoteAuthorName" to e.remoteAuthor.name)
|
||||
return ctx.json(details)
|
||||
} catch (e: PendingContactExistsException) {
|
||||
ctx.status(FORBIDDEN_403)
|
||||
val details = mapOf("error" to "PENDING_EXISTS")
|
||||
val details =
|
||||
mapOf("error" to "PENDING_EXISTS", "pendingContactAlias" to e.pendingContact.alias)
|
||||
return ctx.json(details)
|
||||
}
|
||||
return ctx.json(pendingContact.output())
|
||||
|
||||
@@ -135,6 +135,7 @@ class ContactControllerIntegrationTest: IntegrationTest() {
|
||||
response = post("$url/contacts/add/pending", json)
|
||||
assertEquals(403, response.statusCode)
|
||||
assertEquals("PENDING_EXISTS", response.jsonObject.getString("error"))
|
||||
assertEquals(alias, response.jsonObject.getString("pendingContactAlias"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -183,8 +183,15 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
link,
|
||||
alias
|
||||
)
|
||||
} throws ContactExistsException(null, null)
|
||||
every { ctx.json(mapOf("error" to "CONTACT_EXISTS")) } returns ctx
|
||||
} throws ContactExistsException(null, author)
|
||||
every {
|
||||
ctx.json(
|
||||
mapOf(
|
||||
"error" to "CONTACT_EXISTS",
|
||||
"remoteAuthorName" to author.name
|
||||
)
|
||||
)
|
||||
} returns ctx
|
||||
controller.addPendingContact(ctx)
|
||||
verify { ctx.status(403) }
|
||||
}
|
||||
@@ -204,8 +211,15 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
link,
|
||||
alias
|
||||
)
|
||||
} throws PendingContactExistsException(null)
|
||||
every { ctx.json(mapOf("error" to "PENDING_EXISTS")) } returns ctx
|
||||
} throws PendingContactExistsException(pendingContact)
|
||||
every {
|
||||
ctx.json(
|
||||
mapOf(
|
||||
"error" to "PENDING_EXISTS",
|
||||
"pendingContactAlias" to pendingContact.alias
|
||||
)
|
||||
)
|
||||
} returns ctx
|
||||
controller.addPendingContact(ctx)
|
||||
verify { ctx.status(403) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user