-
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.
fix: jwt can be used at initialization
- Loading branch information
github-actions
committed
Feb 15, 2024
1 parent
b44d038
commit c40baae
Showing
6 changed files
with
92 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,12 @@ import org.apache.commons.lang3.RandomStringUtils | |
import org.assertj.core.api.Assertions.assertThat | ||
import org.awaitility.Awaitility.await | ||
import org.awaitility.Duration | ||
import org.json.JSONObject | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.time.Instant | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ExtoleSdkTests { | ||
|
||
|
@@ -414,4 +414,71 @@ class ExtoleSdkTests { | |
assertThat(emailAfterIdentify).isEqualTo("null") | ||
} | ||
|
||
@Test | ||
fun testIdentifyJwtAtInit() { | ||
val jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6IjUzNmQwNWE2LTMzZWUtNDI2NC04ODI2LW" + | ||
"JhZDRjOTAyMWZhZiJ9.eyJpc3MiOiJtb2JpbGUtc2RrLmV4dG9sZS5jb20iLCJhdWQiOlsiZXh0b2xlLmNvbSJ" + | ||
"dLCJlbWFpbCI6InNka3BlcnNvbi1lbWFpbEBtYWlsb3NhdXIuY29tIiwiaWF0IjoxNzA1NTg0Mjg0LCJleHAiO" + | ||
"jI0ODMxODQyODR9.XdB5-j58GcEeKqKkCLd5f_G78CLLJIHCmsfcOpH-n3o" | ||
val extole = | ||
runBlocking { | ||
return@runBlocking Extole.init( | ||
"mobile-monitor.extole.io", | ||
context = context, appName = "mobile-monitor", labels = setOf("business"), | ||
data = mapOf("version" to "1.0"), | ||
jwt = jwt | ||
) | ||
} | ||
|
||
val emailBeforeIdentify = runBlocking { | ||
val (ctaZone, _) = extole.fetchZone("mobile_cta_timestamp") | ||
ctaZone?.get("email").toString() | ||
} | ||
assertThat(emailBeforeIdentify).isEqualTo("[email protected]") | ||
} | ||
|
||
@Test | ||
fun testIdentifyJwtWithoutEmailAndEmailPassedAsASeparateParameter() { | ||
val jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6IjUzNmQwNWE2LTMzZWUtNDI2NC04ODI2" + | ||
"LWJhZDRjOTAyMWZhZiJ9.eyJpc3MiOiJtb2JpbGUtc2RrLmV4dG9sZS5jb20iLCJhdWQiOlsiZXh0b2xlLmN" + | ||
"vbSJdLCJpYXQiOjE3MDU5MjQwMDksImV4cCI6MjQ4MzUyNDAwOX0.X2GnR6OV9amojSLSzoXeecoujrnMzyY" + | ||
"As5VWzR86U4M" | ||
val extole = | ||
runBlocking { | ||
return@runBlocking Extole.init( | ||
"mobile-monitor.extole.io", | ||
context = context, appName = "mobile-monitor", labels = setOf("business"), | ||
data = mapOf("version" to "1.0"), | ||
email = "[email protected]", | ||
jwt = jwt | ||
) | ||
} | ||
|
||
val personEmail = runBlocking { | ||
val (ctaZone, _) = extole.fetchZone("mobile_cta_timestamp") | ||
ctaZone?.get("email").toString() | ||
} | ||
assertThat(personEmail).isEqualTo("[email protected]") | ||
} | ||
|
||
@Test | ||
fun testIdentifyJwtAtInitWithoutEmailIsInitializedAsAnonymous() { | ||
val jwt = "invalid_jwt" | ||
val extole = | ||
runBlocking { | ||
return@runBlocking Extole.init( | ||
"mobile-monitor.extole.io", | ||
context = context, appName = "mobile-monitor", labels = setOf("business"), | ||
data = mapOf("version" to "1.0"), | ||
jwt = jwt | ||
) | ||
} | ||
|
||
val personEmail = runBlocking { | ||
val (ctaZone, _) = extole.fetchZone("mobile_cta_timestamp") | ||
ctaZone?.get("email").toString() | ||
} | ||
assertThat(personEmail).isEqualTo("null") | ||
} | ||
|
||
} |
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
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
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