Revision: 1827
Author: olavmrk
Date: Wed Oct  7 02:12:01 2009
Log: Add autotest module.

This module provides some webpages that can be used to test
authentication sources.
http://code.google.com/p/simplesamlphp/source/detail?r=1827

Added:
  /trunk/modules/autotest
  /trunk/modules/autotest/default-disable
  /trunk/modules/autotest/docs
  /trunk/modules/autotest/docs/test.txt
  /trunk/modules/autotest/www
  /trunk/modules/autotest/www/attributes.php
  /trunk/modules/autotest/www/login.php
  /trunk/modules/autotest/www/logout.php

=======================================
--- /dev/null
+++ /trunk/modules/autotest/default-disable     Wed Oct  7 02:12:01 2009
@@ -0,0 +1,3 @@
+This file indicates that the default state of this module
+is disabled. To enable, create a file named enable in the
+same directory as this file.
=======================================
--- /dev/null
+++ /trunk/modules/autotest/docs/test.txt       Wed Oct  7 02:12:01 2009
@@ -0,0 +1,18 @@
+`autotest` module
+=================
+
+This module provides an interface to do automatic testing of  
authentication sources.
+To enable it, create a file named "enable" in modules/autotest.
+
+It provides three webpages:
+- https://.../simplesaml/module.php/autotest/login.php
+- https://.../simplesaml/module.php/autotest/logout.php
+- https://.../simplesaml/module.php/autotest/attributes.php
+
+All the webpages have a mandatory paremeter 'SourceID', which is the name  
of the authentication source.
+
+On success, the web pages print a single line with "OK".
+The attributes page will also list all the attributes of the user.
+On error they set the HTTP status code to 500 Internal Server Error, print  
a line with "ERROR" and then any information about the error.
+
+Note that you still have to parse the login pages to extract the  
parameters in the login form.
=======================================
--- /dev/null
+++ /trunk/modules/autotest/www/attributes.php  Wed Oct  7 02:12:01 2009
@@ -0,0 +1,31 @@
+<?php
+
+try {
+       if (!isset($_GET['SourceID'])) {
+               throw new SimpleSAML_Error_BadRequest('Missing SourceID 
parameter');
+       }
+       $sourceId = $_GET['SourceID'];
+
+       $as = new SimpleSAML_Auth_Simple($sourceId);
+
+       if (!$as->isAuthenticated()) {
+               throw new SimpleSAML_Error_Exception('Not authenticated.');
+       }
+
+       $attributes = $as->getAttributes();
+
+       header('Content-Type: text/plain; charset=utf-8');
+       echo("OK\n");
+       foreach ($attributes as $name => $values) {
+               echo("$name\n");
+               foreach ($values as $value) {
+                       echo("\t$value\n");
+               }
+       }
+
+} catch (Exception $e) {
+       header('HTTP/1.0 500 Internal Server Error');
+       header('Content-Type: text/plain; charset=utf-8');
+       echo("ERROR\n");
+       echo($e->getMessage() . "\n");
+}
=======================================
--- /dev/null
+++ /trunk/modules/autotest/www/login.php       Wed Oct  7 02:12:01 2009
@@ -0,0 +1,20 @@
+<?php
+
+try {
+       if (!isset($_GET['SourceID'])) {
+               throw new SimpleSAML_Error_BadRequest('Missing SourceID 
parameter');
+       }
+       $sourceId = $_GET['SourceID'];
+
+       $as = new SimpleSAML_Auth_Simple($sourceId);
+
+       $as->requireAuth();
+
+       header('Content-Type: text/plain; charset=utf-8');
+       echo("OK\n");
+} catch (Exception $e) {
+       header('HTTP/1.0 500 Internal Server Error');
+       header('Content-Type: text/plain; charset=utf-8');
+       echo("ERROR\n");
+       echo($e->getMessage() . "\n");
+}
=======================================
--- /dev/null
+++ /trunk/modules/autotest/www/logout.php      Wed Oct  7 02:12:01 2009
@@ -0,0 +1,24 @@
+<?php
+
+try {
+       if (!isset($_GET['SourceID'])) {
+               throw new SimpleSAML_Error_BadRequest('Missing SourceID 
parameter');
+       }
+       $sourceId = $_GET['SourceID'];
+
+       $as = new SimpleSAML_Auth_Simple($sourceId);
+
+       if ($as->isAuthenticated()) {
+               $as->logout();
+       }
+
+
+       header('Content-Type: text/plain; charset=utf-8');
+       echo("OK\n");
+
+} catch (Exception $e) {
+       header('HTTP/1.0 500 Internal Server Error');
+       header('Content-Type: text/plain; charset=utf-8');
+       echo("ERROR\n");
+       echo($e->getMessage() . "\n");
+}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to