📄 myproxy-test
字号:
$passphrase . "\n"); $timeleft = `$grid_proxy_info -file /tmp/myproxy-test.$$ -timeleft`; if (defined($timeleft) && $timeleft > 60*60*2+300 || $timeleft < 60*60*2-300) { $output = "Credential lifetime ($timeleft) incorrect." . "It should be " . (60*60*2) . ".\n"; $exitstatus = 1; }}if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-get-delegation -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n"); $timeleft = `$grid_proxy_info -file /tmp/myproxy-test.$$ -timeleft`; if ($timeleft > 60*61 || $timeleft < 60*59) { $output = "Credential lifetime ($timeleft) incorrect." . "It should be " . (60*60) . ".\n"; $exitstatus = 1; }}if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}&runtest("myproxy-destroy -v", undef);## Start of myproxy-store and myproxy-retrieve tests## commands to test: myproxy-store, myproxy-info, myproxy-destroy,# myproxy-get-delegation, myproxy-retrieve, and # myproxy-change-pass-phrase# For myproxy-store, we need an encrypted key to store.# So, let's encrypt our proxy key.$passphrase = sprintf "%010.d", int(rand(0x7fffffff));$testkey = "/tmp/myproxy-test.$$.key";&runtest("openssl rsa -des3 -passout stdin -in \$X509_USER_KEY -out $testkey", $passphrase . "\n");chmod(0600, $testkey);## Test 17#($exitstatus, $output) = &runtest("myproxy-store -x -E '$cert_subject' -v -t 1 -y $testkey", undef);print "MyProxy Test 17 (store credential with default name): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} elsif (($output =~ /Error checking authorization/) || ($output =~ /unknown command/)) { print "UNSUPPORTED\n"; $FAILURES++; print "Server does not support myproxy-store. Skipping futher myproxy-store tests.\n"; goto end_of_store_tests;} else { print "FAILED\n"; $FAILURES++; print STDERR $output; print "Skipping futher myproxy-store tests.\n"; goto end_of_store_tests;}## Test 18#($exitstatus, $output) = &runtest("myproxy-info -v", undef);print "MyProxy Test 18 (get info for stored credential): ";if ($exitstatus == 0 && $output =~ /username/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 19#($exitstatus, $output) = &runtest("myproxy-get-delegation -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n");print "MyProxy Test 19 (create proxy from stored credential): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 20#($exitstatus, $output) = &runtest("myproxy-retrieve -c /tmp/myproxy-test.cert.$$ -y /tmp/myproxy-test.key.$$ -v -S", $passphrase . "\n");print "MyProxy Test 20 (retrieve stored credential): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifycert("/tmp/myproxy-test.cert.$$", "/tmp/myproxy-test.key.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}unlink( "/tmp/myproxy-test.cert.$$" );unlink( "/tmp/myproxy-test.key.$$" );if ($test_trustroots) { ($exitstatus, $output) = &runtest("myproxy-retrieve -T -c /tmp/myproxy-test.cert.$$ -y /tmp/myproxy-test.key.$$ -v -S", $passphrase . "\n"); print "MyProxy Test 20T (retrieve stored credential w/ trustroots): "; if ($exitstatus == 0) { ($exitstatus, $output) = &verifycert("/tmp/myproxy-test.cert.$$", "/tmp/myproxy-test.key.$$"); } if ($exitstatus == 0) { ($exitstatus, $output) = &verifytrustroots(); } if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR $output; } unlink( "/tmp/myproxy-test.cert.$$" ); unlink( "/tmp/myproxy-test.key.$$" );}## Test 21#($exitstatus, $output) = &runtest("myproxy-get-delegation -t 1 -o /tmp/myproxy-test.$$ -v -S", "badpassphrase\n");print "MyProxy Test 21 (verify passphrase checking on myproxy-get-delegation): ";if ($exitstatus != 0 && $output =~ /invalid pass phrase/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 22#($exitstatus, $output) = &runtest("myproxy-retrieve -c /tmp/myproxy-test-cert.$$ -y /tmp/myproxy-test-key.$$ -v -S", "badpassphrase\n");print "MyProxy Test 22 (verify passphrase checking on myproxy-retrieve): ";if ($exitstatus != 0 && $output =~ /invalid pass phrase/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}unlink( "/tmp/myproxy-test.cert.$$" );unlink( "/tmp/myproxy-test.key.$$" );## Test 23#($exitstatus, $output) = &runtest("myproxy-get-delegation -a \$X509_USER_PROXY -t 1 -o /tmp/myproxy-test.$$ -v", undef);print "MyProxy Test 23 (verify myproxy-get-delegation default renewal policy): ";if ($exitstatus != 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 24#($exitstatus, $output) = &runtest("myproxy-retrieve -a \$X509_USER_PROXY -c /tmp/myproxy-test-cert.$$ -y /tmp/myproxy-test-key.$$ -v", undef);print "MyProxy Test 24 (verify myproxy-retrieve default renewal policy): ";if ($exitstatus != 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}unlink( "/tmp/myproxy-test-cert.$$" );unlink( "/tmp/myproxy-test-key.$$" );## Test 25#($exitstatus, $output) = &runtest("myproxy-destroy -v", undef);print "MyProxy Test 25 (remove credential from repository): ";if ($exitstatus == 0 && $output =~ /was successfully removed/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 26#($exitstatus, $output) = &runtest("myproxy-info -v", undef);print "MyProxy Test 26 (verify credentials are removed): ";if (!($output =~ /default credential/)) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 27#($exitstatus, $output) = &runtest("myproxy-store -v -r 'nobody' -k 'nobody' -t 1 -y $testkey", undef);print "MyProxy Test 27 (store credentials with retrieval policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-store -x -E '$cert_subject' -v -r '$cert_subject' -k 'mine' -t 1 -y $testkey", undef);}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 28#($exitstatus, $output) = &runtest("myproxy-get-delegation -k 'mine' -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n");print "MyProxy Test 28 (verify myproxy-get-delegation retrieval policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-get-delegation -k 'nobody' -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n"); if ($exitstatus != 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR "Shouldn't have allowed retrieval.\n"; print STDERR $output; }} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 29#($exitstatus, $output) = &runtest("myproxy-retrieve -k 'mine' -c /tmp/myproxy-test.cert.12.1.$$ -y /tmp/myproxy-test.key.12.1.$$ -v -S", $passphrase . "\n");print "MyProxy Test 29 (verify myproxy-retrieve retrieval policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifycert("/tmp/myproxy-test.cert.12.1.$$", "/tmp/myproxy-test.key.12.1.$$");}if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-retrieve -k 'nobody' -c /tmp/myproxy-test.cert.12.2.$$ -y /tmp/myproxy-test.key.12.2.$$ -v -S", $passphrase . "\n"); if ($exitstatus != 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR "Shouldn't have allowed retrieval.\n"; print STDERR $output; }} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}&runtest("myproxy-destroy -v -k 'mine'", undef);&runtest("myproxy-destroy -v -k 'nobody'", undef);`rm -f /tmp/myproxy-test.*.12.*.$$`;## Test 30#($exitstatus, $output) = &runtest("myproxy-store -v -R 'nobody' -k 'nobody' -t 1 -d -y \$X509_USER_PROXY -c \$X509_USER_PROXY", undef);print "MyProxy Test 30 (store credentials with renewal policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-store -v -x -R '$cert_subject' -k 'mine' -t 1 -d -y \$X509_USER_PROXY -c \$X509_USER_PROXY", undef);}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 31#($exitstatus, $output) = &runtest("myproxy-info -v -d", undef);print "MyProxy Test 31 (get info for stored renewal credentials): ";if ($exitstatus == 0 && $output =~ /username/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 32#($exitstatus, $output) = &runtest("myproxy-get-delegation -k 'mine' -a $ENV{'X509_USER_PROXY'} -t 1 -o /tmp/myproxy-test.$$ -v -d -S", $passphrase . "\n");print "MyProxy Test 32 (verify renewal policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-get-delegation -k 'nobody' -a $ENV{'X509_USER_PROXY'} -t 1 -o /tmp/myproxy-test.$$ -v -d -S", $passphrase . "\n"); if ($exitstatus != 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR "Shouldn't have allowed retrieval.\n"; print STDERR $output; }} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}&runtest("myproxy-destroy -v -k 'mine' -d", undef);&runtest("myproxy-destroy -v -k 'nobody' -d", undef);## Test 33#($exitstatus, $output) = &runtest("myproxy-store -x -E '$cert_subject' -v -a -t 2 -y $testkey", undef);print "MyProxy Test 33 (verify lifetime of retrieved credentials): ";if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-get-delegation -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n"); $timeleft = `$grid_proxy_info -file /tmp/myproxy-test.$$ -timeleft`; if (defined($timeleft) && $timeleft > 60*60*2+300 || $timeleft < 60*60*2-300) { $output = "Credential lifetime ($timeleft) incorrect." . "It should be " . (60*60*2) . ".\n"; $exitstatus = 1; }}if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-get-delegation -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n"); $timeleft = `$grid_proxy_info -file /tmp/myproxy-test.$$ -timeleft`; if ($timeleft > 60*61 || $timeleft < 60*59) { $output = "Credential lifetime ($timeleft) incorrect." . "It should be " . (60*60) . ".\n"; $exitstatus = 1; }}if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}&runtest("myproxy-destroy -v", undef);## Test 34#($exitstatus, $output) = &runtest("myproxy-store -v -E 'nobody' -k 'nobody' -t 1 -y $testkey", undef);print "MyProxy Test 34 (store credentials with retrieve key policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-store -v -x -E '$cert_subject' -k 'mine' -t 1 -y $testkey", undef);}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 35#($exitstatus, $output) = &runtest("myproxy-info -v", undef);print "MyProxy Test 35 (get info for stored retrieve key credentials): ";if ($exitstatus == 0 && $output =~ /username/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 36#($exitstatus, $output) = &runtest("myproxy-retrieve -k 'mine' -c /tmp/myproxy-test.cert.12.1.$$ -y /tmp/myproxy-test.key.12.1.$$ -v -S", $passphrase . "\n");print "MyProxy Test 36 (verify myproxy-retrieve key retrieval policies): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifycert("/tmp/myproxy-test.cert.12.1.$$", "/tmp/myproxy-test.key.12.1.$$");}if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("myproxy-retrieve -k 'nobody' -c /tmp/myproxy-test.cert.12.2.$$ -y /tmp/myproxy-test.key.12.2.$$ -v -S", $passphrase . "\n"); if ($exitstatus != 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR "Shouldn't have allowed retrieval.\n"; print STDERR $output; }} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}end_of_store_tests:&runtest("myproxy-destroy -v -k 'mine'", undef);&runtest("myproxy-destroy -v -k 'nobody'", undef);`rm -f /tmp/myproxy-test.*.12.*.$$`;unlink("/tmp/myproxy-test.$$.key");## COG tests#if (defined($ENV{"COG_INSTALL_PATH"})) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -