Private GIT

Skip to content
Snippets Groups Projects
Commit 10a0cce3 authored by Matthieu Mandoula's avatar Matthieu Mandoula Committed by Kevin Duret
Browse files

Ldap manual import (#5381)

* 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
parent 838e5913
No related branches found
No related tags found
No related merge requests found
...@@ -189,6 +189,11 @@ default: ...@@ -189,6 +189,11 @@ default:
contexts: contexts:
- LdapConfigurationContext - LdapConfigurationContext
ldap_manual_import:
paths: [ %paths.base%/features/LdapManualImport.feature ]
contexts:
- LdapManualImportContext
control_login: control_login:
paths: [ %paths.base%/features/ControlLogin.feature ] paths: [ %paths.base%/features/ControlLogin.feature ]
contexts: contexts:
......
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
...@@ -14,15 +14,6 @@ class LdapContext extends CentreonContext ...@@ -14,15 +14,6 @@ class LdapContext extends CentreonContext
{ {
private $page; 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 * @Given a ldap user has been imported
*/ */
......
<?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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment