diff --git a/Manifest/EasyCloud.yaml b/Manifest/EasyCloud.yaml index a41a174..eea6e0c 100644 --- a/Manifest/EasyCloud.yaml +++ b/Manifest/EasyCloud.yaml @@ -27,6 +27,17 @@ services: - traefik.http.services.WebAduc.loadbalancer.server.port=80 networks: - extBackend + - default + + dc1: + image: easylinux/samba-ad-dc:4.13 + privileged: true + volumes: + - /Data/Docker/Apps/EasyCloud/AD/Config:/etc/samba + - /Data/Docker/Apps/EasyCloud/AD/Data:/var/lib/samba + + + networks: extBackend: diff --git a/README.md b/README.md index d645df4..1e4913f 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,9 @@ All * Stockage des datas dans AD * packer * Terraform -* Ansible \ No newline at end of file +* Ansible + + +http://proton.orangehilldev.com + +1. With Linux (e.g. Debian, Ubuntu) you have to add "TLS_REQCERT never" to your /etc/ldap/ldap.conf. On other distributions this config file may be located somewhere else. diff --git a/Sources/webAduc/.gitignore b/Sources/webAduc/.gitignore deleted file mode 100644 index cf6d85d..0000000 --- a/Sources/webAduc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -www/vendor/* -www/templates_c/* \ No newline at end of file diff --git a/Sources/webAduc/README.md b/Sources/webAduc/README.md deleted file mode 100644 index d1e4d00..0000000 --- a/Sources/webAduc/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# webAduc - -webAduc is a web tool aimed to become one one the best way to administer an Active Directory server. - -Keys : -. full Web -. scalable -. extensible -. plugin -. opensource \ No newline at end of file diff --git a/Sources/webAduc/tests/Documentation Tests/README.md b/Sources/webAduc/tests/Documentation Tests/README.md index 517a746..869fc02 100644 --- a/Sources/webAduc/tests/Documentation Tests/README.md +++ b/Sources/webAduc/tests/Documentation Tests/README.md @@ -1 +1 @@ -Placer la documentation dans ce répertoire \ No newline at end of file +Placer la documentation dans ce répertoire \ No newline at end of file diff --git a/Sources/webAduc/tests/func/README.txt b/Sources/webAduc/tests/func/README.txt index c01ae60..cbc4669 100644 --- a/Sources/webAduc/tests/func/README.txt +++ b/Sources/webAduc/tests/func/README.txt @@ -1 +1 @@ -Placer les tests fonctionnels dans ce répertoire \ No newline at end of file +Placer les tests fonctionnels dans ce répertoire \ No newline at end of file diff --git a/Sources/webAduc/tests/phpSelenium.md b/Sources/webAduc/tests/phpSelenium.md new file mode 100644 index 0000000..f2414fd --- /dev/null +++ b/Sources/webAduc/tests/phpSelenium.md @@ -0,0 +1,206 @@ +Cheat sheet for using Selenium2TestCase v1.4 extension PHPUnit +===== +Prepare browser + +(URL)[https://gist.githubusercontent.com/julienhay/47f878aa9d1eb58c462f/raw/d6bd976e81d990006d587b881753bc65d6ac5473/Selenium2TestCase-cheat-sheet.md] + +---- +- Full screen browser +```php +class ClassTest extends \PHPUnit_Extensions_Selenium2TestCase +{ + public static $browsers = array( + array( + 'browserName' => 'chrome', + 'host' => 'hub.browserstack.com', + 'port' => 80, + ), + ); + + protected function setUp() + { + parent::setUp(); + $this->setBrowserUrl("http://www.example.com"); + + // Full screen browser + $this->prepareSession()->currentWindow()->maximize(); + } + } +``` + +- Navigate +```php +$this->url("http://www.google.fr"); +``` + +Selectors +---- +- Select by name +```php +$this->byName("comment"); +``` +- Select By Css Selector +```php +$this->byCssSelector('.element'); +``` +- Select by label +```php +$select = $this->select($this->byCssSelector('#selectWithOptgroup')); +$select->selectOptionByLabel("Second"); +``` + +Element's Operation +---- +- Get text +```php +$element->text() +``` +- Displayed +```php +$element->displayed() +``` +- Title page +```php +$this->title(); +```` +- Get attribute +```php +$element->attribute('class') +```` + +Operations +---- + +- Text field send keys +```php +$this->keys("content"); +``` + +- Wait Until (ajax) +```php +$this->waitUntil(function () use($var) { + if($end) { + return true; + } +}, 5000); +``` +- Count elements +```php +$elements = $this->byCssSelector('body')->elements($this->using('css selector')->value('.element')); +count($elements)); +// OR +$elements = $this->elements($this->using('css selector')->value('div')); +count($elements)); +``` + +Javascript +---- +- Simple execution JS +```php +$this->execute(array( + 'script' => "alert('test');", + 'args' => array() +)); +``` +- Return value from Javascript +```php +$script = 'return $("#element").html()'; +$data = $this->execute(array( + 'script' => $script, + 'args' => array() +)); +``` + +Full Examples +---- +- Fill form and submit +```php +$element = $this->byName("comment"); +$element->click(); +$this->keys("content"); +$element->submit(); +``` + + +To document +--- +```php + +void acceptAlert() Press OK on an alert, or confirms a dialog + +mixed alertText() alertText($value = NULL) Gets the alert dialog text, or sets the text for a prompt dialog + +void back() + +\PHPUnit_Extensions_Selenium2TestCase_Element byClassName() byClassName($value) + +\PHPUnit_Extensions_Selenium2TestCase_Element byCssSelector() byCssSelector($value) + +\PHPUnit_Extensions_Selenium2TestCase_Element byId() byId($value) + +\PHPUnit_Extensions_Selenium2TestCase_Element byLinkText() byLinkText($value) + +\PHPUnit_Extensions_Selenium2TestCase_Element byName() byName($value) + +\PHPUnit_Extensions_Selenium2TestCase_Element byTag() byTag($value) + +\PHPUnit_Extensions_Selenium2TestCase_Element byXPath() byXPath($value) + +void click() click(int $button = 0) Click any mouse button (at the coordinates set by the last moveto command). + +void clickOnElement() clickOnElement($id) + +string currentScreenshot() BLOB of the image file + +void dismissAlert() Press Cancel on an alert, or does not confirm a dialog + +void doubleclick() Double clicks (at the coordinates set by the last moveto command). + +\PHPUnit_Extensions_Selenium2TestCase_Element element() element(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) Retrieves an element + +array elements() elements(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) Retrieves an array of Element instances + +string execute() execute($javaScriptCode) Injects arbitrary JavaScript in the page and returns the last + +string executeAsync() executeAsync($javaScriptCode) Injects arbitrary JavaScript and wait for the callback (last element of arguments) to be called + +void forward() + +void frame() frame(mixed $element) Changes the focus to a frame in the page (by frameCount of type int, htmlId of type string, htmlName of type string or element of type \PHPUnit_Extensions_Selenium2TestCase_Element) + +void moveto() moveto(\PHPUnit_Extensions_Selenium2TestCase_Element $element) Move the mouse by an offset of the specificed element. + +void refresh() + +\PHPUnit_Extensions_Selenium2TestCase_Element_Select select() select($element) + +string source() Returns the HTML source of the page + +\PHPUnit_Extensions_Selenium2TestCase_Session_Timeouts timeouts() + +string title() + +void|string url() url($url = NULL) + +PHPUnit_Extensions_Selenium2TestCase_ElementCriteria using() using($strategy) Factory Method for Criteria objects + +void window() window($name) Changes the focus to another window + +string windowHandle() Retrieves the current window handle + +string windowHandles() Retrieves a list of all available window handles + +string keys() Send a sequence of key strokes to the active element. + +string file($file_path) Upload a local file. Returns the fully qualified path to the transferred file. + +array log(string $type) Get the log for a given log type. Log buffer is reset after each request. + +array logTypes() Get available log types. + +void closeWindow() Close the current window. + +void close() Close the current window and clear session data. + +\PHPUnit_Extensions_Selenium2TestCase_Element active() Get the element on the page that currently has focus. +``` \ No newline at end of file diff --git a/Sources/webAduc/tests/phpSeleniumTestCase2.php b/Sources/webAduc/tests/phpSeleniumTestCase2.php new file mode 100644 index 0000000..59be031 --- /dev/null +++ b/Sources/webAduc/tests/phpSeleniumTestCase2.php @@ -0,0 +1,1240 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_Selenium + * @author Giorgio Sironi + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + */ + +use BadMethodCallException; +use PHPUnit\Extensions\Selenium2TestCase; +use PHPUnit\Extensions\Selenium2TestCase\Keys; +use PHPUnit\Extensions\Selenium2TestCase\SessionCommand\Click; +use PHPUnit\Extensions\Selenium2TestCase\WebDriverException; +use PHPUnit\Extensions\Selenium2TestCase\Window; +use Tests\Selenium2TestCase\BaseTestCase; + +/** + * Tests for Selenium2TestCase. + * + * @package PHPUnit_Selenium + * @author Giorgio Sironi + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + */ +class Selenium2TestCaseTest extends BaseTestCase +{ + protected function tearDown(): void + { + Selenium2TestCase::setDefaultWaitUntilTimeout(0); + Selenium2TestCase::setDefaultWaitUntilSleepInterval(500); + } + + + public function testOpen() + { + $this->url('html/test_open.html'); + $this->assertStringEndsWith('html/test_open.html', $this->url()); + } + + public function testVersionCanBeReadFromTheTestCaseClass() + { + $this->assertEquals(1, version_compare(Selenium2TestCase::VERSION, "1.2.0")); + } + + public function testCamelCaseUrlsAreSupported() + { + $this->url('html/CamelCasePage.html'); + $this->assertStringEndsWith('html/CamelCasePage.html', $this->url()); + $this->assertEquals('CamelCase page', $this->title()); + } + + public function testAbsoluteUrlsAreSupported() + { + $this->url(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL . 'html/test_open.html'); + $this->assertEquals('Test open', $this->title()); + } + + public function testElementSelection() + { + $this->url('html/test_open.html'); + $element = $this->byCssSelector('body'); + $this->assertEquals('This is a test of the open command.', $element->text()); + + $this->url('html/test_click_page1.html'); + $link = $this->byId('link'); + $this->assertEquals('Click here for next page', $link->text()); + } + + public function testMultipleElementsSelection() + { + $this->url('html/test_element_selection.html'); + $elements = $this->elements($this->using('css selector')->value('div')); + $this->assertEquals(4, count($elements)); + $this->assertEquals('Other div', $elements[0]->text()); + } + + public function testElementFromResponseValue() + { + $this->url('html/test_open.html'); + $elementArray = $this->execute(array( + 'script' => 'return document.body;', + 'args' => array(), + )); + $element = $this->elementFromResponseValue($elementArray); + $this->assertEquals('This is a test of the open command.', $element->text()); + } + + public function testSelectOptionsInMultiselect() + { + $this->url('html/test_multiselect.html'); + $this->select($this->byId('theSelect'))->selectOptionByValue("option1"); + $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); + $this->assertEquals(array('First Option','Second Option'), $selectedOptions); + $this->select($this->byId('theSelect'))->selectOptionByLabel("Fourth Option"); + $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); + $this->assertEquals(array('First Option','Second Option','Fourth Option'), $selectedOptions); + } + + public function testClearMultiselectSelectedOptions() + { + $this->url('html/test_multiselect.html'); + $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); + $this->assertEquals(array('Second Option'), $selectedOptions); + $this->select($this->byId('theSelect'))->clearSelectedOptions(); + $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); + $this->assertEquals(array(), $selectedOptions); + } + + public function testTheElementWithFocusCanBeInspected() + { + $this->url('html/test_select.html'); + + // Select input and check if active + $theInput = $this->byCssSelector('input[name="theInput"]'); + $theInput->click(); + $this->assertTrue($this->active()->equals($theInput), 'Input not recognized as active.'); + + // Select select-group and check if active + $selectGroup = $this->byCssSelector('#selectWithOptgroup'); + $selectGroup->click(); + $this->assertTrue($this->active()->equals($selectGroup), 'Select-group not recognized as active.'); + + // Make sure that input is not recognized as selected + $this->assertFalse($this->active()->equals($theInput), 'Input falsely recognized as active.'); + } + + public function testActivePageElementReceivesTheKeyStrokes() + { + $this->markTestIncomplete('Firefox (geckodriver) does not support this command yet'); + + $this->timeouts()->implicitWait(10000); + + $this->url('html/test_send_keys.html'); + $this->byId('q')->click(); + $this->keys('phpunit '); + $this->assertEquals('phpunit', $this->byId('result')->text()); + } + + public function testElementsCanBeSelectedAsChildrenOfAlreadyFoundElements() + { + $this->url('html/test_element_selection.html'); + $parent = $this->byCssSelector('div#parentElement'); + $child = $parent->element($this->using('css selector')->value('span')); + $this->assertEquals('Child span', $child->text()); + + $rows = $this->byCssSelector('table')->elements($this->using('css selector')->value('tr')); + $this->assertEquals(2, count($rows)); + } + + /** + * Test on Session and Element + * + * @dataProvider getObjectsWithAccessToElement + */ + public function testShortenedApiForSelectionOfElement($factory) + { + $this->url('html/test_element_selection.html'); + $parent = $factory($this); + + $element = $parent->byClassName('theDivClass'); + $this->assertEquals('The right div', $element->text()); + + $element = $parent->byCssSelector('div.theDivClass'); + $this->assertEquals('The right div', $element->text()); + + $element = $parent->byId('theDivId'); + $this->assertEquals('The right div', $element->text()); + + $element = $parent->byName('theDivName'); + $this->assertEquals('The right div', $element->text()); + + $element = $parent->byTag('div'); + $this->assertEquals('Other div', $element->text()); + + $element = $parent->byXPath('//div[@id]'); + $this->assertEquals('The right div', $element->text()); + } + + public function getObjectsWithAccessToElement() + { + return array( + array(function($s) { return $s; }), + array(function($s) { return $s->byXPath('//body'); }) + ); + } + + public function testElementsKnowTheirTagName() + { + $this->url('html/test_element_selection.html'); + $element = $this->byClassName('theDivClass'); + $this->assertEquals('div', $element->name()); + } + + public function testFormElementsKnowIfTheyAreEnabled() + { + $this->url('html/test_form_elements.html'); + $this->assertTrue($this->byId('enabledInput')->enabled()); + $this->assertFalse($this->byId('disabledInput')->enabled()); + } + + public function testElementsKnowTheirAttributes() + { + $this->url('html/test_element_selection.html'); + $element = $this->byId('theDivId'); + $this->assertEquals('theDivClass', $element->attribute('class')); + } + + public function testElementsDiscoverTheirEqualityWithOtherElements() + { + $this->url('html/test_element_selection.html'); + $element = $this->byId('theDivId'); + $differentElement = $this->byId('parentElement'); + $equalElement = $this->byId('theDivId'); + $this->assertTrue($element->equals($equalElement)); + $this->assertFalse($element->equals($differentElement)); + } + + public function testElementsKnowWhereTheyAreInThePage() + { + $this->url('html/test_element_selection.html'); + $element = $this->byCssSelector('body'); + $location = $element->location(); + $this->assertEquals(0, $location['x']); + $this->assertEquals(0, $location['y']); + } + + public function testElementsKnowTheirSize() + { + $this->url('html/test_geometry.html'); + $element = $this->byId('rectangle'); + $size = $element->size(); + $this->assertEquals(200, $size['width']); + $this->assertEquals(100, $size['height']); + } + + public function testElementsKnowTheirCssPropertiesValues() + { + $this->url('html/test_geometry.html'); + $element = $this->byId('colored'); + $this->assertMatchesRegularExpression('/rgb[a]?\(0,\s*0,\s*255[,\s*1]?\)/', $element->css('background-color')); + } + + public function testClick() + { + $this->timeouts()->implicitWait(10000); + $this->url('html/test_click_page1.html'); + $link = $this->byId('link'); + $link->click(); + $back = $this->byId('previousPage'); + $this->assertEquals('Click Page Target', $this->title()); + $back->click(); + $this->byId('link'); + $this->assertEquals('Click Page 1', $this->title()); + + $withImage = $this->byId('linkWithEnclosedImage'); + $withImage->click(); + $back = $this->byId('previousPage'); + $this->assertEquals('Click Page Target', $this->title()); + $back->click(); + + $enclosedImage = $this->byId('enclosedImage'); + $enclosedImage->click(); + $back = $this->byId('previousPage'); + $this->assertEquals('Click Page Target', $this->title()); + $back->click(); + + $toAnchor = $this->byId('linkToAnchorOnThisPage'); + $toAnchor->click(); + $withOnClick = $this->byId('linkWithOnclickReturnsFalse'); + $this->assertEquals('Click Page 1', $this->title()); + + $withOnClick->click(); + $this->assertEquals('Click Page 1', $this->title()); + } + + public function testDoubleclick() + { + $this->markTestIncomplete('Moveto command is not in the webdriver specification'); + + $this->url('html/test_doubleclick.html'); + $link = $this->byId('link'); + + $this->moveto($link); + $this->doubleclick(); + + $this->assertEquals('doubleclicked', $this->alertText()); + $this->acceptAlert(); + } + + public function testByLinkText() + { + $this->timeouts()->implicitWait(10000); + $this->url('html/test_click_page1.html'); + $link = $this->byLinkText('Click here for next page'); + $link->click(); + $this->byId('previousPage'); + + $this->assertEquals('Click Page Target', $this->title()); + } + + public function testByPartialLinkText() + { + $this->timeouts()->implicitWait(10000); + $this->url('html/test_click_page1.html'); + $link = $this->byPartialLinkText('next page'); + $link->click(); + $this->byId('previousPage'); + $this->assertEquals('Click Page Target', $this->title()); + } + + public function testClicksOnJavaScriptHref() + { + $this->url('html/test_click_javascript_page.html'); + $this->clickOnElement('link'); + $this->assertEquals('link clicked', $this->byId('result')->text()); + } + + public function testTypingViaTheKeyboard() + { + $this->url('html/test_type_page1.html'); + $usernameInput = $this->byName('username'); + $usernameInput->value('TestUser'); + $this->assertEquals('TestUser', $usernameInput->value()); + + $passwordInput = $this->byName('password'); + $passwordInput->value('testUserPassword'); + $this->assertEquals('testUserPassword', $passwordInput->value()); + + $this->clickOnElement('submitButton'); + $h2 = $this->byCssSelector('h2'); + $this->assertMatchesRegularExpression('/Welcome, TestUser!/', $h2->text()); + } + + /** + * #190 + */ + public function testTypingAddsCharactersToTheCurrentValueOfAnElement() + { + $this->url('html/test_type_page1.html'); + $usernameInput = $this->byName('username'); + $usernameInput->value('first'); + $usernameInput->value('second'); + $this->assertEquals('firstsecond', $usernameInput->value()); + } + + /** + * #165 + */ + public function testNumericValuesCanBeTyped() + { + $this->url('html/test_type_page1.html'); + $usernameInput = $this->byName('username'); + $usernameInput->value(1.13); + $this->assertEquals('1.13', $usernameInput->value()); + } + + public function testFormsCanBeSubmitted() + { + $this->url('html/test_type_page1.html'); + $usernameInput = $this->byName('username'); + $usernameInput->value('TestUser'); + + $this->byId('submitButton')->submit(); + + // fix slow submiting + $this->waitUntil(function() { + try { + $this->byCssSelector('h2'); + + return true; + } catch (WebDriverException $e) { + return null; + } + }, 10000); + + $h2 = $this->byCssSelector('h2'); + $this->assertMatchesRegularExpression('/Welcome, TestUser!/', $h2->text()); + } + + /** + * @depends testTypingViaTheKeyboard + */ + public function testTextTypedInAreasCanBeCleared() + { + $this->url('html/test_type_page1.html'); + $usernameInput = $this->byName('username'); + $usernameInput->value('TestUser'); + $usernameInput->clear(); + $this->assertEquals('', $usernameInput->value()); + } + + public function testTypingNonLatinText() + { + $this->url('html/test_type_page1.html'); + $usernameInput = $this->byName('username'); + $usernameInput->value('テストユーザ'); + $this->assertEquals('テストユーザ', $usernameInput->value()); + } + + public function testSelectElements() + { + $this->url('html/test_select.html'); + $option = $this->byId('o2'); + $this->assertEquals('Second Option', $option->text()); + $this->assertEquals('option2', $option->value()); + $this->assertTrue($option->selected()); + $option = $this->byId('o3'); + $this->assertFalse($option->selected()); + $option->click(); + $this->assertTrue($option->selected()); + } + + public function testASelectObjectCanBeBuildWithASpecificAPI() + { + $this->url('html/test_select.html'); + $select = $this->select($this->byCssSelector('select')); + + // basic + $this->assertEquals('Second Option', $select->selectedLabel()); + $this->assertEquals('option2', $select->selectedValue()); + + // by text, value attribute or generic criteria + $select->selectOptionByLabel('Fourth Option'); + $this->assertEquals('option4', $select->selectedValue()); + + $select->selectOptionByValue('option3'); + $this->assertEquals('Third Option', $select->selectedLabel()); + + $select->selectOptionByCriteria($this->using('id')->value('o4')); + $this->assertEquals('option4', $select->selectedValue()); + + // empty values + $select->selectOptionByValue(''); + $this->assertEquals('Empty Value Option', $select->selectedLabel()); + + $select->selectOptionByLabel(''); + $this->assertEquals('', $select->selectedLabel()); + + } + + /** + * Ticket 119 + */ + public function testSelectOptionSelectsDescendantElement() + { + $this->url('html/test_select.html'); + $select = $this->select($this->byCssSelector('#secondSelect')); + $this->assertEquals("option2", $select->selectedValue()); + + $select->selectOptionByLabel("First Option"); + $this->assertEquals("option1", $select->selectedValue()); + + $select->selectOptionByValue("option2"); + $this->assertEquals("option2", $select->selectedValue()); + } + + /** + * Ticket 170 + */ + public function testSelectOptgroupDoNotGetInTheWay() + { + $this->url('html/test_select.html'); + $select = $this->select($this->byCssSelector('#selectWithOptgroup')); + + $select->selectOptionByLabel("Second"); + $this->assertEquals("2", $select->selectedValue()); + + $select->selectOptionByValue("1"); + $this->assertEquals("1", $select->selectedValue()); + } + + public function testCheckboxesCanBeSelectedAndDeselected() + { + $this->markTestIncomplete("Flaky: fails on clicking in some browsers."); + $this->url('html/test_check_uncheck.html'); + $beans = $this->byId('option-beans'); + $butter = $this->byId('option-butter'); + + $this->assertTrue($beans->selected()); + $this->assertFalse($butter->selected()); + + $butter->click(); + $this->assertTrue($butter->selected()); + $butter->click(); + $this->assertFalse($butter->selected()); + } + + public function testRadioBoxesCanBeSelected() + { + $this->url('html/test_check_uncheck.html'); + $spud = $this->byId('base-spud'); + $rice = $this->byId('base-rice'); + + $this->assertTrue($spud->selected()); + $this->assertFalse($rice->selected()); + + $rice->click(); + $this->assertFalse($spud->selected()); + $this->assertTrue($rice->selected()); + + $spud->click(); + $this->assertTrue($spud->selected()); + $this->assertFalse($rice->selected()); + } + + public function testWaitPeriodsAreImplicitInSelection() + { + $this->timeouts()->implicitWait(10000); + $this->url('html/test_delayed_element.html'); + $element = $this->byId('createElementButton')->click(); + $div = $this->byXPath("//div[@id='delayedDiv']"); + $this->assertEquals('Delayed div.', $div->text()); + } + + public function testTimeoutsCanBeDefinedForAsynchronousExecutionOfJavaScript() + { + $this->url('html/test_open.html'); + $this->timeouts()->asyncScript(10000); + $script = 'var callback = arguments[0]; + window.setTimeout(function() { + callback(document.title); + }, 1000); + '; + $result = $this->executeAsync(array( + 'script' => $script, + 'args' => array() + )); + $this->assertEquals("Test open", $result); + } + + public function testTheBackAndForwardButtonCanBeUsedToNavigate() + { + $this->url('html/test_click_page1.html'); + $this->assertEquals('Click Page 1', $this->title()); + + $this->clickOnElement('link'); + $this->byId('previousPage'); + $this->assertEquals('Click Page Target', $this->title()); + + $this->back(); + $this->assertEquals('Click Page 1', $this->title()); + + $this->forward(); + $this->assertEquals('Click Page Target', $this->title()); + } + + public function testThePageCanBeRefreshed() + { + $this->url('html/test_page.slow.html'); + $this->assertStringEndsWith('html/test_page.slow.html', $this->url()); + $this->assertEquals('Slow Loading Page', $this->title()); + + $this->clickOnElement('changeSpan'); + $this->assertEquals('Changed the text', $this->byId('theSpan')->text()); + $this->refresh(); + $this->assertEquals('This is a slow-loading page.', $this->byId('theSpan')->text()); + + $this->clickOnElement('changeSpan'); + $this->assertEquals('Changed the text', $this->byId('theSpan')->text()); + } + + public function testLinkEventsAreGenerated() + { + $this->markTestIncomplete("Waiting for new phpunit-selenium release"); + $this->url('html/test_form_events.html'); + $eventLog = $this->byId('eventlog'); + $eventLog->clear(); + + $this->clickOnElement('theLink'); + $this->waitUntil(function () { + $this->alertIsPresent(); + }, 8000); + + $this->assertEquals('link clicked', $text); + $this->acceptAlert(); + $this->assertContains('{click(theLink)}', $eventLog->value()); + } + + public function testButtonEventsAreGenerated() + { + $this->url('html/test_form_events.html'); + $eventLog = $this->byId('eventlog'); + $eventLog->clear(); + + $this->clickOnElement('theButton'); + + // Not generated with firefox + //$this->assertContains('{focus(theButton)}', $eventLog->value()); + $this->assertStringContainsString('{click(theButton)}', $eventLog->value()); + $eventLog->clear(); + + $this->clickOnElement('theSubmit'); + $this->assertStringContainsString('{click(theSubmit)} {submit}', $eventLog->value()); + } + + public function testSelectEventsAreGeneratedbutOnlyIfANewSelectionIsMade() + { + $this->url('html/test_form_events.html'); + $select = $this->select($this->byId('theSelect')); + $eventLog = $this->byId('eventlog'); + $eventLog->clear(); + + $select->selectOptionByLabel('First Option'); + $this->assertEquals('option1', $select->selectedValue()); + $this->assertStringContainsString('{focus(theSelect)}', $eventLog->value()); + $this->assertStringContainsString('{change(theSelect)}', $eventLog->value()); + + $eventLog->clear(); + $select->selectOptionByLabel('First Option'); + $this->assertEquals('option1', $select->selectedValue()); + $this->assertEquals('', $eventLog->value()); + } + + public function testRadioEventsAreGenerated() + { + $this->markTestIncomplete("Flaky: fails on focus in some browsers."); + $this->url('html/test_form_events.html'); + $first = $this->byId('theRadio1'); + $second = $this->byId('theRadio2'); + $eventLog = $this->byId('eventlog'); + + $this->assertFalse($first->selected()); + $this->assertFalse($second->selected()); + $this->assertEquals('', $eventLog->value()); + + $first->click(); + $this->assertContains('{focus(theRadio1)}', $eventLog->value()); + $this->assertContains('{click(theRadio1)}', $eventLog->value()); + $this->assertContains('{change(theRadio1)}', $eventLog->value()); + $this->assertNotContains('theRadio2', $eventLog->value()); + + $eventLog->clear(); + $first->click(); + $this->assertContains('{focus(theRadio1)}', $eventLog->value()); + $this->assertContains('{click(theRadio1)}', $eventLog->value()); + } + + public function testCheckboxEventsAreGenerated() + { + $this->markTestIncomplete("Flaky: fails on focus in some browsers."); + $this->url('html/test_form_events.html'); + $checkbox = $this->byId('theCheckbox'); + $eventLog = $this->byId('eventlog'); + $this->assertFalse($checkbox->selected()); + $this->assertEquals('', $eventLog->value()); + + $checkbox->click(); + $this->assertContains('{focus(theCheckbox)}', $eventLog->value()); + $this->assertContains('{click(theCheckbox)}', $eventLog->value()); + $this->assertContains('{change(theCheckbox)}', $eventLog->value()); + + $eventLog->clear(); + $checkbox->click(); + $this->assertContains('{focus(theCheckbox)}', $eventLog->value()); + $this->assertContains('{click(theCheckbox)}', $eventLog->value()); + $this->assertContains('{change(theCheckbox)}', $eventLog->value()); + } + + public function testTextEventsAreGenerated() + { + $this->markTestIncomplete('focus event not generated with firefox (geckodriver)'); + + $this->url('html/test_form_events.html'); + $textBox = $this->byId('theTextbox'); + $eventLog = $this->byId('eventlog'); + $this->assertEquals('', $textBox->value()); + $this->assertEquals('', $eventLog->value()); + + $textBox->value('first value'); + $this->assertContains('{focus(theTextbox)}', $eventLog->value()); + } + + public function testMouseEventsAreGenerated() + { + $this->url('html/test_form_events.html'); + $this->clickOnElement('theTextbox'); + $this->clickOnElement('theButton'); + $eventLog = $this->byId('eventlog'); + $this->assertStringContainsString('{mouseover(theTextbox)}', $eventLog->value()); + $this->assertStringContainsString('{mousedown(theButton)}', $eventLog->value()); + $this->assertStringContainsString('{mouseover(theTextbox)}', $eventLog->value()); + $this->assertStringContainsString('{mousedown(theButton)}', $eventLog->value()); + } + + public function testKeyEventsAreGenerated() + { + $this->url('html/test_form_events.html'); + $this->byId('theTextbox')->value('t'); + + $this->assertStringContainsString('{keydown(theTextbox - 84)}' + . ' {keypress(theTextbox - 116)}' + . ' {keyup(theTextbox - 84)}', + $this->byId('eventlog')->value()); + } + + public function testConfirmationsAreHandledAsAlerts() + { + $this->markTestIncomplete("Waiting for new phpunit-selenium release"); + $this->url('html/test_confirm.html'); + $this->clickOnElement('confirmAndLeave'); + $text = ""; + + $this->waitUntil(function () { + $this->alertIsPresent(); + }, 8000); + $this->assertEquals('You are about to go to a dummy page.', $this->alertText()); + $this->dismissAlert(); + $this->assertEquals('Test Confirm', $this->title()); + + $this->clickOnElement('confirmAndLeave'); + + $this->waitUntil(function () { + $this->alertIsPresent(); + }, 8000); + $this->assertEquals('You are about to go to a dummy page.', $this->alertText()); + $this->acceptAlert(); + $this->assertEquals('This is a dummy page.', $this->byId('theSpan')->text()); + } + + public function testPromptsCanBeAnsweredByTyping() + { + $this->markTestIncomplete("Waiting for new phpunit-selenium release"); + $this->url('html/test_prompt.html'); + + $this->clickOnElement('promptAndLeave'); + $this->waitUntil(function () { + $this->alertIsPresent(); + }, 8000); + $this->assertEquals("Type 'yes' and click OK", $this->alertText()); + $this->dismissAlert(); + $this->assertEquals('Test Prompt', $this->title()); + + $this->clickOnElement('promptAndLeave'); + $this->waitUntil(function () { + $this->alertIsPresent(); + }, 8000); + $this->alertText('yes'); + $this->acceptAlert(); + $this->assertEquals('Dummy Page', $this->title()); + } + + public function testInvisibleElementsDoNotHaveADisplayedText() + { + $this->url('html/test_visibility.html'); + $this->assertEquals('A visible paragraph', $this->byId('visibleParagraph')->text()); + $this->assertTrue($this->byId('visibleParagraph')->displayed()); + + $this->assertEquals('', $this->byId('hiddenParagraph')->text()); + $this->assertFalse($this->byId('hiddenParagraph')->displayed()); + + $this->assertEquals('', $this->byId('suppressedParagraph')->text()); + $this->assertEquals('', $this->byId('classSuppressedParagraph')->text()); + $this->assertEquals('', $this->byId('jsClassSuppressedParagraph')->text()); + $this->assertEquals('', $this->byId('hiddenSubElement')->text()); + $this->assertEquals('sub-element that is explicitly visible', $this->byId('visibleSubElement')->text()); + $this->assertEquals('', $this->byId('suppressedSubElement')->text()); + $this->assertEquals('', $this->byId('jsHiddenParagraph')->text()); + } + + public function testScreenshotsCanBeTakenAtAnyMoment() + { + $this->url('html/test_open.html'); + $screenshot = $this->currentScreenshot(); + $this->assertTrue(is_string($screenshot)); + $this->assertTrue(strlen($screenshot) > 0); + $this->markTestIncomplete('By guaranteeing the size of the window, we could add a deterministic assertion for the image.'); + } + + public function testACurrentWindowHandleAlwaysExist() + { + $this->url('html/test_open.html'); + $window = $this->windowHandle(); + $this->assertTrue(is_string($window)); + $this->assertTrue(strlen($window) > 0); + $allHandles = $this->windowHandles(); + $this->assertEquals(array('0' => $window), $allHandles); + } + + public function testThePageSourceCanBeRead() + { + $this->url('html/test_open.html'); + $source = $this->source(); + + // No guarantee that it will exactly match the contents of the file + //$this->assertStringStartsWith(' - - - - - - - + + + + + + + + + + + + + {$Title} - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/Sources/webAduc/www/src/templates/login.smarty b/Sources/webAduc/www/src/templates/login.smarty index a21417c..bc5c19f 100644 --- a/Sources/webAduc/www/src/templates/login.smarty +++ b/Sources/webAduc/www/src/templates/login.smarty @@ -27,14 +27,15 @@ {/if}
- +
-
+