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

Ldap manual import #5381

Merged
merged 13 commits into from
Jul 4, 2017
5 changes: 5 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,8 @@ default:
paths: [ %paths.base%/features/LdapConfiguration.feature ]
contexts:
- LdapConfigurationContext

ldap_manual_import:
paths: [ %paths.base%/features/LdapManualImport.feature ]
contexts:
- LdapManualImportContext
21 changes: 21 additions & 0 deletions features/LdapManualImport.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature: LDAP_Manual_Import
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
And a LDAP configuration has been created
And LDAP authentication is enabled
And users auto import is disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much "And" :
Given I am logged in a Centreon server
And a LDAP configuration has been created
And users auto import is disabled


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
140 changes: 140 additions & 0 deletions features/bootstrap/LdapManualImportContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php

use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Administration\LdapConfigurationListingPage;
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 has been created
*/
public function aLdapConfigurationHasBeenCreated()
{
$this->launchCentreonWebContainer('web_openldap');
$this->iAmLoggedIn();

$this->page = new LdapConfigurationListingPage($this);
$this->page = $this->page->inspect('openldap');
$this->page->setProperties(array(
'enable_authentification' => 1,
'auto_import' => 0,
));

$this->page->save();
}

/**
* @Given LDAP authentication is enabled
*/
public function ldapAuthenticationIsDisabled()
{
$this->page = new LdapConfigurationListingPage($this);
$object = $this->page->getEntry('openldap');

if ($object['status'] != 'Enabled') {
throw new Exception(' LDAP authentification is disabled');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fr: authentification
en: authentication

}
}

/**
* @Given users auto import is disabled
*/
public function usersAutoImportIsDisabled()
{
$this->page = new LdapConfigurationListingPage($this);
$this->assertFindLink('openldap')->click();
$value = $this->assertFind('css', 'input[name="ldap_auto_import[ldap_auto_import]"]')->getValue();

if ($value != 0) {
throw new Exception('Users auto import enabled');
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

/**
* @Given I search a specific user whose alias contains a special character such as an accent
*/
public function iSearchASpecificUserWhoseAliasContainsASpecialCharacterSuchAsAnAccent()
{
$this->page = new LdapConfigurationListingPage($this);
$this->assertFindLink('openldap')->click();
sleep(5);
$this->assertFindButton('Import users manually')->click();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

/**
* @When I import the user
*/
public function iImportTheUser()
{
sleep(5);
$this->assertFind('css', 'input[name="contact_select[select][3]"]')->click();
$this->assertFindButton('submitA')->click();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

/**
* @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) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

throw new Exception(' contact not created ');
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

/**
* @When this user logins to Centreon Web
*/
public function thisUserLoginsToCentreonWeb()
{
$this->iAmLoggedOut();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not the better way to check login

}

/**
* @Then he's logged by default on Home page
*/
public function hesLoggedByDefaultOnHomePage()
{
$this->page = new LoginPage($this);
$this->page->login($this->alias, 'centreon-ldap4');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful about blank lines (coding style)

}

}