Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for Php 8.1 #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . "/src")
->in(__DIR__ . "/tests");
$config = new PhpCsFixer\Config();

return PhpCsFixer\Config::create()
return $config
->setRules([
'@PSR2' => true,
'@Symfony' => true,
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
}
},
"require": {
"php": ">=7.1",
"php": ">=8.1",
"paragonie/random_compat": "^1.0|^2.0|9.99.99",
"psr/http-message": "^1.0"
"psr/http-message": "^1.0",
"nyholm/psr7": "^1.5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2",
"friendsofphp/php-cs-fixer": "^v3.13.0",
"guzzlehttp/psr7": "^1.2",
"phpunit/phpunit": "~7.0",
"symfony/http-foundation": "~2.8|~3.0",
"symfony/psr-http-message-bridge": "^1.0.2",
"zendframework/zend-diactoros": "^1.1"
"phpunit/phpunit": "^9.5.26",
"symfony/http-foundation": "^v6.1.8",
"symfony/psr-http-message-bridge": "^v2.1.3",
"laminas/laminas-diactoros": "^2.22.0"
}
}
25 changes: 6 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnError="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="HTTP Signatures Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion tests/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ContextTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->noDigestContext = new Context([
'keys' => ['pda' => 'secret'],
Expand Down
4 changes: 1 addition & 3 deletions tests/KeyStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ public function testFetchSuccess()
$this->assertEquals('secret', $key->secret);
}

/**
* @expectedException \HttpSignatures\Exception
*/
public function testFetchFail()
{
$this->expectException(\HttpSignatures\Exception::class);
$ks = new KeyStore(['id' => 'secret']);
$key = $ks->fetch('nope');
}
Expand Down
8 changes: 2 additions & 6 deletions tests/SignatureParametersParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,16 @@ public function testParseReturnsExpectedAssociativeArray()
);
}

/**
* @expectedException \HttpSignatures\SignatureParseException
*/
public function testParseThrowsTypedException()
{
$this->expectException(\HttpSignatures\SignatureParseException::class);
$parser = new SignatureParametersParser('nope');
$parser->parse();
}

/**
* @expectedException \HttpSignatures\SignatureParseException
*/
public function testParseExceptionForMissingComponents()
{
$this->expectException(\HttpSignatures\SignatureParseException::class);
$parser = new SignatureParametersParser(
'keyId="example",algorithm="hmac-sha1",headers="(request-target) date"'
);
Expand Down
15 changes: 6 additions & 9 deletions tests/SigningStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use GuzzleHttp\Psr7\Request;
use HttpSignatures\HeaderList;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use HttpSignatures\SigningString;
use Nyholm\Psr7\Factory\Psr17Factory;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -66,11 +67,9 @@ public function testSigningStringWithUnorderedQueryParametersSymfonyRequest()
);
}

/**
* @expectedException \HttpSignatures\Exception
*/
public function testSigningStringErrorForMissingHeader()
{
$this->expectException(\HttpSignatures\Exception::class);
$headerList = new HeaderList(['nope']);
$ss = new SigningString($headerList, $this->message('/'));
$ss->string();
Expand All @@ -85,10 +84,8 @@ private function symfonyMessage($path)
{
$symfonyRequest = SymfonyRequest::create($path, 'GET');
$symfonyRequest->headers->replace(['date' => 'Mon, 28 Jul 2014 15:39:13 -0700']);

$psr7Factory = new DiactorosFactory();
$psrRequest = $psr7Factory->createRequest($symfonyRequest)->withRequestTarget($symfonyRequest->getRequestUri());

return $psrRequest;
$psr17Factory = new Psr17Factory;
$psr7Factory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
return $psr7Factory->createRequest($symfonyRequest)->withRequestTarget($symfonyRequest->getRequestUri());
}
}
2 changes: 1 addition & 1 deletion tests/VerifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class VerifierTest extends TestCase
*/
private $message;

protected function setUp()
protected function setUp(): void
{
$this->setUpVerifier();
$this->setUpValidMessage();
Expand Down