summaryrefslogtreecommitdiffstats
path: root/bindings/php5/tests/profile_tests.php
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:04:32 +0000
committerFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:04:32 +0000
commitc8762f405baaac8cbb6475b39d4fbd701a34060a (patch)
treeeb2ab078ae4ccc7af0cb7869e4c78d72bcb7dca9 /bindings/php5/tests/profile_tests.php
parentdedaa6e0eebeeb6d46f721e3c1a2022b75267901 (diff)
downloadlasso-c8762f405baaac8cbb6475b39d4fbd701a34060a.tar.gz
lasso-c8762f405baaac8cbb6475b39d4fbd701a34060a.tar.xz
lasso-c8762f405baaac8cbb6475b39d4fbd701a34060a.zip
[project @ fpeters@0d.be-20071102093734-mv4amat73ulcri17]
merged Damien branch Original author: Frederic Peters <fpeters@0d.be> Date: 2007-11-02 10:37:34.842000+01:00
Diffstat (limited to 'bindings/php5/tests/profile_tests.php')
-rwxr-xr-xbindings/php5/tests/profile_tests.php113
1 files changed, 99 insertions, 14 deletions
diff --git a/bindings/php5/tests/profile_tests.php b/bindings/php5/tests/profile_tests.php
index 3e353781..2aa900cc 100755
--- a/bindings/php5/tests/profile_tests.php
+++ b/bindings/php5/tests/profile_tests.php
@@ -25,16 +25,16 @@
require("../lasso.php");
-define("DATA_DIR", "../../tests/data/");
+define("DATA_DIR", "../../../tests/data/");
function test01() {
echo "Server construction, dump & newFromDump... ";
$server = new LassoServer(
- DATA_DIR . "sp1-la/metadata.xml",
- DATA_DIR . "sp1-la/private-key-raw.pem",
- NULL,
- DATA_DIR . "sp1-la/certificate.pem");
+ 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",
@@ -73,10 +73,10 @@ function test03() {
echo "SP login; testing access to authentication request... ";
$server = new LassoServer(
- DATA_DIR . "sp1-la/metadata.xml",
- DATA_DIR . "sp1-la/private-key-raw.pem",
- NULL,
- DATA_DIR . "sp1-la/certificate.pem");
+ 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",
@@ -98,13 +98,40 @@ function test03() {
}
function test04() {
+ echo "SP login; testing processing of an empty Response... ";
+
+ $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);
+ try {
+ $login->processResponseMsg("");
+ }
+ catch (LassoError $error) {
+ if ($error->getCode() != LASSO_PARAM_ERROR_INVALID_VALUE) {
+ throw $error;
+ }
+ }
+
+ echo "OK.\n";
+}
+
+function test05() {
echo "Conversion of a lib:AuthnRequest with an AuthnContext into a query and back... ";
$spServer = new LassoServer(
- DATA_DIR . "sp1-la/metadata.xml",
- DATA_DIR . "sp1-la/private-key-raw.pem",
- NULL,
- DATA_DIR . "sp1-la/certificate.pem");
+ DATA_DIR . "sp1-la/metadata.xml",
+ DATA_DIR . "sp1-la/private-key-raw.pem",
+ NULL,
+ DATA_DIR . "sp1-la/certificate.pem");
$spServer->addProvider(
LASSO_PROVIDER_ROLE_IDP,
DATA_DIR . "idp1-la/metadata.xml",
@@ -116,22 +143,80 @@ function test04() {
$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;
$spLogin->buildAuthnRequestMsg();
- var_dump($spLogin->msgUrl);
$authnRequestUrl = $spLogin->msgUrl;
assert(! is_null($spLogin->msgUrl));
assert($spLogin->msgUrl != "");
+ $idpServer = new LassoServer(
+ DATA_DIR . "idp1-la/metadata.xml",
+ DATA_DIR . "idp1-la/private-key-raw.pem",
+ NULL,
+ DATA_DIR . "idp1-la/certificate.pem");
+ $idpServer->addProvider(
+ LASSO_PROVIDER_ROLE_IDP,
+ DATA_DIR . "sp1-la/metadata.xml",
+ DATA_DIR . "sp1-la/public-key.pem",
+ DATA_DIR . "sp1-la/certificate.pem");
+
+ $idpLogin = new LassoLogin($idpServer);
+ 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);
+
echo "OK.\n";
}
+function test06() {
+ echo "SP logout without session and identity; testing initRequest... ";
+
+ $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");
+
+ $logout = new LassoLogout($server);
+ try {
+ $logout->initRequest();
+ echo "logout.initRequest without having set identity before should fail\n";
+ assert(False);
+ }
+ catch (LassoError $error) {
+ if ($error->getCode() != LASSO_PROFILE_ERROR_SESSION_NOT_FOUND) {
+ throw $error;
+ }
+ }
+
+ echo "OK.\n";
+}
+
+
lasso_init();
test01();
test02();
test03();
test04();
+test05();
+test06();
+test07();
lasso_shutdown();