mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
briar-headless: Last round of review comments
This commit is contained in:
@@ -15,6 +15,7 @@ import org.briarproject.bramble.api.system.Clock
|
||||
import org.briarproject.bramble.test.TestUtils.*
|
||||
import org.briarproject.bramble.util.StringUtils.getRandomString
|
||||
import org.skyscreamer.jsonassert.JSONAssert.assertEquals
|
||||
import org.skyscreamer.jsonassert.JSONCompareMode.STRICT
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
|
||||
@@ -38,7 +39,7 @@ abstract class ControllerTest {
|
||||
protected val timestamp = 42L
|
||||
|
||||
protected fun assertJsonEquals(json: String, obj: Any) {
|
||||
assertEquals(json, outputCtx.json(obj).resultString(), false)
|
||||
assertEquals(json, outputCtx.json(obj).resultString(), STRICT)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ internal class BlogControllerTest : ControllerTest() {
|
||||
fun testOutputBlogPost() {
|
||||
val json = """
|
||||
{
|
||||
"body": "$body",
|
||||
"text": "$body",
|
||||
"author": ${toJson(author.output())},
|
||||
"authorStatus": "ourselves",
|
||||
"type": "post",
|
||||
|
||||
@@ -41,6 +41,7 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
fun testOutputAuthor() {
|
||||
val json = """
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"id": ${toJson(author.id.bytes)},
|
||||
"name": "${author.name}",
|
||||
"publicKey": ${toJson(author.publicKey)}
|
||||
|
||||
@@ -30,7 +30,7 @@ internal class ForumControllerTest : ControllerTest() {
|
||||
|
||||
@Test
|
||||
fun create() {
|
||||
every { ctx.body() } returns """{"text": "${forum.name}"}"""
|
||||
every { ctx.body() } returns """{"name": "${forum.name}"}"""
|
||||
every { forumManager.addForum(forum.name) } returns forum
|
||||
every { ctx.json(forum.output()) } returns ctx
|
||||
|
||||
@@ -46,14 +46,14 @@ internal class ForumControllerTest : ControllerTest() {
|
||||
|
||||
@Test
|
||||
fun createEmptyName() {
|
||||
every { ctx.body() } returns """{"text": ""}"""
|
||||
every { ctx.body() } returns """{"name": ""}"""
|
||||
|
||||
assertThrows(BadRequestResponse::class.java) { controller.create(ctx) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createNullName() {
|
||||
every { ctx.body() } returns """{"text": null}"""
|
||||
every { ctx.body() } returns """{"name": null}"""
|
||||
|
||||
assertThrows(BadRequestResponse::class.java) { controller.create(ctx) }
|
||||
}
|
||||
@@ -67,7 +67,7 @@ internal class ForumControllerTest : ControllerTest() {
|
||||
|
||||
@Test
|
||||
fun createTooLongName() {
|
||||
every { ctx.body() } returns """{"text": "${getRandomString(MAX_FORUM_NAME_LENGTH + 1)}"}"""
|
||||
every { ctx.body() } returns """{"name": "${getRandomString(MAX_FORUM_NAME_LENGTH + 1)}"}"""
|
||||
|
||||
assertThrows(BadRequestResponse::class.java) { controller.create(ctx) }
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
fun testOutputPrivateMessageHeader() {
|
||||
val json = """
|
||||
{
|
||||
"body": "$body",
|
||||
"text": "$body",
|
||||
"type": "PrivateMessage",
|
||||
"timestamp": $timestamp,
|
||||
"groupId": ${toJson(header.groupId.bytes)},
|
||||
@@ -180,15 +180,15 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
fun testOutputPrivateMessage() {
|
||||
val json = """
|
||||
{
|
||||
"body": "$body",
|
||||
"text": "$body",
|
||||
"type": "PrivateMessage",
|
||||
"timestamp": ${message.timestamp},
|
||||
"groupId": ${toJson(message.groupId.bytes)},
|
||||
"contactId": ${contact.id.int},
|
||||
"local": true,
|
||||
"seen": true,
|
||||
"seen": false,
|
||||
"read": true,
|
||||
"sent": true,
|
||||
"sent": false,
|
||||
"id": ${toJson(message.id.bytes)}
|
||||
}
|
||||
"""
|
||||
@@ -203,7 +203,7 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
)
|
||||
val json = """
|
||||
{
|
||||
"body": null,
|
||||
"text": null,
|
||||
"type": "IntroductionRequest",
|
||||
"timestamp": $timestamp,
|
||||
"groupId": ${toJson(request.groupId.bytes)},
|
||||
|
||||
Reference in New Issue
Block a user