18 $TEST_RESULT_PATH =
"./test_result";
29 public $WGET_PATH =
"";
38 protected function setUp() : void {
43 $cwd = dirname(__DIR__, 4).
'/build/src/wget_agent';
45 $this->testDb =
new TestPgDb(
"fosswgetagenttest");
46 $db_conf = $this->testDb->getFossSysConf();
48 $this->testInstaller->init();
49 $this->testInstaller->cpRepo();
50 $this->testInstaller->install($cwd);
51 $WGET_PATH = $cwd .
'/agent/wget_agent';
53 if(file_exists($WGET_PATH))
55 $usage =
"Usage: $WGET_PATH [options] [OBJ]";
59 $this->assertFileExists($WGET_PATH,
60 $message =
'FATAL: cannot find executable file, stop testing\n');
63 $WGET_PATH .=
" -C -c $db_conf";
64 $last = exec(
"$WGET_PATH -h 2>&1", $out, $rtn);
65 $this->assertEquals($usage, $out[0]);
80 global $TEST_RESULT_PATH;
84 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/3.0.0/fedora/20/x86_64/ -A rpm -R fossology-common-3.0.0-1.fc20.x86_64.rpm,fossology-debuginfo-3.0.0-1.fc20.x86_64.rpm,fossology-web-3.0.0-1.fc20.x86_64.rpm,fossology-3.0.0-1.fc20.src.rpm -d $TEST_RESULT_PATH";
86 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/3.0.0/fedora/20/x86_64/fossology-3.0.0-1.fc20.x86_64.rpm");
87 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/3.0.0/fedora/20/x86_64/fossology-wgetagent-3.0.0-1.fc20.x86_64.rpm");
88 $this->assertFileNotExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/3.0.0/fedora/20/x86_64/fossology-debuginfo-3.0.0-1.fc20.x86_64.rpm");
103 global $TEST_RESULT_PATH;
107 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/3.0.0/debian/7.0/ -A deb -R fossology-* -d $TEST_RESULT_PATH";
110 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/3.0.0/debian/7.0/fossology_3.0.0-1_i386.deb");
111 $this->assertFileNotExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/3.0.0/debian/7.0/fossology-ununpack_3.0.0-1_amd64.deb");
126 global $TEST_RESULT_PATH;
130 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/ -A rpm -R fossology-2.0.0-1.fc15.src.rpm,fossology-common-2.0.0-1.fc15.x86_64.rpm -l 1 -d $TEST_RESULT_PATH";
133 $this->assertFileNotExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386/fossology-common-2.0.0-1.fc15.x86_64.rpm");
134 $this->assertFileNotExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/x86_64/fossology-common-2.0.0-1.fc15.x86_64.rpm");
135 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386");
136 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/x86_64");
148 global $TEST_RESULT_PATH;
152 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386/fossology-db-2.0.0-1.fc15.i386.rpm";
155 $this->assertFileExists(
"mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386/fossology-db-2.0.0-1.fc15.i386.rpm");
156 exec(
"/bin/rm -rf 'mirrors.kernel.org'");
173 $command =
"$WGET_PATH 'http://www.fossology.org/~vincent/test/test%20dir(special)/WINKERS%20-%20Final_tcm19-16386.doc' -d './test result(special)'";
176 $this->assertFileExists(
"test result(special)/www.fossology.org/~vincent/test/test dir(special)/WINKERS - Final_tcm19-16386.doc");
177 exec(
"/bin/rm -rf 'test result(special)'");
190 global $TEST_RESULT_PATH;
194 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386/ -A fossology* -R fossology-2.0.0-1.fc15.i386.rpm,fossology-2.0.0-1.fc15.src.rpm -d $TEST_RESULT_PATH -l 2";
197 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386/fossology-pkgagent-2.0.0-1.fc15.i386.rpm");
198 $this->assertFileNotExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Fedora/15/i386/fossology-2.0.0-1.fc15.src.rpm");
211 global $TEST_RESULT_PATH;
215 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/2.0.0/Debian/squeeze/6.0/ -A fossology-scheduler_2.0.0* -R gz,fossology-scheduler_2.0.0-1_i386* -d $TEST_RESULT_PATH -l 1";
218 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Debian/squeeze/6.0/fossology-scheduler_2.0.0-1_amd64.deb");
219 $this->assertFileNotExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Debian/squeeze/6.0/fossology-scheduler_2.0.0-1_i386.deb");
229 $foss_conf = $db_conf.
"/fossology.conf";
230 exec(
"sudo sed 's/.$proxy_type.*=.*/$proxy_type=$porxy/' $foss_conf >/tmp/fossology.conf");
231 exec(
"sudo mv /tmp/fossology.conf $foss_conf");
243 global $TEST_RESULT_PATH;
248 $command =
"$WGET_PATH ftp://releases.ubuntu.com/releases/trusty/SHA1SUMS -d $TEST_RESULT_PATH";
250 $this->assertFileExists(
"$TEST_RESULT_PATH/releases.ubuntu.com/releases/trusty/SHA1SUMS");
262 global $TEST_RESULT_PATH;
266 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/2.0.0/Debian/squeeze/6.0/fossology-mimetype_2.0.0-1_amd64.deb -d $TEST_RESULT_PATH";
268 $this->assertFileExists(
"$TEST_RESULT_PATH/mirrors.kernel.org/fossology/releases/2.0.0/Debian/squeeze/6.0/fossology-mimetype_2.0.0-1_amd64.deb");
272 $command =
"$WGET_PATH https://mirrors.kernel.org/fossology/releases/2.0.0/Debian/squeeze/6.0/fossology-mimetype_2.0.0-1_amd64.deb -d $TEST_RESULT_PATH";
286 global $TEST_RESULT_PATH;
291 $command =
"$WGET_PATH https://www.google.com/images/srpr/nav_logo80.png -l 1 -d $TEST_RESULT_PATH";
293 $this->assertFileExists(
"$TEST_RESULT_PATH/www.google.com/images/srpr/nav_logo80.png");
301 if (!is_callable(
'pg_connect')) {
304 $this->testDb->fullDestruct();
305 $this->testDb =
null;
testDownloadDirHasChildDirLevel0()
download one dir(one url)
testDownloadAcceptRejectType1()
download one dir(one url)
change_proxy($proxy_type, $porxy)
Change proxy to test.
testtDownloadAcceptRejectType2()
download one dir(one url)
test_proxy_http()
Test proxy http and no proxy.
test_proxy_https()
Test proxy https.
testDownloadDirHasChildDirLevel1()
Download one dir(one url)
testDownloadDirCurrentDirLevel0()
Download one file(one url)
test_proxy_ftp()
Test proxy ftp.
testDownloadDirHasNoChildDirLevel0()
Download one dir(one url)
testDownloadURLDesAbnormal()
download one file(one url)
if(!preg_match("/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid']))
get monk license list of one specified uploadtree_id