Skip to content

Commit 97902df

Browse files
committed
Use GithubAction to run ldap tests
1 parent af9562b commit 97902df

File tree

11 files changed

+31
-92
lines changed

11 files changed

+31
-92
lines changed

.github/workflows/actions/populate-ldap/Dockerfile

-9
This file was deleted.

.github/workflows/actions/populate-ldap/action.yml

-9
This file was deleted.

.github/workflows/actions/populate-ldap/fixtures.ldif

-26
This file was deleted.

.github/workflows/tests.yml

+18-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ jobs:
1515
php: ['7.1', '7.4']
1616

1717
services:
18+
ldap:
19+
image: bitnami/openldap
20+
ports:
21+
- 3389:3389
22+
env:
23+
LDAP_ADMIN_USERNAME: admin
24+
LDAP_ADMIN_PASSWORD: symfony
25+
LDAP_ROOT: dc=symfony,dc=com
26+
LDAP_PORT_NUMBER: 3389
27+
LDAP_USERS: a
28+
LDAP_PASSWORDS: a
1829
redis:
1930
image: redis:6.0.0
2031
ports:
@@ -45,17 +56,20 @@ jobs:
4556
- name: Checkout
4657
uses: actions/checkout@v2
4758

48-
- name: Populate LDAP
49-
uses: ./.github/actions/populate-ldap
50-
5159
- name: Setup PHP
5260
uses: shivammathur/setup-php@v2
5361
with:
5462
coverage: "none"
55-
extensions: "memcached,redis,xsl"
63+
extensions: "memcached,redis,xsl,ldap"
5664
ini-values: "memory_limit=-1"
5765
php-version: "${{ matrix.php }}"
5866

67+
- name: Load fixtures
68+
uses: docker://bitnami/openldap
69+
with:
70+
entrypoint: /bin/bash
71+
args: -c "(ldapwhoami -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony||sleep 5) && ldapadd -h ldap:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif && ldapdelete -h ldap:3389 -D cn=admin,dc=symfony,dc=com -w symfony cn=a,ou=users,dc=symfony,dc=com"
72+
5973
- name: Configure composer
6074
run: |
6175
COMPOSER_HOME="$(composer config home)"

.travis.yml

-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ addons:
99
apt_packages:
1010
- parallel
1111
- language-pack-fr-base
12-
- ldap-utils
13-
- slapd
1412
- zookeeperd
1513
- libzookeeper-mt-dev
1614

@@ -164,13 +162,6 @@ before_install:
164162
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
165163
done
166164
167-
- |
168-
# Load fixtures
169-
if [[ ! $skip ]]; then
170-
ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif &&
171-
ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif
172-
fi
173-
174165
install:
175166
- |
176167
# Install the phpunit-bridge from a PR if required

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/**
2424
* @requires extension ldap
25+
* @group integration
2526
*/
2627
class AdapterTest extends LdapTestCase
2728
{
@@ -116,7 +117,7 @@ public function testLdapQueryScopeOneLevel()
116117

117118
public function testLdapPagination()
118119
{
119-
$ldap = new Adapter(array_merge($this->getLdapConfig()));
120+
$ldap = new Adapter($this->getLdapConfig());
120121
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
121122
$entries = $this->setupTestUsers($ldap);
122123

@@ -147,7 +148,7 @@ public function testLdapPagination()
147148
$this->assertEquals(\count($fully_paged_query->getResources()), 1);
148149
$this->assertEquals(\count($paged_query->getResources()), 5);
149150

150-
if (\PHP_MAJOR_VERSION > 7 || (\PHP_MAJOR_VERSION == 7 && \PHP_MINOR_VERSION >= 2)) {
151+
if (\PHP_VERSION_ID >= 70200) {
151152
// This last query is to ensure that we haven't botched the state of our connection
152153
// by not resetting pagination properly. extldap <= PHP 7.1 do not implement the necessary
153154
// bits to work around an implementation flaw, so we simply can't guarantee this to work there.
@@ -199,7 +200,7 @@ private function destroyEntries($ldap, $entries)
199200

200201
public function testLdapPaginationLimits()
201202
{
202-
$ldap = new Adapter(array_merge($this->getLdapConfig()));
203+
$ldap = new Adapter($this->getLdapConfig());
203204
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
204205

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

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public function testLdapAddDouble()
9696
$em->add($entry);
9797
try {
9898
$em->add($entry);
99-
} catch (LdapException $e) {
99+
} finally {
100100
$em->remove($entry);
101-
throw $e;
102101
}
103102
}
104103

@@ -215,12 +214,12 @@ public function testLdapRenameWithoutRemovingOldRdn()
215214
$newEntry = $result[0];
216215
$originalCN = $entry->getAttribute('cn')[0];
217216

218-
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
219-
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
220-
221-
$entryManager->rename($newEntry, 'cn='.$originalCN);
222-
223-
$this->executeSearchQuery(1);
217+
try {
218+
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
219+
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
220+
} finally {
221+
$entryManager->rename($newEntry, 'cn='.$originalCN);
222+
}
224223
}
225224

226225
public function testLdapAddRemoveAttributeValues()

src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf

-18
This file was deleted.

src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif

-4
This file was deleted.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +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);
12+
@ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);
1313

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

src/Symfony/Component/Ldap/phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
<php>
1212
<ini name="error_reporting" value="-1" />
13-
<env name="LDAP_HOST" value="127.0.0.1" />
13+
<env name="LDAP_HOST" value="localhost" />
1414
<env name="LDAP_PORT" value="3389" />
1515
</php>
1616

0 commit comments

Comments
 (0)