-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(uri-util): refactor uri scheme checker (WPB-3554) (#2090)
(cherry picked from commit 8f8ff33)
- Loading branch information
Showing
3 changed files
with
43 additions
and
12 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
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
package com.wire.android.util | ||
|
||
import com.wire.android.string | ||
import org.junit.Ignore | ||
import org.amshove.kluent.internal.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import kotlin.random.Random | ||
|
||
|
@@ -28,32 +28,55 @@ class UriUtilTest { | |
val input = "https://google.com" | ||
val expected = "https://google.com" | ||
val actual = normalizeLink(input) | ||
assert(expected == actual) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun givenLink_whenTheLinkStartsWithHttp_thenReturnsTheSameLink() { | ||
val input = "http://google.com" | ||
val expected = "http://google.com" | ||
val actual = normalizeLink(input) | ||
assert(expected == actual) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun givenLink_whenTheLinkStartsWithMailTo_thenReturnsTheSameLink() { | ||
val input = "mailto:[email protected]" | ||
val expected = "mailto:[email protected]" | ||
val actual = normalizeLink(input) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun givenLink_whenTheLinkIsWireDeepLink_thenReturnsTheSameLink() { | ||
val input = "wire://access/?config=https://nginz-https.elna.wire.link/deeplink.json" | ||
val expected = "wire://access/?config=https://nginz-https.elna.wire.link/deeplink.json" | ||
val actual = normalizeLink(input) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
@Ignore | ||
fun givenLink_whenTheLinkStartsWithRandomSchema_thenReturnsTheSameLink() { | ||
val randomString = Random.string(Random.nextInt(5)) | ||
val randomString = Random.string(Random.nextInt(1, 5)) | ||
val input = "$randomString://google.com" | ||
val expected = "$randomString://google.com" | ||
val actual = normalizeLink(input) | ||
assert(expected == actual) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun givenLink_whenTheLinkWithoutSchema_thenReturnsTheLinkWithHttps() { | ||
val input = Random.string(Random.nextInt(20)) | ||
val input = Random.string(Random.nextInt(1, 20)) | ||
val expected = "https://$input" | ||
val actual = normalizeLink(input) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun givenLink_whenTheLinkIsValidWithoutSchema_thenReturnsTheLinkWithHttps() { | ||
val input = "google.com" | ||
val expected = "https://$input" | ||
val actual = normalizeLink(input) | ||
assert(expected == actual) | ||
assertEquals(expected, actual) | ||
} | ||
} |