FOSSology  4.4.0
Open Source License Compliance by Open Source Software
foss_ui.php
1 #!/usr/bin/php
2 
3 <?php
4 /*
5  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
6 
7  SPDX-License-Identifier: GPL-2.0-only
8 */
9 /*
10  * first try at testing web interface...
11  */
12 
13 class TestRepoLogin extends WebTestCase{
14 
15  function testLogin(){
16  $this->useProxy('http://web-proxy.fc.hp.com:8088', 'web-proxy', '');
17  $this->assertTrue($this->get('http://repo.fossology.org/'));
18  $this->assertAuthentication('Basic');
19  $this->authenticate('fossology', 'xxxxxxxx');
20  $this->assertText('Software Repository Viewer');
21  }
22 }
23 class TestAboutMenu extends WebTestCase {
24 
25  function testMenuAbout(){
26  $this->useProxy('http://web-proxy.fc.hp.com:8088', 'web-proxy', '');
27  $this->assertTrue($this->get('http://repo.fossology.org/'));
28  $this->assertAuthentication('Basic');
29  $this->authenticate('fossology', 'xxxxxxx');
30  $this->assertText('Software Repository');
31 
32  $this->click('About');
33  $this->assertText('FOSSology');
34  }
35 }
36 /*
37  * NOTE: the url is for the internal machines... fix this!
38  * they fail when run from home, can't seem to get a url to work on doc....
39  * They work when run from sirius.
40  */
41 class TestToolsMenu extends WebTestCase {
42 
43  function testMenuTools(){
44  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
45  //$this->assertAuthentication('Basic');
46  //$this->authenticate('fossology', 'xxxxxxx');
47  $this->assertText('Software Repository');
48 
49  $this->click('Tools');
50  $this->clicklink('Folders (refresh)', 0);
51  }
52 }
53 
54 class TestOrganizeFolders extends WebTestCase {
55 
56  function testFolderCreate(){
57  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
58  //$this->assertAuthentication('Basic');
59  //$this->authenticate('fossology', 'xxxxxxxx');
60  $this->assertText('Software Repository');
61 
62  $this->click('Organize');
63  $this->click('Folders');
64  $this->click('Create');
65  $this->assertText('Create a new');
66  $this->assertField('parentid', '1');
67  }
68  /*
69  * testFolderMove assumes that folder created in testFolderCreate above
70  * exists.
71  */
72  function testFolderMove(){
73  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
74  //$this->assertAuthentication('Basic');
75  //$this->authenticate('fossology', 'xxxxxxxx');
76  $this->assertText('Software Repository');
77 
78  $this->click('Organize');
79  $this->click('Folders');
80  $this->click('Move');
81  $this->assertText('Move Folder');
82  }
83 
84  function createfolder($name) {
85  // Web page load
86  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
87  //$this->assertAuthentication('Basic');
88  //$this->authenticate('fossology', 'xxxxxxxx');
89  $this->assertText('Software Repository');
90  // Navigate test (plugin is there)
91  $this->click('Organize');
92  $this->click('Folders');
93  $this->setField('parentid', 'Software Repository');
94  $this->setField('newname', '$name');
95  $this->setField('description', 'edit properties Test folder');
96  $this->clickSubmit('Create!');
97  }
98 
99  function testEditProperties(){
100  // Web page load
101  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
102  //$this->assertAuthentication('Basic');
103  //$this->authenticate('fossology', 'xxxxxxxx');
104  $this->assertText('Software Repository');
105  // Navigate test (plugin is there)
106  $this->click('Organize');
107  $this->click('Folders');
108  $this->click('Edit Properties');
109  $this->assertText('Edit Folder Properties');
110  // functional test name change, no description changed. (can't verify
111  // on the screen)
112  $this->setField('parentid', 'Software Repository');
113  $this->createfolder('epTfolder');
114  $this->setField('parentid', 'epTfolder');
115  $this->setField('newname', 'EditPropTest');
116  $this->clickSubmit('Edit!');
117  // functional test, don't change name, change description.
118  // Note, relys on the name change in the test case above.
119  $this->setField('parentid', 'EditPropTest');
120  $this->setField('description', 'Changed description for EditPropTest');
121  $this->clickSubmit('Edit!');
122  // This tests that the error text is shown (how do you tell if it's red?)
123  // and that the pulldown is reset to the root folder
124  // doesn't work that way! We are seeing the css sheet hmmmm
125  $this->setField('parentid', 'Software Repository');
126  $this->setField('description', 'Should see Please Select... in red');
127  $this->clickSubmit('Edit!');
128  // This doesn't work, need to investigate.
129  //$this->assertText('Please Select');
130  $this->setField('parentid', 'Software Repository');
131  }
132 
133 }
134 
135 class TestCreateFolder extends WebTestCase {
136 
137  function testFuncCreateFolder(){
138  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
139  //$this->assertAuthentication('Basic');
140  //$this->authenticate('fossology', 'xxxxxxxx');
141  $this->assertText('Software Repository');
142 
143  $this->click('Organize');
144  $this->click('Folders');
145  $this->click('Create');
146  $this->assertTrue($this->setField('parentid', 'Software Repository'));
147  // Generate a random number so names will not collide with multiple
148  // test runs.
149  $tail = random_int(0, getrandmax());
150  $folder_name = 'TestFolder' . "$tail";
151  $this->setField('newname', $folder_name);
152  $this->clickSubmit('Create!');
153  // Wonder why we don't have to click the OK button for the test to
154  // pass.
155  //$this->click('OK');
156  // The assertion below will try to set the pull down to the just created
157  // folder. If the folder did not get created, it will fail.
158  $this->click('Organize');
159  $this->click('Folders');
160  $this->click('Create');
161  echo "folder name:$folder_name\n";
162  $this->setField('parentid', $folder_name);
163  }
164 }