function LdapAuthorizationDeriveEntry::testDeriveFromDN in Lightweight Directory Access Protocol (LDAP) 7
File
- ldap_authorization/tests/DeriveFromDN/DeriveFromDN.test, line 21
Class
- LdapAuthorizationDeriveEntry
Code
function testDeriveFromDN() {
return;
$this->ldapTestId = 'DeriveFromDN';
$this->serversData = 'DeriveFromDN/ldap_servers.inc';
$this->authorizationData = 'DeriveFromDN/ldap_authorization.inc';
$this->authenticationData = 'DeriveFromDN/ldap_authentication.inc';
$this->consumerType = 'drupal_role';
$this
->prepTestData();
$user = $this
->drupalCreateUser(array());
$unkool = $this->testFunctions
->drupalLdapUpdateUser(array(
'name' => 'unkool',
'mail' => 'unkool@nowhere.myuniversity.edu',
), TRUE, $user);
list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($unkool, 'query');
debug("new_authorizations, notifications");
debug(array(
$new_authorizations,
$notifications,
));
$this
->assertTrue(count($new_authorizations[$this->consumerType]) == 0, 'user account unkool tested for granting no drupal roles ', $this->ldapTestId . '.nomatch');
$user = $this
->drupalCreateUser(array());
$jkool = $this->testFunctions
->drupalLdapUpdateUser(array(
'name' => 'jkool',
'mail' => 'jkool@guests.myuniversity.edu',
), TRUE, $user);
list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($jkool, 'query');
$correct_roles = (bool) (isset($new_authorizations['drupal_role']) && in_array('guests', $new_authorizations['drupal_role']));
$this
->assertTrue($correct_roles, 'user account jkool tested for granting drupal_role "guests"', $this->ldapTestId . '.onematch');
$user = $this
->drupalCreateUser(array());
$verykool = $this->testFunctions
->drupalLdapUpdateUser(array(
'name' => 'verykool',
'mail' => 'verykool@myuniversity.edu',
), TRUE, $user);
list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($verykool, 'query');
$correct_roles = (bool) (isset($new_authorizations['drupal_role']) && in_array('guests', $new_authorizations[$this->consumerType]) && in_array('special guests', $new_authorizations[$this->consumerType]));
$this
->assertTrue($correct_roles, 'user account verykool tested for granting "guests" and "special guests" drupal roles ', $this->ldapTestId . '.manymatch');
$this
->assertTrue($correct_roles, 'user account verykool tested for case insensitivity ', $this->ldapTestId . '.caseinsensitive');
$edit = array(
'name' => 'newkool',
'pass' => 'goodpwd',
);
$this
->drupalPost('user', $edit, t('Log in'));
$this
->assertText(t('Member for'));
$newkool = user_load_by_name('newkool');
$granted_roles = array_values($newkool->roles);
$this
->assertTrue(in_array('guests', $granted_roles) && in_array('special guests', $granted_roles), 'Proper roles granted to newkool on actual logon');
$this
->drupalLogout();
}