Skip to content

Commit

Permalink
fixing server embedded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Nov 16, 2015
1 parent e461347 commit a460c1d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.xdi.oxauth.model.token.ClientAssertionType;
import org.xdi.oxauth.model.token.TokenErrorResponseType;
import org.xdi.oxauth.model.util.Util;
import org.xdi.oxauth.service.AuthenticationService;
import org.xdi.oxauth.service.ClientService;
import org.xdi.oxauth.service.SessionIdService;
import org.xdi.util.StringHelper;
Expand All @@ -41,7 +40,6 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
Expand Down Expand Up @@ -74,7 +72,8 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
@Override
public void process() {
try {
if (httpRequest.getRequestURL().toString().equals(ConfigurationFactory.instance().getConfiguration().getTokenEndpoint())) {
final String requestUrl = httpRequest.getRequestURL().toString();
if (requestUrl.equals(ConfigurationFactory.instance().getConfiguration().getTokenEndpoint()) || isLocalEmbeddedTest(requestUrl)) {
if (httpRequest.getParameter("client_assertion") != null
&& httpRequest.getParameter("client_assertion_type") != null) {
processJwtAuth(httpRequest, httpResponse, filterChain);
Expand Down Expand Up @@ -116,6 +115,11 @@ public void process() {
}.run();
}

private boolean isLocalEmbeddedTest(String requestUrl) {
return Boolean.parseBoolean(System.getProperty("seam.local.test")) &&
requestUrl.equals("http://localhost:80/seam/resource/restv1/oxauth/token");
}

private void processSessionAuth(String p_sessionId, SessionIdService sessionIdService, HttpServletRequest p_httpRequest, HttpServletResponse p_httpResponse, FilterChain p_filterChain) throws IOException, ServletException {
boolean requireAuth;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private boolean load(String clientId, ClientAssertionType clientAssertionType, S
throw new InvalidJwtException("JWT has expired");
}
} else {
throw new InvalidJwtException("Invalid audience");
throw new InvalidJwtException("Invalid audience: " + audience + ", tokenUrl: " + tokenUrl);
}
} else {
throw new InvalidJwtException("Invalid clientId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ public int executeExternalGetApiVersion(CustomScriptConfiguration customScriptCo
}

public boolean isEnabled(AuthenticationScriptUsageType usageType) {
return this.customScriptConfigurationsMapByUsageType.get(usageType).size() > 0;
return this.customScriptConfigurationsMapByUsageType != null &&
this.customScriptConfigurationsMapByUsageType.get(usageType).size() > 0;
}

public CustomScriptConfiguration getExternalAuthenticatorByAuthLevel(AuthenticationScriptUsageType usageType, int authLevel) {
Expand Down
6 changes: 3 additions & 3 deletions Server/src/test/resources/testng.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ federationMetadataPath=/restv1/oxauth/federationmetadata
federationPath=/restv1/oxauth/federation
idGenerationPath=/restv1/id
introspectionPath=/restv1/introspection
userId=${auth.user.uid}
userSecret=${auth.user.password}
userInum=${auth.user.inum}
userId=yuriy
userSecret=secret
userInum=@!1111!0000!DDD1
userEmail=${auth.user.email}
clientId=${auth.client.id}
clientSecret=${auth.client.secret}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@
<skipTests>false</skipTests>
<failIfNoTests>false</failIfNoTests>
<trimStackTrace>false</trimStackTrace>
<argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
<argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true -Dseam.local.test=true</argLine>
<suiteXmlFiles>
<suiteXmlFile>target/test-classes/testng.xml</suiteXmlFile>
</suiteXmlFiles>
Expand Down Expand Up @@ -748,7 +748,7 @@
<skipTests>false</skipTests>
<failIfNoTests>false</failIfNoTests>
<trimStackTrace>false</trimStackTrace>
<argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
<argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true -Dseam.local.test=true</argLine>
<suiteXmlFiles>
<suiteXmlFile>target/test-classes/testng-benchmark.xml</suiteXmlFile>
</suiteXmlFiles>
Expand Down

0 comments on commit a460c1d

Please sign in to comment.