Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit285adf4

Browse files
committed
Use GithubAction to run ldap tests
1 parentf4c241d commit285adf4

File tree

10 files changed

+37
-80
lines changed

10 files changed

+37
-80
lines changed

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

Lines changed: 0 additions & 9 deletions
This file was deleted.

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

Lines changed: 0 additions & 9 deletions
This file was deleted.

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

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎.github/workflows/tests.yml‎

Lines changed: 19 additions & 4 deletions
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:
@@ -40,21 +51,25 @@ jobs:
4051
image:rabbitmq:3.8.3
4152
ports:
4253
-5672:5672
54+
4355
steps:
4456
-name:Checkout
4557
uses:actions/checkout@v2
4658

47-
-name:Populate LDAP
48-
uses:./.github/actions/populate-ldap
49-
5059
-name:Setup PHP
5160
uses:shivammathur/setup-php@v2
5261
with:
5362
coverage:"none"
54-
extensions:"memcached,redis,xsl"
63+
extensions:"memcached,redis,xsl,ldap"
5564
ini-values:"memory_limit=-1"
5665
php-version:"${{ matrix.php }}"
5766

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+
5873
-name:Configure composer
5974
run:|
6075
COMPOSER_HOME="$(composer config home)"

‎.travis.yml‎

Lines changed: 0 additions & 14 deletions
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

@@ -55,11 +53,6 @@ before_install:
5553
# General configuration
5654
set -e
5755
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 &
6356
cp .github/composer-config.json "$(composer config home)/config.json"
6457
export PHPUNIT=$(readlink -f ./phpunit)
6558
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
@@ -169,13 +162,6 @@ before_install:
169162
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
170163
done
171164
172-
-|
173-
# Load fixtures
174-
if [[ ! $skip ]]; then
175-
ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif &&
176-
ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif
177-
fi
178-
179165
install:
180166
-|
181167
# Install the phpunit-bridge from a PR if required

‎src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function execute()
100100
$cookie ='';
101101
do {
102102
if ($pageControl) {
103-
$this->controlPagedResult($con,$pageSize,$cookie);
103+
$this->controlPagedResult($con,$pageSize,true,$cookie);
104104
}
105105
$sizeLimit =$itemsLeft;
106106
if ($pageSize >0 &&$sizeLimit >=$pageSize) {
@@ -174,7 +174,7 @@ public function getResources(): array
174174
privatefunctionresetPagination()
175175
{
176176
$con =$this->connection->getResource();
177-
$this->controlPagedResult($con,0,'');
177+
$this->controlPagedResult($con,0,false,'');
178178
$this->serverctrls = [];
179179

180180
// This is a workaround for a bit of a bug in the above invocation
@@ -204,15 +204,15 @@ private function resetPagination()
204204
*
205205
* @param resource $con
206206
*/
207-
privatefunctioncontrolPagedResult($con,int$pageSize,string$cookie):bool
207+
privatefunctioncontrolPagedResult($con,int$pageSize,bool$critical,string$cookie):bool
208208
{
209209
if (\PHP_VERSION_ID <70300) {
210-
returnldap_control_paged_result($con,$pageSize,true,$cookie);
210+
returnldap_control_paged_result($con,$pageSize,$critical,$cookie);
211211
}
212212
$this->serverctrls = [
213213
[
214214
'oid' => \LDAP_CONTROL_PAGEDRESULTS,
215-
'isCritical' =>true,
215+
'isCritical' =>$critical,
216216
'value' => [
217217
'size' =>$pageSize,
218218
'cookie' =>$cookie,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

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

117118
publicfunctiontestLdapPagination()
118119
{
119-
$ldap =newAdapter(array_merge($this->getLdapConfig()));
120+
$ldap =newAdapter($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
publicfunctiontestLdapPaginationLimits()
201202
{
202-
$ldap =newAdapter(array_merge($this->getLdapConfig()));
203+
$ldap =newAdapter($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‎

Lines changed: 7 additions & 8 deletions
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
publicfunctiontestLdapAddRemoveAttributeValues()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class LdapTestCase extends TestCase
99
protectedfunctiongetLdapConfig()
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
<php>
1212
<ininame="error_reporting"value="-1" />
13-
<envname="LDAP_HOST"value="127.0.0.1" />
13+
<envname="LDAP_HOST"value="localhost" />
1414
<envname="LDAP_PORT"value="3389" />
1515
</php>
1616

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp