Add script 'get-openssl-version.sh'.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# users.auth.php
|
||||
# <?php exit()?>
|
||||
# Don't modify the lines above
|
||||
#
|
||||
# Userfile
|
||||
#
|
||||
# Format:
|
||||
#
|
||||
# login:passwordhash:Real Name:email:groups,comma,separated
|
||||
|
||||
|
||||
user_1:$1$tGu7CW5z$VpsMjRIx5tbyOJaQ2SP23.:Admin:admin@example.com:user,first_group
|
||||
user_2:$1$2uJ5C3ib$edo0EDEb/yLAFHme7RK851:User 2:user2@example.com:user,second_group,third_group
|
||||
user_3:$1$yqnlDqgZ$Sste968uKhuxH6wIQt6/D/:User 3:user3@example.com:user,fourth_group,first_group,third_group
|
||||
user_4:$1$tXjajS9s$peoGPBQep.P245H1Lfloj0:User 4:user4@example.com:user,third_group
|
||||
user_5:$1$IWrqdhol$xXOmufjZ2hW1aAVp7zDP.1:User 5:user5@example.com:user,second_group,fifth_group
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* These tests are designed to test the capacity of pluginauth to handle
|
||||
* correct escaping of colon field delimiters and backslashes in user content.
|
||||
*
|
||||
* (Note that these tests set some Real Names, etc. that are may not be
|
||||
* valid in the broader dokuwiki context, but the tests ensure that
|
||||
* authplain won't get unexpectedly surprised.)
|
||||
*
|
||||
* @group plugin_authplain
|
||||
* @group auth_plugins
|
||||
* @group plugins
|
||||
* @group bundled_plugins
|
||||
*/
|
||||
class helper_plugin_authplain_escaping_test extends DokuWikiTest {
|
||||
|
||||
protected $pluginsEnabled = array('authplain');
|
||||
/** @var auth_plugin_authplain */
|
||||
protected $auth;
|
||||
|
||||
protected function reloadUsers() {
|
||||
/* auth caches data loaded from file, but recreated object forces reload */
|
||||
$this->auth = new auth_plugin_authplain();
|
||||
}
|
||||
|
||||
function setUp() : void {
|
||||
global $config_cascade;
|
||||
parent::setUp();
|
||||
$name = $config_cascade['plainauth.users']['default'];
|
||||
copy($name, $name.".orig");
|
||||
$this->reloadUsers();
|
||||
}
|
||||
|
||||
function tearDown() : void {
|
||||
global $config_cascade;
|
||||
parent::tearDown();
|
||||
$name = $config_cascade['plainauth.users']['default'];
|
||||
copy($name.".orig", $name);
|
||||
}
|
||||
|
||||
public function testMediawikiPasswordHash() {
|
||||
global $conf;
|
||||
$conf['passcrypt'] = 'mediawiki';
|
||||
$this->auth->createUser("mwuser", "12345", "Mediawiki User", "me@example.com");
|
||||
$this->reloadUsers();
|
||||
$this->assertTrue($this->auth->checkPass("mwuser", "12345"));
|
||||
$mwuser = $this->auth->getUserData("mwuser");
|
||||
$this->assertStringStartsWith(":B:",$mwuser['pass']);
|
||||
$this->assertEquals("Mediawiki User",$mwuser['name']);
|
||||
}
|
||||
|
||||
public function testNameWithColons() {
|
||||
$name = ":Colon: User:";
|
||||
$this->auth->createUser("colonuser", "password", $name, "me@example.com");
|
||||
$this->reloadUsers();
|
||||
$user = $this->auth->getUserData("colonuser");
|
||||
$this->assertEquals($name,$user['name']);
|
||||
}
|
||||
|
||||
public function testNameWithBackslashes() {
|
||||
$name = "\\Slash\\ User\\";
|
||||
$this->auth->createUser("slashuser", "password", $name, "me@example.com");
|
||||
$this->reloadUsers();
|
||||
$user = $this->auth->getUserData("slashuser");
|
||||
$this->assertEquals($name,$user['name']);
|
||||
}
|
||||
|
||||
public function testModifyUser() {
|
||||
global $conf;
|
||||
$conf['passcrypt'] = 'mediawiki';
|
||||
$user = $this->auth->getUserData("testuser");
|
||||
$user['name'] = "\\New:Crazy:Name\\";
|
||||
$user['pass'] = "awesome new password";
|
||||
$this->auth->modifyUser("testuser", $user);
|
||||
$this->reloadUsers();
|
||||
|
||||
$saved = $this->auth->getUserData("testuser");
|
||||
$this->assertEquals($saved['name'], $user['name']);
|
||||
$this->assertTrue($this->auth->checkPass("testuser", $user['pass']));
|
||||
}
|
||||
|
||||
// really only required for developers to ensure this plugin will
|
||||
// work with systems running on PCRE 6.6 and lower.
|
||||
public function testLineSplit(){
|
||||
$names = array(
|
||||
'plain',
|
||||
'ut-fठ8',
|
||||
'colon:',
|
||||
'backslash\\',
|
||||
'alltogether\\ठ:'
|
||||
);
|
||||
$userpass = 'user:password_hash:';
|
||||
$other_user_data = ':email@address:group1,group2';
|
||||
|
||||
foreach ($names as $testname) {
|
||||
$escaped = str_replace(array('\\',':'),array('\\\\','\\:'),$testname); // escape : & \
|
||||
$test_line = $userpass.$escaped.$other_user_data;
|
||||
$result = $this->callInaccessibleMethod($this->auth, 'splitUserData', [$test_line]);
|
||||
|
||||
$this->assertEquals($escaped, $result[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see testCleaning
|
||||
*/
|
||||
public function provideCleaning()
|
||||
{
|
||||
return [
|
||||
['user', 'user'],
|
||||
['USER', 'user'],
|
||||
[' USER ', 'user'],
|
||||
[' US ER ', 'us_er'],
|
||||
['http://foo;bar', 'http_foo_bar'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input
|
||||
* @param string $expected
|
||||
* @dataProvider provideCleaning
|
||||
*/
|
||||
public function testCleaning($input, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->auth->cleanUser($input));
|
||||
$this->assertEquals($expected, $this->auth->cleanGroup($input));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class userdata_test
|
||||
*
|
||||
* Test group retrieval
|
||||
*
|
||||
* @group plugins
|
||||
*/
|
||||
class userdata_test extends DokuWikiTest
|
||||
{
|
||||
/** @var auth_plugin_authplain */
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Load auth with test conf
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
global $config_cascade;
|
||||
$config_cascade['plainauth.users']['default'] = __DIR__ . '/conf/auth.users.php';
|
||||
$this->auth = new auth_plugin_authplain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that all groups are retrieved in the correct order, without duplicates
|
||||
*/
|
||||
public function test_retrieve_groups()
|
||||
{
|
||||
$expected = ['user', 'first_group', 'second_group', 'third_group', 'fourth_group', 'fifth_group'];
|
||||
$actual = $this->auth->retrieveGroups();
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with small and large limits
|
||||
*/
|
||||
public function test_retrieve_groups_limit()
|
||||
{
|
||||
$expected = ['user', 'first_group'];
|
||||
$actual = $this->auth->retrieveGroups(0, 2);
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = ['user', 'first_group', 'second_group', 'third_group', 'fourth_group', 'fifth_group'];
|
||||
$actual = $this->auth->retrieveGroups(0, 20);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with small and large offsets
|
||||
*/
|
||||
public function test_retrieve_groups_offset()
|
||||
{
|
||||
$expected = ['third_group', 'fourth_group', 'fifth_group'];
|
||||
$actual = $this->auth->retrieveGroups(3,10);
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [];
|
||||
$actual = $this->auth->retrieveGroups(10,3);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user