19 require_once (
'TestEnvironment.php');
20 require_once (
'fossologyTest.php');
53 public function addUser($UserName, $Description = NULL, $Email = NULL, $Access = 1, $Folder = 1, $Password = NULL, $EmailNotify =
'y')
59 if (empty ($UserName))
61 return (
"No User Name, cannot add user");
64 $page = $this->mybrowser->get($URL);
65 $page = $this->mybrowser->clickLink(
'Add');
66 $this->assertTrue($this->myassertText($page,
'/Add A User/'),
"Did NOT find Title, 'Add A User'");
68 $this->
setUserFields($UserName, $Description, $Email, $Access, $Folder, NULL, NULL, $Password, $EmailNotify);
71 $page = $this->mybrowser->clickSubmit(
'Add!',
"Could not select the Add! button");
72 $this->assertTrue($page);
74 if ($this->myassertText($page,
"/User .*? added/"))
78 if ($this->myassertText($page,
"/User already exists\. Not added/"))
80 return (
'User already exists. Not added');
82 if ($this->myassertText($page,
"/ERROR/"))
84 return (
"addUser FAILED! ERROR when adding users, please investigate");
113 'ERROR! Must supply a number to verify'
117 $headers = getMailSubjects();
118 if (empty ($headers))
132 if (preg_match(
'/ERROR/', $headers[0], $matches))
134 $this->fail(
"{$headers[0]}\n");
137 $pattern =
'completed with no errors';
140 foreach ($headers as $header)
143 $match = preg_match(
"/$pattern/", $header, $matches);
149 if (!empty ($failed))
151 $this->fail(
"Failures! there were jobs that did not report as completed\n");
183 if (is_null($parent))
187 if (is_null($description))
189 $description =
"Folder $name created by createFolder as subfolder of $parent";
193 $this->fail(
"FATAL! No folder name supplied, cannot create folder\n");
195 $page = $this->mybrowser->get($URL);
198 $page = $this->mybrowser->clickLink(
'Create');
199 $this->assertTrue($this->myassertText($page,
'/Create a new Fossology folder/'));
203 $FolderId = $this->
getFolderId($parent, $page,
'parentid');
205 $this->assertTrue($this->mybrowser->setField(
'parentid', $FolderId));
206 $this->assertTrue($this->mybrowser->setField(
'newname', $name),
207 "FATAL! Could not set newname for folder:$name\n");
208 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"),
209 "FATAL! Could not set description for folder:$name\n");
210 $createdPage = $this->mybrowser->clickSubmit(
'Create!');
211 $this->assertTrue($createdPage);
212 if ($this->myassertText($createdPage,
"/Folder $name Created/"))
214 $folderId = $this->
getFolderId($name, $createdPage,
'parentid');
217 if ($this->myassertText($createdPage,
"/Folder $name Exists/"))
219 $folderId = $this->
getFolderId($name, $createdPage,
'parentid');
224 $this->fail(
"Failure! Did not find phrase 'Folder $name Created'\n");
246 $page = $this->mybrowser->get($URL);
247 $page = $this->mybrowser->clickLink(
'Delete Folder');
248 $this->assertTrue($this->myassertText($page,
'/Select the folder to delete/'));
249 $FolderId = $this->
getFolderId($folder, $page,
'folder');
250 if (empty ($FolderId))
254 $this->assertTrue($this->mybrowser->setField(
'folder', $FolderId));
255 $page = $this->mybrowser->clickSubmit(
'Delete!');
256 $this->assertTrue($page);
257 $this->assertTrue($this->myassertText($page,
"/Deletion of folder $folder added to job queue/"),
"delete Folder Failed!\nPhrase 'Deletion of folder $folder added to job queue' not found\n");
278 $page = $this->mybrowser->get($URL);
279 $page = $this->mybrowser->clickLink(
'Delete Uploaded File');
280 $this->assertTrue($this->myassertText($page,
'/Select the uploaded file to delete/'));
281 $UploadId = $this->
getUploadId($upload, $page,
'upload');
282 if (empty ($UploadId))
286 $this->assertTrue($this->mybrowser->setField(
'upload', $UploadId));
287 $page = $this->mybrowser->clickSubmit(
'Delete!');
288 $this->assertTrue($page);
289 $this->assertTrue($this->myassertText($page,
"/Deletion added to job queue/"),
"delete Upload Failed!\nPhrase 'Deletion added to job queue' not found\n");
305 return (
'No User Specified');
308 $page = $this->mybrowser->get(
"$URL?mod=user_del");
311 if (!is_null($select))
313 $this->assertTrue($this->mybrowser->setField(
'userid', $select));
314 $this->assertTrue($this->mybrowser->setField(
'confirm', 1));
315 $page = $this->mybrowser->clickSubmit(
'Delete!',
"Could not select the Delete! button");
316 $this->assertTrue($page);
317 if ($this->myassertText($page,
"/User deleted/"))
319 print
"User $User Deleted\n";
323 $this->fail(
"Delete User Failed!\nPhrase 'User deleted' not found\n");
338 public function editFolder($folder, $newName, $description =
null)
347 if (is_null($description))
349 $description =
"Folder $newName edited by editFolder Test, this is the changed description";
351 $page = $this->mybrowser->get($URL);
352 $page = $this->mybrowser->clickLink(
'Edit Properties');
353 $this->assertTrue($this->myassertText($page,
'/Edit Folder Properties/'));
354 $FolderId = $this->
getFolderId($folder, $page,
'oldfolderid');
355 $this->assertTrue($this->mybrowser->setField(
'oldfolderid', $FolderId));
356 if (!(empty ($newName)))
358 $this->assertTrue($this->mybrowser->setField(
'newname', $newName));
360 $this->assertTrue($this->mybrowser->setField(
'newdesc',
"$description"));
361 $page = $this->mybrowser->clickSubmit(
'Edit!');
362 $this->assertTrue($page);
363 $this->assertTrue($this->myassertText($page,
"/Folder Properties changed/"),
"editFolder Failed!\nPhrase 'Folder Properties changed' not found\n");
383 public function editUser($UserName, $Description = NULL, $Email = NULL, $Access = 1, $Folder = 1, $Block = NULL, $Blank = NULL, $Password = NULL, $EmailNotify =
'y')
389 if (empty ($UserName))
391 return (
"No User Name, cannot add user");
393 $page = $this->mybrowser->get($URL);
394 $page = $this->mybrowser->clickLink(
'Edit Users');
395 $this->assertTrue($this->myassertText($page,
'/Edit A User/'),
"Did NOT find Title, 'Edit A User'");
396 $this->
setUserFields($UserName, $Description, $Email, $Access, $Folder, NULL, NULL, $Password, $EmailNotify);
399 $page = $this->mybrowser->clickSubmit(
'Edit!',
"Could not select the Edit! button");
400 $this->assertTrue($page);
402 if ($this->myassertText($page,
"/User edited/"))
429 print
"mU: OF:$oldFolder DF:$destFolder U:$upload\n";
430 if (empty ($oldFolder))
434 if (empty ($destFolder))
436 $destFolder =
'root';
438 $page = $this->mybrowser->get($URL);
440 $page = $this->mybrowser->get(
"$URL?mod=upload_move");
442 $this->assertTrue($this->myassertText($page,
'/Move upload to different folder/'));
443 $oldFolderId = $this->
getFolderId($oldFolder, $page,
'oldfolderid');
444 $this->assertTrue($this->mybrowser->setField(
'oldfolderid', $oldFolderId));
445 $uploadId = $this->
getUploadId($upload, $page,
'uploadid');
446 if (empty ($uploadId))
448 $this->fail(
"moveUpload FAILED! could not find upload id for upload" .
449 "$upload\n is $upload in $oldFolder?\n");
451 $this->assertTrue($this->mybrowser->setField(
'uploadid', $uploadId));
452 $destFolderId = $this->
getFolderId($destFolder, $page,
'targetfolderid');
453 $this->assertTrue($this->mybrowser->setField(
'targetfolderid', $destFolderId));
454 $page = $this->mybrowser->clickSubmit(
'Move!');
455 $this->assertTrue($page);
456 print
"page after move is:\n$page\n";
457 $this->assertTrue($this->myassertText($page,
459 "/Moved $upload from folder /"),
"moveUpload Failed!\nPhrase 'Move $upload from folder $oldFolder " .
460 "to folder $destFolder' not found\n");
480 if (empty ($destination))
484 $page = $this->mybrowser->get($URL);
485 $page = $this->mybrowser->clickLink(
'Move');
486 $this->assertTrue($this->myassertText($page,
'/Move Folder/'));
487 $FolderId = $this->
getFolderId($folder, $page,
'oldfolderid');
488 $this->assertTrue($this->mybrowser->setField(
'oldfolderid', $FolderId));
489 if ($destination != 1)
491 $DfolderId = $this->
getFolderId($destination, $page,
'targetfolderid');
493 $this->assertTrue($this->mybrowser->setField(
'targetfolderid', $DfolderId));
494 $page = $this->mybrowser->clickSubmit(
'Move!');
495 $this->assertTrue($page);
496 $this->assertTrue($this->myassertText($page,
"/Moved folder $folder to folder $destination/"),
"moveFolder Failed!\nPhrase 'Move folder $folder to folder ....' not found\n");
513 if (is_NULL($groupName))
515 $msg =
"FATAL! no group name to set\n";
521 $msg =
"FATAL! no user name to set\n";
526 $page = $this->mybrowser->get(
"$URL?mod=group_manage");
527 $this->assertTrue($this->myassertText($page,
'/Manage Group/'),
"Did NOT find Title, 'Manage Group'");
528 $this->assertTrue($this->myassertText($page,
'/Add a Group/'),
"Did NOT find phrase, 'Add a Group'");
531 $groupNotSet =
'FATAL! Could Not set the groupname field';
532 if (!empty ($groupName))
534 $this->assertTrue($this->mybrowser->setField(
'groupname', $groupName), $groupNotSet);
538 $userNotSet =
'FATAL! Could Not set the userid field in select';
539 $this->assertTrue($this->mybrowser->setField(
'userid', $user), $userNotSet);
564 $Email = NULL, $Access = 1, $Folder = 1, $Block = NULL, $Blank = NULL,
565 $Password = NULL, $EmailNotify = NULL, $BucketPool = 1, $Ui =
'simple')
576 $this->fail(
"setUserFields, FATAL! no user name to set\n");
606 if (
strtoupper($EmailNotify) ==
'NULL' || is_null($EmailNotify))
608 unset ($EmailNotify);
610 if ($BucketPool == NULL)
614 if (strcasecmp($Ui,
'simple'))
618 else if (strcasecmp($Ui,
'original'))
623 $page = $this->mybrowser->get($URL);
624 $page = $this->mybrowser->clickLink(
'Add');
625 $this->assertTrue($this->myassertText($page,
'/Add A User/'),
626 "Did NOT find Title, 'Add A User'");
628 if (!empty ($UserName))
630 $this->assertTrue($this->mybrowser->setField(
'username', $UserName),
631 "Could Not set the username field");
633 if (!empty ($Description))
635 $this->assertTrue($this->mybrowser->setField(
'description', $Description),
636 "Could Not set the description field");
640 $this->assertTrue($this->mybrowser->setField(
'email', $Email),
641 "Could Not set the email field");
643 if (!empty ($Access))
645 $this->assertTrue($this->mybrowser->setField(
'permission', $Access),
646 "Could Not set the permission field");
649 return (
'FATAL: Access/permission is a required field');
651 if (!empty ($Folder))
653 $this->assertTrue($this->mybrowser->setField(
'folder', $Folder),
654 "Could Not set the folder Field");
658 $this->assertTrue($this->mybrowser->setField(
'block', $Block),
659 "Could Not set the block Field");
663 $this->assertTrue($this->mybrowser->setField(
'blank', $Blank),
664 "Could Not set the blank Field");
666 if (!empty ($Password))
668 $this->assertTrue($this->mybrowser->setField(
'pass1', $Password),
669 "Could Not set the pass1 field");
670 $this->assertTrue($this->mybrowser->setField(
'pass2', $Password),
671 "Could Not set the pass2 field");
673 if (isset ($EmailNotify))
675 $this->assertTrue($this->mybrowser->setField(
'enote', TRUE),
676 "Could Not set the enote Field to non default value");
679 $this->assertTrue($this->mybrowser->setField(
'enote', FALSE),
680 "Could Not set the enote Field");
682 if (!empty($BucketPool))
684 $this->assertTrue($this->mybrowser->setField(
'default_bucketpool_fk', $BucketPool),
685 "Could Not set the default bucketpool select");
689 $this->assertTrue($this->mybrowser->setField(
'simple',
'checked'),
690 "Could Not set the simple check box");
695 $this->assertTrue($this->mybrowser->setField(
'original',
'checked'),
696 "Could Not set the original check box");
717 public function uploadFile($parentFolder, $uploadFile, $description =
null, $uploadName =
null, $agents =
null)
727 if (empty ($parentFolder))
731 if (empty ($uploadFile))
735 if (is_null($description))
737 $description =
"File $uploadFile uploaded by test UploadFileTest";
740 $loggedIn = $this->mybrowser->get($URL);
741 $this->assertTrue($this->myassertText($loggedIn,
'/Upload/'));
742 $page = $this->mybrowser->get(
"$URL?mod=upload_file");
743 $this->assertTrue($this->myassertText($page,
'/Upload a New File/'));
744 $this->assertTrue($this->myassertText($page,
'/Select the file to upload:/'));
745 $FolderId = $this->
getFolderId($parentFolder, $page,
'folder');
746 $this->assertTrue($this->mybrowser->setField(
'folder', $FolderId),
747 "uploadFile FAILED! could not set 'folder' field!\n");
748 $this->assertTrue($this->mybrowser->setField(
'getfile',
"$uploadFile"),
749 "uploadFile FAILED! could not set 'getfile' field!\n");
750 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"),
751 "uploadFile FAILED! could not set 'description' field!\n");
756 if (!(is_null($uploadName)))
758 $this->assertTrue($this->mybrowser->setField(
'name',
"$uploadName"),
759 "uploadFile FAILED! could not set 'name' field!\n");
765 if (!(is_null($agents)))
769 $page = $this->mybrowser->clickSubmit(
'Upload');
770 $this->assertTrue($page);
771 $this->assertTrue($this->myassertText($page,
'/The file .*? has been uploaded/'),
"FAILURE:Did not find the message 'The file .*? has been uploaded'\n");
793 public function uploadServer($parentFolder, $uploadPath, $description =
null, $uploadName =
null, $agents =
null)
804 if (empty ($parentFolder))
808 if (empty ($uploadPath))
812 if (is_null($description))
814 $description =
"File $uploadPath uploaded by test UploadAUrl";
817 $loggedIn = $this->mybrowser->get($URL);
818 $this->assertTrue($this->myassertText($loggedIn,
'/Upload/'),
"uploadURL FAILED! cannot file Upload menu, did we get a fossology page?\n");
819 $page = $this->mybrowser->clickLink(
"From Server");
821 $this->assertTrue($this->myassertText($page,
'/Upload from Server/'));
822 $this->assertTrue($this->myassertText($page,
'/Select the directory or file\(s\) on the server to upload/'));
824 $folderId = $parentFolder;
825 if ($parentFolder != 1)
827 $folderId = $this->
getFolderId($parentFolder, $page,
'folder');
829 $this->assertTrue($this->mybrowser->setField(
'folder', $folderId),
"Count not set folder field\n");
830 $this->assertTrue($this->mybrowser->setField(
'sourcefiles', $uploadPath),
"Count not set sourcefiles field\n");
831 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"),
"Count not set description field\n");
833 if (!is_null($uploadName))
835 $this->assertTrue($this->mybrowser->setField(
'name', $uploadName));
841 $this->fail(
"FAIL: could not set agents in uploadServer test\n");
843 $page = $this->mybrowser->clickSubmit(
'Upload!');
844 $this->assertTrue($page);
845 $this->assertTrue($this->myassertText($page,
'/The upload for .*? has been scheduled/'),
"FAIL! did not see phrase The upload for .*? has been scheduled\n");
868 public function uploadUrl($parentFolder, $url, $description =
null, $uploadName =
null, $agents =
null)
879 if (empty ($parentFolder))
887 if (is_null($description))
889 $description =
"File $url uploaded by test UploadAUrl";
892 $loggedIn = $this->mybrowser->get($URL);
893 $this->assertFalse($this->myassertText($loggedIn,
'/Network Error/'),
"uploadURL FAILED! there was a Newtwork Error (dns lookup?)\n");
894 $this->assertTrue($this->myassertText($loggedIn,
'/Upload/'),
"uploadURL FAILED! cannot file Upload menu, did we get a fossology page?\n");
895 $this->assertTrue($this->myassertText($loggedIn,
'/From URL/'));
896 $page = $this->mybrowser->get(
"$URL?mod=upload_url");
898 $this->assertTrue($this->myassertText($page,
'/Upload from URL/'));
899 $this->assertTrue($this->myassertText($page,
'/Enter the URL to the file/'));
901 $folderId = $parentFolder;
902 if ($parentFolder != 1)
904 $folderId = $this->
getFolderId($parentFolder, $page,
'folder');
906 $this->assertTrue($this->mybrowser->setField(
'folder', $folderId));
907 $this->assertTrue($this->mybrowser->setField(
'geturl', $url));
908 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"));
910 if (!(is_null($uploadName)))
912 $this->assertTrue($this->mybrowser->setField(
'name', $url));
918 $this->fail(
"FAIL: could not set agents in uploadAFILE test\n");
920 $page = $this->mybrowser->clickSubmit(
'Upload!');
921 $this->assertTrue($page);
922 $this->assertTrue($this->myassertText($page,
'/The upload .*? has been scheduled/'),
"FAIL! did find phrase The upload .*? has been scheduled\n");
946 require_once (
'testClasses/check4jobs.php');
948 define(
"FiveMIN",
"300");
954 for ($i = 1; $i <= 24; $i++)
957 $number = $Jq->Check();
971 print
"{$argv[0]} waited for 2 hours and the jobs are still not done\n" .
972 "Please investigate\n";
982 public function dbCheck()
987 public function jobsSummary()
991 public function jobsDetail()
996 public function oneShotLicense()
1000 public function rmLicAnalysis()
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify='y')
fillGroupForm($groupName, $user)
moveUpload($oldFolder, $destFolder, $upload)
uploadServer($parentFolder, $uploadPath, $description=null, $uploadName=null, $agents=null)
setUserFields($UserName=NULL, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Block=NULL, $Blank=NULL, $Password=NULL, $EmailNotify=NULL, $BucketPool=1, $Ui='simple')
mvFolder($folder, $destination)
uploadUrl($parentFolder, $url, $description=null, $uploadName=null, $agents=null)
editUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Block=NULL, $Blank=NULL, $Password=NULL, $EmailNotify='y')
checkEmailNotification($number)
editFolder($folder, $newName, $description=null)
uploadFile($parentFolder, $uploadFile, $description=null, $uploadName=null, $agents=null)
createFolder($parent, $name, $description=null)
getUploadId($uploadName, $page, $selectName)
getFolderId($folderName, $page, $selectName)
parseSelectStmnt($page, $selectName, $optionText=NULL)
FUNCTION char * strtoupper(char *s)
Helper function to upper case a string.