8000 [LDAP] Add ldap tests to github CI by lucasaba · Pull Request #39030 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[LDAP] Add ldap tests to github CI #39030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use GithubAction to run ldap tests
  • Loading branch information
jderusse committed Nov 16, 2020
commit ea78f728b153fccc37f732c5f25c897b8dd3123c
9 changes: 0 additions & 9 deletions .github/workflows/actions/populate-ldap/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/actions/populate-ldap/action.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/actions/populate-ldap/fixtures.ldif

This file was deleted.

24 changes: 19 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ jobs:
php: ['7.1', '7.4']

services:
ldap:
image: bitnami/openldap
ports:
- 3389:3389
env:
LDAP_ADMIN_USERNAME: admin
LDAP_ADMIN_PASSWORD: symfony
LDAP_ROOT: dc=symfony,dc=com
LDAP_PORT_NUMBER: 3389
LDAP_USERS: a
LDAP_PASSWORDS: a
redis:
image: redis:6.0.0
ports:
Expand Down Expand Up @@ -45,17 +56,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Populate LDAP
uses: ./.github/actions/populate-ldap

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "memcached,redis,xsl"
extensions: "memcached,redis,xsl,ldap"
ini-values: "memory_limit=-1"
php-version: "${{ matrix.php }}"

- name: Load fixtures
uses: docker://bitnami/openldap
with:
entrypoint: /bin/bash
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"

- name: Configure composer
run: |
COMPOSER_HOME="$(composer config home)"
Expand Down Expand Up @@ -83,7 +97,7 @@ jobs:
echo "::endgroup::"

- name: Run tests
run: ./phpunit --group integration
run: ./phpunit --group integration -v
env:
REDIS_HOST: localhost
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhos 8000 t:7002 localhost:7003 localhost:7004 localhost:7005'
Expand Down
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ addons:
apt_packages:
- parallel
- language-pack-fr-base
- ldap-utils
- slapd
- zookeeperd
- libzookeeper-mt-dev

Expand Down Expand Up @@ -164,13 +162,6 @@ before_install:
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
done

- |
# Load fixtures
if [[ ! $skip ]]; then
ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif &&
ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif
fi

install:
- |
# Install the phpunit-bridge from a PR if required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/**
* @requires extension ldap
* @group integration
*/
class AdapterTest extends LdapTestCase
{
Expand Down Expand Up @@ -116,7 +117,7 @@ public function testLdapQueryScopeOneLevel()

public function testLdapPagination()
{
$ldap = new Adapter(array_merge($this->getLdapConfig()));
$ldap = new Adapter($this->getLdapConfig());
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
$entries = $this->setupTestUsers($ldap);

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

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

public function testLdapPaginationLimits()
{
$ldap = new Adapter(array_merge($this->getLdapConfig()));
$ldap = new Adapter($this->getLdapConfig());
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');

$entries = $this->setupTestUsers($ldap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ public function testLdapAddDouble()
$em->add($entry);
try {
$em->add($entry);
} catch (LdapException $e) {
} finally {
$em->remove($entry);
throw $e;
}
}

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

$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));

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

$this->executeSearchQuery(1);
try {
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
} finally {
$entryManager->rename($newEntry, 'cn='.$originalCN);
}
}

public function testLdapAddRemoveAttributeValues()
Expand Down
18 changes: 0 additions & 18 deletions src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Tests/LdapTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LdapTestCase extends TestCase
protected function getLdapConfig()
{
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);
@ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);

if (!$h || !@ldap_bind($h)) {
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="LDAP_HOST" value="127.0.0.1" />
<env name="LDAP_HOST" value="localhost" />
<env name="LDAP_PORT" value="3389" />
</php>

Expand Down
0