public function testOutputFilter() { $noh = new NativeOutputHandlersTestCore(); $hasher = new Hasher(); $hasher->addDistinguishVariable("testOutputFilter" . rand()); $cache = new FileCache(array(CacheParams::PARAM_TTL => 1000)); $outputFilter = new OutputFilter(); $outputFilter->addBlacklistCondition("/Needle/"); $poc = new Poc(array(PocParams::PARAM_CACHE => $cache, Poc::PARAM_TOOLSET => new HttpCapture(new TestOutput()), PocParams::PARAM_HASHER => $hasher)); $poc->addPlugin($outputFilter); $noh->pocBurner($poc, rand() . "Needle" . rand()); //$this->assertContains('because', $noh->getOutput()); }
/** * @dataProvider dataProviderForTests */ public function testminifyHtmlWithPoc($input, $expectedOutput) { $noh = new NativeOutputHandlersTestCore(); $hasher = new Hasher(); $hasher->addDistinguishVariable("TestMinify" . rand()); $cache = new FileCache(array(CacheParams::PARAM_TTL => 1000)); $outputHandler = new TestOutput(); $poc = new Poc(array(Poc::PARAM_CACHE => $cache, Poc::PARAM_TOOLSET => new HttpCapture(new TestOutput()), PocParams::PARAM_HASHER => $hasher)); $poc->addPlugin(new MinifyHtmlOutput()); $noh->pocBurner($poc, $input); $output = $noh->getOutput(); $this->assertEquals($expectedOutput, $output); }
public function testCompression() { $noh = new NativeOutputHandlersTestCore(); $hasher = new Hasher(); $hasher->addDistinguishVariable("TestCompress" . rand()); $cache = new FileCache(); $outputHandler = new TestOutput(); $outputHandler->header('Accept-Encoding:' . Compress::COMPRESSION_GZIP); // var_dump($outputHandler->getallheaders()); $poc = new Poc(array(Poc::PARAM_CACHE => $cache, Poc::PARAM_TOOLSET => new HttpCapture($outputHandler), PocParams::PARAM_HASHER => $hasher)); $poc->addPlugin(new Compress()); $input1 = "absdefg"; $noh->pocBurner($poc, $input1); $output1 = $noh->getOutput(); $header1 = $outputHandler->getallheaders(); $input2 = "habsdefgh"; $noh->pocBurner($poc, $input2); $output2 = $noh->getOutput(); $header2 = $outputHandler->getallheaders(); // die("BBBBBBBBBBBB".print_r($outputHandler->getallheaders())."AAAAAAAAAAAAAAAA"); $this->assertEquals($output1, $output2); $this->assertEquals(\gzdecode($output1), $input1); // $this->assertEquals($header1, $header2); }
public function testPocWithDifferentHashers() { $testAdapter = new NativeOutputHandlersTestCore(); $objects = new \Pimple(); $ttl = self::$TTL; $objects['c1'] = function () use($ttl) { return new FileCache(array(CacheParams::PARAM_TTL => $ttl)); }; $objects['c2'] = function () use($ttl) { return new FileCache(array(CacheParams::PARAM_TTL => $ttl)); }; $cacheHandler1 = $objects['c1']; $hasher1 = new Hasher(); $hasher1->addDistinguishVariable("a" . rand()); $poc1 = new Poc(array(Poc::PARAM_HASHER => $hasher1, Poc::PARAM_TOOLSET => new HttpCapture(new TestOutput()))); $testAdapter->pocBurner($poc1, self::NEEDLE); $output1 = $testAdapter->getOutput(); $hasher2 = new Hasher(); $hasher2->addDistinguishVariable("b" . rand()); $poc2 = new Poc(array(Poc::PARAM_HASHER => $hasher2, Poc::PARAM_TOOLSET => new HttpCapture(new TestOutput()))); $testAdapter->pocBurner($poc2, self::TESTSTRING2); $output2 = $testAdapter->getOutput(); $this->assertTrue($output1 != $output2); }