-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
110 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,96 @@ | ||
package com.vonage.client.kt | ||
|
||
import org.junit.jupiter.api.Test | ||
import java.net.URI | ||
import java.util.UUID | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNotNull | ||
|
||
class VerifyTest : AbstractTest() { | ||
private val verifyClient = vonageClient.verify | ||
private val baseUrl = "/v2/verify" | ||
|
||
@Test | ||
fun `send verification all workflows and parameters`() { | ||
val brand = "Nexmo KT" | ||
val clientRef = "my-personal-reference" | ||
val timeout = 60 | ||
val fraudCheck = false | ||
val sandbox = true | ||
val codeLength = 5 | ||
val locale = "ja-jp" | ||
val whatsappNumber = "447700400080" | ||
val entityId = "1101407360000017170" | ||
val contentId = "1107158078772563946" | ||
val appHash = "ABC123def45" | ||
val toEmail = "alice@example.com" | ||
val fromEmail = "bob@example.org" | ||
val requestId = "c11236f4-00bf-4b89-84ba-88b25df97315" | ||
val checkUrl = "https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect" | ||
val redirectUrl = "https://acme-app.com/sa/redirect" | ||
|
||
mockJsonJwtPostRequestResponse(baseUrl, | ||
expectedRequestParams = mapOf( | ||
"brand" to brand, | ||
"client_ref" to clientRef, | ||
"channel_timeout" to timeout, | ||
"code_length" to codeLength, | ||
"locale" to "ja-jp", | ||
"fraud_check" to fraudCheck, | ||
"workflow" to listOf( | ||
mapOf( | ||
"channel" to "silent_auth", | ||
"to" to toNumber, | ||
"sandbox" to sandbox, | ||
"redirect_url" to redirectUrl | ||
), | ||
mapOf( | ||
"channel" to "voice", | ||
"to" to altNumber | ||
), | ||
mapOf( | ||
"channel" to "sms", | ||
"to" to toNumber, | ||
"from" to altNumber, | ||
"content_id" to contentId, | ||
"entity_id" to entityId, | ||
"app_hash" to appHash | ||
), | ||
mapOf( | ||
"channel" to "email", | ||
"to" to toEmail, | ||
"from" to fromEmail | ||
), | ||
mapOf( | ||
"channel" to "whatsapp", | ||
"to" to altNumber, | ||
"from" to whatsappNumber | ||
), | ||
mapOf( | ||
"channel" to "whatsapp_interactive", | ||
"to" to toNumber, | ||
"from" to whatsappNumber | ||
) | ||
) | ||
), | ||
expectedResponseParams = mapOf( | ||
"request_id" to requestId, | ||
"check_url" to checkUrl | ||
) | ||
) | ||
|
||
val response = verifyClient.sendVerification { | ||
brand(brand); clientRef(clientRef); channelTimeout(timeout) | ||
fraudCheck(fraudCheck); codeLength(codeLength); locale(locale) | ||
silentAuth(toNumber, sandbox, redirectUrl); voice(altNumber); sms(toNumber) { | ||
entityId(entityId); contentId(contentId); appHash(appHash); from(altNumber) | ||
}; email(toEmail, fromEmail) | ||
whatsapp(altNumber, whatsappNumber); whatsappCodeless(toNumber, whatsappNumber) | ||
} | ||
|
||
assertNotNull(response) | ||
assertEquals(UUID.fromString(requestId), response.requestId) | ||
assertEquals(URI.create(checkUrl), response.checkUrl) | ||
} | ||
|
||
} |