Use GithubAction to run ldap tests
This commit is contained in:
parent
af9562b12c
commit
ea78f728b1
@ -1,9 +0,0 @@
|
|||||||
FROM osixia/openldap
|
|
||||||
LABEL maintainer="wshihadeh.devx@gmail.com"
|
|
||||||
ENV LDAP_ORGANISATION="Symfony"
|
|
||||||
ENV LDAP_DOMAIN="symfony.com"
|
|
||||||
ENV LDAP_ADMIN_PASSWORD="symfony"
|
|
||||||
ENV LDAP_BASE_DN="dc=symfony,dc=com"
|
|
||||||
ENV LDAP_SEED_INTERNAL_LDIF_PATH="/ldif-data"
|
|
||||||
RUN mkdir /ldif-data
|
|
||||||
COPY ./fixtures.ldif /ldif-data/50-fixtures.ldif
|
|
@ -1,9 +0,0 @@
|
|||||||
name: 'LDAP Populate'
|
|
||||||
description: 'Create a pre-populated LDAP server with symfony test data'
|
|
||||||
branding:
|
|
||||||
icon: 'database'
|
|
||||||
color: 'blue'
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: 'docker'
|
|
||||||
image: 'Dockerfile'
|
|
@ -1,26 +0,0 @@
|
|||||||
dn: cn=Fabien Potencier,dc=symfony,dc=com
|
|
||||||
objectClass: inetOrgPerson
|
|
||||||
objectClass: organizationalPerson
|
|
||||||
objectClass: person
|
|
||||||
objectClass: top
|
|
||||||
cn: Fabien Potencier
|
|
||||||
sn: fabpot
|
|
||||||
mail: fabpot@symfony.com
|
|
||||||
mail: fabien@potencier.com
|
|
||||||
ou: People
|
|
||||||
ou: Maintainers
|
|
||||||
ou: Founder
|
|
||||||
givenName: Fabien Potencier
|
|
||||||
description: Founder and project lead @Symfony
|
|
||||||
|
|
||||||
dn: ou=Components,dc=symfony,dc=com
|
|
||||||
objectclass: organizationalunit
|
|
||||||
ou: Components
|
|
||||||
|
|
||||||
dn: ou=Ldap,ou=Components,dc=symfony,dc=com
|
|
||||||
objectclass: organizationalunit
|
|
||||||
ou: Ldap
|
|
||||||
|
|
||||||
dn: ou=Ldap scoping,ou=Ldap,ou=Components,dc=symfony,dc=com
|
|
||||||
objectclass: organizationalunit
|
|
||||||
ou: Ldap scoping
|
|
24
.github/workflows/tests.yml
vendored
24
.github/workflows/tests.yml
vendored
@ -15,6 +15,17 @@ jobs:
|
|||||||
php: ['7.1', '7.4']
|
php: ['7.1', '7.4']
|
||||||
|
|
||||||
services:
|
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:
|
redis:
|
||||||
image: redis:6.0.0
|
image: redis:6.0.0
|
||||||
ports:
|
ports:
|
||||||
@ -45,17 +56,20 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Populate LDAP
|
|
||||||
uses: ./.github/actions/populate-ldap
|
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
coverage: "none"
|
coverage: "none"
|
||||||
extensions: "memcached,redis,xsl"
|
extensions: "memcached,redis,xsl,ldap"
|
||||||
ini-values: "memory_limit=-1"
|
ini-values: "memory_limit=-1"
|
||||||
php-version: "${{ matrix.php }}"
|
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
|
- name: Configure composer
|
||||||
run: |
|
run: |
|
||||||
COMPOSER_HOME="$(composer config home)"
|
COMPOSER_HOME="$(composer config home)"
|
||||||
@ -83,7 +97,7 @@ jobs:
|
|||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./phpunit --group integration
|
run: ./phpunit --group integration -v
|
||||||
env:
|
env:
|
||||||
REDIS_HOST: localhost
|
REDIS_HOST: localhost
|
||||||
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
|
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
|
||||||
|
@ -9,8 +9,6 @@ addons:
|
|||||||
apt_packages:
|
apt_packages:
|
||||||
- parallel
|
- parallel
|
||||||
- language-pack-fr-base
|
- language-pack-fr-base
|
||||||
- ldap-utils
|
|
||||||
- slapd
|
|
||||||
- zookeeperd
|
- zookeeperd
|
||||||
- libzookeeper-mt-dev
|
- libzookeeper-mt-dev
|
||||||
|
|
||||||
@ -164,13 +162,6 @@ before_install:
|
|||||||
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
|
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
|
||||||
done
|
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:
|
||||||
- |
|
- |
|
||||||
# Install the phpunit-bridge from a PR if required
|
# Install the phpunit-bridge from a PR if required
|
||||||
|
@ -22,6 +22,7 @@ use Symfony\Component\Ldap\Tests\LdapTestCase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension ldap
|
* @requires extension ldap
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class AdapterTest extends LdapTestCase
|
class AdapterTest extends LdapTestCase
|
||||||
{
|
{
|
||||||
@ -116,7 +117,7 @@ class AdapterTest extends LdapTestCase
|
|||||||
|
|
||||||
public function testLdapPagination()
|
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');
|
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
|
||||||
$entries = $this->setupTestUsers($ldap);
|
$entries = $this->setupTestUsers($ldap);
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ class AdapterTest extends LdapTestCase
|
|||||||
$this->assertEquals(\count($fully_paged_query->getResources()), 1);
|
$this->assertEquals(\count($fully_paged_query->getResources()), 1);
|
||||||
$this->assertEquals(\count($paged_query->getResources()), 5);
|
$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
|
// 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
|
// 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.
|
// bits to work around an implementation flaw, so we simply can't guarantee this to work there.
|
||||||
@ -199,7 +200,7 @@ class AdapterTest extends LdapTestCase
|
|||||||
|
|
||||||
public function testLdapPaginationLimits()
|
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');
|
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
|
||||||
|
|
||||||
$entries = $this->setupTestUsers($ldap);
|
$entries = $this->setupTestUsers($ldap);
|
||||||
|
@ -96,9 +96,8 @@ class LdapManagerTest extends LdapTestCase
|
|||||||
$em->add($entry);
|
$em->add($entry);
|
||||||
try {
|
try {
|
||||||
$em->add($entry);
|
$em->add($entry);
|
||||||
} catch (LdapException $e) {
|
} finally {
|
||||||
$em->remove($entry);
|
$em->remove($entry);
|
||||||
throw $e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,12 +214,12 @@ class LdapManagerTest extends LdapTestCase
|
|||||||
$newEntry = $result[0];
|
$newEntry = $result[0];
|
||||||
$originalCN = $entry->getAttribute('cn')[0];
|
$originalCN = $entry->getAttribute('cn')[0];
|
||||||
|
|
||||||
|
try {
|
||||||
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
|
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
|
||||||
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
|
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
|
||||||
|
} finally {
|
||||||
$entryManager->rename($newEntry, 'cn='.$originalCN);
|
$entryManager->rename($newEntry, 'cn='.$originalCN);
|
||||||
|
}
|
||||||
$this->executeSearchQuery(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLdapAddRemoveAttributeValues()
|
public function testLdapAddRemoveAttributeValues()
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
# See slapd.conf(5) for details on configuration options.
|
|
||||||
include /etc/ldap/schema/core.schema
|
|
||||||
include /etc/ldap/schema/cosine.schema
|
|
||||||
include /etc/ldap/schema/inetorgperson.schema
|
|
||||||
include /etc/ldap/schema/nis.schema
|
|
||||||
|
|
||||||
pidfile /tmp/slapd/slapd.pid
|
|
||||||
argsfile /tmp/slapd/slapd.args
|
|
||||||
|
|
||||||
modulepath /tmp/slapd-modules
|
|
||||||
moduleload back_hdb
|
|
||||||
|
|
||||||
database hdb
|
|
||||||
directory /tmp/slapd
|
|
||||||
|
|
||||||
suffix "dc=symfony,dc=com"
|
|
||||||
rootdn "cn=admin,dc=symfony,dc=com"
|
|
||||||
rootpw {SSHA}btWUi971ytYpVMbZLkaQ2A6ETh3VA0lL
|
|
@ -1,4 +0,0 @@
|
|||||||
dn: dc=symfony,dc=com
|
|
||||||
objectClass: dcObject
|
|
||||||
objectClass: organizationalUnit
|
|
||||||
ou: Organization
|
|
@ -9,7 +9,7 @@ class LdapTestCase extends TestCase
|
|||||||
protected function getLdapConfig()
|
protected function getLdapConfig()
|
||||||
{
|
{
|
||||||
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
|
$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)) {
|
if (!$h || !@ldap_bind($h)) {
|
||||||
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
|
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
>
|
>
|
||||||
<php>
|
<php>
|
||||||
<ini name="error_reporting" value="-1" />
|
<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" />
|
<env name="LDAP_PORT" value="3389" />
|
||||||
</php>
|
</php>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user