function let() { $this->filter = new FilterBuilder(); $config = new Configuration(); $parser = new SchemaYamlParser($config->getSchemaFolder()); $this->schema = $parser->parse('ad', 'user'); $this->collection = new OperatorCollection(); $this->collection->addLdapObjectSchema($this->schema); $this->collection->addLdapObjectSchema($parser->parse('ad', 'ou')); $this->beConstructedThrough('getInstance', [$this->schema, $this->collection, AttributeConverterInterface::TYPE_SEARCH_TO]); }
function it_should_hydrate_the_ldap_filter_for_a_query_operation_based_off_the_current_alias($connection) { $this->setLdapConnection($connection); $gSchema = $this->parser->parse('ad', 'group'); $operators = new OperatorCollection(); $operators->addLdapObjectSchema($this->schema, 'u'); $operators->addLdapObjectSchema($gSchema, 'g'); $operators->add(new Comparison('g.foo', '=', 'bar')); $operators->add(new Comparison('u.bar', '=', 'foo')); $operation = new QueryOperation($operators); $this->setAlias('g'); $this->hydrateToLdap($operation)->getFilter()->shouldBeEqualTo('(&(objectClass=group)(foo=bar))'); }
function it_should_get_the_ldif_string_representation_in_the_context_of_a_type_and_a_schema(LdapConnectionInterface $connection, LdapObject $rootdse) { $domain = new DomainConfiguration('example.local'); $domain->setUseTls(true); $connection->getConfig()->willReturn($domain); $connection->getRootDse()->willReturn($rootdse); $config = new Configuration(); $parser = new SchemaYamlParser($config->getSchemaFolder()); $schema = $parser->parse('ad', 'user'); $dn = 'cn=foo,dc=foo,dc=bar'; $this->beConstructedWith($dn); $this->setLdapObjectSchema($schema); $this->setLdapConnection($connection); $this->add('phoneNumber', '555-5555'); $this->reset('lastName'); $this->replace('firstName', 'bar'); $this->delete('password', 'foo'); $this->add('password', 'bar'); $ldif = "dn: {$dn}\r\n" . "changetype: modify\r\n" . "add: telephoneNumber\r\n" . "telephoneNumber: 555-5555\r\n" . "-\r\n" . "delete: sn\r\n" . "-\r\n" . "replace: givenName\r\n" . "givenName: bar\r\n" . "-\r\n" . "delete: unicodePwd\r\n" . "unicodePwd: IgBmAG8AbwAiAA==\r\n" . "-\r\n" . "add: unicodePwd\r\n" . "unicodePwd: IgBiAGEAcgAiAA==\r\n" . "-\r\n"; $this->toString()->shouldBeEqualTo($ldif); }
function it_should_get_the_ldif_representation_in_the_context_of_a_type_and_schema(LdapConnectionInterface $connection, LdapObject $rootdse) { $domain = new DomainConfiguration('example.local'); $domain->setUseTls(true); $connection->getConfig()->willReturn($domain); $connection->getRootDse()->willReturn($rootdse); $config = new Configuration(); $parser = new SchemaYamlParser($config->getSchemaFolder()); $schema = $parser->parse('ad', 'user'); $this->beConstructedWith(null); $this->setLdapObjectSchema($schema); $this->setLdapConnection($connection); $this->setAttributes(['username' => 'John', 'password' => '12345']); $this->setLocation('ou=employees,dc=example,dc=local'); $ldif = "dn: cn=John,ou=employees,dc=example,dc=local\r\n" . "changetype: add\r\n" . "cn: John\r\n" . "displayname: John\r\n" . "givenName: John\r\n" . "userPrincipalName: John@example.local\r\n" . "objectclass: top\r\n" . "objectclass: person\r\n" . "objectclass: organizationalPerson\r\n" . "objectclass: user\r\n" . "sAMAccountName: John\r\n" . "unicodePwd: IgAxADIAMwA0ADUAIgA=\r\n" . "userAccountControl: 512\r\n"; $this->toString()->shouldBeEqualTo($ldif); }