mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 09:49:16 +02:00
Merge pull request #433 from LDAPAccountManager/feature/409-customScripts-split-config
Feature/409 custom scripts split config
This commit is contained in:
commit
4167603f66
4 changed files with 51 additions and 69 deletions
|
@ -4,6 +4,8 @@ June 2025 9.2
|
||||||
- Multi-edit tool: change operations are combined by DN to allow e.g. adding object classes with required attributes (408)
|
- Multi-edit tool: change operations are combined by DN to allow e.g. adding object classes with required attributes (408)
|
||||||
- Windows users: support thumbnail images (needs to be activated in server profile) (431)
|
- Windows users: support thumbnail images (needs to be activated in server profile) (431)
|
||||||
- Tree view: better editing of olcAccess (420)
|
- Tree view: better editing of olcAccess (420)
|
||||||
|
- LAM Pro:
|
||||||
|
-> Custom scripts: split config by account type (409)
|
||||||
- Fixed bugs:
|
- Fixed bugs:
|
||||||
-> Unix: profile editor for users not working (418)
|
-> Unix: profile editor for users not working (418)
|
||||||
-> Custom fields: problems with deleting facsimileTelephoneNumber (419)
|
-> Custom fields: problems with deleting facsimileTelephoneNumber (419)
|
||||||
|
|
|
@ -608,6 +608,38 @@
|
||||||
version. Unless explicitly noticed there is no need to install an
|
version. Unless explicitly noticed there is no need to install an
|
||||||
intermediate release.</para>
|
intermediate release.</para>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>9.1 -> 9.2</title>
|
||||||
|
|
||||||
|
<para>LAM Pro:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>Custom scripts: The settings in server profile were split by
|
||||||
|
account type. If you use custom scripts then you need to perform
|
||||||
|
these steps for each server profile that uses them (no scripts
|
||||||
|
will be executed till migration was done):</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>Open server profile and switch to tab "Module
|
||||||
|
settings"</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Review the automated migration of the custom scripts
|
||||||
|
settings (complex configurations will need manual
|
||||||
|
adaptions)</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Save the server profile</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>9.0 -> 9.1</title>
|
<title>9.0 -> 9.1</title>
|
||||||
|
|
||||||
|
|
|
@ -120,9 +120,9 @@ function setlanguage() {
|
||||||
* @param string $target owner, group or other
|
* @param string $target owner, group or other
|
||||||
* @param string $chmod the chmod rights
|
* @param string $chmod the chmod rights
|
||||||
*
|
*
|
||||||
* @return true, if the chmod $right for $target were set
|
* @return bool true, if the chmod $right for $target were set
|
||||||
*/
|
*/
|
||||||
function checkChmod($right, $target, $chmod) {
|
function checkChmod($right, $target, $chmod): bool {
|
||||||
$right_arr = ["read", "write", "execute"];
|
$right_arr = ["read", "write", "execute"];
|
||||||
$target_arr = ["owner", "group", "other"];
|
$target_arr = ["owner", "group", "other"];
|
||||||
|
|
||||||
|
@ -133,13 +133,13 @@ function checkChmod($right, $target, $chmod) {
|
||||||
|
|
||||||
$chmod_num = -1;
|
$chmod_num = -1;
|
||||||
// owner:
|
// owner:
|
||||||
if ($target == "owner") {
|
if ($target === "owner") {
|
||||||
$chmod_num = 0;
|
$chmod_num = 0;
|
||||||
}
|
}
|
||||||
if ($target == "group") {
|
if ($target === "group") {
|
||||||
$chmod_num = 1;
|
$chmod_num = 1;
|
||||||
}
|
}
|
||||||
if ($target == "other") {
|
if ($target === "other") {
|
||||||
$chmod_num = 2;
|
$chmod_num = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,9 +153,9 @@ function checkChmod($right, $target, $chmod) {
|
||||||
$write = [2, 3, 6, 7];
|
$write = [2, 3, 6, 7];
|
||||||
// What numbers allow "execute"
|
// What numbers allow "execute"
|
||||||
$execute = [1, 3, 5, 7];
|
$execute = [1, 3, 5, 7];
|
||||||
return (($right == "read") && in_array($chmod_num, $read))
|
return (($right === "read") && in_array($chmod_num, $read))
|
||||||
|| (($right == "write") && in_array($chmod_num, $write))
|
|| (($right === "write") && in_array($chmod_num, $write))
|
||||||
|| (($right == "execute") && in_array($chmod_num, $execute));
|
|| (($right === "execute") && in_array($chmod_num, $execute));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2024 Roland Gruber
|
Copyright (C) 2024 - 2025 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -51,16 +51,13 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
|
||||||
'LAM_TEXT_COMMENT: Comment=no comment',
|
'LAM_TEXT_COMMENT: Comment=no comment',
|
||||||
'LAM_TEXT_AMOUNT:Amount',
|
'LAM_TEXT_AMOUNT:Amount',
|
||||||
'LAM_GROUP: Group 1',
|
'LAM_GROUP: Group 1',
|
||||||
'user manual LAMLABEL="echo uid" echo $uid$',
|
'manual LAMLABEL="echo uid" echo $uid$',
|
||||||
'LAM_GROUP: Group 2',
|
'LAM_GROUP: Group 2',
|
||||||
'user manual echo $description$',
|
'manual echo $description$',
|
||||||
'user postModify echo $dn$',
|
'postModify echo $dn$',
|
||||||
'gon preModify echo NEW $member$ OLD $ORIG.member$',
|
|
||||||
'',
|
'',
|
||||||
' ',
|
' ',
|
||||||
'group:group_3 manual echo group3',
|
'preCreate echo user',
|
||||||
'group:group_3 postCreate echo group3',
|
|
||||||
'group preCreate echo group',
|
|
||||||
];
|
];
|
||||||
$this->configLinesSelfService = [
|
$this->configLinesSelfService = [
|
||||||
'postModify echo $dn$',
|
'postModify echo $dn$',
|
||||||
|
@ -70,17 +67,12 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
|
||||||
|
|
||||||
public function testCustomScriptParser() {
|
public function testCustomScriptParser() {
|
||||||
$parser = new \CustomScriptParser();
|
$parser = new \CustomScriptParser();
|
||||||
$scripts = $parser->parse($this->configLines, false);
|
$scripts = $parser->parse($this->configLines);
|
||||||
|
|
||||||
$this->assertNotEmpty($scripts);
|
$this->assertNotEmpty($scripts);
|
||||||
$this->assertEquals(7, count($scripts));
|
$this->assertEquals(4, count($scripts));
|
||||||
$typeManager = new TypeManager();
|
|
||||||
|
|
||||||
$script = $scripts[0];
|
$script = $scripts[0];
|
||||||
$configuredType = new ConfiguredType($typeManager, 'user', 'user');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertTrue($script->isManual());
|
$this->assertTrue($script->isManual());
|
||||||
$this->assertEquals('echo $uid$', $script->getCommand());
|
$this->assertEquals('echo $uid$', $script->getCommand());
|
||||||
$this->assertEquals('manual', $script->getType());
|
$this->assertEquals('manual', $script->getType());
|
||||||
|
@ -88,10 +80,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
|
||||||
$this->assertEquals('Group 1', $script->getGroupLabel());
|
$this->assertEquals('Group 1', $script->getGroupLabel());
|
||||||
|
|
||||||
$script = $scripts[1];
|
$script = $scripts[1];
|
||||||
$configuredType = new ConfiguredType($typeManager, 'user', 'user');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertTrue($script->isManual());
|
$this->assertTrue($script->isManual());
|
||||||
$this->assertEquals('echo $description$', $script->getCommand());
|
$this->assertEquals('echo $description$', $script->getCommand());
|
||||||
$this->assertEquals('manual', $script->getType());
|
$this->assertEquals('manual', $script->getType());
|
||||||
|
@ -99,10 +87,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
|
||||||
$this->assertEquals('Group 2', $script->getGroupLabel());
|
$this->assertEquals('Group 2', $script->getGroupLabel());
|
||||||
|
|
||||||
$script = $scripts[2];
|
$script = $scripts[2];
|
||||||
$configuredType = new ConfiguredType($typeManager, 'user', 'user');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertFalse($script->isManual());
|
$this->assertFalse($script->isManual());
|
||||||
$this->assertEquals('echo $dn$', $script->getCommand());
|
$this->assertEquals('echo $dn$', $script->getCommand());
|
||||||
$this->assertEquals('postModify', $script->getType());
|
$this->assertEquals('postModify', $script->getType());
|
||||||
|
@ -110,44 +94,8 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
|
||||||
$this->assertEquals(_('Post-modify'), $script->getTypeLabel());
|
$this->assertEquals(_('Post-modify'), $script->getTypeLabel());
|
||||||
|
|
||||||
$script = $scripts[3];
|
$script = $scripts[3];
|
||||||
$configuredType = new ConfiguredType($typeManager, 'gon', 'gon_1');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertFalse($script->isManual());
|
$this->assertFalse($script->isManual());
|
||||||
$this->assertEquals('echo NEW $member$ OLD $ORIG.member$', $script->getCommand());
|
$this->assertEquals('echo user', $script->getCommand());
|
||||||
$this->assertEquals('preModify', $script->getType());
|
|
||||||
$this->assertNull($script->getLabel());
|
|
||||||
$this->assertEquals(_('Pre-modify'), $script->getTypeLabel());
|
|
||||||
|
|
||||||
$script = $scripts[4];
|
|
||||||
$configuredType = new ConfiguredType($typeManager, 'group', 'group_3');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertTrue($script->isManual());
|
|
||||||
$this->assertEquals('echo group3', $script->getCommand());
|
|
||||||
$this->assertEquals('manual', $script->getType());
|
|
||||||
$this->assertNull($script->getLabel());
|
|
||||||
|
|
||||||
$script = $scripts[5];
|
|
||||||
$configuredType = new ConfiguredType($typeManager, 'group', 'group_3');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'gon', 'gon_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertFalse($script->isManual());
|
|
||||||
$this->assertEquals('echo group3', $script->getCommand());
|
|
||||||
$this->assertEquals('postCreate', $script->getType());
|
|
||||||
$this->assertNull($script->getLabel());
|
|
||||||
$this->assertEquals(_('Post-create'), $script->getTypeLabel());
|
|
||||||
|
|
||||||
$script = $scripts[6];
|
|
||||||
$configuredType = new ConfiguredType($typeManager, 'group', 'group_3');
|
|
||||||
$configuredWrongType = new ConfiguredType($typeManager, 'gon', 'gon_1');
|
|
||||||
$this->assertTrue($script->matchesConfiguredType($configuredType));
|
|
||||||
$this->assertFalse($script->matchesConfiguredType($configuredWrongType));
|
|
||||||
$this->assertFalse($script->isManual());
|
|
||||||
$this->assertEquals('echo group', $script->getCommand());
|
|
||||||
$this->assertEquals('preCreate', $script->getType());
|
$this->assertEquals('preCreate', $script->getType());
|
||||||
$this->assertNull($script->getLabel());
|
$this->assertNull($script->getLabel());
|
||||||
$this->assertEquals(_('Pre-create'), $script->getTypeLabel());
|
$this->assertEquals(_('Pre-create'), $script->getTypeLabel());
|
||||||
|
@ -174,7 +122,7 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
|
||||||
|
|
||||||
public function testCustomScriptParserSelfService() {
|
public function testCustomScriptParserSelfService() {
|
||||||
$parser = new \CustomScriptParser();
|
$parser = new \CustomScriptParser();
|
||||||
$scripts = $parser->parse($this->configLinesSelfService, true);
|
$scripts = $parser->parse($this->configLinesSelfService);
|
||||||
|
|
||||||
$this->assertNotEmpty($scripts);
|
$this->assertNotEmpty($scripts);
|
||||||
$this->assertEquals(2, count($scripts));
|
$this->assertEquals(2, count($scripts));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue