From 797613979cc7d439143d1d4a50ee524fa080ecf1 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Fri, 13 Aug 2021 16:33:41 +0300 Subject: [PATCH] Restored WkdClientTest with a few changes.| #1201 --- .../email/api/email/WkdClientTest.kt | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 FlowCrypt/src/test/java/com/flowcrypt/email/api/email/WkdClientTest.kt diff --git a/FlowCrypt/src/test/java/com/flowcrypt/email/api/email/WkdClientTest.kt b/FlowCrypt/src/test/java/com/flowcrypt/email/api/email/WkdClientTest.kt new file mode 100644 index 0000000000..1cc2178384 --- /dev/null +++ b/FlowCrypt/src/test/java/com/flowcrypt/email/api/email/WkdClientTest.kt @@ -0,0 +1,52 @@ +/* + * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com + * Contributors: + * Ivan Pizhenko + * DenBond7 + */ + +package com.flowcrypt.email.api.email + +import com.flowcrypt.email.api.wkd.WkdClient +import kotlinx.coroutines.runBlocking +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment + +@RunWith(RobolectricTestRunner::class) +class WkdClientTest { + @Test + fun existingEmailTest() = runBlocking { + val keys = + WkdClient.lookupEmail(RuntimeEnvironment.getApplication(), "human@flowcrypt.com") + assertTrue("Key not found", keys != null) + assertTrue("There are no keys in the key collection", keys!!.keyRings.hasNext()) + } + + @Test + fun nonExistingEmailTest1() = runBlocking { + val keys = WkdClient.lookupEmail( + RuntimeEnvironment.getApplication(), + "no.such.email.for.sure@flowcrypt.com" + ) + assertTrue("Key found for non-existing email", keys == null) + } + + @Test + fun nonExistingEmailTest2() = runBlocking { + val keys = WkdClient.lookupEmail(RuntimeEnvironment.getApplication(), "doesnotexist@google.com") + assertTrue("Key found for non-existing email", keys == null) + } + + @Test + fun nonExistingDomainTest() = runBlocking { + val keys = WkdClient.lookupEmail( + RuntimeEnvironment.getApplication(), + "doesnotexist@thisdomaindoesnotexist.test" + ) + assertTrue("Key found for non-existing email", keys == null) + } +} +