[Rt-commit] rt branch, 4.2/validate-all-roles, created. rt-4.2.10-237-g29709ad

Alex Vandiver alexmv at bestpractical.com
Thu Apr 9 20:57:27 EDT 2015


The branch, 4.2/validate-all-roles has been created
        at  29709ad2cf29c597a5d8ffdcca67c535cf450084 (commit)

- Log -----------------------------------------------------------------
commit 01fbfc434dca62f69564c4c0cf3c33209a756721
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Jul 9 19:51:37 2014 -0400

    Ensure tickets and queues have all of their role groups, individually

diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index 16432a3..1534147 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -288,14 +288,15 @@ push @CHECKS, 'User <-> ACL equivalence group' => sub {
 
 # check integrity of Queue role groups
 push @CHECKS, 'Queues <-> Role Groups' => sub {
-    # XXX: we check only that there is at least one group for a queue
     # from queue to group
     my $res = 1;
-    $res *= check_integrity(
-        'Queues', 'id' => 'Groups', 'Instance',
-        join_condition   => 't.Domain = ?',
-        bind_values => [ 'RT::Queue-Role' ],
-    );
+    for my $role (RT::Ticket->Roles) {
+        $res *= check_integrity(
+            'Queues', 'id' => 'Groups', 'Instance',
+            join_condition   => 't.Domain = ? AND t.Type = ?',
+            bind_values => [ 'RT::Queue-Role', $role ],
+        );
+    }
     # from group to queue
     $res *= check_integrity(
         'Groups', 'Instance' => 'Queues', 'id',
@@ -315,14 +316,15 @@ push @CHECKS, 'Queues <-> Role Groups' => sub {
 
 # check integrity of Ticket role groups
 push @CHECKS, 'Tickets <-> Role Groups' => sub {
-    # XXX: we check only that there is at least one group for a queue
     # from queue to group
     my $res = 1;
-    $res *= check_integrity(
-        'Tickets', 'id' => 'Groups', 'Instance',
-        join_condition   => 't.Domain = ?',
-        bind_values => [ 'RT::Ticket-Role' ],
-    );
+    for my $role (RT::Ticket->Roles) {
+        $res *= check_integrity(
+            'Tickets', 'id' => 'Groups', 'Instance',
+            join_condition   => 't.Domain = ? AND t.Type = ?',
+            bind_values => [ 'RT::Ticket-Role', $role ],
+        );
+    }
     # from group to ticket
     $res *= check_integrity(
         'Groups', 'Instance' => 'Tickets', 'id',

commit 29709ad2cf29c597a5d8ffdcca67c535cf450084
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Jul 9 19:52:25 2014 -0400

    Prompt to create missing role groups

diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index 1534147..b5c7d5d 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -295,6 +295,22 @@ push @CHECKS, 'Queues <-> Role Groups' => sub {
             'Queues', 'id' => 'Groups', 'Instance',
             join_condition   => 't.Domain = ? AND t.Type = ?',
             bind_values => [ 'RT::Queue-Role', $role ],
+            action => sub {
+                my $id = shift;
+                return unless prompt(
+                    'Create', "Found a queue missing a $role role group"
+                );
+
+                my $group = RT::Group->new( RT->SystemUser );
+                $group->_Create(
+                    Domain   => 'RT::Queue-Role',
+                    Name     => $role,
+                    Instance => $id,
+                );
+                $redo_check{ $_ } = 1 for
+                    @{ $redo_on{'Create'}{ Principals } || [] },
+                    @{ $redo_on{'Create'}{ Groups } || [] };
+            },
         );
     }
     # from group to queue
@@ -323,6 +339,22 @@ push @CHECKS, 'Tickets <-> Role Groups' => sub {
             'Tickets', 'id' => 'Groups', 'Instance',
             join_condition   => 't.Domain = ? AND t.Type = ?',
             bind_values => [ 'RT::Ticket-Role', $role ],
+            action => sub {
+                my $id = shift;
+                return unless prompt(
+                    'Create', "Found a ticket missing a $role role group"
+                );
+
+                my $group = RT::Group->new( RT->SystemUser );
+                $group->_Create(
+                    Domain   => 'RT::Ticket-Role',
+                    Name     => $role,
+                    Instance => $id,
+                );
+                $redo_check{ $_ } = 1 for
+                    @{ $redo_on{'Create'}{ Principals } || [] },
+                    @{ $redo_on{'Create'}{ Groups } || [] };
+            },
         );
     }
     # from group to ticket

-----------------------------------------------------------------------


More information about the rt-commit mailing list