31 require_once (
'TestEnvironment.php');
32 require_once (
'fossologyTest.php');
65 public function addUser($UserName, $Description = NULL, $Email = NULL, $Access = 1, $Folder = 1, $Password = NULL, $EmailNotify =
'y')
71 if (empty ($UserName))
73 return (
"No User Name, cannot add user");
76 $page = $this->mybrowser->get($URL);
77 $page = $this->mybrowser->clickLink(
'Add');
78 $this->assertTrue($this->myassertText($page,
'/Add A User/'),
"Did NOT find Title, 'Add A User'");
80 $this->
setUserFields($UserName, $Description, $Email, $Access, $Folder, NULL, NULL, $Password, $EmailNotify);
83 $page = $this->mybrowser->clickSubmit(
'Add!',
"Could not select the Add! button");
84 $this->assertTrue($page);
86 if ($this->myassertText($page,
"/User .*? added/"))
90 if ($this->myassertText($page,
"/User already exists\. Not added/"))
92 return (
'User already exists. Not added');
94 if ($this->myassertText($page,
"/ERROR/"))
96 return (
"addUser FAILED! ERROR when adding users, please investigate");
125 'ERROR! Must supply a number to verify' 129 $headers = getMailSubjects();
130 if (empty ($headers))
144 if (preg_match(
'/ERROR/', $headers[0], $matches))
146 $this->fail(
"{$headers[0]}\n");
149 $pattern =
'completed with no errors';
152 foreach ($headers as $header)
155 $match = preg_match(
"/$pattern/", $header, $matches);
161 if (!empty ($failed))
163 $this->fail(
"Failures! there were jobs that did not report as completed\n");
188 public function createFolder($parent = null, $name, $description = null)
195 if (is_null($parent))
199 if (is_null($description))
201 $description =
"Folder $name created by createFolder as subfolder of $parent";
205 $this->fail(
"FATAL! No folder name supplied, cannot create folder\n");
207 $page = $this->mybrowser->get($URL);
210 $page = $this->mybrowser->clickLink(
'Create');
211 $this->assertTrue($this->myassertText($page,
'/Create a new Fossology folder/'));
215 $FolderId = $this->
getFolderId($parent, $page,
'parentid');
217 $this->assertTrue($this->mybrowser->setField(
'parentid', $FolderId));
218 $this->assertTrue($this->mybrowser->setField(
'newname', $name),
219 "FATAL! Could not set newname for folder:$name\n");
220 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"),
221 "FATAL! Could not set description for folder:$name\n");
222 $createdPage = $this->mybrowser->clickSubmit(
'Create!');
223 $this->assertTrue($createdPage);
224 if ($this->myassertText($createdPage,
"/Folder $name Created/"))
226 $folderId = $this->
getFolderId($name, $createdPage,
'parentid');
229 if ($this->myassertText($createdPage,
"/Folder $name Exists/"))
231 $folderId = $this->
getFolderId($name, $createdPage,
'parentid');
236 $this->fail(
"Failure! Did not find phrase 'Folder $name Created'\n");
258 $page = $this->mybrowser->get($URL);
259 $page = $this->mybrowser->clickLink(
'Delete Folder');
260 $this->assertTrue($this->myassertText($page,
'/Select the folder to delete/'));
261 $FolderId = $this->
getFolderId($folder, $page,
'folder');
262 if (empty ($FolderId))
266 $this->assertTrue($this->mybrowser->setField(
'folder', $FolderId));
267 $page = $this->mybrowser->clickSubmit(
'Delete!');
268 $this->assertTrue($page);
269 $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");
290 $page = $this->mybrowser->get($URL);
291 $page = $this->mybrowser->clickLink(
'Delete Uploaded File');
292 $this->assertTrue($this->myassertText($page,
'/Select the uploaded file to delete/'));
293 $UploadId = $this->
getUploadId($upload, $page,
'upload');
294 if (empty ($UploadId))
298 $this->assertTrue($this->mybrowser->setField(
'upload', $UploadId));
299 $page = $this->mybrowser->clickSubmit(
'Delete!');
300 $this->assertTrue($page);
301 $this->assertTrue($this->myassertText($page,
"/Deletion added to job queue/"),
"delete Upload Failed!\nPhrase 'Deletion added to job queue' not found\n");
317 return (
'No User Specified');
320 $page = $this->mybrowser->get(
"$URL?mod=user_del");
323 if (!is_null($select))
325 $this->assertTrue($this->mybrowser->setField(
'userid', $select));
326 $this->assertTrue($this->mybrowser->setField(
'confirm', 1));
327 $page = $this->mybrowser->clickSubmit(
'Delete!',
"Could not select the Delete! button");
328 $this->assertTrue($page);
329 if ($this->myassertText($page,
"/User deleted/"))
331 print
"User $User Deleted\n";
335 $this->fail(
"Delete User Failed!\nPhrase 'User deleted' not found\n");
350 public function editFolder($folder, $newName, $description = null)
359 if (is_null($description))
361 $description =
"Folder $newName edited by editFolder Test, this is the changed description";
363 $page = $this->mybrowser->get($URL);
364 $page = $this->mybrowser->clickLink(
'Edit Properties');
365 $this->assertTrue($this->myassertText($page,
'/Edit Folder Properties/'));
366 $FolderId = $this->
getFolderId($folder, $page,
'oldfolderid');
367 $this->assertTrue($this->mybrowser->setField(
'oldfolderid', $FolderId));
368 if (!(empty ($newName)))
370 $this->assertTrue($this->mybrowser->setField(
'newname', $newName));
372 $this->assertTrue($this->mybrowser->setField(
'newdesc',
"$description"));
373 $page = $this->mybrowser->clickSubmit(
'Edit!');
374 $this->assertTrue($page);
375 $this->assertTrue($this->myassertText($page,
"/Folder Properties changed/"),
"editFolder Failed!\nPhrase 'Folder Properties changed' not found\n");
395 public function editUser($UserName, $Description = NULL, $Email = NULL, $Access = 1, $Folder = 1, $Block = NULL, $Blank = NULL, $Password = NULL, $EmailNotify =
'y')
401 if (empty ($UserName))
403 return (
"No User Name, cannot add user");
405 $page = $this->mybrowser->get($URL);
406 $page = $this->mybrowser->clickLink(
'Edit Users');
407 $this->assertTrue($this->myassertText($page,
'/Edit A User/'),
"Did NOT find Title, 'Edit A User'");
408 $this->
setUserFields($UserName, $Description, $Email, $Access, $Folder, NULL, NULL, $Password, $EmailNotify);
411 $page = $this->mybrowser->clickSubmit(
'Edit!',
"Could not select the Edit! button");
412 $this->assertTrue($page);
414 if ($this->myassertText($page,
"/User edited/"))
441 print
"mU: OF:$oldFolder DF:$destFolder U:$upload\n";
442 if (empty ($oldFolder))
446 if (empty ($destFolder))
448 $destFolder =
'root';
450 $page = $this->mybrowser->get($URL);
452 $page = $this->mybrowser->get(
"$URL?mod=upload_move");
454 $this->assertTrue($this->myassertText($page,
'/Move upload to different folder/'));
455 $oldFolderId = $this->
getFolderId($oldFolder, $page,
'oldfolderid');
456 $this->assertTrue($this->mybrowser->setField(
'oldfolderid', $oldFolderId));
457 $uploadId = $this->
getUploadId($upload, $page,
'uploadid');
458 if (empty ($uploadId))
460 $this->fail(
"moveUpload FAILED! could not find upload id for upload" .
461 "$upload\n is $upload in $oldFolder?\n");
463 $this->assertTrue($this->mybrowser->setField(
'uploadid', $uploadId));
464 $destFolderId = $this->
getFolderId($destFolder, $page,
'targetfolderid');
465 $this->assertTrue($this->mybrowser->setField(
'targetfolderid', $destFolderId));
466 $page = $this->mybrowser->clickSubmit(
'Move!');
467 $this->assertTrue($page);
468 print
"page after move is:\n$page\n";
469 $this->assertTrue($this->myassertText($page,
471 "/Moved $upload from folder /"),
"moveUpload Failed!\nPhrase 'Move $upload from folder $oldFolder " .
472 "to folder $destFolder' not found\n");
492 if (empty ($destination))
496 $page = $this->mybrowser->get($URL);
497 $page = $this->mybrowser->clickLink(
'Move');
498 $this->assertTrue($this->myassertText($page,
'/Move Folder/'));
499 $FolderId = $this->
getFolderId($folder, $page,
'oldfolderid');
500 $this->assertTrue($this->mybrowser->setField(
'oldfolderid', $FolderId));
501 if ($destination != 1)
503 $DfolderId = $this->
getFolderId($destination, $page,
'targetfolderid');
505 $this->assertTrue($this->mybrowser->setField(
'targetfolderid', $DfolderId));
506 $page = $this->mybrowser->clickSubmit(
'Move!');
507 $this->assertTrue($page);
508 $this->assertTrue($this->myassertText($page,
"/Moved folder $folder to folder $destination/"),
"moveFolder Failed!\nPhrase 'Move folder $folder to folder ....' not found\n");
525 if (is_NULL($groupName))
527 $msg =
"FATAL! no group name to set\n";
533 $msg =
"FATAL! no user name to set\n";
538 $page = $this->mybrowser->get(
"$URL?mod=group_manage");
539 $this->assertTrue($this->myassertText($page,
'/Manage Group/'),
"Did NOT find Title, 'Manage Group'");
540 $this->assertTrue($this->myassertText($page,
'/Add a Group/'),
"Did NOT find phrase, 'Add a Group'");
543 $groupNotSet =
'FATAL! Could Not set the groupname field';
544 if (!empty ($groupName))
546 $this->assertTrue($this->mybrowser->setField(
'groupname', $groupName), $groupNotSet);
550 $userNotSet =
'FATAL! Could Not set the userid field in select';
551 $this->assertTrue($this->mybrowser->setField(
'userid', $user), $userNotSet);
573 $Email = NULL, $Access = 1, $Folder = 1, $Block = NULL, $Blank = NULL,
574 $Password = NULL, $EmailNotify = NULL, $BucketPool = 1, $Ui =
'simple')
583 if (strtoupper($UserName) ==
'NULL')
585 $this->fail(
"setUserFields, FATAL! no user name to set\n");
587 if (strtoupper($Description) ==
'NULL')
591 if (strtoupper($Email) ==
'NULL')
595 if (strtoupper($Access) ==
'NULL')
599 if (strtoupper($Folder) ==
'NULL')
603 if (strtoupper($Block) ==
'NULL')
607 if (strtoupper($Blank) ==
'NULL')
611 if (strtoupper($Password) ==
'NULL')
615 if (strtoupper($EmailNotify) ==
'NULL' || is_null($EmailNotify))
617 unset ($EmailNotify);
619 if ($BucketPool == NULL)
623 if (strcasecmp($Ui,
'simple'))
627 else if (strcasecmp($Ui,
'original'))
632 $page = $this->mybrowser->get($URL);
633 $page = $this->mybrowser->clickLink(
'Add');
634 $this->assertTrue($this->myassertText($page,
'/Add A User/'),
635 "Did NOT find Title, 'Add A User'");
637 if (!empty ($UserName))
639 $this->assertTrue($this->mybrowser->setField(
'username', $UserName),
640 "Could Not set the username field");
642 if (!empty ($Description))
644 $this->assertTrue($this->mybrowser->setField(
'description', $Description),
645 "Could Not set the description field");
649 $this->assertTrue($this->mybrowser->setField(
'email', $Email),
650 "Could Not set the email field");
652 if (!empty ($Access))
654 $this->assertTrue($this->mybrowser->setField(
'permission', $Access),
655 "Could Not set the permission field");
658 return (
'FATAL: Access/permission is a required field');
660 if (!empty ($Folder))
662 $this->assertTrue($this->mybrowser->setField(
'folder', $Folder),
663 "Could Not set the folder Field");
667 $this->assertTrue($this->mybrowser->setField(
'block', $Block),
668 "Could Not set the block Field");
672 $this->assertTrue($this->mybrowser->setField(
'blank', $Blank),
673 "Could Not set the blank Field");
675 if (!empty ($Password))
677 $this->assertTrue($this->mybrowser->setField(
'pass1', $Password),
678 "Could Not set the pass1 field");
679 $this->assertTrue($this->mybrowser->setField(
'pass2', $Password),
680 "Could Not set the pass2 field");
682 if (isset ($EmailNotify))
684 $this->assertTrue($this->mybrowser->setField(
'enote', TRUE),
685 "Could Not set the enote Field to non default value");
688 $this->assertTrue($this->mybrowser->setField(
'enote', FALSE),
689 "Could Not set the enote Field");
691 if (!empty($BucketPool))
693 $this->assertTrue($this->mybrowser->setField(
'default_bucketpool_fk', $BucketPool),
694 "Could Not set the default bucketpool select");
698 $this->assertTrue($this->mybrowser->setField(
'simple',
'checked'),
699 "Could Not set the simple check box");
704 $this->assertTrue($this->mybrowser->setField(
'original',
'checked'),
705 "Could Not set the original check box");
726 public function uploadFile($parentFolder, $uploadFile, $description = null, $uploadName = null, $agents = null)
736 if (empty ($parentFolder))
740 if (empty ($uploadFile))
744 if (is_null($description))
746 $description =
"File $uploadFile uploaded by test UploadFileTest";
749 $loggedIn = $this->mybrowser->get($URL);
750 $this->assertTrue($this->myassertText($loggedIn,
'/Upload/'));
751 $page = $this->mybrowser->get(
"$URL?mod=upload_file");
752 $this->assertTrue($this->myassertText($page,
'/Upload a New File/'));
753 $this->assertTrue($this->myassertText($page,
'/Select the file to upload:/'));
754 $FolderId = $this->
getFolderId($parentFolder, $page,
'folder');
755 $this->assertTrue($this->mybrowser->setField(
'folder', $FolderId),
756 "uploadFile FAILED! could not set 'folder' field!\n");
757 $this->assertTrue($this->mybrowser->setField(
'getfile',
"$uploadFile"),
758 "uploadFile FAILED! could not set 'getfile' field!\n");
759 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"),
760 "uploadFile FAILED! could not set 'description' field!\n");
765 if (!(is_null($uploadName)))
767 $this->assertTrue($this->mybrowser->setField(
'name',
"$uploadName"),
768 "uploadFile FAILED! could not set 'name' field!\n");
774 if (!(is_null($agents)))
778 $page = $this->mybrowser->clickSubmit(
'Upload');
779 $this->assertTrue($page);
780 $this->assertTrue($this->myassertText($page,
'/The file .*? has been uploaded/'),
"FAILURE:Did not find the message 'The file .*? has been uploaded'\n");
802 public function uploadServer($parentFolder = 1, $uploadPath, $description = null, $uploadName = null, $agents = null)
813 if (empty ($parentFolder))
817 if (empty ($uploadPath))
821 if (is_null($description))
823 $description =
"File $uploadPath uploaded by test UploadAUrl";
826 $loggedIn = $this->mybrowser->get($URL);
827 $this->assertTrue($this->myassertText($loggedIn,
'/Upload/'),
"uploadURL FAILED! cannot file Upload menu, did we get a fossology page?\n");
828 $page = $this->mybrowser->clickLink(
"From Server");
830 $this->assertTrue($this->myassertText($page,
'/Upload from Server/'));
831 $this->assertTrue($this->myassertText($page,
'/Select the directory or file\(s\) on the server to upload/'));
833 $folderId = $parentFolder;
834 if ($parentFolder != 1)
836 $folderId = $this->
getFolderId($parentFolder, $page,
'folder');
838 $this->assertTrue($this->mybrowser->setField(
'folder', $folderId),
"Count not set folder field\n");
839 $this->assertTrue($this->mybrowser->setField(
'sourcefiles', $uploadPath),
"Count not set sourcefiles field\n");
840 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"),
"Count not set description field\n");
842 if (!is_null($uploadName))
844 $this->assertTrue($this->mybrowser->setField(
'name', $uploadName));
850 $this->fail(
"FAIL: could not set agents in uploadServer test\n");
852 $page = $this->mybrowser->clickSubmit(
'Upload!');
853 $this->assertTrue($page);
854 $this->assertTrue($this->myassertText($page,
'/The upload for .*? has been scheduled/'),
"FAIL! did not see phrase The upload for .*? has been scheduled\n");
877 public function uploadUrl($parentFolder = 1, $url, $description = null, $uploadName = null, $agents = null)
888 if (empty ($parentFolder))
896 if (is_null($description))
898 $description =
"File $url uploaded by test UploadAUrl";
901 $loggedIn = $this->mybrowser->get($URL);
902 $this->assertFalse($this->myassertText($loggedIn,
'/Network Error/'),
"uploadURL FAILED! there was a Newtwork Error (dns lookup?)\n");
903 $this->assertTrue($this->myassertText($loggedIn,
'/Upload/'),
"uploadURL FAILED! cannot file Upload menu, did we get a fossology page?\n");
904 $this->assertTrue($this->myassertText($loggedIn,
'/From URL/'));
905 $page = $this->mybrowser->get(
"$URL?mod=upload_url");
907 $this->assertTrue($this->myassertText($page,
'/Upload from URL/'));
908 $this->assertTrue($this->myassertText($page,
'/Enter the URL to the file/'));
910 $folderId = $parentFolder;
911 if ($parentFolder != 1)
913 $folderId = $this->
getFolderId($parentFolder, $page,
'folder');
915 $this->assertTrue($this->mybrowser->setField(
'folder', $folderId));
916 $this->assertTrue($this->mybrowser->setField(
'geturl', $url));
917 $this->assertTrue($this->mybrowser->setField(
'description',
"$description"));
919 if (!(is_null($uploadName)))
921 $this->assertTrue($this->mybrowser->setField(
'name', $url));
927 $this->fail(
"FAIL: could not set agents in uploadAFILE test\n");
929 $page = $this->mybrowser->clickSubmit(
'Upload!');
930 $this->assertTrue($page);
931 $this->assertTrue($this->myassertText($page,
'/The upload .*? has been scheduled/'),
"FAIL! did find phrase The upload .*? has been scheduled\n");
955 require_once (
'testClasses/check4jobs.php');
957 define(
"FiveMIN",
"300");
963 for ($i = 1; $i <= 24; $i++)
966 $number = $Jq->Check();
980 print
"{$argv[0]} waited for 2 hours and the jobs are still not done\n" .
981 "Please investigate\n";
991 public function dbCheck()
996 public function jobsSummary()
1000 public function jobsDetail()
1005 public function oneShotLicense()
1009 public function rmLicAnalysis()
createFolder($parent=null, $name, $description=null)
getUploadId($uploadName, $page, $selectName)
parseSelectStmnt($page, $selectName, $optionText=NULL)
editUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Block=NULL, $Blank=NULL, $Password=NULL, $EmailNotify= 'y')
fillGroupForm($groupName, $user)
uploadFile($parentFolder, $uploadFile, $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')
editFolder($folder, $newName, $description=null)
uploadUrl($parentFolder=1, $url, $description=null, $uploadName=null, $agents=null)
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify= 'y')
getFolderId($folderName, $page, $selectName)
checkEmailNotification($number)
mvFolder($folder, $destination)
moveUpload($oldFolder, $destFolder, $upload)
uploadServer($parentFolder=1, $uploadPath, $description=null, $uploadName=null, $agents=null)