xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / tests / ldap_core.php (ec1e18adef8f12919ee4cee1abfbd12689a750ed) (1,734B) (mode 100644) [raw]
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('track_errors', 'On');

$rg_cache_debug = TRUE;
$rg_util_debug = TRUE;
$rg_sql_debug = 100;
$test_normal = TRUE;

$INC = dirname(__FILE__) . '/../inc';
require_once(dirname(__FILE__) . '/config.php');
require_once($INC . '/init.inc.php');
require_once($INC . '/util.inc.php');
require_once($INC . '/ldap_core.inc.php');

rg_log_set_file('ldap_core.log');

require_once('common.php');

$_testns = 'admin_ldap_core';


rg_log('');
rg_log_enter('Testing ldif2array [1a] (truncated input)...');
$r = rg_ldap_core_ldif2array("a: b\nc:");
if (($r['ok'] != 1) || ($r['used'] != 0)) {
	rg_log('Truncated input must return ok(' . $r['ok'] . ') and'
		. ' used(' . $r['used'] . ') = 0!');
	exit(1);
}
rg_log_exit();


rg_log('');
$s = "a b\n\n";
rg_log_enter('Testing ldif2array [1b] (s=' . $s . ')...');
$r = rg_ldap_core_ldif2array($s);
if ($r['ok'] == 1) {
	rg_log_ml('r: ' . print_r($r, TRUE));
	rg_log('Line without \':\' should not be allowed');
	exit(1);
}
rg_log_exit();


rg_log('');
rg_log_enter('Testing ldif2array [2]...');
$x = @file_get_contents('ldap_core1.ldif');
if ($x === FALSE) {
	rg_log('Cannot load ldap_core1.ldif!');
	exit(1);
}
$r = rg_ldap_core_ldif2array($x);
rg_log_ml('r: ' . print_r($r, TRUE));
if ($r['ok'] != 1) {
	rg_log('Error parsing ldif: ' . $r['errmsg']);
	exit(1);
}
if (@strcmp($r['data'][0]['xxx'], 'my-domain') != 0) {
	rg_log_ml('r: ' . print_r($r, TRUE));
	rg_log('data[0][xxx] is not \'my-domain\'!');
	exit(1);
}
if (@strcmp($r['data'][2]['dn'], 'ou=People-șț,dc=my-domain,dc=com') != 0) {
	rg_log_ml('r: ' . print_r($r, TRUE));
	rg_log('data[2][dn] is not \'ou=People-șț,dc=my-domain,dc=com\'!');
	exit(1);
}
rg_log_exit();


rg_log('OK!');
?>
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master