Compare commits

..

5 commits

Author SHA1 Message Date
5221ca9df6
Merge pull request #3 from open-source-contributions/migrate_github_action
Replace Travis CI with GitHub Actions
2021-05-19 22:40:21 -05:00
0644b94303
Merge pull request #4 from open-source-contributions/issue_#2
Resolves issue #2
2021-05-19 22:34:49 -05:00
peter279k
d96fdc3120 Resolves issue #2 2021-01-04 01:42:44 +08:00
peter279k
da6dd242a0 Replace Travis CI with GitHub Actions 2021-01-04 01:16:24 +08:00
340711b331
docs: add funding 2020-03-02 20:55:28 -06:00
9 changed files with 149 additions and 199 deletions

View file

@ -1 +0,0 @@
service_name: travis-ci

29
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,29 @@
name: Test
on: [push, pull_request]
jobs:
test:
name: Test PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: PHP Version
run: php --version
- name: Composer Version
run: composer --version
- name: Install Dependencies
run: COMPOSER_MEMORY_LIMIT=-1 composer install
- name: Run Tests
run: vendor/bin/phpunit --coverage-clover ./coverage.xml
- name: Upload Coverage
if: ${{ matrix.php-version == '7.4' }}
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml

View file

@ -1,40 +0,0 @@
language: php
dist: bionic
sudo: required
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:
- php: nightly
install:
- php --version
- composer install
before_script:
- mkdir -p build/logs
script:
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
after_success:
- |
if [[ $COVERAGE ]]; then
travis_retry php vendor/bin/php-coveralls --config .coveralls.yml -v
fi

View file

@ -1 +1 @@
patreon: joshtronic
github: joshtronic

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman
Copyright (c) 2012-2014 Josh Sherman
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

View file

@ -1,33 +1,26 @@
{
"name": "joshtronic/php-projecthoneypot",
"description": "PHP Wrapper for Project Honey Pot",
"version": "1.0.1",
"version": "1.0.0",
"type": "library",
"keywords": [
"project",
"honey",
"pot",
"api",
"spam",
"spammer"
],
"keywords": ["project", "honey", "pot", "api", "spam", "spammer"],
"homepage": "https://github.com/joshtronic/php-projecthoneypot",
"license": "MIT",
"authors": [{
"name": "Josh Sherman",
"email": "hello@joshtronic.com",
"homepage": "https://joshtronic.com"
"homepage": "http://joshtronic.com"
}],
"require": {
"php": ">=5.3"
"php": ">=5.3.0"
},
"require-dev": {
"php-coveralls/php-coveralls": ">=1",
"phpunit/phpunit": ">=4"
"phpunit/phpunit": "^4.8.36 || ^9.0"
},
"autoload": {
"psr-4": {
"joshtronic\\": "src/"
}
"psr-4": {"joshtronic\\": "src/"}
},
"autoload-dev": {
"psr-4": {"joshtronic\\Tests\\": "tests/"}
}
}

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
@ -11,7 +12,7 @@
verbose="true"
>
<testsuites>
<testsuite name="Project Honey Pot">
<testsuite name="Project Honeypot">
<directory>tests</directory>
</testsuite>
</testsuites>

View file

@ -9,7 +9,7 @@
* Redistribution of these files must retain the above copyright notice.
*
* @author Josh Sherman <hello@joshtronic.com>
* @copyright Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018 Josh Sherman
* @copyright Copyright 2012-2015, Josh Sherman
* @license http://www.opensource.org/licenses/mit-license.html
* @link https://github.com/joshtronic/php-projecthoneypot
* @link http://www.projecthoneypot.org/httpbl_configure.php
@ -122,7 +122,7 @@ class ProjectHoneyPot
/**
* DNS Get Record
*
* Wrapper method for dns_get_record() to allow fo easy mocking of the
* Wrapper method for dns_get_record() to allow for easy mocking of the
* results in our tests. Takes an already reversed IP address and does a
* DNS lookup for A records against the http:BL API.
*

View file

@ -1,34 +1,22 @@
<?php
namespace joshtronic\Tests;
use joshtronic\ProjectHoneyPot;
use PHPUnit\Framework\TestCase;
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 TestCase
{
/**
* @expectedException Exception
* @expectedExceptionMessage You must specify a valid API key.
*/
public function testInvalidKey()
{
new joshtronic\ProjectHoneyPot('foo');
try {
new ProjectHoneyPot('foo');
} catch (\Exception $e) {
$this->assertSame('You must specify a valid API key.', $e->getMessage());
}
}
public function testInvalidIP()
{
$object = new joshtronic\ProjectHoneyPot('foobarfoobar');
$object = new ProjectHoneyPot('foobarfoobar');
$this->assertEquals(
array('error' => 'Invalid IP address.'),
@ -38,14 +26,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testMissingResults()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue('foo'));
@ -54,14 +40,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory0()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.0'))));
@ -72,14 +56,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory1()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.1'))));
@ -90,14 +72,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory2()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.2'))));
@ -108,14 +88,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory3()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.3'))));
@ -129,14 +107,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory4()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.4'))));
@ -150,14 +126,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory5()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.5'))));
@ -171,14 +145,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory6()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.6'))));
@ -192,14 +164,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategory7()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.7'))));
@ -213,14 +183,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testCategoryDefault()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '127.0.0.255'))));
@ -234,14 +202,12 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
public function testWithout127()
{
$mock = $this->$createMock(
'joshtronic\ProjectHoneyPot',
array('dns_get_record'),
array('foobarfoobar')
);
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
->setConstructorArgs(array('foobarfoobar'))
->setMethods(array('dns_get_record'))
->getMock();
$mock
->expects($this->once())
$mock->expects($this->once())
->method('dns_get_record')
->will($this->returnValue(array(array('ip' => '1.0.0.0'))));
@ -251,9 +217,11 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase
// Doesn't serve much purpose aside from helping achieve 100% coverage
public function testDnsGetRecord()
{
$object = new joshtronic\ProjectHoneyPot('foobarfoobar');
$object = new ProjectHoneyPot('foobarfoobar');
$object->dns_get_record('1.2.3.4');
$result = $object->dns_get_record('1.2.3.4');
$this->assertEquals(array(), $result);
}
}