diff --git a/Tests/authTest.php b/Tests/authTest.php new file mode 100644 index 0000000..4b0da7c --- /dev/null +++ b/Tests/authTest.php @@ -0,0 +1,42 @@ +pageHTML ("http://localhost"); + $this->assertSame (!! strpos ($res, "
pageHTML ("http://localhost", "MESSAGE"); + $this->assertSame (!! strpos ($res, "MESSAGE"), true); + } + + public function test_URL_1 () + { + $auth = new auth (); + $res = $auth->pageHTML ("http://localhost", "MESSAGE", "URL/TEST"); + $this->assertSame (!! strpos ($res, "URL/TEST"), true); + } + + public function test_alreadyAuth_1 () + { + // Not Authenticated + $auth = new auth (); + $res = $auth->pageHTML ("http://localhost", "MESSAGE", "URL/TEST", false); + $this->assertSame (!! strpos ($res, "Please sign in"), true); + } + + public function test_alreadyAuth_2 () + { + // Authenticated + $auth = new auth (); + $res = $auth->pageHTML ("http://localhost", "", "", "AUTHENTICATED USER"); + $this->assertSame (!! strpos ($res, "AUTHENTICATED USER"), true); + } +} diff --git a/Tests/authsympaTest.php b/Tests/authsympaTest.php new file mode 100644 index 0000000..ed9073a --- /dev/null +++ b/Tests/authsympaTest.php @@ -0,0 +1,79 @@ +expectException (); + $authsympa->connect (); + } + + public function test_connect_2 () + { + $authsympa = new authsympa (); + $authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl"; + $authsympa->connect (); + $res = $authsympa->getDetails (); + $this->assertSame ($res, null); + } + + public function test_auth_1 () + { + // 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 test_auth_2 () + { + // 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 test_auth_3 () + { + // 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", "Lavchdn8!"); + $this->assertSame ($res, true); + } + + public function test_auth_4 () + { + // 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 test_auth_5 () + { + // 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!"); + } +} + +