memberOf resembles a DN as well and is actively used

This commit is contained in:
Arthur Schiwon 2015-09-28 18:38:57 +02:00
parent d68079f932
commit 0dde79b75b
2 changed files with 37 additions and 1 deletions

View File

@ -215,7 +215,9 @@ class Access extends LDAPUtility implements user\IUserTools {
$resemblingAttributes = array(
'dn',
'uniquemember',
'member'
'member',
// memberOf is an "operational" attribute, without a definition in any RFC
'memberof'
);
return in_array($attr, $resemblingAttributes);
}

View File

@ -260,4 +260,38 @@ class Test_Access extends \Test\TestCase {
$access->batchApplyUserAttributes($data);
}
public function dNAttributeProvider() {
// corresponds to Access::resemblesDN()
return array(
'dn' => array('dn'),
'uniqueMember' => array('uniquemember'),
'member' => array('member'),
'memberOf' => array('memberof')
);
}
/**
* @dataProvider dNAttributeProvider
*/
public function testSanitizeDN($attribute) {
list($lw, $con, $um) = $this->getConnectorAndLdapMock();
$dnFromServer = 'cn=Mixed Cases,ou=Are Sufficient To,ou=Test,dc=example,dc=org';
$lw->expects($this->any())
->method('isResource')
->will($this->returnValue(true));
$lw->expects($this->any())
->method('getAttributes')
->will($this->returnValue(array(
$attribute => array('count' => 1, $dnFromServer)
)));
$access = new Access($con, $lw, $um);
$values = $access->readAttribute('uid=whoever,dc=example,dc=org', $attribute);
$this->assertSame($values[0], strtolower($dnFromServer));
}
}