Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Nov 15, 2024
1 parent 2de4bd5 commit 019de32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public boolean allowed(HttpServletRequest request) throws URISyntaxException {
public boolean validateDomain(String url) throws URISyntaxException {
URI uri = new URI(url);
String domain = uri.getHost();
for (String allowedDomain : getAllowedDomainsRegex()) {
if (domain.matches(allowedDomain)) {
return true;
if(domain != null) {
for (String allowedDomain : getAllowedDomainsRegex()) {
if (domain.matches(allowedDomain)) {
return true;
}
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CrossDomainWebMangerTest {
CrossDomainWebManger crossDomainWebManger;

String [] allowedDomains = {"http://localhost", "https://localhost"};
String [] forbiddenDomains = {"http://.orcid.org", "http://www.otherorcid.org", "http://www.myorcid.org", "http://www.ihateorcid.org", "http://qa.ihateorcid.org", "https://.orcid.org", "https://www.otherorcid.org", "https://www.myorcid.org", "https://www.ihateorcid.org", "https://qa.ihateorcid.org"};
String [] forbiddenDomains = {"http://.orcid.org", "http://www.otherorcid.org", "http://www.myorcid.org", "http://www.testorcid.org", "http://qa.testorcid.org", "https://.orcid.org", "https://www.otherorcid.org", "https://www.myorcid.org", "https://www.testorcid.org", "https://qa.testorcid.org"};

String [] allowedPaths = {"/lang.json","/userStatus.json","/oauth/userinfo","/oauth/jwks","/.well-known/openid-configuration"};
String [] forbiddenPaths = {"/oauth","/whatever/oauth","/whatever/oauth/","/whatever/oauth/other",
Expand Down Expand Up @@ -54,9 +54,4 @@ public void testPaths() throws URISyntaxException {
assertFalse("Testing: " + forbidden, crossDomainWebManger.validatePath(forbidden));
}
}

@Test
public void failTest() {
fail();
}
}

0 comments on commit 019de32

Please sign in to comment.