mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Include pending contact id in error response
This commit is contained in:
@@ -175,6 +175,7 @@ possible attack.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"error": "PENDING_EXISTS",
|
"error": "PENDING_EXISTS",
|
||||||
|
"pendingContactId": "jsTgWcsEQ2g9rnomeK1g/hmO8M1Ix6ZIGWAjgBtlS9U=",
|
||||||
"pendingContactAlias": "Alice"
|
"pendingContactAlias": "Alice"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -117,8 +117,11 @@ constructor(
|
|||||||
return ctx.json(details)
|
return ctx.json(details)
|
||||||
} catch (e: PendingContactExistsException) {
|
} catch (e: PendingContactExistsException) {
|
||||||
ctx.status(FORBIDDEN_403)
|
ctx.status(FORBIDDEN_403)
|
||||||
val details =
|
val details = mapOf(
|
||||||
mapOf("error" to "PENDING_EXISTS", "pendingContactAlias" to e.pendingContact.alias)
|
"error" to "PENDING_EXISTS",
|
||||||
|
"pendingContactId" to e.pendingContact.id.bytes,
|
||||||
|
"pendingContactAlias" to e.pendingContact.alias
|
||||||
|
)
|
||||||
return ctx.json(details)
|
return ctx.json(details)
|
||||||
}
|
}
|
||||||
return ctx.json(pendingContact.output())
|
return ctx.json(pendingContact.output())
|
||||||
|
|||||||
@@ -132,9 +132,12 @@ class ContactControllerIntegrationTest: IntegrationTest() {
|
|||||||
var response = post("$url/contacts/add/pending", json)
|
var response = post("$url/contacts/add/pending", json)
|
||||||
assertEquals(200, response.statusCode)
|
assertEquals(200, response.statusCode)
|
||||||
|
|
||||||
|
val pendingContactId = response.jsonObject.getString("pendingContactId")
|
||||||
|
|
||||||
response = post("$url/contacts/add/pending", json)
|
response = post("$url/contacts/add/pending", json)
|
||||||
assertEquals(403, response.statusCode)
|
assertEquals(403, response.statusCode)
|
||||||
assertEquals("PENDING_EXISTS", response.jsonObject.getString("error"))
|
assertEquals("PENDING_EXISTS", response.jsonObject.getString("error"))
|
||||||
|
assertEquals(pendingContactId, response.jsonObject.getString("pendingContactId"))
|
||||||
assertEquals(alias, response.jsonObject.getString("pendingContactAlias"))
|
assertEquals(alias, response.jsonObject.getString("pendingContactAlias"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ internal class ContactControllerTest : ControllerTest() {
|
|||||||
ctx.json(
|
ctx.json(
|
||||||
mapOf(
|
mapOf(
|
||||||
"error" to "PENDING_EXISTS",
|
"error" to "PENDING_EXISTS",
|
||||||
|
"pendingContactId" to pendingContact.id.bytes,
|
||||||
"pendingContactAlias" to pendingContact.alias
|
"pendingContactAlias" to pendingContact.alias
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user