Skip to content

Commit

Permalink
Update tools/ to 1.0.3, add Makefile
Browse files Browse the repository at this point in the history
run integration and security tests in Travis

no need to disable security twice

use submodule

remove tools/ from composer.json

Add security-tests suite

Modify test target
  • Loading branch information
Luke Bakken committed Oct 25, 2016
1 parent 2542752 commit 067e1d0
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 43 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ vendor
composer.lock

# ignore mac files
.DS_Store
.DS_Store/

# ignore generated docs
docs

# ignore composer.phar file
composer
composer.phar
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ before_script:
- composer self-update
- composer install --prefer-source
- sudo ./tools/travis-ci/riak-install -d "$RIAK_DOWNLOAD_URL"
- sudo ./tools/devrel/riak-cluster-config "$(which riak-admin)" 8098 false false
- sudo ./tools/setup-riak -s
script:
- sudo riak-admin security disable
- make test
- sudo riak-admin security enable
- make security-test
notifications:
slack:
secure: ZtgcjTxhTxrzWW6MIHLRtucW/BMm42RKS3nGRtSfgER9rx7oJ0Y9gOYkh1FM0GsM7Z11Q/iDhWs/8WTccAV0PrMZ6KHaq54wGmfYyqwPM4YreUwQ87PnOW4wZbl0TJTeWutasEwZvnVJ8VEyyQcS2PHt0zlsENn0XWvobvaZ+FM=
script: "./vendor/bin/phpunit --coverage-text"
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.PHONY: all unit-test integration-test security-test
.PHONY: install-composer install-deps help

all: test

test: unit-test integration-test

unit-test:
@php ./vendor/bin/phpunit --testsuite=unit-tests

integration-test:
@php ./vendor/bin/phpunit --testsuite=functional-tests

security-test:
@php ./vendor/bin/phpunit --testsuite=security-tests

install-deps:
@./composer install

install-composer:
@rm -f ./composer.phar ./composer
@php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
@php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
@php ./composer-setup.php --filename=composer
@rm -f ./composer-setup.php

help:
@echo ''
@echo ' Targets:'
@echo '-----------------------------------------------------------------'
@echo ' all - Run all tests '
@echo ' install-deps - Install required dependencies '
@echo ' install-composer - Installs composer '
@echo ' test - Run unit & integration tests '
@echo ' unit-test - Run unit tests '
@echo ' integration-test - Run integration tests '
@echo ' security-test - Run security tests '
@echo '-----------------------------------------------------------------'
@echo ''
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ Thank you for being part of the community! We love you for it.

* Author: Christopher Mancini (https://github.com/christophermancini)
* Author: Alex Moore (https://github.com/alexmoore)
* Author: Luke Bakken (https://github.com/lukebakken)

Copyright (c) 2015 Basho Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"). For more details, see [License](License).
16 changes: 1 addition & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,13 @@
"support": {
"issues": "https://github.com/basho/riak-php-client/issues"
},
"repositories": [
{
"type": "package",
"package": {
"name": "basho/tools",
"version": "1.0.0",
"dist": {
"url": "https://github.com/basho/riak-client-tools/archive/master.zip",
"type": "zip"
}
}
}
],
"require": {
"php": ">=5.4",
"ext-json": "*",
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "4.8.*",
"apigen/apigen": "4.1.*",
"basho/tools": "1.0.0"
"apigen/apigen": "4.1.*"
}
}
9 changes: 6 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

<phpunit colors="true">
<testsuites>
<testsuite name="Unit Tests">
<testsuite name="unit-tests">
<directory>tests/unit</directory>
</testsuite>
<testsuite name="Functional Tests">
<testsuite name="functional-tests">
<directory>tests/functional</directory>
<exclude>tests/functional/SecurityFeaturesTest.php</exclude>
<exclude>tests/functional/TimeSeriesOperationsTest.php</exclude>
</testsuite>
<testsuite name="Scenario Tests">
<testsuite name="security-tests">
<file>tests/functional/SecurityFeaturesTest.php</file>
</testsuite>
<testsuite name="scenario-tests">
<directory>tests/scenario</directory>
<exclude>tests/scenario/InternalServerErrorTest.php</exclude>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
const TEST_NODE_HOST = 'riak-test';
const TEST_NODE_PORT = 8087;
const TEST_NODE_HTTP_PORT = 8098;
const TEST_NODE_SECURE_PORT = 10011;
const TEST_NODE_SECURE_PORT = 8498;

const BITCASK_BUCKET_TYPE = 'bitcask';
const COUNTER_BUCKET_TYPE = 'counters';
Expand Down
18 changes: 2 additions & 16 deletions tests/functional/SecurityFeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,14 @@
*/
class SecurityFeaturesTest extends TestCase
{
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();

shell_exec('sudo riak-admin security enable');
}

public static function tearDownAfterClass()
{
shell_exec('sudo riak-admin security disable');

parent::tearDownAfterClass();
}

public function testUnauthorized()
{
$nodes = [
(new Riak\Node\Builder())
->atHost(static::getTestHost())
->onPort(static::getTestSecurePort())
->usingPasswordAuthentication('unauthorizeduser', 'hispassword')
->withCertificateAuthorityFile(getcwd() . '/vendor/basho/tools/test-ca/certs/cacert.pem')
->withCertificateAuthorityFile(getcwd() . '/tools/test-ca/certs/cacert.pem')
->build()
];

Expand All @@ -58,7 +44,7 @@ public function testPasswordAuth()
->atHost(static::getTestHost())
->onPort(static::getTestSecurePort())
->usingPasswordAuthentication('riakpass', 'Test1234')
->withCertificateAuthorityFile(getcwd() . '/vendor/basho/tools/test-ca/certs/cacert.pem')
->withCertificateAuthorityFile(getcwd() . '/tools/test-ca/certs/cacert.pem')
->build()
];

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Riak/Node/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ public function testUsingAuth()
->atHost(static::getTestHost())
->onPort(static::getTestSecurePort())
->usingPasswordAuthentication('unauthorizeduser', 'hispassword')
->withCertificateAuthorityFile(getcwd() . '/vendor/basho/tools/test-ca/certs/cacert.pem')
->withCertificateAuthorityFile(getcwd() . '/tools/test-ca/certs/cacert.pem')
->build();

$riak = new Riak([$node]);

$this->assertEquals('unauthorizeduser', $node->getUserName());
$this->assertEquals('hispassword', $node->getPassword());
$this->assertEquals(getcwd() . '/vendor/basho/tools/test-ca/certs/cacert.pem', $node->getCaFile());
$this->assertEquals(getcwd() . '/tools/test-ca/certs/cacert.pem', $node->getCaFile());
$this->assertInstanceOf('Basho\Riak', $riak);
}
}

0 comments on commit 067e1d0

Please sign in to comment.