tests/func/Site/top.php -text
tests/func/Site/trove.php -text
tests/func/Soap/AllTests.php -text
+tests/func/Soap/checks.php -text
tests/func/Soap/login.php -text
tests/func/Soap/usergroup.php -text
tests/func/Tasks/AllTests.php -text
libnusoap-php instead (Closes: #529575).
* Add provides tag to control for fusionforge.
* Change default system name to FusionForge instead of GForge.
+ * Fix changelog entry for previous version adding details of CVE entry.
[ Roland Mas ]
* Fix for symlink attack (CVE-2009-3304).
}
}
-if (PHPUnit_MAIN_METHOD == 'Trackers_AllTests::main') {
+if (PHPUnit_MAIN_METHOD == 'Site_AllTests::main') {
Site_AllTests::main();
}
?>
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'func/config.php';
+require_once 'func/Soap/checks.php';
require_once 'func/Soap/login.php';
require_once 'func/Soap/usergroup.php';
{
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
- $suite->addTestSuite('SoapLoginProcess');
- $suite->addTestSuite('SoapUserGroupProcess');
+ $suite->addTestSuite('SoapChecksProcess');
+ $suite->addTestSuite('SoapLoginProcess');
+ $suite->addTestSuite('SoapUserGroupProcess');
return $suite;
}
--- /dev/null
+<?php
+/*
+ * Copyright (C) 2009 Olivier Berger, Institut TELECOM
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+class SoapChecksProcess extends PHPUnit_Framework_TestCase
+{
+ // Check that the SOAP API server corresponds to a hostname that
+ // resolves otherwise, phpunit fails with error code 255 on
+ // SoapClient instanciation with WSDL ... strange
+ // This assumes that upon failure, the hostname is returned instead
+ // of the IP.
+ function testHostnameResolves()
+ {
+
+ $ip = gethostbyname(FORGE_HOSTNAME);
+ $this->assertNotEquals(FORGE_HOSTNAME, $ip);
+
+ }
+
+ // This checks that the login will be able to proceed as the test
+ // environment was configured the right way
+ function testExistingUserPasswordConfigured()
+ {
+
+ $this->assertNotEquals('xxxxx', PASSWD_OF_EXISTING_USER);
+
+ }
+
+ // This checks that the WSDL URL looks fine
+ function testWSDLUrl()
+ {
+ $this->assertRegExp('/^http.?:\/\//', WSDL_URL);
+ }
+
+}
+?>
// print_r("setup\n");
- $this->loggedIn = FALSE;
$this->session = NULL;
- //print_r("session :".$this->session);
+ $this->soapclient = NULL;
- $this->assertRegExp('/^http.?:\/\//', WSDL_URL);
+ //try {
- // try {
+ // This is to check that the SoapClient instanciation will
+ // work. There's aparently a different behaviour if
+ // resolving the hostname doesn't work under phpunit. If
+ // this fails, the hostname and IP address should be
+ // different and the WSDL retrieval should work
+ $ip = gethostbyname(FORGE_HOSTNAME);
+ if ($ip != FORGE_HOSTNAME)
+ {
- $this->soapclient = new SoapClient(WSDL_URL,
+ // Instantiate the SOAP client with WSDL
+ $this->soapclient = new SoapClient(WSDL_URL,
array('cache_wsdl' => WSDL_CACHE_NONE,
'trace' => true));
// $fault->faultstring;
// print_r($fault);
// }
- // print_r($this->soapclient);
+ // print_r($this->soapclient);
+ }
}
- // function tearDown()
- // {
- // //
- // }
+ function tearDown()
+ {
+ if ($this->session) {
+ $response = $this->soapclient->logout($this->session);
+ // print($response);
+ }
+ }
// performs a login and returns a session "cookie"
function login($userid, $passwd)
{
+ $this->assertNotNull($this->soapclient);
+
$response = $this->soapclient->login($userid, $passwd);
if ($response) {
- $this->loggedIn = TRUE;
-
$this->session = $response;
-
// print_r($this->session);
-
}
return $response;
}
-// Name: version
-// Binding: GForgeAPIBinding
-// Input:
-// use: encoded
-// message: versionRequest
-// parts:
-// Output:
-// use: encoded
-// message: versionResponse
-// parts:
-// versionResponse: xsd:string
+ // Name: version
+ // Binding: GForgeAPIBinding
+ // Input:
+ // use: encoded
+ // message: versionRequest
+ // parts:
+ // Output:
+ // use: encoded
+ // message: versionResponse
+ // parts:
+ // versionResponse: xsd:string
function testVersion()
{
+ $this->assertNotNull($this->soapclient);
+
$version = $this->soapclient->version();
$this->assertEquals('4.8.50', $version);
}
+ /**
+ * @depends testVersion
+ */
function testGETFUNCTIONS()
{
+ $this->assertNotNull($this->soapclient);
$response = $this->soapclient->__getFunctions();
// print_r($response);
}
-// Name: login
-// Binding: GForgeAPIBinding
-// Input:
-// use: encoded
-// message: loginRequest
-// parts:
-// userid: xsd:string
-// passwd: xsd:string
-// Output:
-// use: encoded
-// message: loginResponse
-// parts:
-// loginResponse: xsd:string
+ // Name: login
+ // Binding: GForgeAPIBinding
+ // Input:
+ // use: encoded
+ // message: loginRequest
+ // parts:
+ // userid: xsd:string
+ // passwd: xsd:string
+ // Output:
+ // use: encoded
+ // message: loginResponse
+ // parts:
+ // loginResponse: xsd:string
+ /**
+ * @depends testVersion
+ */
function testLoginNonExistantUser()
{
+ $this->assertNotNull($this->soapclient);
+
$userid = 'coin';
try {
-
$response = $this->soapclient->login($userid, 'pan');
-
}
catch (SoapFault $expected) {
$this->assertEquals("Unable to log in with userid of ".$userid, $expected->faultstring);
-
- // print_r($response);
-
+ // print_r($response);
return;
}
$this->fail('An expected exception has not been raised.');
}
+ /**
+ * @depends testVersion
+ */
function testLoginWrongPwd()
{
+ $this->assertNotNull($this->soapclient);
+
$userid = EXISTING_USER;
try {
-
$response = $this->soapclient->login($userid, 'xxxxxx');
-
}
catch (SoapFault $expected) {
$this->assertEquals("Unable to log in with userid of ".$userid, $expected->faultstring);
// print_r($response);
-
return;
}
$this->fail('An expected exception has not been raised.');
}
+ /**
+ * @depends testVersion
+ */
function testLoginSuccesful()
{
$userid = EXISTING_USER;
$response = $this->login($userid, $passwd);
$this->assertNotNull($response);
-
}
-// Name: logout
-// Binding: GForgeAPIBinding
-// Input:
-// use: encoded
-// message: logoutRequest
-// parts:
-// session_ser: xsd:string
-// Output:
-// use: encoded
-// message: logoutResponse
-// parts:
-// logoutResponse: xsd:string
+ // Name: logout
+ // Binding: GForgeAPIBinding
+ // Input:
+ // use: encoded
+ // message: logoutRequest
+ // parts:
+ // session_ser: xsd:string
+ // Output:
+ // use: encoded
+ // message: logoutResponse
+ // parts:
+ // logoutResponse: xsd:string
/**
* @depends testLoginSuccesful
/* function testLogout()
{
- print_r($this->loggedIn);
- $this->assertNotNull($this->loggedIn);
$response = $this->soapclient->logout('coin');
class SoapUserGroupProcess extends PHPUnit_Framework_TestCase
{
-
+
function setUp()
{
+ // print_r("setup\n");
+ $this->session = NULL;
+ $this->soapclient = NULL;
+
+ // try {
- // print_r("setup\n");
-
- $this->loggedIn = FALSE;
- $this->session = NULL;
- //print_r("session :".$this->session);
-
- $this->assertRegExp('/http.?:\/\//', WSDL_URL);
-
- // try {
+ // see comments in SoapLoginProcess:setup() for details about this
+ $ip = gethostbyname(FORGE_HOSTNAME);
+ if ($ip != FORGE_HOSTNAME)
+ {
$this->soapclient = new SoapClient(WSDL_URL,
- array('cache_wsdl' => WSDL_CACHE_NONE,
- 'trace' => true));
+ array('cache_wsdl' => WSDL_CACHE_NONE,
+ 'trace' => true));
// } catch (SoapFault $fault) {
// $fault->faultstring;
// print_r($fault);
// }
// print_r($this->soapclient);
+ }
+ }
-}
+ function tearDown()
+ {
+ if ($this->session) {
+ $response = $this->soapclient->logout($this->session);
+ // print($response);
+ }
+ }
-// function tearDown()
-// {
-// //
- // }
// performs a login and returns a session "cookie"
function login($userid, $passwd)
{
+ $this->assertNotNull($this->soapclient);
$response = $this->soapclient->login($userid, $passwd);
if ($response) {
- $this->loggedIn = TRUE;
$this->session = $response;
// print_r($this->session);
-
}
return $response;
function testGetGroupsByNameEmpty()
{
- // print_r($this->loggedIn);
-
$this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
- $this->assertNotNull($this->loggedIn);
+
$this->assertNotNull($this->session);
try {
*/
function testGetGroupsByName()
{
-
- // print_r($this->loggedIn);
-
$this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
- $this->assertNotNull($this->loggedIn);
+
$this->assertNotNull($this->session);
$groups = array('template' => 'template',
// return: tns:ArrayOfstring
- /**
- * @depends testLoginSuccesful
- */
- function testGetPublicProjectNamesNotLoggedIn()
- {
+ // /**
+ // * @depends testLoginSuccesful
+ // */
+ // function testGetPublicProjectNamesNotLoggedIn()
+ // {
- // print_r($this->loggedIn);
- $this->assertNotNull($this->loggedIn);
+ // // print_r($this->loggedIn);
+ // $this->assertNotNull($this->loggedIn);
- $response = $this->soapclient->getPublicProjectNames();
-
-// $this->assertContains("newsadmin", $response);
-// $this->assertContains("siteadmin", $response);
+ // $response = $this->soapclient->getPublicProjectNames();
- // print_r($response);
- }
+ // print_r($response);
+ // $this->assertContains("newsadmin", $response);
+ // $this->assertContains("siteadmin", $response);
+
+ // }
/**
* @depends testLoginSuccesful
*/
- function testGetPublicProjectNamesLoggedIn()
- {
+ // function testGetPublicProjectNamesLoggedIn()
+ // {
- $this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
- $this->assertNotNull($this->loggedIn);
- $this->assertNotNull($this->session);
+ // $this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
+ // $this->assertNotNull($this->loggedIn);
+ // $this->assertNotNull($this->session);
- // print_r($this->loggedIn);
- $this->assertNotNull($this->loggedIn);
+ // // print_r($this->loggedIn);
+ // $this->assertNotNull($this->loggedIn);
- $response = $this->soapclient->getPublicProjectNames($this->session);
-// $this->assertContains("newsadmin", $response);
-// $this->assertContains("siteadmin", $response);
+ // $response = $this->soapclient->getPublicProjectNames($this->session);
+ // $this->assertContains("newsadmin", $response);
+ // $this->assertContains("siteadmin", $response);
- //print_r($response);
- }
+ // //print_r($response);
+ // }
// Name: getUsers
// Binding: GForgeAPIBinding
*/
function testGetUsersByNameEmpty()
{
-
- // print_r($this->loggedIn);
-
$this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
- $this->assertNotNull($this->loggedIn);
+
$this->assertNotNull($this->session);
try {
$this->fail('An expected exception has not been raised. Got response :'.$response);
}
- /**
+ /**
* @depends testLoginSuccesful
*/
- function testGetUsersByName()
+ function testGetUsersByNameBug63()
{
+ $this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
+
+ $this->assertNotNull($this->session);
- // print_r($this->loggedIn);
+ // corner case, but a dangerous ? one : the way the SOAP
+ // server works allow to trick it in returning several
+ // values at a time : this one may be fixed some day and we'd then
+ $users = array('admin", "None' => array( 'count' => 2,
+ 'user_names' => array('admin', 'None')));
+ foreach (array_keys($users) as $user_name) {
+ $response = $this->soapclient->getUsersByName($this->session,array($user_name));
+
+ $this->assertEquals($users[$user_name]['count'], count($response));
+
+ foreach ($response as $user) {
+ // print_r($user);
+ $this->assertContains($user->user_name, $users[$user_name]['user_names']);
+ }
+ }
+ }
+
+ /**
+ * @depends testLoginSuccesful
+ */
+ function testGetUsersByName()
+ {
$this->login(EXISTING_USER, PASSWD_OF_EXISTING_USER);
- $this->assertNotNull($this->loggedIn);
+
$this->assertNotNull($this->session);
$users = array('admin'=>'admin',
- 'None'=>'None',
- EXISTING_USER => EXISTING_USER);
+ 'None'=>'None',
+ EXISTING_USER => EXISTING_USER);
foreach (array_keys($users) as $user_name) {
// print_r($user_name);
- // $user_name='admin';
$response = $this->soapclient->getUsersByName($this->session,array($user_name));
- // $response = $this->soapclient->__soapCall('getUsersByName',
- // array('session_ser' => $this->session,
- // 'user_ids' => array('admin')));
$user = $response[0];
// print_r($user);
// Host where selenium-rc is running
define ('SELENIUM_RC_HOST', 'localhost');
-// URL to access the application
-define ('URL', 'http://test.local/');
+// The forge's hostname
+define ('FORGE_HOSTNAME', 'test.local');
// Base URL where FusionForge is installed
define ('BASE', '');
define('DB_PASSWORD', '@@FFDB_PASS@@');
define('DB_INIT_CMD', 'php '.dirname(__FILE__).'/db_reload.php');
-define ('WSDL_URL', URL.'soap/index.php?wsdl');
-
// this should be an existing user of the forge together with its password
// (the password should be different from 'xxxxxx')
define ('EXISTING_USER', 'admin');
-define ('PASSWD_OF_EXISTING_USER', 'myadmin');
+define ('PASSWD_OF_EXISTING_USER', 'xxxxx');
// Enter true when file is configured.
define('CONFIGURED', false);
+
+//
+// DON'T MODIFY BELOW THIS LINE UNLESS YOU KNOW WHAT YOU DO
+//
+
+// These are deduced from the previous definitions.
+
+// URL to access the application
+define ('URL', 'http://'.FORGE_HOSTNAME.'/');
+
+// WSDL of the forges SOAP API
+define ('WSDL_URL', URL.'soap/index.php?wsdl');
?>