summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Raviart <eraviart@entrouvert.com>2004-07-22 08:37:09 +0000
committerEmmanuel Raviart <eraviart@entrouvert.com>2004-07-22 08:37:09 +0000
commitc2dc90e2e99a83a1d80042c0405ecba94ad01845 (patch)
tree329fb42f4f50fedf6c52d98d4fc1a5cd840c507c
parent255f09ed98f1e554093dce03c384bf5c4dbea091 (diff)
downloadlasso-c2dc90e2e99a83a1d80042c0405ecba94ad01845.tar.gz
lasso-c2dc90e2e99a83a1d80042c0405ecba94ad01845.tar.xz
lasso-c2dc90e2e99a83a1d80042c0405ecba94ad01845.zip
Java & Python tests do not regress. They even progress.
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoLogin.c2
-rw-r--r--java/src/java/com/entrouvert/lasso/Lasso.java10
-rw-r--r--java/src/java/com/entrouvert/lasso/LassoLogin.java2
-rw-r--r--java/tests/LoginTest.java14
-rw-r--r--python/tests/.cvsignore1
-rw-r--r--python/tests/login_tests.py25
6 files changed, 45 insertions, 9 deletions
diff --git a/java/src/c/com_entrouvert_lasso_LassoLogin.c b/java/src/c/com_entrouvert_lasso_LassoLogin.c
index a3dd9f74..e0a726c0 100644
--- a/java/src/c/com_entrouvert_lasso_LassoLogin.c
+++ b/java/src/c/com_entrouvert_lasso_LassoLogin.c
@@ -201,7 +201,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_initRequest
return result;
}
-JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_mustAuthenticate
+JNIEXPORT jboolean JNICALL Java_com_entrouvert_lasso_LassoLogin_mustAuthenticate
(JNIEnv * env, jobject this){
int result;
LassoLogin* login;
diff --git a/java/src/java/com/entrouvert/lasso/Lasso.java b/java/src/java/com/entrouvert/lasso/Lasso.java
index a1d5700d..884dfcbf 100644
--- a/java/src/java/com/entrouvert/lasso/Lasso.java
+++ b/java/src/java/com/entrouvert/lasso/Lasso.java
@@ -30,6 +30,16 @@ public class Lasso { // Lasso
System.loadLibrary("jlasso");
}
+ static final public int httpMethodGet = 1;
+ static final public int httpMethodPost = 2;
+ static final public int httpMethodRedirect = 3;
+ static final public int httpMethodSoap = 4;
+
+ /* Consent */
+ static final public String libConsentObtained = "urn:liberty:consent:obtained";
+ static final public String libConsentUnavailable = "urn:liberty:consent:unavailable";
+ static final public String libConsentInapplicable = "urn:liberty:consent:inapplicable";
+
/* NameIDPolicyType */
static final public String libNameIdPolicyTypeNone = "none";
static final public String libNameIdPolicyTypeOneTime = "onetime";
diff --git a/java/src/java/com/entrouvert/lasso/LassoLogin.java b/java/src/java/com/entrouvert/lasso/LassoLogin.java
index 91d59406..d8229543 100644
--- a/java/src/java/com/entrouvert/lasso/LassoLogin.java
+++ b/java/src/java/com/entrouvert/lasso/LassoLogin.java
@@ -67,7 +67,7 @@ public class LassoLogin extends LassoProfileContext { // LassoLogin
native public int initRequest(String responseMsg,
int responseMethod);
- native public int mustAuthenticate();
+ native public boolean mustAuthenticate();
native public int processAuthnResponseMsg(String authnResponseMsg);
diff --git a/java/tests/LoginTest.java b/java/tests/LoginTest.java
index d4455f34..018e8545 100644
--- a/java/tests/LoginTest.java
+++ b/java/tests/LoginTest.java
@@ -77,6 +77,7 @@ public class LoginTest extends TestCase {
}
public void test02_serviceProviderLogin() {
+ // Service provider login using HTTP redirect.
String spContextDump = generateServiceProviderContextDump();
assertNotNull(spContextDump);
LassoServer spContext = new LassoServer(spContextDump);
@@ -86,9 +87,20 @@ public class LoginTest extends TestCase {
LassoAuthnRequest authnRequest = (LassoAuthnRequest) spLoginContext.getRequest();
authnRequest.setPassive(false);
authnRequest.setNameIdPolicy(Lasso.libNameIdPolicyTypeFederated);
- // FIXME authnRequest.setConsent(Lasso.libConsentObtained);
+ authnRequest.setConsent(Lasso.libConsentObtained);
authnRequest.setRelayState("fake");
assertEquals(spLoginContext.buildAuthnRequestMsg(), 0);
+ String authnRequestUrl = spLoginContext.getMsgUrl();
+ String authnRequestMsg = authnRequestUrl.substring(authnRequestUrl.indexOf("?") + 1);
+ int method = Lasso.httpMethodRedirect;
+
+ // Identity provider singleSignOn, for a user having no federation.
+ String idpContextDump = generateIdentityProviderContextDump();
+ assertNotNull(idpContextDump);
+ LassoServer idpContext = new LassoServer(idpContextDump);
+ LassoLogin idpLoginContext = new LassoLogin(idpContext, null);
+ assertEquals(idpLoginContext.initFromAuthnRequestMsg(authnRequestMsg, method), 0);
+ assertTrue(idpLoginContext.mustAuthenticate());
}
public static Test suite() {
diff --git a/python/tests/.cvsignore b/python/tests/.cvsignore
new file mode 100644
index 00000000..0d20b648
--- /dev/null
+++ b/python/tests/.cvsignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/python/tests/login_tests.py b/python/tests/login_tests.py
index 6d88588c..258e3269 100644
--- a/python/tests/login_tests.py
+++ b/python/tests/login_tests.py
@@ -77,19 +77,32 @@ class LoginTestCase(unittest.TestCase):
self.failUnless(serviceProviderContextDump)
def test02_serviceProviderLogin(self):
+ """Service provider initiated login"""
+
+ # Service provider login using HTTP redirect.
spContextDump = self.generateServiceProviderContextDump()
self.failUnless(spContextDump)
spContext = lasso.Server.new_from_dump(spContextDump)
spLoginContext = lasso.Login.new(spContext)
- self.failIf(spLoginContext.init_authn_request(
- "https://identity-provider:1998/liberty-alliance/metadata"))
+ self.failUnlessEqual(spLoginContext.init_authn_request(
+ "https://identity-provider:1998/liberty-alliance/metadata"), 0)
spLoginContext.request.set_isPassive(False)
spLoginContext.request.set_nameIDPolicy(lasso.libNameIDPolicyTypeFederated)
- # FIXME spLoginContext.request.set_consent(lasso.libConsentObtained)
+ spLoginContext.request.set_consent(lasso.libConsentObtained)
spLoginContext.request.set_relayState("fake")
- self.failIf(spLoginContext.build_authn_request_msg())
- # spLoginContext.msg_url
-
+ self.failUnlessEqual(spLoginContext.build_authn_request_msg(), 0)
+ authnRequestUrl = spLoginContext.msg_url
+ authnRequestMsg = authnRequestUrl.split("?", 1)[1]
+ method = lasso.httpMethodRedirect
+
+ # Identity provider singleSignOn, for a user having no federation.
+ idpContextDump = self.generateIdentityProviderContextDump()
+ self.failUnless(idpContextDump)
+ idpContext = lasso.Server.new_from_dump(idpContextDump)
+ idpLoginContext = lasso.Login.new(idpContext)
+ self.failUnlessEqual(idpLoginContext.init_from_authn_request_msg(authnRequestMsg, method),
+ 0)
+ self.failUnless(idpLoginContext.must_authenticate())
suite1 = unittest.makeSuite(LoginTestCase, 'test')