home *** CD-ROM | disk | FTP | other *** search
/ Peanuts NeXT Software Archives / Peanuts-2.iso / Developer / webobjects / extensions / win-nt / NTPerl5-109.exe / ntt / NT / nrs.manual.test < prev    next >
Encoding:
Text File  |  1996-04-16  |  2.7 KB  |  161 lines

  1. #test for Perl NetResource Module Extension.
  2. #Written by Jesse Dougherty for hip communications.
  3. #NOTE:
  4. #this test will only work if a username and password are supplied in the 
  5. #$user and $passwd vars.
  6.  
  7. $user = "";
  8. $passwd = "";
  9.  
  10. BEGIN{
  11.         @INC = qw( ..\lib );
  12. };
  13.  
  14. use Win32::NetResource;
  15. use Win32;
  16. #$debug = 1;
  17. sub ErrorCheck
  18. {
  19.     if( $debug ){
  20.         Win32::NetResource::GetError($ErrorCode);
  21.         print "#";
  22.         print NTFormatMessage( $ErrorCode );
  23.     }
  24. }
  25.  
  26. sub deb
  27. {
  28.     print $_[0] if $debug;
  29. }
  30.  
  31. print "1..7\n";
  32.  
  33.  
  34. $ShareInfo = {      'path' => 'c:\\',
  35.                     'netname' => "myshare",
  36.                     'remark' => "This mine, leave it alone",
  37.                     'passwd' => "soundgarden",
  38.                     'current-users' =>0,
  39.                     'permissions' => 0,
  40.                     'maxusers' => 10,
  41.                     'type'  => 10,
  42.  
  43.                     };
  44.  
  45.  
  46. #test the hash conversion.
  47.  
  48. deb( "#testing the hash conversion routines\n");
  49.  
  50. $this = Win32::NetResource::_hash2SHARE( $ShareInfo );
  51. $that = Win32::NetResource::_SHARE2hash( $this );
  52.  
  53. foreach( keys %$ShareInfo ){
  54.     if($ShareInfo->{$_} ne $that->{$_} ){
  55.         print "not ";
  56.     }
  57. }
  58. print "ok 1\n";
  59.  
  60. ErrorCheck();
  61.  
  62. $ShareInfo={};
  63.  
  64.  
  65. # Make a share of the current directory.
  66.  
  67.  
  68. $ShareInfo = {
  69.                 'path' => "e:\\temp",
  70.                     'netname' => "Temp",
  71.                     'remark' => "This mine, leave it alone",
  72.                     'passwd' => "",
  73.                     'current-users' =>0,
  74.                     'permissions' => 0,
  75.                     'maxusers' => -1,
  76.                     'type'  => 0,
  77.  
  78.                     };
  79.  
  80.  
  81.  
  82. $ErrorCode = 0;
  83.  
  84. deb("#Testing NetShareAdd\n");
  85. Win32::NetResource::NetShareAdd( $ShareInfo,$parm )|| print"not ";
  86. print "ok 2\n";
  87.  
  88.  
  89. ErrorCheck();
  90.  
  91. deb("#testing NetShareGetInfo\n");
  92.  
  93. $NewShare = {};
  94. Win32::NetResource::NetShareGetInfo( "Temp",$NewShare) || print "not ";
  95. print "ok 3\n";
  96. ErrorCheck();
  97.  
  98. if( $debug ){
  99.     foreach( keys %$NewShare ){
  100.         print"# $_ => $NewShare->{ $_ }\n";
  101.     }
  102.     print "\n";
  103. }
  104.  
  105.  
  106.  
  107. #test the GetSharedResources function call.
  108.  
  109. $Aref=[];
  110.  
  111. deb("#testing GetSharedResources\n");
  112.  
  113. Win32::NetResource::GetSharedResources($Aref,0);
  114. print "ok 4\n";
  115. ErrorCheck();
  116.  
  117. if( $debug == 2 ){
  118.  
  119.     foreach $href (@$Aref){
  120.     
  121.         foreach( keys %$href ){
  122.     
  123.             print "$_: $href->{$_}\n";
  124.             }
  125.         }
  126.  
  127. }
  128.  
  129. # try to connect to the Temp share.
  130.  
  131. # Find the NETRESOURCE information for the Temp share.
  132.  
  133. foreach $href (@$Aref ){
  134.         $myRef = $href if( $href->{'RemoteName'} =~ /Temp/ );
  135.     }
  136.  
  137.  
  138. $myRef->{'LocalName'} = "Z:";
  139.             
  140.  
  141. Win32::NetResource::AddConnection($myRef,$passwd,$user,0);
  142. ErrorCheck();
  143.  
  144.  
  145. Win32::NetResource::GetUNCName( $UNCName, "Z:" )|| print "not ";
  146. print "ok 5\n";
  147. deb( "uncname is $UNCName\n");
  148.  
  149. Win32::NetResource::CancelConnection("Z:",0,1)||print "not ";
  150. print "ok 6\n";
  151. ErrorCheck();
  152.  
  153.  
  154. Win32::NetResource::NetShareDel( "Temp")|| print "not ";
  155. print "ok 7\n";
  156. ErrorCheck();
  157.  
  158.  
  159.  
  160.  
  161.