use P4::test; use P4::TM { DATA_DIR => 'self' }; use Data::Dumper; use File::Copy; use Text::Diff; use File::Copy::Recursive 'dircopy'; P4::TM::add_mask_func sub { s/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}/UUIDMASK/gi; s/manuals\/v[0-9]{2}\.[0-9]{1}\/extensions/manuals\/vYY.H\/extensions/g; $_ }; `p4 configure set server.extensions.allow.unsigned=1`; my @us = qw / theUser otherUser /; my $pass = 'asgjayqkrqEQYQE%$QWHSDHSDa3'; map { `p4 -u $_ changes`; $stdin = "$pass\n$pass"; `p4 -u $_ passwd` } @us; `p4 -u sampleExtensionsUser changes`; # for GetAutoClientApi() $stdin = "$pass\n$pass"; `p4 -u sampleExtensionsUser passwd`; $stdin = `p4 group -o groupUser` . "\n theUser"; tm `p4 group -i`; $stdin = `p4 group -o groupIndirect` . "\n groupUser"; tm `p4 group -i`; $stdin = `p4 group -o groupOther` . "\n otherUser"; tm `p4 group -i`; my ( $rplA, $cA ) = newReplica RPL_TYPE => 'edge-server'; # replica2 my ( $rplB, $cB ) = newReplica RPL_TYPE => 'edge-server'; # replica3 dircopy $script_abspath =~ s/\.t$//r . '/*', 'LoginMOTDExt'; tm `p4 extension --package LoginMOTDExt`; tm `p4 extension --install LoginMOTDExt.p4-extension`; tm `p4 extension --install LoginMOTDExt.p4-extension -y`; tm `p4 extension --configure ExampleInc::LoginMOTDExt -o | p4 extension --configure ExampleInc::LoginMOTDExt -i`; sub mk_cfg { our ( $name, $cfg ) = @_; $stdin = `p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-$name -o`; $stdin =~ s/The message displayed before login.//g; $stdin =~ s/Space-separated list of groups whose//g; $stdin =~ s/members receive the message. An empty//g; $stdin =~ s/list means the message goes to everyone.//g; $stdin =~ s/Server ID to limit the message to.//g; my $message = $cfg->{ message } //= ''; my $groups = $cfg->{ groups } //= ''; my $serverID = $cfg->{ serverID } //= ''; $stdin =~ s/message:.*/message: $message/g; $stdin =~ s/groups:.*/groups: $groups/g; $stdin =~ s/serverID:.*/serverID: $serverID/g; tm `p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-$name -i`; } sub rm_cfg { my $name = $_[ 0 ]; $stdin = `p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-$name -o`; $stdin =~ s/ExtEnabled:.*/ExtEnabled: false/g; tm `p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-$name -i`; } sub tl { my $p4 = $_[ 0 ]; rplWait $p4->GetPort; `$p4 logout`; $stdin = "$pass\n"; my $r = `$p4 login`; rplWait $cA; rplWait $cB; $r } my $tcM = $client->clone; $tcM->{ P4USER } = 'theUser'; my $tcA = $cA->clone; $tcA->{ P4USER } = 'theUser'; my $tcB = $cB->clone; $tcB->{ P4USER } = 'theUser'; my $ocM = $client->clone; $ocM->{ P4USER } = 'otherUser'; my $ocA = $cA->clone; $ocA->{ P4USER } = 'otherUser'; my $ocB = $cB->clone; $ocB->{ P4USER } = 'otherUser'; sub sep { '-' x ( 80 - length $_[ 0 ] ) . " $_[0 ]" } my $msg = '**** This is the Extension login message'; tm sep 'all'; mk_cfg 'all', { message => "$msg.\n\t\tA B C D\n" }; tm tl $tcM; # tcm tm tl $tcA; # tca tm tl $tcB; # tcb tm tl $ocM; # ocm tm tl $ocA; # oca tm tl $ocB; # ocb rm_cfg 'all'; tm sep 'justTheUser'; mk_cfg 'justTheUser', { message => "$msg\n", groups => 'groupUser' }; tm tl $tcM; # tcm tm tl $tcA; # tca tm tl $ocM; # ocm tm tl $ocB; # ocb rm_cfg 'justTheUser'; tm sep 'justTheUserIndirect'; tm 'todo: this does not work'; mk_cfg 'justTheUserIndirect', { message => "$msg\n", groups => 'groupIndirect' }; tm tl $tcM; # tcm tm tl $tcA; # tca tm tl $ocM; # ocm tm tl $ocB; # ocb rm_cfg 'justTheUserIndirect'; tm sep 'justOtherUser'; mk_cfg 'justOtherUser', { message => "$msg\n", groups => 'groupOther' }; tm tl $tcM; # tcm tm tl $tcA; # tca tm tl $ocM; # ocm tm tl $ocB; # ocb rm_cfg 'justOtherUser'; tm sep 'bothUsers'; mk_cfg 'bothUsers', { message => "$msg\n", groups => 'groupOther groupUser' }; tm tl $tcM; # tcm tm tl $tcA; # tca tm tl $ocM; # ocm tm tl $ocB; # ocb rm_cfg 'bothUsers'; tm sep 'justTheUserReplica2'; mk_cfg 'justTheUserReplica2', { message => "$msg\n", groups => 'groupUser', serverID => 'replica2' }; tm tl $tcM; # tcm tm tl $tcA; # tca tm tl $tcB; # tcb tm tl $ocM; # ocm tm tl $ocB; # ocb #diag `p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUserReplica2 -o`; rm_cfg 'justTheUserReplica2'; #use Data::Dumper; #diag 'stdout: '.Dumper $server->getSTDOUT; #diag 'stderr: '.Dumper $server->getSTDERR; #diag 'rplA stdout: '.Dumper $rplA->getSTDOUT; #diag 'rplB stdout: '.Dumper $rplB->getSTDOUT; __DATA__ [[27,29,31,37,38,39,40,61,'61.1','61.2','61.3','61.4','61.5',68,'68.1','68.2','68.3','68.4','68.5',100,102,103,104,105,106,107,110,112,113,114,115,118,119,121,122,123,124,127,129,130,131,132,135,137,138,139,140,143,146,147,148,149,150], [ 'p4 group -i', 'Group groupUser created. ', 0, 'p4 group -i', 'Group groupIndirect created. ', 0, 'p4 group -i', 'Group groupOther created. ', 0, 'p4 extension --package LoginMOTDExt', 'Extension packaged successfully. ', 0, 'p4 extension --install LoginMOTDExt.p4-extension', ' Would install Extension \'ExampleInc::LoginMOTDExt\' Version: \'2019.1\' UUID: UUIDMASK Developer: Perforce Software Inc. Description: [Example Extension, sample code] This Extension allows an administrator to selectively display a MOTD/EULA/etc type text to users before they log in. E.g.: p4 login LoginMOTDExt/UUIDMASK/1.0 beta: **** This is the Extension login message Enter password: User someUser logged in. License: BSD Homepage URL: https://swarm.workshop.perforce.com/files/guest/perforce_software/extensions/2019-1 Compatible products: p4d This was report mode. Use -y to perform the operation. ', 0, 'p4 extension --install LoginMOTDExt.p4-extension -y', ' Extension \'ExampleInc::LoginMOTDExt\' version \'2019.1\' installed successfully. Perform the following steps to turn on the Extension: # Create a global configuration if one doesn\'t already exist. p4 extension --configure ExampleInc::LoginMOTDExt # Create an instance configuration to enable the Extension. p4 extension --configure ExampleInc::LoginMOTDExt --name ExampleInc::LoginMOTDExt-instanceName For more information, visit: https://www.perforce.com/manuals/vYY.H/extensions/Content/Extensions/Home-extensions.html ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt -o | p4 extension --configure ExampleInc::LoginMOTDExt -i', 'Extension config LoginMOTDExt saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-all -i', 'Extension config LoginMOTDExt-all saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUser -i', 'Extension config LoginMOTDExt-justTheUser saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUserIndirect -i', 'Extension config LoginMOTDExt-justTheUserIndirect saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justOtherUser -i', 'Extension config LoginMOTDExt-justOtherUser saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-bothUsers -i', 'Extension config LoginMOTDExt-bothUsers saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUserReplica2 -i', 'Extension config LoginMOTDExt-justTheUserReplica2 saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-all -i', 'Extension config LoginMOTDExt-all saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUser -i', 'Extension config LoginMOTDExt-justTheUser saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUserIndirect -i', 'Extension config LoginMOTDExt-justTheUserIndirect saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justOtherUser -i', 'Extension config LoginMOTDExt-justOtherUser saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-bothUsers -i', 'Extension config LoginMOTDExt-bothUsers saved. ', 0, 'p4 extension --configure ExampleInc::LoginMOTDExt --name LoginMOTDExt-justTheUserReplica2 -i', 'Extension config LoginMOTDExt-justTheUserReplica2 saved. ', 0, 'sep \'all\'', '----------------------------------------------------------------------------- all', 0, 'tl ; # tcm', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message. A B C D Enter password: User theUser logged in. ', 0, 'tl ; # tca', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message. A B C D User theUser logged in. ', 0, 'tl ; # tcb', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message. A B C D User theUser logged in. ', 0, 'tl ; # ocm', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message. A B C D Enter password: User otherUser logged in. ', 0, 'tl ; # oca', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message. A B C D User otherUser logged in. ', 0, 'tl ; # ocb', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message. A B C D User otherUser logged in. ', 0, 'sep \'justTheUser\'', '--------------------------------------------------------------------- justTheUser', 0, 'tl ; # tcm', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message Enter password: User theUser logged in. ', 0, 'tl ; # tca', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message User theUser logged in. ', 0, 'tl ; # ocm', ' Enter password: User otherUser logged in. ', 0, 'tl ; # ocb', ' Enter password: User otherUser logged in. ', 0, 'sep \'justTheUserIndirect\'', '------------------------------------------------------------- justTheUserIndirect', 0, '\'todo: this does not work\'', 'todo: this does not work', 0, 'tl ; # tcm', ' Enter password: User theUser logged in. ', 0, 'tl ; # tca', ' Enter password: User theUser logged in. ', 0, 'tl ; # ocm', ' Enter password: User otherUser logged in. ', 0, 'tl ; # ocb', ' Enter password: User otherUser logged in. ', 0, 'sep \'justOtherUser\'', '------------------------------------------------------------------- justOtherUser', 0, 'tl ; # tcm', ' Enter password: User theUser logged in. ', 0, 'tl ; # tca', ' Enter password: User theUser logged in. ', 0, 'tl ; # ocm', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message Enter password: User otherUser logged in. ', 0, 'tl ; # ocb', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message User otherUser logged in. ', 0, 'sep \'bothUsers\'', '----------------------------------------------------------------------- bothUsers', 0, 'tl ; # tcm', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message Enter password: User theUser logged in. ', 0, 'tl ; # tca', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message User theUser logged in. ', 0, 'tl ; # ocm', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message Enter password: User otherUser logged in. ', 0, 'tl ; # ocb', ' Enter password: LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message User otherUser logged in. ', 0, 'sep \'justTheUserReplica2\'', '------------------------------------------------------------- justTheUserReplica2', 0, 'tl ; # tcm', ' Enter password: User theUser logged in. ', 0, 'tl ; # tca', ' LoginMOTDExt/UUIDMASK/2019.1 GA: **** This is the Extension login message Enter password: User theUser logged in. ', 0, 'tl ; # tcb', ' Enter password: User theUser logged in. ', 0, 'tl ; # ocm', ' Enter password: User otherUser logged in. ', 0, 'tl ; # ocb', ' Enter password: User otherUser logged in. ', 0 ] ]
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 30809 | C. Thomas Tyler |
Code drop with newer versions of Extensions. Thanks to @jason_gibon. #review-30810 @jabson_gibson |
||
#1 | 30808 | C. Thomas Tyler |
Promoted from 2019.1/... to main/... |
||
//guest/perforce_software/extensions/2019.1/login_motd.t | |||||
#1 | 25601 | Jason Gibson |
Import example Extensions. p19.1@1797741 |