From f349109205f49eb8a68ca0670bde35b07419ef8b Mon Sep 17 00:00:00 2001 From: David Coutadeur Date: Tue, 19 Mar 2024 18:46:40 +0100 Subject: [PATCH] create unit tests for existing functions (#8) --- .github/workflows/unittests.yml | 27 ++ README.md | 48 ++++ composer.json | 4 + phpunit.xml | 14 + run/ENVVAR.example | 23 ++ runIntegrationTests.sh | 59 ++++ src/Ltb/AttributeValue.php | 4 +- src/Ltb/Ldap.php | 44 +-- src/Ltb/LtbUtil.php | 12 +- src/Ltb/PhpLDAP.php | 75 +++++ tests/IntegrationTests/IntegrationTest.php | 153 ++++++++++ tests/Ltb/AttributeValueTest.php | 87 ++++++ tests/Ltb/LdapTest.php | 319 +++++++++++++++++++++ tests/Ltb/LtbUtilTest.php | 138 +++++++++ tests/Ltb/MailTest.php | 139 +++++++++ tests/Ltb/attribute_value.php | 36 --- tests/Ltb/ldap_search.php | 47 --- tests/Ltb/mail.php | 49 ---- 18 files changed, 1116 insertions(+), 162 deletions(-) create mode 100644 .github/workflows/unittests.yml create mode 100644 phpunit.xml create mode 100644 run/ENVVAR.example create mode 100755 runIntegrationTests.sh create mode 100644 src/Ltb/PhpLDAP.php create mode 100644 tests/IntegrationTests/IntegrationTest.php create mode 100644 tests/Ltb/AttributeValueTest.php create mode 100644 tests/Ltb/LdapTest.php create mode 100644 tests/Ltb/LtbUtilTest.php create mode 100644 tests/Ltb/MailTest.php delete mode 100644 tests/Ltb/attribute_value.php delete mode 100644 tests/Ltb/ldap_search.php delete mode 100644 tests/Ltb/mail.php diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml new file mode 100644 index 0000000..e03e5cd --- /dev/null +++ b/.github/workflows/unittests.yml @@ -0,0 +1,27 @@ +name: CI + +on: [push] + +jobs: + build-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + uses: php-actions/composer@v6 + with: + php_version: 8.3 + command: update + php_extensions: ldap xdebug + - name: PHPUnit Tests for php8.3 + uses: php-actions/phpunit@v3 + env: + XDEBUG_MODE: coverage + with: + configuration: phpunit.xml + version: latest + php_version: 8.3 + php_extensions: ldap xdebug + args: --coverage-text + diff --git a/README.md b/README.md index ca8e2de..9e3ebf2 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,51 @@ if (!$result) { exit 1; } ``` + +## Tests + + +### Unit tests + +Get composer dependencies: + +``` +composer update +``` + +Run the tests: + +``` +vendor/bin/phpunit tests/Ltb +``` + +If you want coverage analysis, make sure to install `xdebug` PHP extension, and run: + +``` +XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration phpunit.xml +``` + + +### Integration tests + +Make sure you have docker or podman installed + +Get composer dependencies: + +``` +composer update +``` + +Run the tests (requires an internet connection for donwloading the openldap docker image): + +``` +./runIntegrationTests.sh +``` + +If you already have an openldap server, you can also adapt the tests in tests/ directory, and run them with: + +``` +vendor/bin/phpunit tests/IntegrationTests +``` + + diff --git a/composer.json b/composer.json index 504e0ca..7c04f5e 100644 --- a/composer.json +++ b/composer.json @@ -12,5 +12,9 @@ "php": ">=7.4", "ext-ldap": ">=7.4", "phpmailer/phpmailer": "^6.5.0" + }, + "require-dev": { + "phpunit/phpunit": "*", + "mockery/mockery": "*" } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..0324c62 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,14 @@ + + + + + tests/Ltb + + + + + + src + + + diff --git a/run/ENVVAR.example b/run/ENVVAR.example new file mode 100644 index 0000000..9a4f820 --- /dev/null +++ b/run/ENVVAR.example @@ -0,0 +1,23 @@ +ACCCONFIGROOTPW=secret +ACCDATAROOTPW=secret +ADMIN_LDAP_PASSWORD=secret +CUSTOMERID=acme +FUSIONDIRECTORY_LDAP_PASSWORD=secret +FUSIONDIRECTORY_LDAP_USERNAME=fd +LSC_LDAP_PASSWORD=secret +LSC_LDAP_USERNAME=lsc +LDAP_PROTO=ldap +LDAP_HOST=ltb-directory-server +LDAP_PORT=33389 +LDAP_SUFFIX=dc=fusioniam,dc=org +LEMONLDAP2_LDAP_PASSWORD=secret +LEMONLDAP2_LDAP_USERNAME=lemonldapng +SERVICEDESK_LDAP_PASSWORD=secret +SERVICEDESK_LDAP_USERNAME=sd +WHITEPAGES_LDAP_PASSWORD=secret +WHITEPAGES_LDAP_USERNAME=wp +LDAP_TLS= +LDAP_CERTIFICATE_FILE=/usr/local/openldap/etc/openldap/tls/cert.pem +LDAP_CERTIFICATE_KEY=/usr/local/openldap/etc/openldap/tls/key.pem +LDAP_TLS_PROTOCOL_MIN=3.4 +LDAP_TLS_CIPHER_SUITE=HIGH diff --git a/runIntegrationTests.sh b/runIntegrationTests.sh new file mode 100755 index 0000000..3743019 --- /dev/null +++ b/runIntegrationTests.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Which container to choose: podman by default, else docker +CTN="docker" +PWD=$( pwd ) + + +ID=$( id -u ) +# fusioniam default user id in container +MYUID=1000 +# fusioniam default group id in container +MYGID=1000 +# uidmap format: rootless user: container_uid:intermediate_uid:amount +# rootful user: container_uid:host_uid:amount +# rootless user: +# map podman user uid (0) to fusioniam container uid (1000) + map lowest user uid in /etc/subuid (1) to root container uid (0) +# rootful user: +# map root (0) to fusioniam container uid (1000) + map user uid 100000 to root container uid (0) +UIDMAP=$( [ "$CTN" = "podman" ] && if [ $(ID) -eq 0 ]; then echo "--uidmap $MYUID:0:1 --uidmap 0:100000:1"; else echo "--uidmap $MYUID:0:1 --uidmap 0:1:1"; fi || echo "" ) +GIDMAP=$( [ "$CTN" = "podman" ] && if [ $(ID) -eq 0 ]; then echo "--gidmap $MYGID:0:1 --gidmap 0:100000:1"; else echo "--gidmap $MYGID:0:1 --gidmap 0:1:1"; fi || echo "" ) + + + +# Get OpenLDAP-LTB docker image before running tests +$CTN pull gitlab.ow2.org:4567/fusioniam/fusioniam/fusioniam-openldap-ltb:snapshot + +# run docker image +mkdir -p run/volumes/ldap-data run/volumes/ldap-config +$CTN run \ + --env-file=./run/ENVVAR.example \ + -v $PWD/run/volumes/ldap-data:/usr/local/openldap/var/openldap-data \ + -v $PWD/run/volumes/ldap-config:/usr/local/openldap/etc/openldap/slapd.d \ + -v $PWD/run/volumes/ldap-tls:/usr/local/openldap/etc/openldap/tls \ + --rm=true \ + --network-alias=ltb-directory-server \ + -p 127.0.0.1:33389:33389 \ + --name=ltb-directory-server \ + --detach=true \ + $UIDMAP \ + $GIDMAP \ + gitlab.ow2.org:4567/fusioniam/fusioniam/fusioniam-openldap-ltb:snapshot + +# Check when started +while ! $CTN logs ltb-directory-server 2>&1 | grep -q "slapd starting"; +do + # Wait for docker container to be up and running + echo "slapd starting, please wait" + sleep 1 +done + + +# Run tests +echo "Starting tests" +vendor/bin/phpunit tests/IntegrationTests + +# Stop and remove openldap container and volumes +$CTN stop ltb-directory-server +rm -rf run/volumes + diff --git a/src/Ltb/AttributeValue.php b/src/Ltb/AttributeValue.php index 9e32112..c7f55f7 100644 --- a/src/Ltb/AttributeValue.php +++ b/src/Ltb/AttributeValue.php @@ -41,11 +41,11 @@ public function __construct($attribute, $value) { public static function ldap_get_first_available_value($ldap, $entry, $attributes) { # loop on attributes, stop on first found - $entry_attributes = ldap_get_attributes($ldap, $entry); + $entry_attributes = \Ltb\PhpLDAP::ldap_get_attributes($ldap, $entry); for ($i = 0; $i < sizeof($attributes); $i++) { $attribute = $attributes[$i]; if ( in_array($attribute, $entry_attributes) ) { - $values = ldap_get_values($ldap, $entry, $attribute); + $values = \Ltb\PhpLDAP::ldap_get_values($ldap, $entry, $attribute); if ( $values && ( $values['count'] > 0 ) ) { return new \Ltb\AttributeValue($attribute,$values[0]); } diff --git a/src/Ltb/Ldap.php b/src/Ltb/Ldap.php index 4b2476e..e212d7e 100644 --- a/src/Ltb/Ldap.php +++ b/src/Ltb/Ldap.php @@ -8,32 +8,32 @@ final class Ldap { static function connect($ldap_url, $ldap_starttls, $ldap_binddn, $ldap_bindpw, $ldap_network_timeout, $ldap_krb5ccname) { # Connect to LDAP - $ldap = \ldap_connect($ldap_url); - \ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); - \ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); + $ldap = \Ltb\PhpLDAP::ldap_connect($ldap_url); + \Ltb\PhpLDAP::ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + \Ltb\PhpLDAP::ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); if ( isset($ldap_network_timeout) ) { - ldap_set_option($ldap, LDAP_OPT_NETWORK_TIMEOUT, $ldap_network_timeout); + \Ltb\PhpLDAP::ldap_set_option($ldap, LDAP_OPT_NETWORK_TIMEOUT, $ldap_network_timeout); } - if ( $ldap_starttls && !ldap_start_tls($ldap) ) { + if ( $ldap_starttls && !\Ltb\PhpLDAP::ldap_start_tls($ldap) ) { error_log("LDAP - Unable to use StartTLS"); return array(false, "ldaperror"); } # Bind if ( isset($ldap_binddn) && isset($ldap_bindpw) ) { - $bind = ldap_bind($ldap, $ldap_binddn, $ldap_bindpw); + $bind = \Ltb\PhpLDAP::ldap_bind($ldap, $ldap_binddn, $ldap_bindpw); } elseif ( isset($ldap_krb5ccname) ) { putenv("KRB5CCNAME=".$ldap_krb5ccname); - $bind = ldap_sasl_bind($ldap, NULL, NULL, 'GSSAPI') or error_log('LDAP - GSSAPI Bind failed'); + $bind = \Ltb\PhpLDAP::ldap_sasl_bind($ldap, NULL, NULL, 'GSSAPI') or error_log('LDAP - GSSAPI Bind failed'); } else { - $bind = ldap_bind($ldap); + $bind = \Ltb\PhpLDAP::ldap_bind($ldap); } if ( !$bind ) { - $errno = ldap_errno($ldap); + $errno = \Ltb\PhpLDAP::ldap_errno($ldap); if ( $errno ) { - error_log("LDAP - Bind error $errno (".ldap_error($ldap).")"); + error_log("LDAP - Bind error $errno (".\Ltb\PhpLDAP::ldap_error($ldap).")"); } else { error_log("LDAP - Bind error"); } @@ -50,14 +50,14 @@ static function get_list($ldap, $ldap_base, $ldap_filter, $key, $value) { if ($ldap) { # Search entry - $search = ldap_search($ldap, $ldap_base, $ldap_filter, array($key, $value) ); + $search = \Ltb\PhpLDAP::ldap_search($ldap, $ldap_base, $ldap_filter, array($key, $value) ); - $errno = ldap_errno($ldap); + $errno = \Ltb\PhpLDAP::ldap_errno($ldap); if ( $errno ) { - error_log("LDAP - Search error $errno (".ldap_error($ldap).")"); + error_log("LDAP - Search error $errno (".\Ltb\PhpLDAP::ldap_error($ldap).")"); } else { - $entries = ldap_get_entries($ldap, $search); + $entries = \Ltb\PhpLDAP::ldap_get_entries($ldap, $search); for ($i=0; $i<$entries["count"]; $i++) { if(isset($entries[$i][$key][0])) { $return[$entries[$i][$key][0]] = isset($entries[$i][$value][0]) ? $entries[$i][$value][0] : $entries[$i][$key][0]; @@ -105,28 +105,28 @@ static function sorted_search($ldap, $ldap_base, $ldap_filter, $attributes, $sor if (isset($sortby) and $sortby) { $check_attribute='supportedControl'; - $check = ldap_read($ldap, '', '(objectClass=*)', [$check_attribute]); - $entries=ldap_get_entries($ldap, $check); + $check = \Ltb\PhpLDAP::ldap_read($ldap, '', '(objectClass=*)', [$check_attribute]); + $entries = \Ltb\PhpLDAP::ldap_get_entries($ldap, $check); if (in_array(LDAP_CONTROL_SORTREQUEST, $entries[0]['supportedcontrol'],true)) { # server side sort $controls=[['oid' => LDAP_CONTROL_SORTREQUEST, 'value' => [['attr'=>$sortby]]]]; # if $sortby is not in $attributes ? what to do ? - $ldap_result = ldap_search($ldap, $ldap_base, $ldap_filter, $attributes, 0, $ldap_size_limit, -1, LDAP_DEREF_NEVER, $controls ); - $errno = ldap_errno($ldap); + $ldap_result = \Ltb\PhpLDAP::ldap_search($ldap, $ldap_base, $ldap_filter, $attributes, 0, $ldap_size_limit, -1, LDAP_DEREF_NEVER, $controls ); + $errno = \Ltb\PhpLDAP::ldap_errno($ldap); if ( $errno === 0 ) { - $entries=ldap_get_entries($ldap, $ldap_result); + $entries=\Ltb\PhpLDAP::ldap_get_entries($ldap, $ldap_result); } } } if (!isset($errno)) { - $ldap_result = ldap_search($ldap, $ldap_base, $ldap_filter, $attributes, 0, $ldap_size_limit); - $errno = ldap_errno($ldap); + $ldap_result = \Ltb\PhpLDAP::ldap_search($ldap, $ldap_base, $ldap_filter, $attributes, 0, $ldap_size_limit); + $errno = \Ltb\PhpLDAP::ldap_errno($ldap); if ( $errno === 0 ) { - $entries=ldap_get_entries($ldap, $ldap_result); + $entries=\Ltb\PhpLDAP::ldap_get_entries($ldap, $ldap_result); Ldap::ldapSort($entries,$sortby); } else { diff --git a/src/Ltb/LtbUtil.php b/src/Ltb/LtbUtil.php index 26af170..c15daa0 100644 --- a/src/Ltb/LtbUtil.php +++ b/src/Ltb/LtbUtil.php @@ -18,7 +18,7 @@ static function search($ldap_filter,$attributes) $size_limit_reached = false; # Connect to LDAP - $ldap_connection = \Ltb\Ldap::connect($ldap_url, $ldap_starttls, $ldap_binddn, $ldap_bindpw, $ldap_network_timeout); + $ldap_connection = \Ltb\Ldap::connect($ldap_url, $ldap_starttls, $ldap_binddn, $ldap_bindpw, $ldap_network_timeout, null); $ldap = $ldap_connection[0]; $result = $ldap_connection[1]; @@ -32,25 +32,25 @@ static function search($ldap_filter,$attributes) $attributes[] = $attributes_map[$search_result_sortby]['attribute']; # Search for users - $search = ldap_search($ldap, $ldap_user_base, $ldap_filter, $attributes, 0, $ldap_size_limit); + $search = \Ltb\PhpLDAP::ldap_search($ldap, $ldap_user_base, $ldap_filter, $attributes, 0, $ldap_size_limit); - $errno = ldap_errno($ldap); + $errno = \Ltb\PhpLDAP::ldap_errno($ldap); if ( $errno == 4) { $size_limit_reached = true; } if ( $errno != 0 and $errno !=4 ) { $result = "ldaperror"; - error_log("LDAP - Search error $errno (".ldap_error($ldap).")"); + error_log("LDAP - Search error $errno (".\Ltb\PhpLDAP::ldap_error($ldap).")"); } else { # Get search results - $nb_entries = ldap_count_entries($ldap, $search); + $nb_entries = \Ltb\PhpLDAP::ldap_count_entries($ldap, $search); if ($nb_entries === 0) { $result = "noentriesfound"; } else { - $entries = ldap_get_entries($ldap, $search); + $entries = \Ltb\PhpLDAP::ldap_get_entries($ldap, $search); # Sort entries if (isset($search_result_sortby)) { diff --git a/src/Ltb/PhpLDAP.php b/src/Ltb/PhpLDAP.php new file mode 100644 index 0000000..84a065c --- /dev/null +++ b/src/Ltb/PhpLDAP.php @@ -0,0 +1,75 @@ + diff --git a/tests/IntegrationTests/IntegrationTest.php b/tests/IntegrationTests/IntegrationTest.php new file mode 100644 index 0000000..f6d29c2 --- /dev/null +++ b/tests/IntegrationTests/IntegrationTest.php @@ -0,0 +1,153 @@ + array("inetOrgPerson", "organizationalPerson", "person"), + "cn" => array("test1", "test2", "test3"), + "sn" => "test", + "uid" => "test", + "userPassword" => "secret", + "mail" => array("test1@domain.com", "test2@domain.com") + ]; + + /* + Function setting up the environement, executed before each test + add a test entry + */ + protected function setUp(): void + { + + error_reporting(E_ALL); + + $ldap = ldap_connect($this->host); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + + // binding to ldap server + $ldapbind = ldap_bind($ldap, $this->managerDN, $this->managerPW); + + // search for ldap entry + $sr = ldap_search($ldap, $this->user_branch, "(uid=test)", $this->attributes); + if( $sr ) + { + $info = ldap_get_entries($ldap, $sr); + if( $info["count"] == 0) + { + // if it does not exist, add the entry + $r = ldap_add($ldap, $this->ldap_entry_dn1, $this->ldap_entry1); + } + } + + ldap_unbind($ldap); + } + + /* + Function cleaning up the environement, executed after each test + remove the test entry created during setup + */ + protected function tearDown(): void + { + + $ldap = ldap_connect($this->host); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + + // binding to ldap server + $ldapbind = ldap_bind($ldap, $this->managerDN, $this->managerPW); + + // search for ldap entry + $sr = ldap_search($ldap, $this->user_branch, "(uid=test)", $this->attributes); + if( $sr ) + { + $info = ldap_get_entries($ldap, $sr); + if( $info["count"] == 1) + { + // if it exists, delete the entry + $r = ldap_delete($ldap, $this->ldap_entry_dn1); + } + } + + ldap_unbind($ldap); + } + + + public function test_ldap_get_first_available_value(): void + { + + $ldap = ldap_connect($this->host); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + + // binding to ldap server + $ldapbind = ldap_bind($ldap, $this->managerDN, $this->managerPW); + + // search for added entry + $sr = ldap_search($ldap, $this->ldap_entry_dn1, "(objectClass=*)", $this->attributes); + $entry = ldap_first_entry($ldap, $sr); + + # Test ldap_get_first_available_value + $ent = Ltb\AttributeValue::ldap_get_first_available_value($ldap, $entry, $this->attributes); + $this->assertEquals($ent->attribute, "cn", "not getting attribute cn"); + $this->assertEquals($ent->value, "test1", "not getting value test1 as cn first value"); + } + + public function test_ldap_get_mail_for_notification(): void + { + + + $ldap = ldap_connect($this->host); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + + // binding to ldap server + $ldapbind = ldap_bind($ldap, $this->managerDN, $this->managerPW); + + // search for added entry + $sr = ldap_search($ldap, $this->ldap_entry_dn1, "(objectClass=*)", $GLOBALS['mail_attributes']); + $entry = ldap_first_entry($ldap, $sr); + + # Test ldap_get_first_available_value + $mail = Ltb\AttributeValue::ldap_get_mail_for_notification($ldap, $entry); + $this->assertEquals($mail, 'test1@domain.com', "not getting test1@domain.com as mail for notification"); + + } + + public function test_connect(): void + { + + list($ldap, $msg) = Ltb\Ldap::connect($this->host, false, $this->managerDN, $this->managerPW, 10, null); + + $this->assertNotFalse($ldap, "Error while connecting to LDAP server"); + $this->assertFalse($msg, "Error message returned while connecting to LDAP server"); + } + + public function test_get_list(): void + { + + $ldap = ldap_connect($this->host); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + + // binding to ldap server + $ldapbind = ldap_bind($ldap, $this->managerDN, $this->managerPW); + + // return hashmap: [ cn_value => sn_value ] + $result = Ltb\Ldap::get_list($ldap, $this->user_branch, "(uid=test)", "cn","sn"); + + $this->assertEquals(array_keys($result)[0], 'test1', "not getting test1 as key in get_list function"); + $this->assertEquals($result["test1"], 'test', "not getting test as value in get_list function"); + + } + +} diff --git a/tests/Ltb/AttributeValueTest.php b/tests/Ltb/AttributeValueTest.php new file mode 100644 index 0000000..c2b0209 --- /dev/null +++ b/tests/Ltb/AttributeValueTest.php @@ -0,0 +1,87 @@ +shouldreceive([ + 'ldap_get_attributes' => ['cn'], + 'ldap_get_values' => [ + 'count' => 3, + 0 => 'test1', + 1 => 'test2', + 2 => 'test3' + ] + ]); + + $ent = Ltb\AttributeValue::ldap_get_first_available_value(null, null, ['cn']); + $this->assertEquals("cn", $ent->attribute, "not getting attribute cn"); + $this->assertEquals("test1", $ent->value, "not getting value test1 as cn first value"); + + } + + public function test_ldap_get_first_available_value_empty(): void + { + + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + $phpLDAPMock->shouldreceive([ + 'ldap_get_attributes' => ['cn'], + 'ldap_get_values' => [ + 'count' => 0 + ] + ]); + + $ent = Ltb\AttributeValue::ldap_get_first_available_value(null, null, ['cn']); + $this->assertFalse($ent, "not getting false result whereas no value has been returned"); + + } + + public function test_ldap_get_mail_for_notification(): void + { + + // global variable for ldap_get_mail_for_notification function + $GLOBALS['mail_attributes'] = array("mail"); + + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + $phpLDAPMock->shouldreceive([ + 'ldap_get_attributes' => ['mail'], + 'ldap_get_values' => [ + 'count' => 2, + 0 => 'test1@domain.com', + 1 => 'test2@domain.com' + ] + ]); + + # Test ldap_get_mail_for_notification + $mail = Ltb\AttributeValue::ldap_get_mail_for_notification(null, null); + $this->assertEquals('test1@domain.com', $mail, "not getting test1@domain.com as mail for notification"); + } + + public function test_ldap_get_proxy_for_notification(): void + { + + // global variable for ldap_get_mail_for_notification function + $GLOBALS['mail_attributes'] = array("proxyAddresses"); + + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + $phpLDAPMock->shouldreceive([ + 'ldap_get_attributes' => ['proxyAddresses'], + 'ldap_get_values' => [ + 'count' => 2, + 0 => 'smtp:test1@domain.com', + 1 => 'smtp:test2@domain.com' + ] + ]); + + # Test ldap_get_mail_for_notification + $mail = Ltb\AttributeValue::ldap_get_mail_for_notification(null, null); + $this->assertEquals('test1@domain.com', $mail, "not getting test1@domain.com as proxyAddress for notification"); + } + +} diff --git a/tests/Ltb/LdapTest.php b/tests/Ltb/LdapTest.php new file mode 100644 index 0000000..8c85c93 --- /dev/null +++ b/tests/Ltb/LdapTest.php @@ -0,0 +1,319 @@ +shouldreceive('ldap_connect') + ->with("ldap://test.my-domain.com") + ->andReturn("ldap_connection"); + + $phpLDAPMock->shouldreceive('ldap_set_option') + ->andReturn(null); + + $phpLDAPMock->shouldreceive('ldap_bind') + ->with("ldap_connection", "cn=test,dc=my-domain,dc=com","secret") + ->andReturn(true); + + list($ldap, $msg) = Ltb\Ldap::connect("ldap://test.my-domain.com", false, "cn=test,dc=my-domain,dc=com", "secret", 10, null); + + $this->assertNotFalse($ldap, "Error while connecting to LDAP server"); + $this->assertFalse($msg, "Error message returned while connecting to LDAP server"); + } + + public function test_get_list(): void + { + + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + + $phpLDAPMock->shouldreceive('ldap_search') + ->with("ldap_connection", "ou=people,dc=my-domain,dc=com", "(uid=test)", array("cn", "sn")) + ->andReturn("ldap_search_result"); + + $phpLDAPMock->shouldreceive('ldap_errno') + ->with("ldap_connection") + ->andReturn(false); + + $phpLDAPMock->shouldreceive('ldap_get_entries') + ->with("ldap_connection","ldap_search_result") + ->andReturn([ + 'count' => 2, + 0 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn1' + ], + 'sn' => [ + 'count' => 1, + 0 => 'testsn1' + ] + ], + 1 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn2' + ], + 'sn' => [ + 'count' => 1, + 0 => 'testsn2' + ] + ] + ]); + + // return hashmap: [ cn_value => sn_value ] + $result = Ltb\Ldap::get_list("ldap_connection", "ou=people,dc=my-domain,dc=com", "(uid=test)", "cn","sn"); + + $this->assertEquals('testcn1', array_keys($result)[0], "not getting testcn1 as key in get_list function"); + $this->assertEquals('testsn1', $result["testcn1"], "not getting testsn1 as value in get_list function"); + + $this->assertEquals('testcn2', array_keys($result)[1], "not getting testcn2 as key in get_list function"); + $this->assertEquals('testsn2', $result["testcn2"], "not getting testsn2 as value in get_list function"); + + } + + public function test_ldapSort(): void + { + + $entries = [ + 'count' => 2, + 0 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn1' + ], + 'sn' => [ + 'count' => 1, + 0 => 'zzzz' + ] + ], + 1 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn2' + ], + 'sn' => [ + 'count' => 1, + 0 => 'aaaa' + ] + ] + ]; + + $return = Ltb\Ldap::ldapSort($entries, "sn"); + + $this->assertTrue($return, "Weird value returned by ldapSort function"); + $this->assertEquals('testcn2', $entries[0]['cn'][0], "testcn2 has not been ordered correctly in entries array"); + $this->assertEquals('testcn1', $entries[1]['cn'][0], "testcn1 has not been ordered correctly in entries array"); + } + + public function test_sorted_search_with_sort_control(): void + { + + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + + $phpLDAPMock->shouldreceive('ldap_read') + ->with("ldap_connection", '', '(objectClass=*)', ['supportedControl']) + ->andReturn("check"); + + $phpLDAPMock->shouldreceive('ldap_get_entries') + ->andReturnUsing( function ($ldap, $ldap_result) + { + if ($ldap_result == "check") { + return [ + 'count' => 1, + 0 => [ + 'count' => 1, + 0 => 'supportedcontrol', + 'supportedcontrol' => [ + 'count' => 1, + 0 => LDAP_CONTROL_SORTREQUEST + ] + ] + ]; + } + elseif($ldap_result == "ldap_search_result") + { + return [ + 'count' => 2, + 0 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn2' + ], + 'sn' => [ + 'count' => 1, + 0 => 'aaaa' + ] + ], + 1 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn1' + ], + 'sn' => [ + 'count' => 1, + 0 => 'zzzz' + ] + ] + ]; + + } + else + { + return "ldap_get_entries_error"; + } + } + ); + + $phpLDAPMock->shouldreceive('ldap_search') + ->with("ldap_connection", + "ou=people,dc=my-domain,dc=com", + "(objectClass=InetOrgPerson)", + ["cn", "sn"], + 0, + 1000, + -1, + LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_SORTREQUEST, 'value' => [['attr'=>'sn']]]] + ) + ->andReturn("ldap_search_result"); + + $phpLDAPMock->shouldreceive('ldap_errno') + ->with("ldap_connection") + ->andReturn(0); + + list($ldap_result,$errno,$entries) = Ltb\Ldap::sorted_search("ldap_connection", + "ou=people,dc=my-domain,dc=com", + "(objectClass=InetOrgPerson)", + ["cn", "sn"], + "sn", + 1000 + ); + + $this->assertEquals("ldap_search_result", $ldap_result, "error while getting ldap_search sorted result"); + $this->assertEquals(0, $errno, "error code invalid while getting ldap_search sorted result"); + $this->assertEquals('testcn2', $entries[0]['cn'][0], "error while getting ldap_search sorted result: first entry is not testcn2"); + $this->assertEquals('testcn1', $entries[1]['cn'][0], "error while getting ldap_search sorted result: second entry is not testcn1"); + + } + + public function test_sorted_search_without_sort_control(): void + { + + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + + $phpLDAPMock->shouldreceive('ldap_read') + ->with("ldap_connection", '', '(objectClass=*)', ['supportedControl']) + ->andReturn("check"); + + $phpLDAPMock->shouldreceive('ldap_get_entries') + ->andReturnUsing( function ($ldap, $ldap_result) + { + if ($ldap_result == "check") { + return [ + 'count' => 1, + 0 => [ + 'count' => 1, + 0 => 'supportedcontrol', + 'supportedcontrol' => [ + 'count' => 1, + 0 => LDAP_CONTROL_VLVREQUEST + ] + ] + ]; + } + elseif($ldap_result == "ldap_search_result") + { + return [ + 'count' => 2, + 0 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn1' + ], + 'sn' => [ + 'count' => 1, + 0 => 'zzzz' + ] + ], + 1 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn2' + ], + 'sn' => [ + 'count' => 1, + 0 => 'aaaa' + ] + ], + ]; + + } + else + { + return "ldap_get_entries_error"; + } + } + ); + + $phpLDAPMock->shouldreceive('ldap_search') + ->with("ldap_connection", + "ou=people,dc=my-domain,dc=com", + "(objectClass=InetOrgPerson)", + ["cn", "sn"], + 0, + 1000 + ) + ->andReturn("ldap_search_result"); + + $phpLDAPMock->shouldreceive('ldap_errno') + ->with("ldap_connection") + ->andReturn(0); + + list($ldap_result,$errno,$entries) = Ltb\Ldap::sorted_search("ldap_connection", + "ou=people,dc=my-domain,dc=com", + "(objectClass=InetOrgPerson)", + ["cn", "sn"], + "sn", + 1000 + ); + + $this->assertEquals("ldap_search_result", $ldap_result, "error while getting ldap_search sorted result"); + $this->assertEquals(0, $errno, "error code invalid while getting ldap_search sorted result"); + $this->assertEquals('testcn2', $entries[0]['cn'][0], "error while getting ldap_search sorted result: first entry is not testcn2"); + $this->assertEquals('testcn1', $entries[1]['cn'][0], "error while getting ldap_search sorted result: second entry is not testcn1"); + + } +} diff --git a/tests/Ltb/LtbUtilTest.php b/tests/Ltb/LtbUtilTest.php new file mode 100644 index 0000000..43e948b --- /dev/null +++ b/tests/Ltb/LtbUtilTest.php @@ -0,0 +1,138 @@ + array( 'attribute' => 'authtimestamp', 'faclass' => 'lock', 'type' => 'date' ), + 'businesscategory' => array( 'attribute' => 'businesscategory', 'faclass' => 'briefcase', 'type' => 'text' ), + 'carlicense' => array( 'attribute' => 'carlicense', 'faclass' => 'car', 'type' => 'text' ), + 'created' => array( 'attribute' => 'createtimestamp', 'faclass' => 'clock-o', 'type' => 'date' ), + 'description' => array( 'attribute' => 'description', 'faclass' => 'info-circle', 'type' => 'text' ), + 'displayname' => array( 'attribute' => 'displayname', 'faclass' => 'user-circle', 'type' => 'text' ), + 'employeenumber' => array( 'attribute' => 'employeenumber', 'faclass' => 'hashtag', 'type' => 'text' ), + 'employeetype' => array( 'attribute' => 'employeetype', 'faclass' => 'id-badge', 'type' => 'text' ), + 'fax' => array( 'attribute' => 'facsimiletelephonenumber', 'faclass' => 'fax', 'type' => 'tel' ), + 'firstname' => array( 'attribute' => 'givenname', 'faclass' => 'user-o', 'type' => 'text' ), + 'fullname' => array( 'attribute' => 'cn', 'faclass' => 'user-circle', 'type' => 'text' ), + 'identifier' => array( 'attribute' => 'uid', 'faclass' => 'user-o', 'type' => 'text' ), + 'l' => array( 'attribute' => 'l', 'faclass' => 'globe', 'type' => 'text' ), + 'lastname' => array( 'attribute' => 'sn', 'faclass' => 'user-o', 'type' => 'text' ), + 'mail' => array( 'attribute' => 'mail', 'faclass' => 'envelope-o', 'type' => 'mailto' ), + 'mailquota' => array( 'attribute' => 'gosamailquota', 'faclass' => 'pie-chart', 'type' => 'bytes' ), + 'manager' => array( 'attribute' => 'manager', 'faclass' => 'user-circle-o', 'type' => 'dn_link' ), + 'mobile' => array( 'attribute' => 'mobile', 'faclass' => 'mobile', 'type' => 'tel' ), + 'modified' => array( 'attribute' => 'modifytimestamp', 'faclass' => 'clock-o', 'type' => 'date' ), + 'organization' => array( 'attribute' => 'o', 'faclass' => 'building', 'type' => 'text' ), + 'organizationalunit' => array( 'attribute' => 'ou', 'faclass' => 'building-o', 'type' => 'text' ), + 'pager' => array( 'attribute' => 'pager', 'faclass' => 'mobile', 'type' => 'tel' ), + 'phone' => array( 'attribute' => 'telephonenumber', 'faclass' => 'phone', 'type' => 'tel' ), + 'postaladdress' => array( 'attribute' => 'postaladdress', 'faclass' => 'map-marker', 'type' => 'address' ), + 'postalcode' => array( 'attribute' => 'postalcode', 'faclass' => 'globe', 'type' => 'text' ), + 'pwdaccountlockedtime' => array( 'attribute' => 'pwdaccountlockedtime', 'faclass' => 'lock', 'type' => 'date' ), + 'pwdchangedtime' => array( 'attribute' => 'pwdchangedtime', 'faclass' => 'lock', 'type' => 'date' ), + 'pwdfailuretime' => array( 'attribute' => 'pwdfailuretime', 'faclass' => 'lock', 'type' => 'date' ), + 'pwdlastsuccess' => array( 'attribute' => 'pwdlastsuccess', 'faclass' => 'lock', 'type' => 'date' ), + 'pwdreset' => array( 'attribute' => 'pwdreset', 'faclass' => 'lock', 'type' => 'boolean' ), + 'secretary' => array( 'attribute' => 'secretary', 'faclass' => 'user-circle-o', 'type' => 'dn_link' ), + 'state' => array( 'attribute' => 'st', 'faclass' => 'globe', 'type' => 'text' ), + 'street' => array( 'attribute' => 'street', 'faclass' => 'map-marker', 'type' => 'text' ), + 'title' => array( 'attribute' => 'title', 'faclass' => 'certificate', 'type' => 'text' ), +); +$GLOBALS['search_result_title'] = "fullname"; +$GLOBALS['search_result_sortby'] = "lastname"; +$GLOBALS['search_result_items'] = array('identifier', 'mail', 'mobile'); + +final class LtbUtilTest extends \Mockery\Adapter\Phpunit\MockeryTestCase +{ + + public function test_search(): void + { + + $entries = [ + 'count' => 2, + 0 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn1' + ], + 'sn' => [ + 'count' => 1, + 0 => 'zzzzzz' + ] + ], + 1 => [ + 'count' => 2, + 0 => 'cn', + 1 => 'sn', + 'cn' => [ + 'count' => 1, + 0 => 'testcn2' + ], + 'sn' => [ + 'count' => 1, + 0 => 'aaaaaa' + ] + ] + ]; + + $phpLDAPMock = Mockery::mock('overload:\Ltb\PhpLDAP'); + + $phpLDAPMock->shouldreceive('ldap_connect') + ->with($GLOBALS['ldap_url']) + ->andReturn("ldap_connection"); + + $phpLDAPMock->shouldreceive('ldap_set_option') + ->andReturn(null); + + $phpLDAPMock->shouldreceive('ldap_bind') + ->with("ldap_connection", $GLOBALS['ldap_binddn'], $GLOBALS['ldap_bindpw']) + ->andReturn(true); + + $phpLDAPMock->shouldreceive('ldap_search') + ->with("ldap_connection", + $GLOBALS['ldap_user_base'], + "(objectClass=inetOrgPerson)", + [0 => 'cn', 1 => 'sn', 2 => 'uid', 3 => 'mail', 4 => 'mobile', 5 => 'cn', 6 => 'sn'], + 0, + $GLOBALS['ldap_size_limit'] + ) + ->andReturn("ldap_search_result"); + + $phpLDAPMock->shouldreceive('ldap_errno') + ->with("ldap_connection") + ->andReturn(0); + + $phpLDAPMock->shouldreceive('ldap_count_entries') + ->with("ldap_connection", "ldap_search_result") + ->andReturn(2); + + $phpLDAPMock->shouldreceive('ldap_get_entries') + ->with("ldap_connection","ldap_search_result") + ->andReturn($entries); + + list($ldap,$result,$nb_entries,$res_entries,$size_limit_reached) = + Ltb\LtbUtil::search( "(objectClass=inetOrgPerson)", + array("cn", "sn") + ); + + $this->assertEquals("ldap_connection", $ldap, "Error while getting ldap_connection in search function"); + $this->assertFalse($result, "Error message returned while connecting to LDAP server in search function"); + $this->assertEquals(2, $nb_entries, "Wrong number of entries returned by search function"); + $this->assertEquals("testcn2", $res_entries[0]["cn"][0], "Wrong cn received in first entry. Entries may have not been sorted?"); + $this->assertEquals("testcn1", $res_entries[1]["cn"][0], "Wrong cn received in second entry. Entries may have not been sorted?"); + $this->assertFalse($size_limit_reached, "Unexpected size limit reached in search function"); + } + +} diff --git a/tests/Ltb/MailTest.php b/tests/Ltb/MailTest.php new file mode 100644 index 0000000..ab8aece --- /dev/null +++ b/tests/Ltb/MailTest.php @@ -0,0 +1,139 @@ +assertEquals($GLOBALS['mail_priority'], $mailer->Priority, "Error while setting mail_priority"); + $this->assertEquals($GLOBALS['mail_charset'], $mailer->CharSet, "Error while setting mail_charset"); + $this->assertEquals($GLOBALS['mail_contenttype'], $mailer->ContentType, "Error while setting mail_contenttype"); + $this->assertEquals($GLOBALS['mail_wordwrap'], $mailer->WordWrap, "Error while setting mail_wordwrap"); + $this->assertEquals($GLOBALS['mail_sendmailpath'], $mailer->Sendmail, "Error while setting mail_sendmailpath"); + $this->assertEquals($GLOBALS['mail_protocol'], $mailer->Mailer, "Error while setting mail_protocol"); + $this->assertEquals($GLOBALS['mail_smtp_debug'], $mailer->SMTPDebug, "Error while setting mail_smtp_debug"); + $this->assertEquals($GLOBALS['mail_debug_format'], $mailer->Debugoutput, "Error while setting mail_debug_format"); + $this->assertEquals($GLOBALS['mail_smtp_host'], $mailer->Host, "Error while setting mail_smtp_host"); + $this->assertEquals($GLOBALS['mail_smtp_port'], $mailer->Port, "Error while setting mail_smtp_port"); + $this->assertEquals($GLOBALS['mail_smtp_secure'], $mailer->SMTPSecure, "Error while setting mail_smtp_secure"); + $this->assertEquals($GLOBALS['mail_smtp_autotls'], $mailer->SMTPAutoTLS, "Error while setting mail_smtp_autotls"); + $this->assertEquals($GLOBALS['mail_smtp_auth'], $mailer->SMTPAuth, "Error while setting mail_smtp_auth"); + $this->assertEquals($GLOBALS['mail_smtp_user'], $mailer->Username, "Error while setting mail_smtp_user"); + $this->assertEquals($GLOBALS['mail_smtp_pass'], $mailer->Password, "Error while setting mail_smtp_pass"); + $this->assertEquals($GLOBALS['mail_smtp_keepalive'], $mailer->SMTPKeepAlive, "Error while setting mail_smtp_keepalive"); + $this->assertEquals($GLOBALS['mail_smtp_options'], $mailer->SMTPOptions, "Error while setting mail_smtp_options"); + $this->assertEquals($GLOBALS['mail_smtp_timeout'], $mailer->Timeout, "Error while setting mail_smtp_timeout"); + + } + + public function test_send_mail(): void + { + + $mail_from = "{mail_from}"; + $mail_from_name = "ltb admin sender"; + $mail_signature = ""; + $mail = ['{mail_to}','ltbadmin@domain.com']; + $data = [ + 'mail_from' => 'ltbadminsender@example.com', + "login" => 'ltbtest', + "mail_to" => 'ltbtest@domain.com', + "password" => 'secret' + ]; + $subject = 'Mail test to {login}'; + $body = 'Hello {login}, this is a mail test from {mail_from}. Your new password is {password}'; + + $mailerMock = Mockery::mock('PHPMailer\PHPMailer\PHPMailer'); + + $mailerMock->shouldreceive('clearAddresses') + ->andReturn(true); + + $mailerMock->shouldreceive('setFrom') + ->with('ltbadminsender@example.com', 'ltb admin sender') + ->andReturn(true); + + $mailerMock->shouldreceive('addReplyTo') + ->with('ltbadminsender@example.com', 'ltb admin sender') + ->andReturn(true); + + $mailerMock->shouldreceive('addAddress') + ->with(Mockery::anyOf('ltbtest@domain.com', 'ltbadmin@domain.com')) + ->andReturn(true); + + $mailerMock->shouldreceive('send') + ->andReturn(true); + + $result = Ltb\Mail::send_mail($mailerMock, $mail, $mail_from, $mail_from_name, $subject, $body, $data); + + $this->assertEquals('Mail test to ltbtest', $mailerMock->Subject, "Error while processing subject"); + $this->assertEquals('Hello ltbtest, this is a mail test from ltbadminsender@example.com. Your new password is secret', $mailerMock->Body, "Error while processing body"); + } + + public function test_send_mail_global(): void + { + + $mail_from = "{mail_from}"; + $mail_from_name = "ltb admin sender"; + $mail_signature = ""; + $mail = ['{mail_to}','ltbadmin@domain.com']; + $data = [ + 'mail_from' => 'ltbadminsender@example.com', + "login" => 'ltbtest', + "mail_to" => 'ltbtest@domain.com', + "password" => 'secret' + ]; + $subject = 'Mail test to {login}'; + $body = 'Hello {login}, this is a mail test from {mail_from}. Your new password is {password}'; + + $GLOBALS['mailer'] = Mockery::mock('PHPMailer\PHPMailer\PHPMailer'); + + $GLOBALS['mailer']->shouldreceive('clearAddresses') + ->andReturn(true); + + $GLOBALS['mailer']->shouldreceive('setFrom') + ->with('ltbadminsender@example.com', 'ltb admin sender') + ->andReturn(true); + + $GLOBALS['mailer']->shouldreceive('addReplyTo') + ->with('ltbadminsender@example.com', 'ltb admin sender') + ->andReturn(true); + + $GLOBALS['mailer']->shouldreceive('addAddress') + ->with(Mockery::anyOf('ltbtest@domain.com', 'ltbadmin@domain.com')) + ->andReturn(true); + + $GLOBALS['mailer']->shouldreceive('send') + ->andReturn(true); + + $result = Ltb\Mail::send_mail_global($mail, $mail_from, $mail_from_name, $subject, $body, $data); + + $this->assertEquals('Mail test to ltbtest', $GLOBALS['mailer']->Subject, "Error while processing subject"); + $this->assertEquals('Hello ltbtest, this is a mail test from ltbadminsender@example.com. Your new password is secret', $GLOBALS['mailer']->Body, "Error while processing body"); + } + +} diff --git a/tests/Ltb/attribute_value.php b/tests/Ltb/attribute_value.php deleted file mode 100644 index f4b68df..0000000 --- a/tests/Ltb/attribute_value.php +++ /dev/null @@ -1,36 +0,0 @@ -getMessage(), "\n"; -}catch (\TypeError $e) { - # expected Got Exception : ldap_get_attributes(): Argument #1 ($ldap) must be of type LDAP\Connection, bool given - echo 'Got Exception : ', $e->getMessage(), "\n"; -} - -$mail_attributes = false; - -try { - AttributeValue::ldap_get_mail_for_notification($ldap, $entry); -} catch (\TypeError $e) { - # expected Got Exception : ldap_get_attributes(): Argument #1 ($ldap) must be of type LDAP\Connection, bool given - echo 'Got Exception : ', $e->getMessage(), "\n"; -} - - diff --git a/tests/Ltb/ldap_search.php b/tests/Ltb/ldap_search.php deleted file mode 100644 index 8d70050..0000000 --- a/tests/Ltb/ldap_search.php +++ /dev/null @@ -1,47 +0,0 @@ - 6, - [ "count" => 0, "dn" => "ou=People,dc=company,dc=example"], - [ "count" => 1, "uid" => ["count"=>1, 0 => "jho"], 0 => "uid", "dn" => "uid=jho,ou=People,dc=company,dc=example" ], - [ "count" => 1, "uid" => ["count"=>1, 0 => "bfranck"], 0 => "uid", "dn" => "uid=bfrank,ou=People,dc=company,dc=example" ], - [ "count" => 1, "uid" => ["count"=>1, 0 => "nkeith"], 0 =>"uid","dn" => "uid=nkeith,ou=People,dc=company,dc=example" ], - [ "count" => 1, "uid" => ["count"=>1, 0 => "amorton"], 0 =>"uid","dn" => "uid=amorton,ou=People,dc=company,dc=example" ], - [ "count" => 1, "uid" => ["count"=>1, 0 => "irangel"], 0 =>"uid","dn" => "uid=irangel,ou=People,dc=company,dc=example" ] -]; - - -var_dump($array); - -Ldap::ldapSort($array,'uid'); - -# dump ... -var_dump($array); - diff --git a/tests/Ltb/mail.php b/tests/Ltb/mail.php deleted file mode 100644 index 9f854fc..0000000 --- a/tests/Ltb/mail.php +++ /dev/null @@ -1,49 +0,0 @@ - $login, "mail" => $mail_to, "password" => $newpassword); - -$messages['changesubject'] = "Votre mot de passe a été changé"; -$messages['changemessage'] = "Bonjour {login},\n\nVotre mot de passe a été changé.\n\nSi vous n'êtes pas à l'origine de cette demande, contactez votre administrateur immédiatement. votre mail : {mail}"; - -Mail::send_mail_global($mail, $mail_from, $mail_from_name, $messages["changesubject"], $messages["changemessage"].$mail_signature, $data);