Skip to content

Commit

Permalink
test: Redact API
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jul 8, 2024
1 parent 81262d3 commit c414c39
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion src/test/kotlin/com/vonage/client/kt/RedactTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,70 @@
package com.vonage.client.kt

import com.vonage.client.redact.RedactRequest
import com.vonage.client.redact.RedactRequest.Type.*
import kotlin.test.*

class RedactTest : AbstractTest() {
private val redactClient = vonage.redact
private val transactionId = "209ab3c7536542b91e8b5aef032f6861"

private fun testSuccess(product: String, type: RedactRequest.Type? = null, invocation: Redact.() -> Unit) {
mockPost(
expectedUrl = "/v1/redact/transaction", status = 204,
authType = AuthType.API_KEY_SECRET_HEADER, expectedRequestParams = mapOf(
"id" to transactionId,
"product" to product
) + if (type != null) mapOf("type" to type.name.lowercase()) else mapOf()
)
invocation.invoke(vonage.redact)
}

@Test
fun `redact SMS`() {
val product = "sms"
testSuccess(product, OUTBOUND) {
redactSms(transactionId)
redactSms(transactionId, OUTBOUND)
}
testSuccess(product, INBOUND) {
redactSms(transactionId, INBOUND)
}
}

@Test
fun `redact message`() {
val product = "messages"
testSuccess(product, OUTBOUND) {
redactMessage(transactionId)
redactMessage(transactionId, OUTBOUND)
}
testSuccess(product, INBOUND) {
redactMessage(transactionId, INBOUND)
}
}

@Test
fun `redact call`() {
val product = "voice"
testSuccess(product, OUTBOUND) {
redactCall(transactionId)
redactCall(transactionId, OUTBOUND)
}
testSuccess(product, INBOUND) {
redactCall(transactionId, INBOUND)
}
}

@Test
fun `redact insight`() {
testSuccess("number-insight") {
redactInsight(transactionId)
}
}

@Test
fun `redact verification`() {
testSuccess("verify") {
redactVerification(transactionId)
}
}
}

0 comments on commit c414c39

Please sign in to comment.