[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[110] trunk/0.3
Status: Beta
                
                Brought to you by:
                
                    crazedsanity
                    
                
            | 
      
      
      From: <cra...@us...> - 2009-08-19 17:14:30
      
     | 
| Revision: 110
          http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=110&view=rev
Author:   crazedsanity
Date:     2009-08-19 17:14:22 +0000 (Wed, 19 Aug 2009)
Log Message:
-----------
Beginnings of cs_authToken class, for storing of generic tokens to test against.
Added Paths:
-----------
    trunk/0.3/cs_authToken.class.php
    trunk/0.3/setup/authtoken_schema.pgsql.sql
    trunk/0.3/tests/testOfAuthToken.php
Added: trunk/0.3/cs_authToken.class.php
===================================================================
--- trunk/0.3/cs_authToken.class.php	                        (rev 0)
+++ trunk/0.3/cs_authToken.class.php	2009-08-19 17:14:22 UTC (rev 110)
@@ -0,0 +1,60 @@
+<?php
+/*
+ * Created on Aug 19, 2009
+ *
+ *  SVN INFORMATION:::
+ * -------------------
+ * Last Author::::::::: $Author$ 
+ * Current Revision:::: $Revision$ 
+ * Repository Location: $HeadURL$ 
+ * Last Updated:::::::: $Date$
+ */
+
+
+require_once(dirname(__FILE__) .'/cs_webapplibs.abstract.class.php');
+
+class cs_authToken extends cs_webapplibsAbstract {
+	
+	/** Database object. */
+	private $db;
+	
+	//=========================================================================
+	public function __construct(cs_phpDB $db) {
+		
+		if($db->is_connected()) {
+			$this->db = $db;
+		}
+		else {
+			throw new exception(__METHOD__ .": database object not connected");
+		}
+		
+	}//end __construct()
+	//=========================================================================
+	
+	
+	
+	//=========================================================================
+	public function load_table() {
+		$file = dirname(__FILE__) .'/setup/authtoken_schema.'. $this->db->get_dbtype() .'.sql';
+		
+		if(file_exists($file)) {
+			try {
+				$this->db->run_update(file_get_contents($file), true);
+			}
+			catch(exception $e) {
+				throw new exception(__METHOD__ .": error while trying to load table::: ". $e->getMessage());
+			}
+		}
+		else {
+			throw new exception(__METHOD__ .": unsupported database type (". $this->db->get_dbtype() .")");
+		}
+	}//end load_table()
+	//=========================================================================
+	
+	
+	
+	//=========================================================================
+	//=========================================================================
+	
+}
+?>
Property changes on: trunk/0.3/cs_authToken.class.php
___________________________________________________________________
Added: svn:keywords
   + Id
Author
Revision
HeadURL
Date
Added: trunk/0.3/setup/authtoken_schema.pgsql.sql
===================================================================
--- trunk/0.3/setup/authtoken_schema.pgsql.sql	                        (rev 0)
+++ trunk/0.3/setup/authtoken_schema.pgsql.sql	2009-08-19 17:14:22 UTC (rev 110)
@@ -0,0 +1,18 @@
+--
+-- SVN INFORMATION:::
+-- ---------------
+--	SVN Signature::::::: $Id$
+--	Last Author::::::::: $Author$
+--	Current Revision:::: $Revision$
+--	Repository Location: $HeadURL$
+--	Last Updated:::::::: $Date$
+--
+
+CREATE TABLE cswal_auth_token_table (
+	auth_token_id serial NOT NULL PRIMARY KEY,
+	uid integer NOT NULL DEFAULT 0,
+	checksum text NOT NULL,
+	token text NOT NULL,
+	creation date NOT NULL DEFAULT NOW(),
+	duration interval NOT NULL DEFAULT '1 day'::interval
+);
\ No newline at end of file
Property changes on: trunk/0.3/setup/authtoken_schema.pgsql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Author
Revision
HeadURL
Date
Copied: trunk/0.3/tests/testOfAuthToken.php (from rev 109, trunk/0.3/tests/testOfCSVersionParse.php)
===================================================================
--- trunk/0.3/tests/testOfAuthToken.php	                        (rev 0)
+++ trunk/0.3/tests/testOfAuthToken.php	2009-08-19 17:14:22 UTC (rev 110)
@@ -0,0 +1,80 @@
+<?php
+/*
+ * Created on Jan 25, 2009
+ * 
+ * FILE INFORMATION:
+ * 
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+require_once(dirname(__FILE__) .'/../cs_authToken.class.php');
+
+class testOfCSAuthToken extends UnitTestCase {
+	
+	//--------------------------------------------------------------------------
+	function __construct() {
+		$this->gfObj = new cs_globalFunctions;
+		$this->gfObj->debugPrintOpt=1;
+	}//end __construct()
+	//--------------------------------------------------------------------------
+	
+	
+	
+	//--------------------------------------------------------------------------
+	function setUp() {
+		$tok = new cs_authToken($this->create_db());
+		try {
+			$tok->load_table();
+		}
+		catch(exception $e) {
+		}
+	}//end setUp()
+	//--------------------------------------------------------------------------
+	
+	
+	
+	//--------------------------------------------------------------------------
+	function tearDown() {
+		$db = $this->create_db();
+		try {
+			$db->run_update('DROP TABLE cswal_auth_token_table', true);
+		}
+		catch(exception $e) {
+		}
+	}//end
+	//--------------------------------------------------------------------------
+	
+	
+	
+	//--------------------------------------------------------------------------
+	private function create_db() {
+		$dbParams = array(
+			'host'		=> constant('DB_PG_HOST'),
+			'dbname'	=> constant('DB_PG_DBNAME'),
+			'user'		=> constant('DB_PG_DBUSER'),
+			'password'	=> constant('DB_PG_DBPASS'),
+			'port'		=> constant('DB_PG_PORT')
+		);
+		$db = new cs_phpDB(constant('DBTYPE'));
+		$db->connect($dbParams);
+		return($db);
+	}//end create_db()
+	//--------------------------------------------------------------------------
+	
+	
+	//--------------------------------------------------------------------------
+	function test_basics() {
+		$db = $this->create_db();
+		$tok = new cs_authToken($db);
+		
+		
+	}//end test_basics()
+	//--------------------------------------------------------------------------
+}
+
+
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |