FOSSology  4.4.0
Open Source License Compliance by Open Source Software
bsam-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/parseBrowseMenu.php');
20 require_once('../../../tests/testClasses/parseMiniMenu.php');
21 require_once('../../../tests/testClasses/parseFolderPath.php');
22 require_once('../../../tests/testClasses/parseLicenseTbl.php');
23 
24 global $URL;
25 
32 {
33  public $mybrowser;
34  public $host;
35 
36  function setUp()
37  {
38  /*
39  * This test requires that the fossology test archive has been
40  * loaded under the name foss23D1F1L.tar.bz2
41  */
42  global $URL;
43  global $name;
44  global $safeName;
45 
46  $name = 'foss23D1F1L.tar.bz2';
47  $safeName = escapeDots($name);
48  $this->host = getHost($URL);
49  $this->Login();
50 
51  /* check for existense of archive */
52  $page = $this->mybrowser->get($URL);
53  $page = $this->mybrowser->clickLink('Browse');
54  $this->assertTrue($this->myassertText($page, '/Browse/'),
55  "verify23D1F1L FAILED! Could not find Browse menu\n");
56  $page = $this->mybrowser->clickLink('Testing');
57  $this->assertTrue($this->myassertText($page, '/Testing/'),
58  "verify23D1F1L FAILED! Could not find Testing folder\n");
59  $result = $this->myassertText($page, "/$name/");
60  if(!($result)) { exit(FALSE); }
61  }
62 
63  function testVerifyFossology()
64  {
65  global $URL;
66  global $name;
67  global $safeName;
68 
69  print "starting VerifyFoss23D1F1L test\n";
70  $page = $this->mybrowser->clickLink('Browse');
71  $this->assertTrue($this->myassertText($page, '/Browse/'),
72  "verify23D1F1L FAILED! Could not find Browse menu\n");
73  $page = $this->mybrowser->clickLink('Testing');
74  //print "************ Page after upload link *************\n$page\n";
75  $this->assertTrue($this->myassertText($page, "/Browse/"),
76  "verify23D1F1L FAILED! Browse Title not found\n");
77  $this->assertTrue($this->myassertText($page, "/$safeName/"),
78  "verify23D1F1L FAILED! did not find $name\n");
79  $this->assertTrue($this->myassertText($page, "/>View</"),
80  "verifyfoss23D1F1L FAILED! >View< not found\n");
81  $this->assertTrue($this->myassertText($page, "/>Meta</"),
82  "verifyFoss23D1F1L FAILED! >Meta< not found\n");
83  $this->assertTrue($this->myassertText($page, "/>Download</"),
84  "verifyFoss23D1F1L FAILED! >Download< not found\n");
85 
86  /* Select archive */
87  $page = $this->mybrowser->clickLink($name);
88  //print "************ Page after select foss archive *************\n$page\n";
89  $this->assertTrue($this->myassertText($page, "/foss23Dirs1File1Lic\//"),
90  "verifyfoss23D1F1L FAILED! 'foss23Dirs1File1Lic/' not found\n");
91  $this->assertTrue($this->myassertText($page, "/1 item/"),
92  "verifyfoss23D1F1L FAILED! '1 item' not found\n");
93 
94  /* Select fossology link */
95  $page = $this->mybrowser->clickLink('foss23Dirs1File1Lic/');
96 
97  /* need to check that there are 9 items */
98  $this->assertTrue($this->myassertText($page, "/9 items/"),
99  "verifyfoss23D1F1L FAILED! '9 items' not found\n");
100  $this->assertTrue($this->myassertText($page, "/agents/"),
101  "verify23D1F1L FAILED! did not find 'agents' directory\n");
102  $this->assertTrue($this->myassertText($page, "/scheduler/"),
103  "verify23D1F1L FAILED! did not find scheduler directory\n");
104 
105  /* Select the License link to View License Historgram */
106  $browse = new parseBrowseMenu($page);
107  $mini = new parseMiniMenu($page);
108  $miniMenu = $mini->parseMiniMenu();
109  $url = makeUrl($this->host, $miniMenu['License']);
110  if($url === NULL) { $this->fail("verify23D1F1L Failed, host is not set"); }
111 
112  $page = $this->mybrowser->get($url);
113  //print "page after get of $url is:\n$page\n";
114  $this->assertTrue($this->myassertText($page, '/License Browser/'),
115  "verify23D1F1L FAILED! License Browser Title not found\n");
116  $this->assertTrue($this->myassertText($page, '/Total licenses: 2/'),
117  "verify23D1F1L FAILED! Total Licenses does not equal 2\n");
118 
119  // get the 'Show' links and License color links
120  $licTbl = new parseLicenseTbl($page);
121  $licTable = $licTbl->parseLicenseTbl();
122  //print "DB: licTable is:\n"; print_r($licTable) . "\n";
123 
124  /* Select show 'GPL v2-stype', verify */
125  $gplv2URL = makeUrl($this->host, $licTable['\'GPL v2\'-style']);
126  $page = $this->mybrowser->get($gplv2URL);
127  $licFileList = new parseFolderPath($page, $URL);
128  $tblList = $licFileList->parseFolderPath();
129  $tableCnt = count($tblList);
130  print "Checking the number of files based on 'GPL v2'-style\n";
131  $this->assertEqual($tableCnt, 1);
132  }
133 }
Login($User=NULL, $Password=NULL)