Skip to content

Commit

Permalink
Merge 142631b into b5e37b0
Browse files Browse the repository at this point in the history
  • Loading branch information
william-suppo committed Apr 7, 2021
2 parents b5e37b0 + 142631b commit 519f40c
Show file tree
Hide file tree
Showing 55 changed files with 308 additions and 580 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -6,6 +6,7 @@ php:
- 7.2
- 7.3
- 7.4
- 8.0

before_install:
- composer self-update
Expand All @@ -19,8 +20,8 @@ install:

script:
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then php php-cs-fixer.phar fix --dry-run -v; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [ "$TRAVIS_PHP_VERSION" != "7.2" ]; then bin/phpunit; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [ "$TRAVIS_PHP_VERSION" != "7.2" ]; then vendor/bin/phpunit; fi

after_script:
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then php php-coveralls.phar -v; fi
3 changes: 3 additions & 0 deletions CHANGELOG-2.0.md
Expand Up @@ -6,3 +6,6 @@ CHANGELOG for 2.0.x

2.0.1 (2021-04-07)
* [CodeStyle] Clean code with php-cs-fixer

2.1.0 (2021-04-07)
* [NewFeature] Update PHPUnit 8.4+
13 changes: 7 additions & 6 deletions composer.json
Expand Up @@ -20,10 +20,14 @@
},
"autoload": {
"psr-0": {
"LightSaml\\Tests\\": "tests/",
"LightSaml\\": "src/"
}
},
"autoload-dev": {
"psr-0": {
"LightSaml\\Tests\\": "tests/"
}
},
"require": {
"php": ">=7.2.5",
"robrichards/xmlseclibs": "~2.0|~3.0|~4.0",
Expand All @@ -34,16 +38,13 @@
"symfony/dom-crawler": "~5.0",
"symfony/css-selector": "~5.0",
"pimple/pimple": "~3.0",
"phpunit/phpunit": "~5.7|~7",
"monolog/monolog": "~1.3"
"phpunit/phpunit": "^8.4",
"monolog/monolog": "^2.0.0"
},
"suggest": {
"lightsaml/symfony-bridge": "Symfony 2 build container bridge",
"lightsaml/sp-bundle": "Symfony 2 SP security bundle"
},
"config": {
"bin-dir": "bin"
},
"prefer-stable": true,
"minimum-stability": "stable"
}
16 changes: 16 additions & 0 deletions phpunit.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
40 changes: 0 additions & 40 deletions phpunit.xml.dist

This file was deleted.

Expand Up @@ -28,13 +28,11 @@ public function test_do_execute_called_with_assertion_context()
$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Expected AssertionContext
*/
public function test_throws_context_exception_for_non_assertion_context()
{
$action = $this->getAbstractAssertionActionMock([$this->getLoggerMock()]);
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$this->expectExceptionMessage("Expected AssertionContext");
$action->execute($this->getMockBuilder(ContextInterface::class)->getMock());
}

Expand Down
Expand Up @@ -16,12 +16,9 @@ public function test_constructs_with_logger_and_name_id_format()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Assertion element must have an issuer element
*/
public function test_throws_context_exception_when_assertion_has_no_issuer()
{

$action = new AssertionIssuerFormatValidatorAction(
$loggerMock = $this->getLoggerMock(),
$expectedIssuerFormat = SamlConstants::NAME_ID_FORMAT_EMAIL
Expand All @@ -33,13 +30,12 @@ public function test_throws_context_exception_when_assertion_has_no_issuer()
->method('error')
->with('Assertion element must have an issuer element', $this->isType('array'));

$this->expectExceptionMessage("Assertion element must have an issuer element");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Response Issuer Format if set must have value 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' but it was 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
*/
public function test_throws_context_exception_when_assertion_issuer_format_does_not_matches_expected_format()
{
$action = new AssertionIssuerFormatValidatorAction(
Expand All @@ -57,6 +53,9 @@ public function test_throws_context_exception_when_assertion_issuer_format_does_
$this->isType('array')
);

$this->expectExceptionMessage("Response Issuer Format if set must have value 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' but it was 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

Expand Down
Expand Up @@ -34,10 +34,6 @@ public function test_does_nothing_if_assertion_has_no_subject()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Unknown InResponseTo '123123123'
*/
public function test_throws_context_exception_on_unknown_in_response_to()
{
$action = new InResponseToValidatorAction(
Expand All @@ -51,6 +47,9 @@ public function test_throws_context_exception_on_unknown_in_response_to()
$subjectConfirmation->setSubjectConfirmationData(new SubjectConfirmationData());
$subjectConfirmation->getSubjectConfirmationData()->setInResponseTo('123123123');

$this->expectExceptionMessage("Unknown InResponseTo '123123123'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

Expand Down
Expand Up @@ -15,10 +15,6 @@ public function test_constructs_with_logger_and_entity_descriptor_store()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Assertion element must have an issuer element
*/
public function test_throws_context_exception_when_assertion_has_no_issuer()
{
$action = new KnownAssertionIssuerAction(
Expand All @@ -32,15 +28,15 @@ public function test_throws_context_exception_when_assertion_has_no_issuer()
->method('error')
->with('Assertion element must have an issuer element');

$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$this->expectExceptionMessage("Assertion element must have an issuer element");

$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Unknown issuer 'http://issuer.com'
*/
public function test_throws_context_exception_on_unknown_issuer()
{

$action = new KnownAssertionIssuerAction(
$loggerMock = $this->getLoggerMock(),
$entityDescriptorStoreMock = $this->getEntityDescriptorStoreMock()
Expand All @@ -58,6 +54,9 @@ public function test_throws_context_exception_on_unknown_issuer()
->method('error')
->with("Unknown issuer 'http://issuer.com'");

$this->expectExceptionMessage("Unknown issuer 'http://issuer.com'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

Expand Down
Expand Up @@ -51,10 +51,6 @@ public function test_does_nothing_when_assertion_has_authn_statement_but_no_bear
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer SubjectConfirmation must contain Recipient attribute
*/
public function test_throws_context_exception_when_bearer_confirmation_has_no_recipient()
{
$action = new RecipientValidatorAction($loggerMock = $this->getLoggerMock(), $this->getEndpointResolverMock());
Expand All @@ -69,15 +65,16 @@ public function test_throws_context_exception_when_bearer_confirmation_has_no_re
->method('error')
->with('Bearer SubjectConfirmation must contain Recipient attribute');

$this->expectExceptionMessage("Bearer SubjectConfirmation must contain Recipient attribute");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Recipient 'http://recipient.com' does not match SP descriptor
*/
public function test_throws_context_exception_when_recipient_does_not_match_any_own_acs_service_location()
{
$this->expectExceptionMessage("Recipient 'http://recipient.com' does not match SP descriptor");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$action = new RecipientValidatorAction(
$loggerMock = $this->getLoggerMock(),
$endpointResolver = $this->getEndpointResolverMock()
Expand Down
Expand Up @@ -31,10 +31,6 @@ public function test_does_nothing_if_assertion_has_no_bearer_subject()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer Assertion must have ID attribute
*/
public function test_throws_context_exception_when_bearer_assertion_has_no_id()
{
$action = new RepeatedIdValidatorAction(
Expand All @@ -52,13 +48,12 @@ public function test_throws_context_exception_when_bearer_assertion_has_no_id()
->method('error')
->with('Bearer Assertion must have ID attribute', $this->isType('array'));

$this->expectExceptionMessage("Bearer Assertion must have ID attribute");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer Assertion must have Issuer element
*/
public function test_throws_context_exception_when_bearer_assertion_has_no_issuer()
{
$action = new RepeatedIdValidatorAction(
Expand All @@ -77,13 +72,12 @@ public function test_throws_context_exception_when_bearer_assertion_has_no_issue
->method('error')
->with('Bearer Assertion must have Issuer element', $this->isType('array'));

$this->expectExceptionMessage("Bearer Assertion must have Issuer element");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Repeated assertion id '123' of issuer 'http://issuer.com'
*/
public function test_throws_context_exception_for_known_assertion_id()
{
$action = new RepeatedIdValidatorAction(
Expand All @@ -108,15 +102,15 @@ public function test_throws_context_exception_for_known_assertion_id()
->method('error')
->with("Repeated assertion id '123' of issuer 'http://issuer.com'", $this->isType('array'));

$this->expectExceptionMessage("Repeated assertion id '123' of issuer 'http://issuer.com'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer SubjectConfirmation must have SubjectConfirmationData element
*/
public function test_throws_context_exception_if_no_subject_confirmation_data()
{

$action = new RepeatedIdValidatorAction(
$loggerMock = $this->getLoggerMock(),
$idStoreMock = $this->getIdStoreMock()
Expand All @@ -139,15 +133,16 @@ public function test_throws_context_exception_if_no_subject_confirmation_data()
->method('error')
->with('Bearer SubjectConfirmation must have SubjectConfirmationData element', $this->isType('array'));

$this->expectExceptionMessage("Bearer SubjectConfirmation must have SubjectConfirmationData element");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer SubjectConfirmation must have NotOnOrAfter attribute
*/
public function test_throws_context_exception_if_no_not_on_or_after_attribute()
{
$this->expectExceptionMessage("Bearer SubjectConfirmation must have NotOnOrAfter attribute");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$action = new RepeatedIdValidatorAction(
$loggerMock = $this->getLoggerMock(),
$idStoreMock = $this->getIdStoreMock()
Expand Down
2 changes: 1 addition & 1 deletion tests/LightSaml/Tests/Action/CompositeActionTest.php
Expand Up @@ -127,7 +127,7 @@ public function test_to_string_returns_json_debug_tree_string()
}
EOT;

$this->assertEquals($expectedValue, $actualValue);
$this->assertJsonStringEqualsJsonString($expectedValue, $actualValue);
}

/**
Expand Down
Expand Up @@ -24,12 +24,10 @@ public function test_calls_do_execute_with_profile_context()
$action->execute($profileContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Expected ProfileContext but got
*/
public function test_throws_exception_on_non_profile_context()
{
$this->expectExceptionMessage("Expected ProfileContext but got");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
/** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject $loggerMock */
$loggerMock = $this->getMockBuilder(LoggerInterface::class)->getMock();
$loggerMock->expects($this->once())
Expand Down
Expand Up @@ -107,12 +107,10 @@ public function test_makes_descriptor_type_criteria_for_own_role($ownRole, $desc
$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Invalid inbound message destination "http://localhost/foo"
*/
public function test_throws_exception_when_destination_does_not_match()
{
$this->expectExceptionMessage("Invalid inbound message destination \"http://localhost/foo\"");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$loggerMock = $this->getLoggerMock();
$endpointResolverMock = $this->getEndpointResolverMock();
/** @var AbstractDestinationValidatorAction $action */
Expand Down

0 comments on commit 519f40c

Please sign in to comment.