Skip to content

Commit 19f017b

Browse files
committed
Merge from safire-ac-za/simplesamlphp-module-fticks
2 parents 6160b3e + 6445c32 commit 19f017b

9 files changed

Lines changed: 103 additions & 29 deletions

File tree

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage_clover: build/logs/clover.xml
2+
json_path: build/logs/coveralls-upload.json
3+
service_name: travis-ci

.travis.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1+
sudo: required
2+
13
language: php
24

35
php:
46
- 5.6
57
- 7.0
68
- 7.1
79
- 7.2
8-
- hhvm
10+
- 7.3
911

10-
matrix:
11-
allow_failures:
12-
- php: 7.2
13-
- php: hhvm
12+
env:
13+
- SIMPLESAMLPHP_VERSION=1.17.*
1414

1515
before_script:
16-
- composer update
17-
- if [[ "$TRAVIS_PHP_VERSION" == "7.2" ]]; then echo 'error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
16+
- composer require "simplesamlphp/simplesamlphp:${SIMPLESAMLPHP_VERSION}" --no-update
17+
- composer update --no-interaction
18+
- if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then composer require --dev php-coveralls/php-coveralls; fi
19+
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then composer require --dev vimeo/psalm:1.1.9; fi
20+
21+
script:
22+
- bin/check-syntax.sh
23+
- if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then php vendor/phpunit/phpunit/phpunit; else php vendor/phpunit/phpunit/phpunit --no-coverage; fi
24+
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then vendor/bin/psalm; fi
1825

19-
script: php vendor/phpunit/phpunit/phpunit
26+
after_success:
27+
- if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then php vendor/bin/php-coveralls -v; fi
2028

bin/check-syntax.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
PHP='/usr/bin/env php'
4+
RETURN=0
5+
6+
# check PHP files
7+
for FILE in `find config-templates hooks lib templates tests www -name "*.php"`; do
8+
$PHP -l $FILE > /dev/null 2>&1
9+
if [ $? -ne 0 ]; then
10+
echo "Syntax check failed for ${FILE}"
11+
RETURN=`expr ${RETURN} + 1`
12+
fi
13+
done
14+
15+
exit $RETURN

composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@
1010
"homepage": "http://orcid.org/0000-0002-9388-8592"
1111
}
1212
],
13+
"abandoned": "simplesamlphp/simplesamlphp-module-fticks",
14+
"config": {
15+
"preferred-install": {
16+
"simplesamlphp/simplesamlphp": "source",
17+
"*": "dist"
18+
}
19+
},
1320
"require": {
1421
"php": ">=5.6",
1522
"simplesamlphp/composer-module-installer": "~1.1"
1623
},
1724
"require-dev": {
1825
"simplesamlphp/simplesamlphp": ">=1.17",
19-
"phpunit/phpunit": "~4.8"
26+
"phpunit/phpunit": "~5.7"
2027
},
2128
"autoload": {
2229
"psr-4": {
@@ -33,4 +40,3 @@
3340
"source": "https://github.com/simplesamlphp/simplesamlphp-module-fticks"
3441
}
3542
}
36-

lib/Auth/Process/Fticks.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ private function log($msg)
5454
/* local syslog call, avoiding SimpleSAMLphp's wrapping */
5555
case 'local':
5656
case 'syslog':
57-
assert('array_key_exists("processname", $this->logconfig)');
58-
assert('array_key_exists("facility", $this->logconfig)');
57+
assert(array_key_exists("processname", $this->logconfig));
58+
assert(array_key_exists("facility", $this->logconfig));
5959
openlog($this->logconfig['processname'], LOG_PID, $this->logconfig['facility']);
6060
syslog(array_key_exists('priority', $this->logconfig) ? $this->logconfig['priority'] : LOG_INFO, $msg);
6161
break;
6262

6363
/* remote syslog call via UDP */
6464
case 'remote':
65-
assert('array_key_exists("processname", $this->logconfig)');
66-
assert('array_key_exists("facility", $this->logconfig)');
65+
assert(array_key_exists("processname", $this->logconfig));
66+
assert(array_key_exists("facility", $this->logconfig));
6767
/* assemble a syslog message per RFC 5424 */
6868
$rfc5424_message = sprintf(
6969
'<%d>',
@@ -118,7 +118,7 @@ private function generatePNhash(&$state)
118118
{
119119
/* get a user id */
120120
if ($this->userId !== false) {
121-
assert('array_key_exists("Attributes", $state)');
121+
assert(array_key_exists("Attributes", $state));
122122
if (array_key_exists($this->userId, $state['Attributes'])) {
123123
if (is_array($state['Attributes'][$this->userId])) {
124124
$uid = $state['Attributes'][$this->userId][0];
@@ -169,7 +169,7 @@ private function escapeFticks($value)
169169
*/
170170
public function __construct($config, $reserved)
171171
{
172-
assert('is_array($config)');
172+
assert(is_array($config));
173173
parent::__construct($config, $reserved);
174174

175175
if (array_key_exists('federation', $config)) {
@@ -271,11 +271,11 @@ public function __construct($config, $reserved)
271271
*/
272272
public function process(&$state)
273273
{
274-
assert('is_array($state)');
275-
assert('array_key_exists("Destination", $state)');
276-
assert('array_key_exists("entityid", $state["Destination"])');
277-
assert('array_key_exists("Source", $state)');
278-
assert('array_key_exists("entityid", $state["Source"])');
274+
assert(is_array($state));
275+
assert(array_key_exists("Destination", $state));
276+
assert(array_key_exists("entityid", $state["Destination"]));
277+
assert(array_key_exists("Source", $state));
278+
assert(array_key_exists("entityid", $state["Source"]));
279279

280280
$fticks = [];
281281

@@ -319,7 +319,7 @@ public function process(&$state)
319319

320320
/* realm */
321321
if ($this->realm !== false) {
322-
assert('array_key_exists("Attributes", $state)');
322+
assert(array_key_exists("Attributes", $state));
323323
if (array_key_exists($this->realm, $state['Attributes'])) {
324324
if (is_array($state['Attributes'][$this->realm])) {
325325
$fticks['REALM'] = $state['Attributes'][$this->realm][0];

phpunit.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<phpunit bootstrap="tests/bootstrap.php" colors="true">
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
bootstrap="./tests/bootstrap.php">
311
<testsuites>
4-
<testsuite name="The project's test suite">
5-
<directory>tests/</directory>
12+
<testsuite name="Unit Tests">
13+
<directory>./tests/</directory>
614
</testsuite>
715
</testsuites>
816
<filter>
917
<whitelist processUncoveredFilesFromWhitelist="true">
1018
<directory suffix=".php">./lib</directory>
19+
<exclude>
20+
<directory>./vendor/</directory>
21+
<directory>./tests/</directory>
22+
</exclude>
1123
</whitelist>
1224
</filter>
1325
<logging>

psalm.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
name="SimpleSAMLphp module"
4+
useDocblockTypes="true"
5+
totallyTyped="false"
6+
>
7+
<projectFiles>
8+
<directory name="lib" />
9+
<ignoreFiles>
10+
<directory name="vendor" />
11+
</ignoreFiles>
12+
</projectFiles>
13+
14+
<issueHandlers>
15+
<LessSpecificReturnType errorLevel="info" />
16+
17+
<!-- level 3 issues - slightly lazy code writing, but probably low false-negatives -->
18+
<DeprecatedMethod errorLevel="info" />
19+
20+
<MissingClosureReturnType errorLevel="info" />
21+
<MissingReturnType errorLevel="info" />
22+
<MissingPropertyType errorLevel="info" />
23+
<InvalidDocblock errorLevel="info" />
24+
<MisplacedRequiredParam errorLevel="info" />
25+
26+
<PropertyNotSetInConstructor errorLevel="info" />
27+
<MissingConstructor errorLevel="info" />
28+
<MissingClosureParamType errorLevel="info" />
29+
<MissingParamType errorLevel="info" />
30+
<UnusedClass errorLevel="info" />
31+
<PossiblyUnusedMethod errorLevel="info" />
32+
</issueHandlers>
33+
</psalm>

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_once($projectRoot.'/vendor/autoload.php');
44

55
// Symlink module into ssp vendor lib so that templates and urls can resolve correctly
6-
$linkPath = $projectRoot.'/vendor/simplesamlphp/simplesamlphp/modules/consent';
6+
$linkPath = $projectRoot.'/vendor/simplesamlphp/simplesamlphp/modules/fticks';
77
if (file_exists($linkPath) === false) {
88
echo "Linking '$linkPath' to '$projectRoot'\n";
99
symlink($projectRoot, $linkPath);

tests/lib/Auth/Process/FticksTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace SimpleSAML\Test\Module\fticks\Auth\Process;
44

5-
/**
6-
* Test for the core:CardinalitySingle filter.
7-
*/
85
class FticksTest extends \PHPUnit_Framework_TestCase
96
{
107
/** @var array minimal request */

0 commit comments

Comments
 (0)