[Rt-commit] rt branch, 4.4/user-create-skip-cfs, updated. rt-4.4.4-66-gc4cd1610e
? sunnavy
sunnavy at bestpractical.com
Mon Sep 23 17:56:20 EDT 2019
The branch, 4.4/user-create-skip-cfs has been updated
via c4cd1610e8201c831ae0a250a04c33c92baceb44 (commit)
via d44ec6045ca19a399ac0188b261ce3670d647faf (commit)
from 3295013b07d80d5e5b35cb606b0355c24cab24a4 (commit)
Summary of changes:
share/html/Elements/EditCustomField | 10 +++++++++
.../Elements/{Section => EditCustomFieldDisplay} | 5 +++--
t/externalauth/ldap.t | 24 +++++++++++++++++++++-
3 files changed, 36 insertions(+), 3 deletions(-)
copy share/html/Elements/{Section => EditCustomFieldDisplay} (98%)
- Log -----------------------------------------------------------------
commit d44ec6045ca19a399ac0188b261ce3670d647faf
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 24 05:23:17 2019 +0800
Only show hints for user CFs configured in external settings on create
These cfs will be automatically set in external sources.
diff --git a/share/html/Elements/EditCustomField b/share/html/Elements/EditCustomField
index 3f24c0189..04af52569 100644
--- a/share/html/Elements/EditCustomField
+++ b/share/html/Elements/EditCustomField
@@ -122,6 +122,16 @@ $m->out("\n".'<input type="hidden" class="hidden" name="'
. ($Name ? $m->interp->apply_escapes($Name, 'h') : $m->interp->apply_escapes($NamePrefix, 'h').$CustomField->Id.'-Values')
. '-Magic" value="1" />'."\n");
+# Just show hints for user cfs that will be set from external sources on create
+if ( RT->Config->Get('ExternalInfoPriority') && $Object && $Object->isa('RT::User') && !$Object->Id ) {
+ for my $source ( @{RT->Config->Get('ExternalInfoPriority')} ) {
+ if ( RT->Config->Get('ExternalSettings')->{$source}{attr_map}{'UserCF.'.$CustomField->Name} ) {
+ $Type = 'Display';
+ $Default = loc('Set from external source');
+ last;
+ }
+ }
+}
my $EditComponent = "EditCustomField$Type";
$m->callback( %ARGS, CallbackName => 'EditComponentName', Name => \$EditComponent, CustomField => $CustomField, Object => $Object, Rows => \$Rows, Cols => \$Cols);
diff --git a/share/html/Elements/EditCustomFieldDisplay b/share/html/Elements/EditCustomFieldDisplay
new file mode 100644
index 000000000..8e93b338b
--- /dev/null
+++ b/share/html/Elements/EditCustomFieldDisplay
@@ -0,0 +1,52 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<% $Default %>
+
+<%ARGS>
+$Default => undef
+</%ARGS>
commit c4cd1610e8201c831ae0a250a04c33c92baceb44
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 24 05:28:56 2019 +0800
Add more tests for user create forms where some cfs are set in LDAP
diff --git a/t/externalauth/ldap.t b/t/externalauth/ldap.t
index 362ab5fb5..b6d696abc 100644
--- a/t/externalauth/ldap.t
+++ b/t/externalauth/ldap.t
@@ -51,6 +51,17 @@ ok( $employee_id_cf->Create(
);
ok( $employee_id_cf->AddToObject( RT::User->new( RT->SystemUser ) ), 'applied Employee ID globally' );
+my $delegate_cf = RT::CustomField->new( RT->SystemUser );
+ok( $delegate_cf->Create(
+ Name => 'Delegate',
+ LookupType => RT::User->CustomFieldLookupType,
+ Type => 'Freeform',
+ MaxValues => 1,
+ ),
+ 'created cf Delegate'
+);
+ok( $delegate_cf->AddToObject( RT::User->new( RT->SystemUser ) ), 'applied Delegate globally' );
+
RT->Config->Set( ExternalAuthPriority => ['My_LDAP'] );
RT->Config->Set( ExternalInfoPriority => ['My_LDAP'] );
RT->Config->Set( AutoCreateNonExternalUsers => 0 );
@@ -139,6 +150,8 @@ diag "test admin user create";
$m->logout;
ok( $m->login );
$m->get_ok( $baseurl . '/Admin/Users/Modify.html?Create=1', 'user create page' );
+ $m->text_contains( 'Employee Type:Select one value Set from external source' );
+ $m->text_contains( 'Employee ID:Enter one value Set from external source' );
my $username = 'testuser2';
$m->submit_form(
@@ -161,9 +174,17 @@ diag "test admin user create";
my $dn = "uid=$username,$base";
$ldap->add( $dn, attr => [ %$entry ] );
+ my $delegate_input = RT::Interface::Web::GetCustomFieldInputName(
+ Object => RT::User->new( RT->SystemUser ),
+ CustomField => $delegate_cf,
+ );
$m->submit_form(
form_name => 'UserCreate',
- fields => { Name => '', EmailAddress => "$username\@invalid.tld" },
+ fields => {
+ Name => '',
+ EmailAddress => "$username\@invalid.tld",
+ $delegate_input => 'root',
+ },
);
$m->text_contains( 'User created' );
my ( $id ) = ( $m->uri =~ /id=(\d+)/ );
@@ -172,6 +193,7 @@ diag "test admin user create";
is( $user->EmailAddress, "$username\@invalid.tld", 'email is not changed' );
is( $user->Name, $username, 'got canonicalized Name' );
is( $user->FirstCustomFieldValue('Employee Type'), 'sale', 'Employee Type set to sale from LDAP' );
+ is( $user->FirstCustomFieldValue('Delegate'), 'root', 'Delegate set to root from Web' );
}
diag "test user update via login";
-----------------------------------------------------------------------
More information about the rt-commit
mailing list