You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/08/14 21:47:45 UTC
[22/30] git commit: updated refs/heads/master to 64ff67d
CLOUDSTACK-8656: validate the throwing of ServerApiException
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2eee6aa9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2eee6aa9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2eee6aa9
Branch: refs/heads/master
Commit: 2eee6aa999fca2805201bf4c7a772cf0c179bacb
Parents: de2d78b
Author: Daan Hoogland <da...@onecht.net>
Authored: Fri Aug 14 15:13:39 2015 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Aug 14 15:13:39 2015 +0200
----------------------------------------------------------------------
.../api/command/SAML2LoginAPIAuthenticatorCmdTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2eee6aa9/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java
index 0c72512..36140f2 100644
--- a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java
+++ b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java
@@ -19,12 +19,15 @@
package org.apache.cloudstack.api.command;
+import static org.junit.Assert.assertFalse;
+
import com.cloud.domain.Domain;
import com.cloud.user.AccountService;
import com.cloud.user.DomainManager;
import com.cloud.user.UserAccountVO;
import com.cloud.user.dao.UserAccountDao;
import com.cloud.utils.HttpUtils;
+
import org.apache.cloudstack.api.ApiServerService;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.ServerApiException;
@@ -64,6 +67,7 @@ import org.opensaml.saml2.core.impl.SubjectBuilder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+
import java.lang.reflect.Field;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
@@ -154,8 +158,6 @@ public class SAML2LoginAPIAuthenticatorCmdTest {
userAccountDaoField.setAccessible(true);
userAccountDaoField.set(cmd, userAccountDao);
- String spId = "someSPID";
- String url = "someUrl";
KeyPair kp = SAMLUtils.generateRandomKeyPair();
X509Certificate cert = SAMLUtils.generateRandomX509Certificate(kp);
@@ -187,10 +189,13 @@ public class SAML2LoginAPIAuthenticatorCmdTest {
// SSO SAMLResponse verification test, this should throw ServerApiException for auth failure
params.put(SAMLPluginConstants.SAML_RESPONSE, new String[]{"Some String"});
Mockito.stub(cmd.processSAMLResponse(Mockito.anyString())).toReturn(buildMockResponse());
+ boolean failing = true;
try {
cmd.authenticate("command", params, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), req, resp);
} catch (ServerApiException ignored) {
+ failing = false;
}
+ assertFalse("authentication should not have succeeded", failing);
Mockito.verify(userAccountDao, Mockito.times(0)).getUserAccount(Mockito.anyString(), Mockito.anyLong());
Mockito.verify(apiServer, Mockito.times(0)).verifyUser(Mockito.anyLong());
}