aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/admin.t
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-08-01 16:36:55 +0100
committerDave Arter <davea@mysociety.org>2016-08-17 15:34:53 +0100
commit91c5520c7078f2caa3cbdbdcff4f86a29d9d7390 (patch)
tree3f6919c4a7713db5db4e83aeddec87591742da6f /t/app/controller/admin.t
parentf0220a9742ef0b7458b2dafaba5d9f860a741a91 (diff)
Restrict user editing in admin
The 'user_edit' permission is required to edit users. The admin pages on UK council cobrands only allow editing of users whose from_body is the same as the logged-in user, or who have sent reports or updates to the council.
Diffstat (limited to 't/app/controller/admin.t')
-rw-r--r--t/app/controller/admin.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index aceaf2981..531fa7726 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -1102,6 +1102,30 @@ subtest 'user search' => sub {
$mech->content_contains('Haringey');
};
+subtest 'search does not show user from another council' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ }, sub {
+ $mech->get_ok('/admin/users');
+ $mech->get_ok('/admin/users?search=' . $user->name);
+
+ $mech->content_contains( "Searching found no users." );
+
+ $mech->get_ok('/admin/users?search=' . $user->email);
+ $mech->content_contains( "Searching found no users." );
+ };
+};
+
+subtest 'user_edit does not show user from another council' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ }, sub {
+ $mech->get('/admin/user_edit/' . $user->id);
+ ok !$mech->res->is_success(), "want a bad response";
+ is $mech->res->code, 404, "got 404";
+ };
+};
+
$log_entries = FixMyStreet::App->model('DB::AdminLog')->search(
{
object_type => 'user',