3 * Copyright (C) 2009 Olivier Berger, Institut TELECOM
5 * This file is part of FusionForge.
7 * FusionForge is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License,
10 * or (at your option) any later version.
12 * FusionForge is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with FusionForge; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 require_once 'PHPUnit/Framework/TestCase.php';
25 class SoapLoginProcess extends PHPUnit_Framework_TestCase
31 // print_r("setup\n");
33 $this->loggedIn = FALSE;
34 $this->session = NULL;
35 //print_r("session :".$this->session);
37 $this->assertRegExp('/^http.?:\/\//', WSDL_URL);
41 $this->soapclient = new SoapClient(WSDL_URL,
42 array('cache_wsdl' => WSDL_CACHE_NONE,
45 // } catch (SoapFault $fault) {
46 // $fault->faultstring;
49 // print_r($this->soapclient);
53 // function tearDown()
59 // performs a login and returns a session "cookie"
60 function login($userid, $passwd)
62 $response = $this->soapclient->login($userid, $passwd);
65 $this->loggedIn = TRUE;
67 $this->session = $response;
69 // print_r($this->session);
77 // Binding: GForgeAPIBinding
80 // message: versionRequest
84 // message: versionResponse
86 // versionResponse: xsd:string
88 function testVersion()
90 $version = $this->soapclient->version();
92 $this->assertEquals('4.8.50', $version);
96 function testGETFUNCTIONS()
98 $response = $this->soapclient->__getFunctions();
99 // print_r($response);
103 // Binding: GForgeAPIBinding
106 // message: loginRequest
108 // userid: xsd:string
109 // passwd: xsd:string
112 // message: loginResponse
114 // loginResponse: xsd:string
116 function testLoginNonExistantUser()
122 $response = $this->soapclient->login($userid, 'pan');
125 catch (SoapFault $expected) {
127 $this->assertEquals("Unable to log in with userid of ".$userid, $expected->faultstring);
129 // print_r($response);
134 $this->fail('An expected exception has not been raised.');
137 function testLoginWrongPwd()
139 $userid = EXISTING_USER;
143 $response = $this->soapclient->login($userid, 'xxxxxx');
146 catch (SoapFault $expected) {
148 $this->assertEquals("Unable to log in with userid of ".$userid, $expected->faultstring);
150 // print_r($response);
155 $this->fail('An expected exception has not been raised.');
158 function testLoginSuccesful()
160 $userid = EXISTING_USER;
161 $passwd = PASSWD_OF_EXISTING_USER;
163 $response = $this->login($userid, $passwd);
165 $this->assertNotNull($response);
171 // Binding: GForgeAPIBinding
174 // message: logoutRequest
176 // session_ser: xsd:string
179 // message: logoutResponse
181 // logoutResponse: xsd:string
184 * @depends testLoginSuccesful
186 /* function testLogout()
189 print_r($this->loggedIn);
191 $this->assertNotNull($this->loggedIn);
193 $response = $this->soapclient->logout('coin');
195 print_r('logout response :'. $response);