Compare commits
6 commits
master
...
developmen
Author | SHA1 | Date | |
---|---|---|---|
90ba4df308 | |||
805b303a04 | |||
83250394b0 | |||
c83f8a4914 | |||
053fe5e75e | |||
7ea1bd219f |
8 changed files with 154 additions and 78 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
composer.lock
|
||||||
|
composer.phar
|
||||||
|
.phpunit.result.cache
|
||||||
|
/vendor/
|
38
.travis.yml
38
.travis.yml
|
@ -1,26 +1,40 @@
|
||||||
language: php
|
language: php
|
||||||
|
dist: bionic
|
||||||
php:
|
sudo: required
|
||||||
- 5.3
|
|
||||||
- 5.4
|
|
||||||
- 5.5
|
|
||||||
- 5.6
|
|
||||||
- hhvm
|
|
||||||
- hhvm-nightly
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
include:
|
||||||
|
- php: 5.3
|
||||||
|
dist: precise
|
||||||
|
- php: 5.4
|
||||||
|
dist: trusty
|
||||||
|
- php: 5.5
|
||||||
|
dist: trusty
|
||||||
|
- php: 5.6
|
||||||
|
dist: trusty
|
||||||
|
- php: 7.0
|
||||||
|
dist: xenial
|
||||||
|
- php: 7.1
|
||||||
|
- php: 7.2
|
||||||
|
- php: 7.3
|
||||||
|
- php: 7.4
|
||||||
|
env: COVERAGE=true
|
||||||
|
- php: nightly
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: hhvm-nightly
|
- php: nightly
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- php --version
|
||||||
- composer install
|
- composer install
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
- cd tests
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit --colors --coverage-clover /home/travis/build/joshtronic/php-projecthoneypot/build/logs/clover.xml .
|
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- php ../vendor/bin/coveralls --config ../.coveralls.yml -v
|
- |
|
||||||
|
if [[ $COVERAGE ]]; then
|
||||||
|
travis_retry php vendor/bin/php-coveralls --config .coveralls.yml -v
|
||||||
|
fi
|
||||||
|
|
1
FUNDING.yml
Normal file
1
FUNDING.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
patreon: joshtronic
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2012-2014 Josh Sherman
|
Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
@ -1,23 +1,33 @@
|
||||||
{
|
{
|
||||||
"name": "joshtronic/php-projecthoneypot",
|
"name": "joshtronic/php-projecthoneypot",
|
||||||
"description": "PHP Wrapper for Project Honey Pot",
|
"description": "PHP Wrapper for Project Honey Pot",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"keywords": ["project", "honey", "pot", "api", "spam", "spammer"],
|
"keywords": [
|
||||||
"homepage": "https://github.com/joshtronic/php-projecthoneypot",
|
"project",
|
||||||
"license": "MIT",
|
"honey",
|
||||||
"authors": [{
|
"pot",
|
||||||
"name": "Josh Sherman",
|
"api",
|
||||||
"email": "hello@joshtronic.com",
|
"spam",
|
||||||
"homepage": "http://joshtronic.com"
|
"spammer"
|
||||||
}],
|
],
|
||||||
"require-dev": {
|
"homepage": "https://github.com/joshtronic/php-projecthoneypot",
|
||||||
"php": ">=5.3.0"
|
"license": "MIT",
|
||||||
},
|
"authors": [{
|
||||||
"require-dev": {
|
"name": "Josh Sherman",
|
||||||
"satooshi/php-coveralls": "dev-master"
|
"email": "hello@joshtronic.com",
|
||||||
},
|
"homepage": "https://joshtronic.com"
|
||||||
"autoload": {
|
}],
|
||||||
"psr-4": {"joshtronic\\": "src/"}
|
"require": {
|
||||||
|
"php": ">=5.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"php-coveralls/php-coveralls": ">=1",
|
||||||
|
"phpunit/phpunit": ">=4"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"joshtronic\\": "src/"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
23
phpunit.xml
Normal file
23
phpunit.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit
|
||||||
|
colors="true"
|
||||||
|
convertErrorsToExceptions="true"
|
||||||
|
convertNoticesToExceptions="true"
|
||||||
|
convertWarningsToExceptions="true"
|
||||||
|
failOnRisky="true"
|
||||||
|
stopOnError="true"
|
||||||
|
stopOnFailure="true"
|
||||||
|
stopOnIncomplete="true"
|
||||||
|
verbose="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Project Honey Pot">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory>./src</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
|
@ -9,7 +9,7 @@
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
* Redistribution of these files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @author Josh Sherman <hello@joshtronic.com>
|
* @author Josh Sherman <hello@joshtronic.com>
|
||||||
* @copyright Copyright 2012-2015, Josh Sherman
|
* @copyright Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018 Josh Sherman
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
* @license http://www.opensource.org/licenses/mit-license.html
|
||||||
* @link https://github.com/joshtronic/php-projecthoneypot
|
* @link https://github.com/joshtronic/php-projecthoneypot
|
||||||
* @link http://www.projecthoneypot.org/httpbl_configure.php
|
* @link http://www.projecthoneypot.org/httpbl_configure.php
|
||||||
|
|
|
@ -2,6 +2,19 @@
|
||||||
|
|
||||||
require_once '../src/ProjectHoneyPot.php';
|
require_once '../src/ProjectHoneyPot.php';
|
||||||
|
|
||||||
|
if (
|
||||||
|
!class_exists('\PHPUnit_Framework_TestCase')
|
||||||
|
&& class_exists('\PHPUnit\Framework\TestCase')
|
||||||
|
) {
|
||||||
|
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
|
||||||
|
}
|
||||||
|
|
||||||
|
$createMock = 'createMock';
|
||||||
|
|
||||||
|
if (version_compare(PHPUnit_Runner_Version::id(), '5.4', '<=')) {
|
||||||
|
$createMock = 'getMock';
|
||||||
|
}
|
||||||
|
|
||||||
class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -25,30 +38,32 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testMissingResults()
|
public function testMissingResults()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue('foo'));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue('foo'));
|
||||||
|
|
||||||
$this->assertFalse($mock->query('1.2.3.4'));
|
$this->assertFalse($mock->query('1.2.3.4'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory0()
|
public function testCategory0()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.0'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.0'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -57,15 +72,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory1()
|
public function testCategory1()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.1'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.1'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -74,15 +90,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory2()
|
public function testCategory2()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.2'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.2'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -91,15 +108,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory3()
|
public function testCategory3()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.3'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.3'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -111,15 +129,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory4()
|
public function testCategory4()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.4'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.4'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -131,15 +150,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory5()
|
public function testCategory5()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.5'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.5'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -151,15 +171,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory6()
|
public function testCategory6()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.6'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.6'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -171,15 +192,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategory7()
|
public function testCategory7()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.7'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.7'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -191,15 +213,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testCategoryDefault()
|
public function testCategoryDefault()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.255'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '127.0.0.255'))));
|
||||||
|
|
||||||
$results = $mock->query('1.2.3.4');
|
$results = $mock->query('1.2.3.4');
|
||||||
|
|
||||||
|
@ -211,15 +234,16 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testWithout127()
|
public function testWithout127()
|
||||||
{
|
{
|
||||||
$mock = $this->getMock(
|
$mock = $this->$createMock(
|
||||||
'joshtronic\ProjectHoneyPot',
|
'joshtronic\ProjectHoneyPot',
|
||||||
array('dns_get_record'),
|
array('dns_get_record'),
|
||||||
array('foobarfoobar')
|
array('foobarfoobar')
|
||||||
);
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
->method('dns_get_record')
|
->expects($this->once())
|
||||||
->will($this->returnValue(array(array('ip' => '1.0.0.0'))));
|
->method('dns_get_record')
|
||||||
|
->will($this->returnValue(array(array('ip' => '1.0.0.0'))));
|
||||||
|
|
||||||
$this->assertFalse($mock->query('1.2.3.4'));
|
$this->assertFalse($mock->query('1.2.3.4'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue