1#! /usr/bin/perl -w 2 3use strict; 4 5use ExtUtils::testlib; 6 7use GSSAPI qw(:all); 8use Test::More tests => 6; 9 10 11# 12# GSSAPI::Cred 13# 14 15 my($cred1, $time, $name ); 16 my $wanted_cred_usage = GSS_C_INITIATE; 17 18 my $oidset; 19 20 my $status = GSSAPI::Cred::acquire_cred(undef, 120, undef, $wanted_cred_usage, 21 $cred1, $oidset, $time); 22 23my $credusage_names = { 24 25 GSS_C_INITIATE + 0 => 'GSS_C_INITIATE', 26 GSS_C_ACCEPT + 0 => 'GSS_C_ACCEPT', 27 GSS_C_BOTH + 0 => 'GSS_C_BOTH', 28 29}; 30 31SKIP: { 32 if ( $status->major != GSS_S_COMPLETE ) { 33 diag( "\n\nNo error: acquire_cred() failed, maybe because you have to run kinit first.\n", 34 "Errormessage from your GSSAPI-implementation is: \n\n" . qq{"$status"}, 35 "\nrun kinit to get a TGT and retry this test (just skipping now).\n\n"); 36 skip( 'This tests only work if user has run kinit succesfully' , 6 ); 37 } 38 ok($status, "GSSAPI::Cred::acquire_cred, wanted_cred_usage $wanted_cred_usage"); 39 ok(ref $cred1 eq "GSSAPI::Cred"); 40 ok(ref $oidset eq "GSSAPI::OID::Set"); 41 42 my($lifetime, $cred_usage); 43 $status = $cred1->inquire_cred($name, $lifetime, $cred_usage, $oidset); 44 45 46 47 ok( $status, '$cred1->inquire_cred($name, $lifetime, $cred_usage, $oidset' ); 48 if ( $lifetime == -1 ) { 49 diag('The returned TGT lifetime is -1 (Heimdal 1.0.x returns -1 in case of ivalid TGT)'); 50 diag('To get full test-coverage please run kinit to get a valid TGT and restart this test.'); 51 skip( '$lifetime == -1' , 2 ); 52 } 53 { 54 my $display; 55 my $status = $name->display($display); 56 if ( $status->major == GSS_S_COMPLETE ) { 57 diag("inquire_cred() name:\t'$display'"); 58 } 59 } 60 diag("inquire_cred() lifetime:\t$lifetime seconds"); 61 diag("inquire_cred() credusage:\t $cred_usage (" . $credusage_names->{$cred_usage} . ')' ); 62 63 ok(ref $oidset eq "GSSAPI::OID::Set"); 64 65 # 66 # currently heimdal 1.3.2 fails the next test - please let me know 67 # if you have any ideas what is going wrong - as far as I can see 68 # this version of Heimal behaves strange and returns 'ACCEPT' if INITIATE 69 # is requested :-/ 70 # 71 ok( 72 ( $cred_usage == $wanted_cred_usage or $cred_usage == GSS_C_BOTH ) , 73 sprintf('expected cred usage (wanted %s, got %s)', map { $credusage_names->{$_} } ($wanted_cred_usage, $cred_usage)) 74 ); 75 76 77} 78