-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
165 additions
and
50 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
17 changes: 17 additions & 0 deletions
17
Model/src/test/java/org/gluu/oxauth/model/util/Tester.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,17 @@ | ||
package org.gluu.oxauth.model.util; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
public class Tester { | ||
private Tester() { | ||
} | ||
|
||
public static void showTitle(String title) { | ||
title = "TEST: " + title; | ||
|
||
System.out.println("#######################################################"); | ||
System.out.println(title); | ||
System.out.println("#######################################################"); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Model/src/test/java/org/gluu/oxauth/model/util/URLPatternListTest.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,54 @@ | ||
package org.gluu.oxauth.model.util; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.gluu.oxauth.model.util.Tester.showTitle; | ||
import static org.testng.Assert.assertTrue; | ||
import static org.testng.AssertJUnit.assertFalse; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
public class URLPatternListTest { | ||
|
||
@Test | ||
public void isUrlListed_forUrlWithWildcard_shouldMatch() { | ||
showTitle("isUrlListed_forUrlWithWildcard_shouldMatch"); | ||
|
||
List<String> urlPatterns = Collections.singletonList("*.gluu.org"); | ||
|
||
URLPatternList urlPatternList = new URLPatternList(urlPatterns, true); | ||
assertTrue(urlPatternList.isUrlListed("https://*.gluu.org")); | ||
assertTrue(urlPatternList.isUrlListed("https://abc.gluu.org")); | ||
} | ||
|
||
@Test | ||
public void isUrlListed_forUrlWithoutWildcardSupport_shouldFail() { | ||
showTitle("isUrlListed_forUrlWithoutWildcardSupport_shouldFail"); | ||
|
||
List<String> urlPatterns = Collections.singletonList("*.gluu.org"); | ||
|
||
URLPatternList urlPatternList = new URLPatternList(urlPatterns, false); | ||
assertFalse(urlPatternList.isUrlListed("https://*.gluu.org")); | ||
assertTrue(urlPatternList.isUrlListed("https://abc.gluu.org")); | ||
} | ||
|
||
|
||
@Test | ||
public void isUrlListed_forAllowAll_shouldMatch() { | ||
showTitle("isUrlListed_forAllowAll_shouldMatch"); | ||
|
||
List<String> urlPatterns = Collections.singletonList("*"); | ||
|
||
URLPatternList urlPatternList = new URLPatternList(urlPatterns, true); | ||
assertTrue(urlPatternList.isUrlListed("https://*.gluu.org")); | ||
assertTrue(urlPatternList.isUrlListed("https://abc.gluu.org")); | ||
|
||
urlPatternList = new URLPatternList(urlPatterns, false); | ||
assertTrue(urlPatternList.isUrlListed("https://*.gluu.org")); | ||
assertTrue(urlPatternList.isUrlListed("https://abc.gluu.org")); | ||
} | ||
} |
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