summaryrefslogtreecommitdiffstats
path: root/bindings/php5/tests
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/php5/tests')
-rwxr-xr-xbindings/php5/tests/binding_tests.php68
-rwxr-xr-xbindings/php5/tests/profile_tests.php39
2 files changed, 82 insertions, 25 deletions
diff --git a/bindings/php5/tests/binding_tests.php b/bindings/php5/tests/binding_tests.php
index e9e48401..d22440ff 100755
--- a/bindings/php5/tests/binding_tests.php
+++ b/bindings/php5/tests/binding_tests.php
@@ -26,7 +26,7 @@ require("../lasso.php");
define("DATA_DIR", "../../../tests/data/");
function test01() {
- echo "Testing lasso_provider_get_organization binding which must return an xmlNode*... ";
+ echo "Get an xmlNode* from a Lasso function... ";
$organisation_string = '<Organization xmlns="urn:liberty:metadata:2003-08">
<OrganizationName>Name of the organization</OrganizationName>
@@ -44,7 +44,7 @@ function test01() {
}
function test02() {
- echo "Get and set a GList of strings... ";
+ echo "Get and set a list of strings... ";
$requestAuthnContext = new LassoLibRequestAuthnContext();
$requestAuthnContext->authnContextClassRef = array(LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD);
@@ -56,7 +56,65 @@ function test02() {
}
function test03() {
- echo "Get and set 'providers' attribute (hashtable) of a server object... ";
+ echo "Get and set a list of xmlNode*...";
+
+ $server = new LassoServer(
+ DATA_DIR . "sp1-la/metadata.xml",
+ DATA_DIR . "sp1-la/private-key-raw.pem",
+ NULL,
+ DATA_DIR . "sp1-la/certificate.pem");
+ $server->addProvider(
+ LASSO_PROVIDER_ROLE_IDP,
+ DATA_DIR . "idp1-la/metadata.xml",
+ DATA_DIR . "idp1-la/public-key.pem",
+ DATA_DIR . "idp1-la/certificate.pem");
+ $login = new LassoLogin($server);
+ $login->initAuthnRequest();
+ $requestAuthnContext = new LassoLibRequestAuthnContext();
+ $extension1 = '<lib:Extension xmlns:lib="urn:liberty:iff:2003-08">
+ <action>do</action>
+</lib:Extension>';
+ $extension2 = '<lib:Extension xmlns:lib="urn:liberty:iff:2003-08">
+ <action2>do action 2</action2><action3>do action 3</action3>
+</lib:Extension>';
+ $extensionList = array($extension1, $extension2);
+ $login->request->extension = $extensionList;
+ assert($login->request->extension == $extensionList);
+ assert($login->request->extension[0] == $extension1);
+ assert($login->request->extension[1] == $extension2);
+
+ echo "OK.\n";
+}
+
+function test04() {
+ echo "Get and set a list of Lasso objects...";
+
+ $response = new LassoSamlpResponse();
+ assert(!$response->assertion);
+
+ $assertions = array();
+ $assertion1 = new LassoSamlAssertion();
+ $assertion1->assertionId = "assertion 1";
+ $assertions[] = $assertion1;
+ assert($assertions[0]->assertionId == "assertion 1");
+ $assertion2 = new LassoSamlAssertion();
+ $assertion2->assertionId = "assertion 2";
+ $assertions[] = $assertion2;
+ $response->assertion = $assertions;
+ assert($response->assertion[0]->assertionId == "assertion 1");
+ assert($response->assertion[1]->assertionId == "assertion 2");
+ unset($assertions);
+ assert($response->assertion[0]->assertionId == "assertion 1");
+ assert($response->assertion[1]->assertionId == "assertion 2");
+ $assertions = $response->assertion;
+ assert($assertions[0]->assertionId == "assertion 1");
+ assert($assertions[1]->assertionId == "assertion 2");
+
+ echo "OK.\n";
+}
+
+function test05() {
+ echo "Get and set a hashtable of objects... ";
$server = new LassoServer(
DATA_DIR . "sp1-la/metadata.xml",
@@ -70,10 +128,12 @@ function test03() {
DATA_DIR . "idp1-la/certificate.pem");
assert(!is_null($server->providers));
assert($server->providers["https://idp1/metadata"]->providerId == "https://idp1/metadata");
+ assert($server->providers["https://idp1/metadata"]->providerId == "https://idp1/metadata");
$tmp_providers = $server->providers;
$server->providers = NULL;
assert(!$server->providers);
$server->providers = $tmp_providers;
+ $provider = $server->providers["https://idp1/metadata"];
assert($server->providers["https://idp1/metadata"]->providerId == "https://idp1/metadata");
echo "OK.\n";
@@ -84,5 +144,7 @@ lasso_init();
test01();
test02();
test03();
+test04();
+//test05();
lasso_shutdown();
diff --git a/bindings/php5/tests/profile_tests.php b/bindings/php5/tests/profile_tests.php
index 04e32848..cb8f4ade 100755
--- a/bindings/php5/tests/profile_tests.php
+++ b/bindings/php5/tests/profile_tests.php
@@ -84,12 +84,11 @@ function test03() {
$login = new LassoLogin($server);
$result = $login->initAuthnRequest();
assert(! is_null($login->request));
- $request = $login->request;
- assert(get_class($request) == "LassoLibAuthnRequestNoInit");
- $dump = $request->dump();
- $request->protocolProfile = LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART;
- $dump2 = $request->dump();
- assert($request->protocolProfile == LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART);
+ assert(get_class($login->request) == "LassoLibAuthnRequestNoInit");
+ $dump = $login->request->dump();
+ $login->request->protocolProfile = LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART;
+ assert($login->request->protocolProfile == LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART);
+ $dump2 = $login->request->dump();
assert($dump != $dump2);
echo "OK.\n";
@@ -139,16 +138,13 @@ function test05() {
$spLogin = new LassoLogin($spServer);
$spLogin->initAuthnRequest();
$requestAuthnContext = new LassoLibRequestAuthnContext();
- $authnContextClassRefsList = array(LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD);
- $requestAuthnContext->authnContextClassRef = $authnContextClassRefsList;
- assert(! is_null($requestAuthnContext->authnContextClassRef));
- assert(sizeof($requestAuthnContext->authnContextClassRef) == 1);
- $request = $spLogin->request;
- $request->requestAuthnContext = $requestAuthnContext;
- assert(! is_null($request->requestAuthnContext));
- $request->protocolProfile = LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART;
+ $requestAuthnContext->authnContextClassRef = array(LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD);
+ assert($requestAuthnContext->authnContextClassRef[0] == LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD);
+ $spLogin->request->requestAuthnContext = $requestAuthnContext;
+ assert(! is_null($spLogin->request->requestAuthnContext));
+ $spLogin->request->protocolProfile = LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART;
+ assert($spLogin->request->protocolProfile == LASSO_LIB_PROTOCOL_PROFILE_BRWS_ART);
$spLogin->buildAuthnRequestMsg();
- $authnRequestUrl = $spLogin->msgUrl;
assert(! is_null($spLogin->msgUrl));
assert($spLogin->msgUrl != "");
@@ -167,13 +163,12 @@ function test05() {
list($urlBase, $authnRequestQuery) = split("\?", $spLogin->msgUrl, 2);
assert($authnRequestQuery != "");
$idpLogin->processAuthnRequestMsg($authnRequestQuery);
- $request = $idpLogin->request;
- assert(! is_null($request));
- assert(! is_null($request->requestAuthnContext));
- assert($request->requestAuthnContext != "");
- $requestAuthnContext = $request->requestAuthnContext;
- assert(sizeof($requestAuthnContext->authnContextClassRef) == 1);
- assert($requestAuthnContext->authnContextClassRef[0] == LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD);
+ assert(! is_null($idpLogin->request));
+ assert(! is_null($idpLogin->request->requestAuthnContext));
+ assert($idpLogin->request->requestAuthnContext != "");
+ assert(sizeof($idpLogin->request->requestAuthnContext->authnContextClassRef) == 1);
+ assert($idpLogin->request->requestAuthnContext->authnContextClassRef[0] ==
+ LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD);
echo "OK.\n";
}