91 lines
2.7 KiB
PHP
91 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* DomFramework - Tests
|
|
* @package domframework
|
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
|
* @license BSD
|
|
*/
|
|
|
|
namespace Domframework\Tests;
|
|
|
|
use Domframework\Authsympa;
|
|
|
|
/**
|
|
* Test the authentication on Sympa Service
|
|
*/
|
|
class AuthsympaTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function testConnect1()
|
|
{
|
|
// Empty
|
|
$authsympa = new Authsympa();
|
|
$this->expectException();
|
|
$authsympa->connect();
|
|
}
|
|
|
|
public function testConnect2()
|
|
{
|
|
$authsympa = new Authsympa();
|
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
|
$authsympa->connect();
|
|
$res = $authsympa->getDetails();
|
|
$this->assertSame($res, null);
|
|
}
|
|
|
|
public function testAuth1()
|
|
{
|
|
// Invalid password
|
|
$authsympa = new Authsympa();
|
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
|
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
|
$authsympa->connect();
|
|
$this->expectException();
|
|
$res = $authsympa->authentication("richard.heral@grenoble.cnrs.fr", "XXXX");
|
|
}
|
|
|
|
public function testAuth2()
|
|
{
|
|
// Unknown user
|
|
$authsympa = new Authsympa();
|
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
|
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
|
$authsympa->connect();
|
|
$this->expectException();
|
|
$res = $authsympa->authentication("Unknown@grenoble.cnrs.fr", "XXXX");
|
|
}
|
|
|
|
public function testAuth3()
|
|
{
|
|
// OK !
|
|
$authsympa = new Authsympa();
|
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
|
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
|
$authsympa->connect();
|
|
$res = $authsympa->authentication("richard.heral@grenoble.cnrs.fr", "Lavchdn7!");
|
|
$this->assertSame($res, true);
|
|
}
|
|
|
|
public function testAuth4()
|
|
{
|
|
// Unknown list
|
|
$authsympa = new Authsympa();
|
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
|
$authsympa->list = "unknown@listes.grenoble.cnrs.fr";
|
|
$authsympa->connect();
|
|
$this->expectException();
|
|
$res = $authsympa->authentication("richard.heral@grenoble.cnrs.fr", "Lavchdn8!");
|
|
}
|
|
|
|
public function testAuth5()
|
|
{
|
|
// User not in list
|
|
$authsympa = new Authsympa();
|
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
|
$authsympa->list = "admins@listes.grenoble.cnrs.fr";
|
|
$authsympa->connect();
|
|
$this->expectException();
|
|
$res = $authsympa->authentication("richard.heral@grenoble.cnrs.fr", "Lavchdn8!");
|
|
}
|
|
}
|