FOSSology  4.4.0
Open Source License Compliance by Open Source Software
verifyFoss23D1F1L.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
16 require_once('../../../tests/fossologyTestCase.php');
17 require_once('../../../tests/commonTestFuncs.php');
18 require_once('../../../tests/TestEnvironment.php');
19 require_once('../../../tests/testClasses/parseMiniMenu.php');
20 require_once('../../../tests/testClasses/parseFolderPath.php');
21 require_once('../../../tests/testClasses/dom-parseLicenseTable.php');
22 
23 global $URL;
24 
30 class verify23D1F1L extends fossologyTestCase
31 {
32  public $mybrowser;
33  public $host;
34 
35  function setUp()
36  {
37  /*
38  * This test requires that the fossology test archive has been
39  * loaded under the name foss23D1F1L.tar.bz2
40  */
41  global $URL;
42  global $name;
43  global $safeName;
44 
45  $name = 'foss23D1F1L.tar.bz2';
46  $safeName = escapeDots($name);
47  $this->host = getHost($URL);
48  $this->Login();
49 
50  /* check for existense of archive */
51  $page = $this->mybrowser->get($URL);
52  $page = $this->mybrowser->clickLink('Browse');
53  $this->assertTrue($this->myassertText($page, '/Browse/'),
54  "verify23D1F1L FAILED! Could not find Browse menu\n");
55  $page = $this->mybrowser->clickLink('Testing');
56  $this->assertTrue($this->myassertText($page, '/Testing/'),
57  "verify23D1F1L FAILED! Could not find Testing folder\n");
58  $result = $this->myassertText($page, "/$name/");
59  if(!($result)) { exit(FALSE); }
60  }
61 
62  function testVerifyFossology()
63  {
64  global $URL;
65  global $name;
66  global $safeName;
67 
68  $licenseSummary = array(
69  'Unique licenses' => 1,
70  'Licenses found' => 1,
71  'Files with no licenses' => 0,
72  'Files' => 1
73  );
74 
75  print "starting VerifyFoss23D1F1L test\n";
76  $page = $this->mybrowser->clickLink('Browse');
77  $this->assertTrue($this->myassertText($page, '/Browse/'),
78  "verify23D1F1L FAILED! Could not find Browse menu\n");
79  $page = $this->mybrowser->clickLink('Testing');
80  //print "************ Page after upload link *************\n$page\n";
81  $this->assertTrue($this->myassertText($page, "/Browse/"),
82  "verify23D1F1L FAILED! Browse Title not found\n");
83  $this->assertTrue($this->myassertText($page, "/$safeName/"),
84  "verify23D1F1L FAILED! did not find $name\n");
85  $this->assertTrue($this->myassertText($page, "/>View</"),
86  "verifyfoss23D1F1L FAILED! >View< not found\n");
87  $this->assertTrue($this->myassertText($page, "/>Info</"),
88  "verifyFoss23D1F1L FAILED! >Info< not found\n");
89  $this->assertTrue($this->myassertText($page, "/>Download</"),
90  "verifyFoss23D1F1L FAILED! >Download< not found\n");
91 
92  /* Select archive */
93  $page = $this->mybrowser->clickLink($name);
94  //print "************ Page after select foss archive *************\n$page\n";
95  $this->assertTrue($this->myassertText($page, "/foss23Dirs1File1Lic\//"),
96  "verifyfoss23D1F1L FAILED! 'foss23Dirs1File1Lic/' not found\n");
97  $this->assertTrue($this->myassertText($page, "/1 item/"),
98  "verifyfoss23D1F1L FAILED! '1 item' not found\n");
99 
100  /* Select fossology link */
101  $page = $this->mybrowser->clickLink('foss23Dirs1File1Lic/');
102 
103  /* need to check that there are 9 items */
104  $this->assertTrue($this->myassertText($page, "/9 items/"),
105  "verifyfoss23D1F1L FAILED! '9 items' not found\n");
106  $this->assertTrue($this->myassertText($page, "/agents/"),
107  "verify23D1F1L FAILED! did not find 'agents' directory\n");
108  $this->assertTrue($this->myassertText($page, "/scheduler/"),
109  "verify23D1F1L FAILED! did not find scheduler directory\n");
110 
111  /* Select the License link to View License Historgram */
112  $mini = new parseMiniMenu($page);
113  $miniMenu = $mini->parseMiniMenu();
114  $url = makeUrl($this->host, $miniMenu['Nomos License']);
115  if($url === NULL) { $this->fail("verify23D1F1L Failed, host is not set"); }
116 
117  $page = $this->mybrowser->get($url);
118  //print "page after get of $url is:\n$page\n";
119  $this->assertTrue($this->myassertText($page, '/Nomos License Browser/'),
120  "verify23D1F1L FAILED! License Browser Title not found\n");
121 
122  // verify license summaries
123  $licSummary = new domParseLicenseTbl($page, 'licsummary', 0);
124  $licSummary->parseLicenseTbl();
125 
126  foreach ($licSummary->hList as $summary) {
127  $key = $summary['textOrLink'];
128  $this->assertEqual($licenseSummary[$key], $summary['count'],
129  "verifyFossDirsOnly FAILED! $key does not equal $licenseSummary[$key],
130  got $summary[count]\n");
131  //print "summary is:\n";print_r($summary) . "\n";
132  }
133 
134  // get the 'Show' links and License color links
135  $licHisto = new domParseLicenseTbl($page, 'lichistogram');
136  $licHisto->parseLicenseTbl();
137  if(empty($licHisto->hList)) {
138  $this->fail("FATAL! table with id=lichistogram was not found on
139  the page, nothing to process, stopping test\n");
140  exit(1);
141  }
142  /* Select show 'GPL_v2', verify */
143  $gplv2URL = makeUrl($this->host, $licHisto->hList[1]['showLink']);
144  $page = $this->mybrowser->get($gplv2URL);
145  $licFileList = new parseFolderPath($page, $URL);
146  $tblList = $licFileList->parseFolderPath();
147  $fileCnt = count($tblList);
148  print "Checking the number of files based on 'GPL_v2'\n";
149  $this->assertTrue($fileCnt == 1,
150  "FAILURE! Should only have 1 file with a GPL_v2 license: " .
151  "Testing/foss23D1F1L.bz2/foss23Dirs1File1Lic/cli/cp2foss.php, " .
152  "got:$fileCnt\n");
153  }
154 }
Login($User=NULL, $Password=NULL)