Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Ldap manual import (#5381)
Browse files Browse the repository at this point in the history
* ldapLDAPManualImport config added into behat.yml

* LdapManualImport and LdapManualImportContext.php.feature files for acceptance test added

* feature's background modified

* LdapManualImportContext.php accpetance test ok

* LdapManuelImport acceptance test enhanced

* UtilsContext Class withdrawn

* features's name modified

* improve acceptance test for ldap manual import

* improve ldap manual import acceptance test
  • Loading branch information
MatthieuMan authored and kduret committed Jul 4, 2017
1 parent cc87a71 commit 29ede94
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 9 deletions.
5 changes: 5 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ default:
paths: [ %paths.base%/features/LdapConfiguration.feature ]
contexts:
- LdapConfigurationContext

ldap_manual_import:
paths: [ %paths.base%/features/LdapManualImport.feature ]
contexts:
- LdapManualImportContext

control_login:
paths: [ %paths.base%/features/ControlLogin.feature ]
Expand Down
19 changes: 19 additions & 0 deletions features/LdapManualImport.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: LDAPManualImport
As a company administrator
I want to import manually users
In order to filter the ones who can access to Centreon Web

Background:
Given I am logged in a Centreon server with a configured ldap
And a LDAP configuration with Users auto import disabled has been created

Scenario: Search and import one user whose alias contains an accent
Given I search a specific user whose alias contains a special character such as an accent
And the LDAP search result displays the expected alias
When I import the user
Then the user is created

Scenario: LDAP manually imported user can authenticate to Centreon Web
Given one alias with an accent has been manually imported
When this user logins to Centreon Web
Then he's logged by default on Home page
9 changes: 0 additions & 9 deletions features/bootstrap/LdapContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ class LdapContext extends CentreonContext
{
private $page;

/**
* @Given I am logged in a Centreon server with a configured ldap
*/
public function iAmLoggedInACentreonServerWithAConfiguredLdap()
{
$this->launchCentreonWebContainer('web_openldap');
$this->iAmLoggedIn();
}

/**
* @Given a ldap user has been imported
*/
Expand Down
124 changes: 124 additions & 0 deletions features/bootstrap/LdapManualImportContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Administration\LdapConfigurationListingPage;
use Centreon\Test\Behat\Administration\LdapUserImportPage;
use Centreon\Test\Behat\Configuration\ContactConfigurationListingPage;
use Centreon\Test\Behat\External\LoginPage;

class LdapManualImportContext extends CentreonContext
{
protected $page;
protected $alias ='centréon-ldap4';

/**
* @Given a LDAP configuration with Users auto import disabled has been created
*/
public function aLdapConfigurationWithUsersAutoImportDisabledHasBeenCreated()
{
$this->page = new LdapConfigurationListingPage($this);
$this->page = $this->page->inspect('openldap');
$this->page->setProperties(array(
'enable_authentication' => 1,
'auto_import' => 0,
));
$this->page = $this->page->save();
$this->page = $this->page->inspect('openldap');
if ($this->page->getProperty('auto_import') != 0) {
throw new Exception('Users auto import enabled');
}
}

/**
* @Given I search a specific user whose alias contains a special character such as an accent
*/
public function iSearchASpecificUserWhoseAliasContainsASpecialCharacterSuchAsAnAccent()
{
$this->page = new LdapUserImportPage($this);
$this->page->setProperties(
array(
'servers' => array(
'openldap' => array(
'checked' => true
)
)
)
);
}

/**
* @Given the LDAP search result displays the expected alias
*/
public function theLdapSearchResultDisplaysTheExpectedAlias()
{
$this->assertFindButton('Search')->click();
}

/**
* @When I import the user
*/
public function iImportTheUser()
{
$this->spin(
function ($context) {
return $context->getSession()->getPage()->has(
'css',
'input[id^="contact_alias"][value="centréon-ldap4"]'
);
},
'user to import not found.',
10
);
$line = $this->assertFind(
'css',
'input[id^="contact_alias"][value="centréon-ldap4"]'
)->getParent()->getParent();
$this->assertFindIn($line, 'css', 'input[type="checkbox"]')->click();
$this->assertFindButton('submitA')->click();
}

/**
* @Then the user is created
*/
public function theUserIsCreated()
{
$this->assertFindLink('centréon-ldap4')->click();
$this->page = new ContactConfigurationListingPage($this);
$object = $this->page->getEntry($this->alias);
if ($object['alias'] != $this->alias) {
throw new Exception(' contact not created ');
}
}

/**
* @Given one alias with an accent has been manually imported
*/
public function oneAliasWithAnAccentHasBeenManuallyImported()
{
$this->aLdapConfigurationWithUsersAutoImportDisabledHasBeenCreated();
$this->iSearchASpecificUserWhoseAliasContainsASpecialCharacterSuchAsAnAccent();
$this->theLdapSearchResultDisplaysTheExpectedAlias();
$this->iImportTheUser();
}

/**
* @When this user logins to Centreon Web
*/
public function thisUserLoginsToCentreonWeb()
{
$this->iAmLoggedOut();
$this->page = new LoginPage($this);
$this->page->login($this->alias, 'centreon-ldap4');
}

/**
* @Then he's logged by default on Home page
*/
public function hesLoggedByDefaultOnHomePage()
{
$value = $this->assertFind('css', 'div#logli a[class="red"]')->getText();
if ($value != 'Logout') {
throw new Exception('The user is not logged in');
}
}
}

0 comments on commit 29ede94

Please sign in to comment.