1package com.peachpasswords.feedback23import org.json.JSONObject4import org.junit.Assert.assertEquals5import org.junit.Assert.assertTrue6import org.junit.Test789101112class FeedbackSubmissionTest {1314 private fun submission(type: String = "bug", message: String = "the thing broke") =15 JSONObject(FeedbackRepository.buildSubmission(type, message, version = "9.9.9"))1617 @Test18 fun `carries the access key, the category and the message, and nothing else`() {19 val json = submission()20 assertEquals(21 setOf("access_key", "subject", "message", "from_name", "botcheck"),22 json.keys().asSequence().toSet(),23 )24 assertEquals(FeedbackRepository.WEB3FORMS_KEY, json.getString("access_key"))25 assertEquals("the thing broke", json.getString("message"))26 assertEquals("Peach Feedback - bug (Android 9.9.9)", json.getString("subject"))27 }2829 @Test30 fun `sends no device or user identifier`() {31 val body = FeedbackRepository.buildSubmission("bug", "hello").lowercase()32 for (leak in listOf("device_id", "deviceid", "vault", "email", "androidid", "serial")) {33 assertTrue("payload must not carry $leak", !body.contains(leak))34 }35 }3637 @Test38 fun `the honeypot ships empty, or Web3Forms drops the submission`() {39 assertEquals("", submission().getString("botcheck"))40 }4142 @Test43 fun `posts to the same inbox as the extension`() {44 assertEquals("https://api.web3forms.com/submit", FeedbackRepository.ENDPOINT)45 }46}