Skip to content

Commit

Permalink
EMPLOYEE PROFILE: drop Dochazka EID...
Browse files Browse the repository at this point in the history
...and present sec_id as Workforce ID.

Fixes: smithfarm/dochazka#17
Signed-off-by: Nathan Cutler <[email protected]>
  • Loading branch information
smithfarm committed Sep 15, 2016
1 parent 0f31e4b commit a22e01c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 66 deletions.
3 changes: 1 addition & 2 deletions lib/App/Dochazka/CLI/Commands/Employee.pm
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ sub _display_employee_ok {
$message .= "Full name: " . ( $emp->fullname ? $emp->fullname : "(not set)" ) . "\n";
$message .= "Nick: " . $emp->nick . "\n";
$message .= "Email: " . ( $emp->email || "(not set)" ) . "\n";
$message .= "Secondary ID: " . ( $emp->sec_id ? $emp->sec_id : "(not set)" ) . "\n";
$message .= "Dochazka EID: " . $emp->eid . "\n";
$message .= "Workforce ID: " . ( $emp->sec_id ? $emp->sec_id : "(not set)" ) . "\n";
$message .= "Reports to: " . ( $supervisor->nick || "(not set)" ) . "\n";

return $CELL->status_ok( 'DOCHAZKA_CLI_NORMAL_COMPLETION', payload => $message );
Expand Down
8 changes: 0 additions & 8 deletions t/cmd_active/employee.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,26 @@ $rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );

$cmd = "EMPLOYEE PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );

# EMPLOYEE_SPEC on self always works
$cmd = "EMPLOYEE=worker PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );

# EMPLOYEE_SPEC on a different employee => works
$cmd = "EMPLOYEE=demo PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+demo/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+passerby/ );

# EMPLOYEE_SPEC on non-existent employee => 404
$cmd = "EMPLOYEE=999999 PROFILE";
Expand Down
51 changes: 7 additions & 44 deletions t/cmd_admin/employee.t
Original file line number Diff line number Diff line change
Expand Up @@ -77,54 +77,34 @@ ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
is( $rv->code, 'DOCHAZKA_CLI_NORMAL_COMPLETION' );
like( $rv->payload, qr/Nick:\s+root/ );
like( $rv->payload, qr/Dochazka EID:\s+1/ );
#like( $rv->payload, qr/Privlevel:\s+admin/ );

$cmd = "EMPLOYEE PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
is( $rv->code, 'DOCHAZKA_CLI_NORMAL_COMPLETION' );
like( $rv->payload, qr/Nick:\s+root/ );
like( $rv->payload, qr/Dochazka EID:\s+1/ );
#like( $rv->payload, qr/Privlevel:\s+admin/ );

note( 'EMPLOYEE_SPEC on self always works' );
$cmd = "EMPLOYEE=root PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+root/ );
like( $rv->payload, qr/Dochazka EID:\s+1/ );
#like( $rv->payload, qr/Privlevel:\s+admin/ );

note( 'EMPLOYEE_SPEC on a different employee => also works, because root is an admin' );
$cmd = "EMPLOYEE=demo SHOW";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+demo/ );
like( $rv->payload, qr/Dochazka EID:\s+2/ );
#like( $rv->payload, qr/Privlevel:\s+passerby/ );

note( 'EMPLOYEE_SPEC on worker' );
$cmd = "EMPLOYEE=worker PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
my ( $worker_eid ) = $rv->payload =~ m/Dochazka EID:\s+(\d+)/;
like( $rv->payload, qr/Dochazka EID:\s+$worker_eid/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );

note( 'EMPLOYEE_SPEC on worker, using EID instead of nick' );
$cmd = "EMPLOYEE=$worker_eid PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
like( $rv->payload, qr/Dochazka EID:\s+$worker_eid/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );

note( 'EMPLOYEE_SPEC on non-existent employee' );
$cmd = "EMPLOYEE=99999 PROFILE";
Expand Down Expand Up @@ -154,7 +134,7 @@ like( $rv->payload, qr/List of employees with priv level ->all<-/ );
# EMPLOYEE_SPEC SET SEC_ID _TERM
#==========================================

note( 'Set my own secondary ID' );
note( 'Set my own Workforce ID' );
$cmd = "EMPLOYEE SET SEC_ID test123";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
Expand All @@ -170,14 +150,14 @@ is( $rv->code, 'DISPATCH_EMPLOYEE_FOUND' );
is( $rv->payload->{'sec_id'}, 'test123' );
is( $rv->payload->{'nick'}, 'root' );

note( 'Set someone else\'s secondary ID to the same thing' );
note( 'Set someone else\'s Workforce ID to the same thing' );
$cmd = "EMPLOYEE=worker SET SEC_ID test123";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
ok( $rv->not_ok );
like( $rv->payload, qr/duplicate key value violates unique constraint/ );

note( 'Set someone else\'s secondary ID to HAMBURG_SUBST' );
note( 'Set someone else\'s Workforce ID to HAMBURG_SUBST' );
$cmd = "EMPLOYEE=worker SET SEC_ID HAMBURG_SUBST";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
Expand All @@ -200,7 +180,7 @@ is( $rv->payload->{'nick'}, 'worker' );
# eid=...
#==========================================

note( "set secondary ID of worker" );
note( "set Workforce ID of worker" );
$cmd = "nick=worker SET sec_id woofer";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
Expand All @@ -213,40 +193,23 @@ $rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
( $worker_eid ) = $rv->payload =~ m/Dochazka EID:\s+(\d+)/;
my ( $worker_sec_id) = $rv->payload =~ m/Secondary ID:\s+(\S+)/;
like( $rv->payload, qr/Dochazka EID:\s+$worker_eid/ );
like( $rv->payload, qr/Secondary ID:\s+$worker_sec_id/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );
my ( $worker_sec_id) = $rv->payload =~ m/Workforce ID:\s+(\S+)/;
like( $rv->payload, qr/Workforce ID:\s+$worker_sec_id/ );

note( 'sec_id= on worker' );
$cmd = "sec_id=$worker_sec_id PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
like( $rv->payload, qr/Dochazka EID:\s+$worker_eid/ );
like( $rv->payload, qr/Secondary ID:\s+$worker_sec_id/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );

note( 'eid= on worker' );
$cmd = "eid=$worker_eid PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+worker/ );
like( $rv->payload, qr/Dochazka EID:\s+$worker_eid/ );
like( $rv->payload, qr/Secondary ID:\s+$worker_sec_id/ );
#like( $rv->payload, qr/Privlevel:\s+active/ );
like( $rv->payload, qr/Workforce ID:\s+$worker_sec_id/ );

note( 'eid= on root' );
$cmd = "eid=1 PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+root/ );
like( $rv->payload, qr/Dochazka EID:\s+1/ );
#like( $rv->payload, qr/Privlevel:\s+admin/ );

#==========================================
# EMPLOYEE SET FULLNAME
Expand Down
6 changes: 0 additions & 6 deletions t/cmd_inactive/employee.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,20 @@ $rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+absent/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+inactive/ );

# EMPLOYEE_SPEC on self always works
$cmd = "EMPLOYEE=absent PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+absent/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+inactive/ );

# EMPLOYEE_SPEC on a different employee => also works
$cmd = "EMPLOYEE=demo PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+demo/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+passerby/ );

# EMPLOYEE_SPEC on non-existent employee => 403
$cmd = "EMPLOYEE=999999 PROFILE";
Expand Down
6 changes: 0 additions & 6 deletions t/cmd_passerby/employee.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,20 @@ $rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+demo/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+passerby/ );

note( 'EMPLOYEE PROFILE command' );
$cmd = "EMPLOYEE PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+demo/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+passerby/ );

note( 'EMPLOYEE_SPEC on self always works' );
$cmd = "EMPLOYEE=demo PROFILE";
$rv = process_command( $cmd );
ok( ref( $rv ) eq 'App::CELL::Status' );
is( $rv->level, 'OK' );
like( $rv->payload, qr/Nick:\s+demo/ );
like( $rv->payload, qr/Dochazka EID:\s+\d+/ );
#like( $rv->payload, qr/Privlevel:\s+passerby/ );

note( 'EMPLOYEE_SPEC on a different employee => 403' );
$cmd = "EMPLOYEE=absent PROFILE";
Expand Down

0 comments on commit a22e01c

Please sign in to comment.