function setUp()
 {
     /*
      * This test requires that the fossology test archive has been
      * loaded under the name fossarchive-T.tar.bz2 For now, the setup
      * will just verify the material is there?
      */
     global $URL;
     global $name;
     global $safeName;
     $name = 'fossI16L518.tar.bz2';
     $safeName = escapeDots($name);
     $this->host = getHost($URL);
     $this->Login();
     /* check for existense of archive */
     $page = $this->mybrowser->get($URL);
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifyFossI16L518 FAILED! Could not find Browse menu\n");
     $page = $this->mybrowser->clickLink('Testing');
     $this->assertTrue($this->myassertText($page, '/Testing/'), "verifyFossI16L518 FAILED! Could not find Testing folder\n");
     $result = $this->myassertText($page, "/{$safeName}/");
     if (!$result) {
         exit(FALSE);
     }
 }
 function setUp()
 {
     /*
      * This test requires that the fossology test archive has been
      * loaded under the name 3files.tar.bz2
      */
     global $URL;
     global $name;
     global $safeName;
     $name = 'RedHat.tar.gz';
     $safeName = escapeDots($name);
     $this->host = getHost($URL);
     //print "SetUp: host is:$this->host\n";
     $this->Login();
     /* check for existense of archive */
     $page = $this->mybrowser->get($URL);
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifySimpletest FAILED! Could not find Browse menu\n");
     $page = $this->mybrowser->clickLink('Testing');
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verifySimpleTest FAILED! Could not find RedHat.tar upload\n");
     $result = $this->myassertText($page, "/{$name}/");
     //if(!($result)) { echo "WTF!\n"; exit(FALSE); }
 }
 function setUp()
 {
     /*
      * This test requires that the fossology test archive has been
      * loaded under the name fossDirsOnly.tar.bz2
      */
     global $URL;
     global $name;
     global $safeName;
     print "starting verifyFossDirsOnly-SetUp\n";
     $name = 'fossDirsOnly.tar.bz2';
     $safeName = escapeDots($name);
     $this->host = getHost($URL);
     $this->Login();
     /* check for existense of archive */
     $page = $this->mybrowser->get($URL);
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifyDirsOnly FAILED! Could not find Browse menu\n");
     $result = $this->myassertText($page, "/{$safeName}/");
     if (!$result) {
         $this->fail("Failure, cannot find archive {$name}, Stopping test\n");
         exit(1);
     }
 }
 function setUp()
 {
     /*
      * This test requires that the fossology test archive has been
      * loaded under the name 3files.tar.bz2
      */
     global $URL;
     global $name;
     global $safeName;
     $name = '3files.tar.bz2';
     $safeName = escapeDots($name);
     $this->host = getHost($URL);
     $this->Login();
     /* check for existense of archive */
     $page = $this->mybrowser->get($URL);
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verify3files FAILED! Could not find Browse menu\n");
     $page = $this->mybrowser->clickLink('Copyright');
     $this->assertTrue($this->myassertText($page, '/Copyright/'), "verify3files FAILED! Could not find copyright folder\n");
     $result = $this->myassertText($page, "/{$name}/");
     if (!$result) {
         exit(FALSE);
     }
 }
 /**
  * parseSelectStmnt
  *
  * Parse the specified select statement on the page
  *
  * @param string $page the page to search
  * @param string $selectName the name of the select
  * @param string $optionText the text of the option statement
  * @return mixed $select either array (if first two args present) or
  * int if all three arguments present. NULL on error.
  *
  * Format of the array returned:
  *
  * Array[option text]=>[option value attribute]
  */
 public function parseSelectStmnt($page, $selectName, $optionText = NULL)
 {
     if (empty($page)) {
         return NULL;
     }
     if (empty($selectName)) {
         return NULL;
     }
     $hpage = new DOMDocument();
     @$hpage->loadHTML($page);
     /* get select and options */
     $selectList = $hpage->getElementsByTagName('select');
     $optionList = $hpage->getElementsByTagName('option');
     /*
      * gather the section names and group the options with each section
      * collect the data at the same time.  Assemble into the data structure.
      */
     for ($i = 0; $i < $selectList->length; $i++) {
         $ChildList = $selectList->item($i)->childNodes;
         foreach ($ChildList as $child) {
             $optionValue = $child->getAttribute('value');
             $orig = $child->nodeValue;
             /*
              * need to clean up the string, to get rid of &nbsp codes, or the keys
              * will not match.
              */
             $he = htmlentities($orig);
             $htmlGone = preg_replace('/&.*?;/', '', $he);
             $cleanText = trim($htmlGone);
             if (!empty($optionText)) {
                 $noDotOptText = escapeDots($optionText);
                 $match = preg_match("/^{$noDotOptText}\$/", $cleanText, $matches);
                 if ($match) {
                     /* Use the matched optionText instead of the whole string */
                     //print "Adding matches[0] to select array\n";
                     $Selects[$selectList->item($i)->getAttribute('name')][$matches[0]] = $optionValue;
                 }
             } else {
                 /*
                  * Add the complete string contained in the <option>, any
                  * html & values should have been removed.
                  */
                 //print "Adding cleanText to select array\n";
                 $Selects[$selectList->item($i)->getAttribute('name')][$cleanText] = $optionValue;
                 $foo = $selectList->item($i)->getAttribute('onload');
             }
         }
     }
     //for
     /*
      * if there were no selects found, then we were passed something that
      * doesn't exist.
      */
     if (empty($Selects)) {
         return NULL;
     }
     //print "FTPSS: selects array is:\n";print_r($Selects) . "\n";
     /* Return either an int or an array */
     if (!is_null($optionText)) {
         if (array_key_exists($optionText, $Selects[$selectName])) {
             return $Selects[$selectName][$optionText];
             // int
         } else {
             return NULL;
         }
     } else {
         if (array_key_exists($selectName, $Selects)) {
             return $Selects[$selectName];
             // array
         } else {
             return NULL;
             // didn't find any...
         }
     }
 }
 function testRHEL()
 {
     global $URL;
     $licBaseLine = array('No_license_found' => 6878, 'Apache_v2.0' => 858, 'ATT' => 812, 'GPL_v2+' => 289, 'CMU' => 247, 'FSF' => 176, 'BSD-style' => 154, 'LGPL' => 131, 'GPL_v3+' => 76, 'Apache-possibility' => 62, 'See-doc(OTHER)' => 28, 'Debian-SPI-style' => 34, 'GNU-Manpages' => 34, 'LGPL_v2.1+' => 29, 'MPL_v1.1' => 29, 'Trademark-ref' => 25, 'IETF' => 28, 'UnclassifiedLicense' => 28, 'GPL-exception' => 24, 'BSD' => 20, 'Apache' => 17, 'GPL' => 73, 'GPL_v2' => 13, 'GPL_v2.1+' => 1, 'Indemnity' => 2, 'GPL-possibility' => 1, 'Public-domain' => 20, 'Non-commercial!' => 6, 'RSA-Security' => 7, 'ATT-possibility' => 6, 'LGPL_v2+' => 6, 'OSL_v1.0' => 6, 'CPL_v1.0' => 5, 'GFDL_v1.1+' => 5, 'GPL_v3' => 5, 'Intel' => 5, 'LGPL_v3+' => 4, 'Public-domain-ref' => 4, 'Perl-possibility' => 4, 'APSL_v1.1' => 3, 'IOS' => 3, 'MIT-style' => 3, 'NOT-public-domain' => 10, 'Apache_v1.1' => 3, 'CMU-possibility' => 2, 'GFDL_v1.1' => 3, 'GFDL_v1.2+' => 3, 'MIT' => 2, 'MPL' => 2, 'Open-Publication_v1.0' => 2, 'Zope-PL_v2.0' => 2, 'AGFA(RESTRICTED)' => 1, 'APSL' => 1, 'APSL_v1.2' => 1, 'ATT-Source_v1.2d' => 1, 'BSD-possibility' => 1, 'CCA' => 1, 'Dyade' => 1, 'HP-possibility' => 1, 'ISC' => 1, 'GPL-Bison-exception' => 1, 'LGPL-possibility' => 1, 'LGPL_v2' => 1, 'MacroMedia-RPSL' => 1, 'Microsoft-possibility' => 1, 'NPL_v1.1' => 1, 'RedHat-EULA' => 1, 'RedHat(Non-commercial)' => 1, 'Same-license-as' => 1, 'See-file(COPYING)' => 1, 'Sun' => 1, 'Sun-BCLA' => 1, 'Sun-possibility' => 1, 'Sun(RESTRICTED)' => 1, 'TeX-exception' => 1, 'U-Wash(Free-Fork)' => 1, 'X11' => 1, 'zlib/libpng' => 1);
     $licenseSummary = array('Unique licenses' => 71, 'Licenses found' => 3328, 'Files with no licenses' => 6878, 'Files' => 12595);
     print "starting testRHEL\n";
     $name = 'RedHat.tar.gz';
     $safeName = escapeDots($name);
     //print "safeName is:$safeName\n";
     $page = $this->mybrowser->clickLink('Browse');
     $page = $this->mybrowser->clickLink('Testing');
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verifyRedHat FAILED! did not find {$safeName}\n");
     /* Select archive */
     //print "CKZDB: page before call parseBMenu:\n$page\n";
     $page = $this->mybrowser->clickLink($name);
     $this->assertTrue($this->myassertText($page, "/1 item/"), "verifyRedHat FAILED! 1 item not found\n");
     $page = $this->mybrowser->clickLink('RedHat.tar');
     //print "page after clicklink RedHat.tar:\n$page\n";
     $page = $this->mybrowser->clickLink('RedHat/');
     //print "page after clicklink RedHat:\n$page\n";
     $this->assertTrue($this->myassertText($page, "/65 items/"), "verifyRedHat FAILED! '65 items' not found\n");
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     //print "miniMenu is:\n";print_r($miniMenu) . "\n";
     $url = makeUrl($this->host, $miniMenu['License Browser']);
     if ($url === NULL) {
         $this->fail("verifyRedHat Failed, host/url is not set");
     }
     $page = $this->mybrowser->get($url);
     //print "page after get of $url is:\n$page\n";
     $this->assertTrue($this->myassertText($page, '/License Browser/'), "verifyRedHat FAILED! License Browser Title not found\n");
     // check that license summarys are correct
     $licSummary = new domParseLicenseTbl($page, 'licsummary', 0);
     $licSummary->parseLicenseTbl();
     print "verifying summaries....\n";
     foreach ($licSummary->hList as $summary) {
         //print "summary is:\n";print_r($summary) . "\n";
         $key = $summary['textOrLink'];
         //print "SUM: key is:$key\n";
         $this->assertEqual($licenseSummary[$key], $summary['count'], "verifyRedHat FAILED! {$key} does not equal {$licenseSummary[$key]},\n      Expected: {$licenseSummary[$key]},\n           Got: {$summary['count']}\n");
         //print "summary is:\n";print_r($summary) . "\n";
     }
     // get the license names and 'Show' links
     $licHistogram = new domParseLicenseTbl($page, 'lichistogram', 1);
     $licHistogram->parseLicenseTbl();
     if ($licHistogram->noRows === TRUE) {
         $this->fail("FATAL! no table rows to process, there should be many for" . " this test, Stopping the test");
         return;
     }
     // verify every row against the standard by comparing the counts.
     /*
      * @todo check the show links, but to do that, need to gather another
      * standard array to match agains?  or just use the count from the
      * baseline?
      */
     //print "table is:\n";print_r($licHistogram->hList) . "\n";
     foreach ($licHistogram->hList as $licFound) {
         $key = $licFound['textOrLink'];
         //print "HDB: key is:$key\n";
         //print "licFound is:\n";print_r($licFound) . "\n";
         if (array_key_exists($key, $licBaseLine)) {
             //print "licFound[textOrLink] is:{$licFound['textOrLink']}\n";
             $this->assertEqual($licBaseLine[$key], $licFound['count'], "verifyRedHat FAILED! the baseline count {$licBaseLine[$key]} does" . " not equal {$licFound['count']} for license {$key},\n" . "Expected: {$licBaseLine[$key]},\n" . "     Got: {$licFound['count']}\n");
         } else {
             $this->fail("verifyRedHat FAILED! A License was found that is " . "not in the standard:\n{$key}\n");
         }
     }
 }
Exemple #7
0
 function testZendLic()
 {
     global $URL;
     print "starting testZendLic\n";
     $name = 'zend-license';
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, "/>View</"), "ckzend FAILED! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Info</"), "ckzend FAILED! >Info< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "ckzend FAILED! >Download< not found\n");
     $page = $this->mybrowser->clickLink('Testing');
     $this->assertTrue($this->myassertText($page, '/Testing/'), "ckzend FAILED! Could not find Testing folder\n");
     $this->assertTrue($this->myassertText($page, "/{$name}/"), "ckzend FAILED! did not find {$name}\n");
     /* Select archive */
     //print "CKZDB: page before call parseBMenu:\n$page\n";
     $browse = new parseBrowseMenu($page, 'browsetbl', 1);
     $browse->parseBrowseMenuFiles();
     // get the View link for zend-license
     $viewLink = $browse->browseList[$name]['View'];
     $page = $this->mybrowser->get($viewLink);
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     $url = makeUrl($this->host, $miniMenu['License Browser']);
     if ($url === NULL) {
         $this->fail("ckzend Failed, host/url is not set");
     }
     $this->assertTrue($this->myassertText($page, '/View File/'), "ckzend FAILED! View File Title not found\n");
     $page = $this->mybrowser->get($url);
     // Check License
     // Get the displayed result
     $matched = preg_match("/<hr>\nThe(.*?)<div class='text'>--/", $page, $matches);
     //print "DBCKZ: we found:\n";print_r($matches) . "\n";
     $foundRaw = $matches[1];
     $stripped = strip_tags($foundRaw);
     $found = escapeDots($stripped);
     $stringToMatch = 'Nomos license detector found: Zend_v2\\.0';
     $this->assertTrue($found, "/{$stringToMatch}/", "ckzend FAILED! Nomos license string does not match\n" . "Expected: {$stringToMatch}\n" . "     Got: {$found}\n");
     $this->assertTrue($this->myassertText($page, '/View License/'), "ckzend FAILED! View License Title not found\n");
     // Check One-shot Analysis
     $urlOneShot = makeUrl($this->host, $miniMenu['One-Shot License']);
     if ($urlOneShot === NULL) {
         $this->fail("ckzend Failed, cannot make One-Shot url");
     }
     $page = $this->mybrowser->get($urlOneShot);
     $this->assertTrue($this->myassertText($page, '/One-Shot License Analysis/'), "ckzend FAILED! One-Shot License Analysis Title not found\n");
     //$osLicText = '<strong>Zend_v2\.0';
     //$this->assertTrue($this->myassertText($page, "/$osLicText/"),
     //"ckzend FAILED! the text:\n$osLicText\n was not found\n");
 }