[Rt-commit] [svn] r1542 - in rt/branches/3.3-TESTING: .
html/Elements lib/t
tla at pallas.eruditorum.org
tla at pallas.eruditorum.org
Wed Sep 22 03:41:23 EDT 2004
Author: tla
Date: Wed Sep 22 03:41:22 2004
New Revision: 1542
Added:
rt/branches/3.3-TESTING/lib/t/07acl.pl.in
Modified:
rt/branches/3.3-TESTING/UPGRADING
rt/branches/3.3-TESTING/configure.ac
rt/branches/3.3-TESTING/html/Elements/Tabs
rt/branches/3.3-TESTING/lib/t/02regression.t.in
Log:
Moved the functionality whereby Config and Prefs tabs disappear to core.
Wrote tests for the new core behavior.
Modified: rt/branches/3.3-TESTING/UPGRADING
==============================================================================
--- rt/branches/3.3-TESTING/UPGRADING (original)
+++ rt/branches/3.3-TESTING/UPGRADING Wed Sep 22 03:41:22 2004
@@ -16,6 +16,14 @@
*******
+UPGRADING FROM 3.2 and earlier - Changes:
+
+= Rights changes =
+
+Now, if you want any user to be able to access the Admin tools (a.k.a.
+the Configuration tab), you must grant that user the "ShowConfigTab"
+right. Making the user a privileged user is no longer sufficient.
+
UPGRADING FROM 3.0.x - Changes:
Modified: rt/branches/3.3-TESTING/configure.ac
==============================================================================
--- rt/branches/3.3-TESTING/configure.ac (original)
+++ rt/branches/3.3-TESTING/configure.ac Wed Sep 22 03:41:22 2004
@@ -240,6 +240,7 @@
lib/t/04_send_email.pl
lib/t/05cronsupport.pl
lib/t/06mailgateway.pl
+ lib/t/07acl.pl
bin/mason_handler.fcgi
bin/mason_handler.scgi
bin/standalone_httpd
Modified: rt/branches/3.3-TESTING/html/Elements/Tabs
==============================================================================
--- rt/branches/3.3-TESTING/html/Elements/Tabs (original)
+++ rt/branches/3.3-TESTING/html/Elements/Tabs Wed Sep 22 03:41:22 2004
@@ -71,17 +71,25 @@
C => { title => loc('Tools'),
path => 'Tools/Offline.html'
},
- E => { title => loc('Configuration'),
- path => 'Admin/'
- },
- K => { title => loc('Preferences'),
- path => 'User/Prefs.html'
- },
P => { title => loc('Approval'),
path => 'Approvals/'
},
};
+if ($session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab',
+ Object => $RT::System )) {
+ $basetabs->{E} = { title => loc('Configuration'),
+ path => 'Admin/',
+ };
+}
+
+if ($session{'CurrentUser'}->HasRight( Right => 'ModifySelf',
+ Object => $RT::System )) {
+ $basetabs->{K} = { title => loc('Preferences'),
+ path => 'User/Prefs.html'
+ };
+}
+
if (!defined $toptabs) {
$toptabs = $basetabs;
}
Modified: rt/branches/3.3-TESTING/lib/t/02regression.t.in
==============================================================================
--- rt/branches/3.3-TESTING/lib/t/02regression.t.in (original)
+++ rt/branches/3.3-TESTING/lib/t/02regression.t.in Wed Sep 22 03:41:22 2004
@@ -46,3 +46,4 @@
require "@RT_LIB_PATH@/t/04_send_email.pl";
require "@RT_LIB_PATH@/t/05cronsupport.pl";
require "@RT_LIB_PATH@/t/06mailgateway.pl";
+require "@RT_LIB_PATH@/t/07acl.pl";
Added: rt/branches/3.3-TESTING/lib/t/07acl.pl.in
==============================================================================
--- (empty file)
+++ rt/branches/3.3-TESTING/lib/t/07acl.pl.in Wed Sep 22 03:41:22 2004
@@ -0,0 +1,86 @@
+#!@PERL@ -w
+
+use WWW::Mechanize;
+use HTTP::Cookies;
+
+# Create a user with basically no rights, to start.
+my $user_obj = RT::User->new($RT::SystemUser);
+my ($ret, $msg) = $user_obj->LoadOrCreateByEmail('customer at example.com');
+ok($ret, 'ACL test user creation');
+$user_obj->SetName('customer');
+$user_obj->SetPrivileged(1);
+my ($val, $msg) = $user_obj->SetPassword('customer');
+ok($val, "ACL test password set. $msg");
+
+# Now test the web interface, making sure objects come and go as
+# required.
+
+my $cookie_jar = HTTP::Cookies->new;
+my $agent = WWW::Mechanize->new();
+
+# give the agent a place to stash the cookies
+
+$agent->cookie_jar($cookie_jar);
+
+
+# get the top page
+my $url = "http://localhost".$RT::WebPath."/";
+$agent->get($url);
+
+is ($agent->{'status'}, 200, "Loaded a page");
+# {{{ test a login
+
+# follow the link marked "Login"
+
+ok($agent->{form}->find_input('user'));
+
+ok($agent->{form}->find_input('pass'));
+ok ($agent->{'content'} =~ /username:/i);
+$agent->field( 'user' => 'customer' );
+$agent->field( 'pass' => 'customer' );
+# the field isn't named, so we have to click link 0
+$agent->click(0);
+is($agent->{'status'}, 200, "Fetched the page ok");
+ok($agent->{'content'} =~ /Logout/i, "Found a logout link");
+
+# Test for absence of Configure and Preferences tabs.
+ok(!$agent->find_link( url => '/Admin/',
+ text => 'Configuration'), "No config tab" );
+ok(!$agent->find_link( url => '/User/Prefs.html',
+ text => 'Preferences'), "No prefs pane" );
+
+# Now test for their presence, one at a time.
+my ($val, $msg) = $user_obj->PrincipalObj->GrantRight(Right => 'ShowConfigTab');
+ok($val, "Grant the right. $msg");
+$agent->reload();
+ok($agent->{'content'} =~ /Logout/i, "Reloaded page successfully");
+ok($agent->find_link( url => '/Admin/',
+ text => 'Configuration'), "Found config tab" );
+$user_obj->PrincipalObj->RevokeRight(Right => 'ShowConfigTab');
+$user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf');
+$agent->reload();
+ok($agent->{'content'} =~ /Logout/i, "Reloaded page successfully");
+ok($agent->find_link( url => '/User/Prefs.html',
+ text => 'Preferences'), "Found prefs pane" );
+$user_obj->PrincipalObj->RevokeRight(Right => 'ModifySelf');
+
+# Good. Now load the search page and test Load/Save Search.
+$agent->follow_link( url => '/Search/Build.html',
+ text => 'Tickets');
+is($agent->{'status'}, 200, "Fetched search builder page");
+ok($agent->{'content'} !~ /Load saved search/i, "No search loading box");
+ok($agent->{'content'} !~ /Saved searches/i, "No saved searches box");
+
+$user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch');
+$agent->reload();
+ok($agent->{'content'} =~ /Load saved search/i, "Search loading box exists");
+ok($agent->{'content'} !~ /Privacy.*Description/mi, "Still no saved searches box");
+
+$user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch');
+$agent->reload();
+ok($agent->{'content'} =~ /Load saved search/i,
+ "Search loading box stillexists");
+ok($agent->{'content'} =~ /Privacy.*Description/mi,
+ "Saved searches box exists");
+
+1;
More information about the Rt-commit
mailing list