-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove DisallowedUriList and AllowedUriList in favour of using UriLis…
…t for both allowing and disallowing URIs
- Loading branch information
Showing
7 changed files
with
72 additions
and
169 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
39 changes: 0 additions & 39 deletions
39
library/src/main/java/dev/gerlot/securewebview/uri/AllowedUriList.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
library/src/main/java/dev/gerlot/securewebview/uri/DisallowedUriList.java
This file was deleted.
Oops, something went wrong.
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
40 changes: 0 additions & 40 deletions
40
library/src/test/java/dev/gerlot/securewebview/uri/AllowedUriListTest.java
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
library/src/test/java/dev/gerlot/securewebview/uri/DisallowedUriListTest.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
library/src/test/java/dev/gerlot/securewebview/uri/UriListTest.java
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.gerlot.securewebview.uri; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import android.net.Uri; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
public class UriListTest { | ||
|
||
@Test | ||
public void testMatches_emptyUriList() { | ||
UriList uriList = new UriList(); | ||
assertFalse(uriList.matches(new Uri.Builder().authority("google.com").build())); | ||
assertFalse(uriList.matches(new Uri.Builder().authority("bing.com").appendPath("search").build())); | ||
} | ||
|
||
@Test | ||
public void testMatches_GoogleOnly() { | ||
UriList uriList = new UriList(uri -> Objects.equals(uri.getAuthority(), "google.com")); | ||
assertTrue(uriList.matches(new Uri.Builder().authority("google.com").build())); | ||
assertFalse(uriList.matches(new Uri.Builder().authority("bing.com").appendPath("search").build())); | ||
} | ||
|
||
@Test | ||
public void testMatches_GoogleAndBing() { | ||
UriList uriList = new UriList(List.of(uri -> Objects.equals(uri.getAuthority(), "google.com"), uri -> Objects.equals(uri.getAuthority(), "bing.com"))); | ||
assertTrue(uriList.matches(new Uri.Builder().authority("google.com").build())); | ||
assertTrue(uriList.matches(new Uri.Builder().authority("bing.com").appendPath("search").build())); | ||
assertFalse(uriList.matches(new Uri.Builder().authority("duckduckgo.com").appendPath("search").build())); | ||
} | ||
|
||
} |