Compare commits
2
Commits
v9.33.0
...
7f0987d036
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f0987d036 | ||
|
|
074d5bed4c |
@@ -200,6 +200,47 @@ final class CoreLibsCreateRandomKeyTest extends TestCase
|
||||
\CoreLibs\Create\RandomKey::getRandomKeyLength()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setRandomKeyCharactersProvider(): array
|
||||
{
|
||||
return [
|
||||
'lower case characters' => [
|
||||
0 => "/^[a-z]+$/",
|
||||
1 => ["a", "z"],
|
||||
],
|
||||
'lower case and upper case' => [
|
||||
0 => "/^[A-Za-z]+$/",
|
||||
1 => ["A", "Z"],
|
||||
1 => ["a", "z"],
|
||||
],
|
||||
'alphanumeric' => [
|
||||
0 => "/^[A-Za-z0-9]+$/",
|
||||
1 => ["A", "Z"],
|
||||
1 => ["a", "z"],
|
||||
1 => ["0", "9"],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @covers ::setRandomKeyCharacters
|
||||
* @dataProvider setRandomKeyCharactersProvider
|
||||
* @testdox check setRandomKeyCharacters [$_dataName]
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSetRandomKeyCharacters(string $expected_regex, array ...$random_keys): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -31,6 +31,7 @@ $log = new CoreLibs\Logging\Logging([
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$log->setLogFileId('classTest-login-override');
|
||||
$login = new CoreLibs\ACL\Login(
|
||||
$db,
|
||||
$log,
|
||||
@@ -45,6 +46,7 @@ $login = new CoreLibs\ACL\Login(
|
||||
'locale_path' => BASE . INCLUDES . LOCALE,
|
||||
]
|
||||
);
|
||||
$log->setLogFileId($LOG_FILE_ID);
|
||||
ob_end_flush();
|
||||
$login->loginMainCall();
|
||||
|
||||
@@ -158,5 +160,6 @@ if (is_string($edit_access_cuid)) {
|
||||
print "EA ID: " . $edit_access_id . "<br>";
|
||||
print "EA CUID: " . $log->prAr($edit_access_cuid) . "<br>";
|
||||
print "REV EA CUID: " . $log->prAr($edit_access_id_rev) . "<br>";
|
||||
$log->info('This is a test');
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
@@ -43,8 +43,10 @@ print "S::RANDOMKEYGEN($key_length): " . RandomKey::randomKeyGen() . "<br>";
|
||||
print "S::RANDOMKEYGEN($key_length_b): " . RandomKey::randomKeyGen($key_length_b) . "<br>";
|
||||
print "S::RANDOMKEYGEN($key_length): " . RandomKey::randomKeyGen() . "<br>";
|
||||
print "S::RANDOMKEYGEN($key_lenght_long): " . RandomKey::randomKeyGen($key_lenght_long) . "<br>";
|
||||
$_array = new CoreLibs\Create\RandomKey();
|
||||
print "C->RANDOMKEYGEN(auto): " . $_array->randomKeyGen() . "<br>";
|
||||
$random_key = new CoreLibs\Create\RandomKey();
|
||||
print "C->RANDOMKEYGEN(auto): " . $random_key->randomKeyGen() . "<br>";
|
||||
$random_key->setRandomKeyCharacters(['a', 'z']);
|
||||
print "C->RANDOMKEYGEN(Fixed set): " . $random_key->randomKeyGen() . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -61,6 +61,32 @@ class RandomKey
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a different character range
|
||||
*
|
||||
* @param array<array{0:string,1:string}> $ranges
|
||||
* @return bool
|
||||
*/
|
||||
public static function setRandomKeyCharacters(array ...$ranges): bool
|
||||
{
|
||||
// each range must be an arary of start end range
|
||||
$character_range = [];
|
||||
foreach ($ranges as $range) {
|
||||
if (count($range) != 2) {
|
||||
throw new \ArgumentCountError(__FUNCTION__ . ' array must have two range entries');
|
||||
}
|
||||
$character_range = array_merge($character_range, range($range[0], $range[1]));
|
||||
}
|
||||
self::$key_range = join('', $character_range);
|
||||
self::$one_key_length = strlen(self::$key_range);
|
||||
if (
|
||||
self::$one_key_length == 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the key length and checks that they key given is valid
|
||||
* if failed it will not change the default key length and return false
|
||||
|
||||
Reference in New Issue
Block a user