8000 [DoctrineBridge] Fix DBAL deprecations in middlewares. · symfony/symfony@3510b67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3510b67

Browse files
derrabusjderusse
authored andcommitted
[DoctrineBridge] Fix DBAL deprecations in middlewares.
Adds LDAP tests Run only ldap tests Change hostname for ldap server Moves LDAP host name in run test env Tests Only run LDAP tests Change LDAP host name in actions Run all tests again
1 parent 091265b commit 3510b67

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ jobs:
4040
image: rabbitmq:3.8.3
4141
ports:
4242
- 5672:5672
43-
43+
openldap:
44+
image: lucasaba/symfony-openldap:0.1
45+
ports:
46+
- 3389:389
47+
env:
48+
LDAP_ADMIN_PASSWORD: symfony
49+
LDAP_BASE_DN: "dc=symfony,dc=com"
50+
LDAP_SEED_INTERNAL_LDIF_PATH: "/ldif-data"
4451
steps:
4552
- name: Checkout
4653
uses: actions/checkout@v2
@@ -87,6 +94,8 @@ jobs:
8794
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
8895
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
8996
MEMCACHED_HOST: localhost
97+
LDAP_HOST: localhost
98+
LDAP_PORT: 3389
9099

91100
- name: Run HTTP push tests
92101
if: matrix.php == '7.4'

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ before_install:
5555
# General configuration
5656
set -e
5757
stty cols 120
58-
mkdir /tmp/slapd
59-
if [ ! -e /tmp/slapd-modules ]; then
60-
[ -d /usr/lib/openldap ] && ln -s /usr/lib/openldap /tmp/slapd-modules || ln -s /usr/lib/ldap /tmp/slapd-modules
61-
fi
62-
slapd -f src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf -h ldap://localhost:3389 &
6358
cp .github/composer-config.json "$(composer config home)/config.json"
6459
export PHPUNIT=$(readlink -f ./phpunit)
6560
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<ini name="memory_limit" value="-1" />
1616
<env name="DUMP_LIGHT_ARRAY" value="" />
1717
<env name="DUMP_STRING_LENGTH" value="" />
18-
<env name="LDAP_HOST" value="127.0.0.1" />
18+
<env name="LDAP_HOST" value="localhost" />
1919
<env name="LDAP_PORT" value="3389" />
2020
<env name="REDIS_HOST" value="localhost" />
2121
<env name="MEMCACHED_HOST" value="localhost" />

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@
2525
*/
2626
class AdapterTest extends LdapTestCase
2727
{
28-
private const PAGINATION_REQUIRED_CONFIG = [
29-
'options' => [
30-
'protocol_version' => 3,
31-
],
32-
];
33-
3428
public function testLdapEscape()
3529
{
3630
$ldap = new Adapter();
@@ -122,7 +116,7 @@ public function testLdapQueryScopeOneLevel()
122116

123117
public function testLdapPagination()
124118
{
125-
$ldap = new Adapter(array_merge($this->getLdapConfig(), static::PAGINATION_REQUIRED_CONFIG));
119+
$ldap = new Adapter(array_merge($this->getLdapConfig()));
126120
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
127121
$entries = $this->setupTestUsers($ldap);
128122

@@ -205,7 +199,7 @@ private function destroyEntries($ldap, $entries)
205199

206200
public function testLdapPaginationLimits()
207201
{
208-
$ldap = new Adapter(array_merge($this->getLdapConfig(), static::PAGINATION_REQUIRED_CONFIG));
202+
$ldap = new Adapter(array_merge($this->getLdapConfig()));
209203
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
210204

211205
$entries = $this->setupTestUsers($ldap);

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
1616
use Symfony\Component\Ldap\Adapter\ExtLdap\UpdateOperation;
1717
use Symfony\Component\Ldap\Entry;
18-
use Symfony\Component\Ldap\Exception\AlreadyExistsException;
1918
use Symfony\Component\Ldap\Exception\LdapException;
2019
use Symfony\Component\Ldap\Exception\NotBoundException;
2120
use Symfony\Component\Ldap\Exception\UpdateOperationException;
2221
use Symfony\Component\Ldap\Tests\LdapTestCase;
2322

2423
/**
2524
* @requires extension ldap
25+
* @group integration
2626
*/
2727
class LdapManagerTest extends LdapTestCase
2828
{
@@ -82,7 +82,7 @@ public function testLdapAddInvalidEntry()
8282
*/
8383
public function testLdapAddDouble()
8484
{
85-
$this->expectException(AlreadyExistsException::class);
85+
$this->expectException(LdapException::class);
8686
$this->executeSearchQuery(1);
8787

8888
$entry = new Entry('cn=Elsa Amrouche,dc=symfony,dc=com', [
@@ -94,7 +94,12 @@ public function testLdapAddDouble()
9494

9595
$em = $this->adapter->getEntryManager();
9696
$em->add($entry);
97-
$em->add($entry);
97+
try {
98+
$em->add($entry);
99+
} catch (LdapException $e) {
100+
$em->remove($entry);
101+
throw $e;
102+
}
98103
}
99104

100105
/**
@@ -210,7 +215,8 @@ public function testLdapRenameWithoutRemovingOldRdn()
210215
$newEntry = $result[0];
211216
$originalCN = $entry->getAttribute('cn')[0];
212217

213-
$this->assertStringContainsString($originalCN, $newEntry->getAttribute('cn'));
218+
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
219+
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
214220

215221
$entryManager->rename($newEntry, 'cn='.$originalCN);
216222

@@ -372,13 +378,16 @@ public function testLdapMove()
372378
$result = $this->executeSearchQuery(1);
373379

374380
$entry = $result[0];
375-
$this->assertNotContains('ou=Ldap', $entry->getDn());
381+
$this->assertStringNotContainsString('ou=Ldap', $entry->getDn());
376382

377383
$entryManager = $this->adapter->getEntryManager();
378384
$entryManager->move($entry, 'ou=Ldap,ou=Components,dc=symfony,dc=com');
379385

380386
$result = $this->executeSearchQuery(1);
381387
$movedEntry = $result[0];
382388
$this->assertStringContainsString('ou=Ldap', $movedEntry->getDn());
389+
390+
// Move back entry
391+
$entryManager->move($movedEntry, 'dc=symfony,dc=com');
383392
}
384393
}

src/Symfony/Component/Ldap/Tests/LdapTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class LdapTestCase extends TestCase
99
protected function getLdapConfig()
1010
{
1111
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
12+
ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);
1213

1314
if (!$h || !@ldap_bind($h)) {
1415
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');

0 commit comments

Comments
 (0)
0