diff --git a/.github/workflows/interoperability.yml b/.github/workflows/interoperability.yml
new file mode 100644
index 000000000..d229ed4c1
--- /dev/null
+++ b/.github/workflows/interoperability.yml
@@ -0,0 +1,101 @@
+---
+
+name: Interoperability
+
+on: # yamllint disable-line rule:truthy
+ push:
+ branches: ['**']
+ paths-ignore:
+ - '**.md'
+ - '**.yml'
+ pull_request:
+ branches: [master, release-*]
+ paths-ignore:
+ - '**.md'
+ - '**.yml'
+ workflow_dispatch:
+
+jobs:
+ edugain:
+ name: "Interoperability tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
+ runs-on: ${{ matrix.operating-system }}
+ strategy:
+ fail-fast: false
+ matrix:
+ operating-system: [ubuntu-latest]
+ php-versions: ['8.2']
+
+ steps:
+ - name: Setup PHP, with composer and extensions
+ # https://github.com/shivammathur/setup-php
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ extensions: ctype, date, dom, hash, mbstring, openssl, pcre, spl, xml
+ tools: composer:v2
+ ini-values: error_reporting=E_ALL, memory_limit=-1
+ coverage: none
+
+ - name: Setup problem matchers for PHP
+ run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+
+ - name: Setup problem matchers for PHPUnit
+ run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+
+ - name: Set git to use LF
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+
+ - uses: actions/checkout@v4
+
+ - name: Cache composer dependencies
+ uses: actions/cache@v4
+ with:
+ path: $(composer config cache-files-dir)
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
+ restore-keys: ${{ runner.os }}-composer-
+
+ - name: Validate composer.json and composer.lock
+ run: composer validate
+
+ - name: Install Composer dependencies
+ run: composer install --no-progress --prefer-dist --optimize-autoloader
+
+ - name: Get current date
+ id: date
+ run: |
+ echo "{date}={$(date +'%Y-%m-%d')}" >> "$GITHUB_STATE"
+
+ - name: Cache metadata
+ id: cache-metadata
+ uses: actions/cache@v4
+ with:
+ path: /tmp/metadata
+ key: ${{ runner.os }}-metadata-${{ env.date }}
+ restore-keys: ${{ runner.os }}-metadata-
+
+ - name: Download eduGAIN metadata & public key
+ if: steps.cache-metadata.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p /tmp/metadata
+ wget https://mds.edugain.org/edugain-v2.xml -O /tmp/metadata/edugain.xml
+ wget https://technical.edugain.org/mds-v2.cer -O /tmp/metadataedugain-pub.crt
+
+
+ - name: Download GRNET metadata
+ if: steps.cache-metadata.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p /tmp/metadata
+ wget https://md.aai.grnet.gr/aggregates/grnet-metadata.xml -O /tmp/metadata/grnet.xml
+
+ - name: Download MicrosoftOnline metadata
+ if: steps.cache-metadata.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p /tmp/metadata
+ wget https://nexus.microsoftonline-p.com/federationmetadata/saml20/federationmetadata.xml \
+ -O /tmp/metadata/microsoftonline.xml
+
+ - name: Run unit tests
+ run: |
+ ./vendor/bin/phpunit -c phpunit-interoperability.xml
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index cd5119274..eebb58608 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -11,6 +11,7 @@ on: # yamllint disable-line rule:truthy
branches: [master, release-*]
paths-ignore:
- '**.md'
+ workflow_dispatch:
jobs:
linter:
@@ -18,16 +19,20 @@ jobs:
runs-on: ['ubuntu-latest']
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
+ # super-linter needs the full git history to get the
+ # list of files that changed across commits
fetch-depth: 0
- name: Lint Code Base
- uses: github/super-linter/slim@v5
+ uses: super-linter/super-linter/slim@v6
env:
+ # To report GitHub Actions status checks
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ LINTER_RULES_PATH: 'tools/linters'
LOG_LEVEL: NOTICE
VALIDATE_ALL_CODEBASE: true
- LINTER_RULES_PATH: 'tools/linters'
VALIDATE_BASH: true
VALIDATE_BASH_EXEC: true
VALIDATE_JSON: true
@@ -47,21 +52,20 @@ jobs:
with:
# Should be the higest supported version, so we can use the newest tools
php-version: '8.3'
- tools: composer, composer-require-checker, composer-unused, phpcs, psalm
- # optional performance gain for psalm: opcache
- extensions: ctype, date, dom, filter, hash, mbstring, opcache, openssl, pcre, soap, spl, xml
+ tools: composer, composer-require-checker, composer-unused, phpcs, phpstan
+ extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
coverage: none
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
- name: Cache composer dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -83,28 +87,13 @@ jobs:
- name: PHP Code Sniffer
run: phpcs
- - name: Psalm
- continue-on-error: true
- run: |
- psalm -c psalm.xml \
- --show-info=true \
- --shepherd \
- --php-version=${{ steps.setup-php.outputs.php-version }}
-
- - name: Psalm (testsuite)
- continue-on-error: true
+ - name: PHPStan
run: |
- psalm -c psalm-dev.xml \
- --show-info=true \
- --shepherd \
- --php-version=${{ steps.setup-php.outputs.php-version }}
+ phpstan analyze -c phpstan.neon
- - name: Psalter
+ - name: PHPStan (testsuite)
run: |
- psalm --alter \
- --issues=UnnecessaryVarAnnotation \
- --dry-run \
- --php-version=${{ steps.setup-php.outputs.php-version }}
+ phpstan analyze -c phpstan-dev.neon
security:
name: Security checks
@@ -123,13 +112,13 @@ jobs:
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
- name: Cache composer dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -179,13 +168,13 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
- name: Cache composer dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -204,7 +193,7 @@ jobs:
- name: Save coverage data
if: ${{ matrix.php-versions == '8.3' }}
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: coverage-data
path: ${{ github.workspace }}/build
@@ -241,13 +230,13 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
- name: Cache composer dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -264,16 +253,30 @@ jobs:
runs-on: [ubuntu-latest]
needs: [unit-tests-linux]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- - uses: actions/download-artifact@v3
+ - uses: actions/download-artifact@v4
with:
name: coverage-data
path: ${{ github.workspace }}/build
- name: Codecov
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
+
+ cleanup:
+ name: Cleanup artifacts
+ needs: [unit-tests-linux, coverage]
+ runs-on: [ubuntu-latest]
+ if: |
+ always() &&
+ needs.coverage.result == 'success' ||
+ (needs.unit-tests-linux == 'success' && needs.coverage == 'skipped')
+
+ steps:
+ - uses: geekyeggo/delete-artifact@v5
+ with:
+ name: coverage-data
diff --git a/composer.json b/composer.json
index f6ff811af..fcec458c2 100644
--- a/composer.json
+++ b/composer.json
@@ -20,11 +20,11 @@
"ext-zlib": "*",
"nyholm/psr7": "^1.8",
+ "psr/clock": "^1.0",
"psr/http-message": "^2.0",
"psr/log": "^2.0 || ^3.0",
- "robrichards/xmlseclibs": "^3.1",
- "simplesamlphp/assert": "^1.0",
- "simplesamlphp/xml-common": "^1.12",
+ "simplesamlphp/assert": "^1.1",
+ "simplesamlphp/xml-common": "^1.16",
"simplesamlphp/xml-security": "^1.6",
"simplesamlphp/xml-soap": "^1.3"
},
diff --git a/phpstan-baseline-dev.neon b/phpstan-baseline-dev.neon
new file mode 100644
index 000000000..5bb101e50
--- /dev/null
+++ b/phpstan-baseline-dev.neon
@@ -0,0 +1,106 @@
+parameters:
+ ignoreErrors:
+ -
+ message: "#^PHPDoc tag @var for property SimpleSAML\\\\Test\\\\SAML2\\\\Assertion\\\\Transformer\\\\NameIdDecryptionTransformerTest\\:\\:\\$validator with type SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\Validator is incompatible with native type SimpleSAML\\\\SAML2\\\\Signature\\\\Validator\\.$#"
+ count: 1
+ path: tests/SAML2/Assertion/Transformer/NameIdDecryptionTransformerTest.php
+
+ -
+ message: "#^Unreachable statement \\- code above always terminates\\.$#"
+ count: 2
+ path: tests/SAML2/Assertion/Transformer/NameIdDecryptionTransformerTest.php
+
+ -
+ message: "#^PHPDoc tag @var for property SimpleSAML\\\\Test\\\\SAML2\\\\Assertion\\\\Validation\\\\AssertionValidatorTest\\:\\:\\$validator with type SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\Validator is incompatible with native type SimpleSAML\\\\SAML2\\\\Signature\\\\Validator\\.$#"
+ count: 1
+ path: tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$xml of static method SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\Assertion\\:\\:fromXML\\(\\) expects DOMElement, DOMNode\\|null given\\.$#"
+ count: 2
+ path: tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
+
+ -
+ message: "#^Result of method SimpleSAML\\\\SAML2\\\\Assertion\\\\Processor\\:\\:validateAssertion\\(\\) \\(void\\) is used\\.$#"
+ count: 2
+ path: tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$serviceProvider of method SimpleSAML\\\\SAML2\\\\Assertion\\\\Validation\\\\ConstraintValidator\\\\SpIsValidAudience\\:\\:setServiceProvider\\(\\) expects SimpleSAML\\\\SAML2\\\\Configuration\\\\ServiceProvider, Mockery\\\\MockInterface given\\.$#"
+ count: 3
+ path: tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
+
+ -
+ message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:andReturnNull\\(\\)\\.$#"
+ count: 2
+ path: tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$response of class SimpleSAML\\\\SAML2\\\\Assertion\\\\Validation\\\\ConstraintValidator\\\\SubjectConfirmationResponseToMatches constructor expects SimpleSAML\\\\SAML2\\\\XML\\\\samlp\\\\Response, Mockery\\\\MockInterface given\\.$#"
+ count: 5
+ path: tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
+
+ -
+ message: "#^PHPDoc tag @var for property SimpleSAML\\\\Test\\\\SAML2\\\\XML\\\\saml\\\\SubjectConfirmationValidatorTest\\:\\:\\$validator with type SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\Validator is incompatible with native type SimpleSAML\\\\SAML2\\\\Signature\\\\Validator\\.$#"
+ count: 1
+ path: tests/SAML2/Assertion/Validation/SubjectConfirmationValidatorTest.php
+
+ -
+ message: "#^Result of method SimpleSAML\\\\SAML2\\\\Assertion\\\\Processor\\:\\:validateAssertion\\(\\) \\(void\\) is used\\.$#"
+ count: 1
+ path: tests/SAML2/Assertion/Validation/SubjectConfirmationValidatorTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$element of method SimpleSAML\\\\SAML2\\\\Certificate\\\\KeyCollection\\:\\:add\\(\\) expects SimpleSAML\\\\SAML2\\\\Certificate\\\\Key, string given\\.$#"
+ count: 1
+ path: tests/SAML2/Certificate/KeyCollectionTest.php
+
+ -
+ message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:atMost\\(\\)\\.$#"
+ count: 2
+ path: tests/SAML2/Certificate/KeyLoaderTest.php
+
+ -
+ message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
+ count: 1
+ path: tests/SAML2/Certificate/KeyLoaderTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$config of method SimpleSAML\\\\SAML2\\\\Certificate\\\\KeyLoader\\:\\:loadKeysFromConfiguration\\(\\) expects SimpleSAML\\\\SAML2\\\\Configuration\\\\CertificateProvider, Mockery\\\\MockInterface given\\.$#"
+ count: 3
+ path: tests/SAML2/Certificate/KeyLoaderTest.php
+
+ -
+ message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
+ count: 8
+ path: tests/SAML2/Response/SignatureValidationTest.php
+
+ -
+ message: "#^Call to method shouldReceive\\(\\) on an unknown class alias\\:SimpleSAML\\\\SAML2\\\\Assertion\\\\ProcessorBuilder\\.$#"
+ count: 1
+ path: tests/SAML2/Response/SignatureValidationTest.php
+
+ -
+ message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
+ count: 2
+ path: tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$response of method SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\ConstraintValidator\\\\DestinationMatches\\:\\:validate\\(\\) expects SimpleSAML\\\\SAML2\\\\XML\\\\samlp\\\\Response, Mockery\\\\MockInterface given\\.$#"
+ count: 2
+ path: tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
+
+ -
+ message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
+ count: 3
+ path: tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$response of method SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\ConstraintValidator\\\\IsSuccessful\\:\\:validate\\(\\) expects SimpleSAML\\\\SAML2\\\\XML\\\\samlp\\\\Response, Mockery\\\\MockInterface given\\.$#"
+ count: 2
+ path: tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$xml of static method SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\Assertion\\:\\:fromXML\\(\\) expects DOMElement, DOMNode\\|null given\\.$#"
+ count: 2
+ path: tests/SAML2/Response/XmlSignatureWrappingTest.php
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
new file mode 100644
index 000000000..e5d39fcc2
--- /dev/null
+++ b/phpstan-baseline.neon
@@ -0,0 +1,211 @@
+parameters:
+ ignoreErrors:
+ -
+ message: "#^Access to constant AES128_CBC on an unknown class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#"
+ count: 1
+ path: src/SAML2/Certificate/PrivateKeyLoader.php
+
+ -
+ message: "#^Access to constant RSA_1_5 on an unknown class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#"
+ count: 1
+ path: src/SAML2/Certificate/PrivateKeyLoader.php
+
+ -
+ message: "#^Instantiated class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey not found\\.$#"
+ count: 2
+ path: src/SAML2/Certificate/PrivateKeyLoader.php
+
+ -
+ message: "#^Method SimpleSAML\\\\SAML2\\\\Certificate\\\\PrivateKeyLoader\\:\\:convertPrivateKeyToRsaKey\\(\\) has invalid return type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#"
+ count: 1
+ path: src/SAML2/Certificate/PrivateKeyLoader.php
+
+ -
+ message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:convertToIdentityProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/Configuration/SimpleSAMLConverter.php
+
+ -
+ message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:convertToServiceProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/Configuration/SimpleSAMLConverter.php
+
+ -
+ message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForDecryptionProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/Configuration/SimpleSAMLConverter.php
+
+ -
+ message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForIdentityProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/Configuration/SimpleSAMLConverter.php
+
+ -
+ message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForServiceProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/Configuration/SimpleSAMLConverter.php
+
+ -
+ message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:pluckConfiguration\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/Configuration/SimpleSAMLConverter.php
+
+ -
+ message: "#^Call to static method addSign\\(\\) on an unknown class SimpleSAML\\\\Module\\\\saml\\\\Message\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Call to static method getInstance\\(\\) on an unknown class SimpleSAML\\\\Configuration\\.$#"
+ count: 2
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Call to static method getInstance\\(\\) on an unknown class SimpleSAML\\\\Store\\\\StoreFactory\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Call to static method getMetadataHandler\\(\\) on an unknown class SimpleSAML\\\\Metadata\\\\MetaDataStorageHandler\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Instantiated class SimpleSAML\\\\Utils\\\\HTTP not found\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Parameter \\$key of method SimpleSAML\\\\SAML2\\\\HTTPArtifact\\:\\:validateSignature\\(\\) has invalid type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Parameter \\$sp of method SimpleSAML\\\\SAML2\\\\HTTPArtifact\\:\\:setSPMetadata\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Property SimpleSAML\\\\SAML2\\\\HTTPArtifact\\:\\:\\$spMetadata has unknown class SimpleSAML\\\\Configuration as its type\\.$#"
+ count: 1
+ path: src/SAML2/HTTPArtifact.php
+
+ -
+ message: "#^Instantiated class SimpleSAML\\\\Utils\\\\Config not found\\.$#"
+ count: 1
+ path: src/SAML2/SOAPClient.php
+
+ -
+ message: "#^Instantiated class SimpleSAML\\\\Utils\\\\Crypto not found\\.$#"
+ count: 1
+ path: src/SAML2/SOAPClient.php
+
+ -
+ message: "#^Parameter \\$dstMetadata of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:send\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/SOAPClient.php
+
+ -
+ message: "#^Parameter \\$key of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:validateSSL\\(\\) has invalid type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#"
+ count: 1
+ path: src/SAML2/SOAPClient.php
+
+ -
+ message: "#^Parameter \\$srcMetadata of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:send\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#"
+ count: 1
+ path: src/SAML2/SOAPClient.php
+
+ -
+ message: "#^Unsafe usage of new static\\(\\)\\.$#"
+ count: 2
+ path: src/SAML2/XML/md/AbstractEndpointType.php
+
+ -
+ message: "#^Unsafe usage of new static\\(\\)\\.$#"
+ count: 2
+ path: src/SAML2/XML/md/AbstractIndexedEndpointType.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_NAME\\.$#"
+ count: 2
+ path: src/SAML2/XML/md/AbstractRoleDescriptor.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#"
+ count: 2
+ path: src/SAML2/XML/md/AbstractRoleDescriptor.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_PREFIX\\.$#"
+ count: 2
+ path: src/SAML2/XML/md/AbstractRoleDescriptor.php
+
+ -
+ message: "#^Call to an undefined static method SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractSignedMdElement\\:\\:getXsiTypeNamespaceURI\\(\\)\\.$#"
+ count: 1
+ path: src/SAML2/XML/md/AbstractSignedMdElement.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_NAME\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractBaseID.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractBaseID.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_PREFIX\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractBaseID.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_NAME\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractCondition.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractCondition.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_PREFIX\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractCondition.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_NAME\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractStatement.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractStatement.php
+
+ -
+ message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_PREFIX\\.$#"
+ count: 2
+ path: src/SAML2/XML/saml/AbstractStatement.php
+
+ -
+ message: "#^Unsafe usage of new static\\(\\)\\.$#"
+ count: 1
+ path: src/SAML2/XML/saml/Attribute.php
+
+ -
+ message: "#^Unsafe usage of new static\\(\\)\\.$#"
+ count: 1
+ path: src/SAML2/XML/saml/EncryptedAttribute.php
+
+ -
+ message: "#^Unsafe usage of new static\\(\\)\\.$#"
+ count: 1
+ path: src/SAML2/XML/saml/EncryptedID.php
+
+ -
+ message: "#^Unsafe usage of new static\\(\\)\\.$#"
+ count: 1
+ path: src/SAML2/XML/saml/NameIDType.php
diff --git a/phpstan-dev.neon b/phpstan-dev.neon
new file mode 100644
index 000000000..c839b6e78
--- /dev/null
+++ b/phpstan-dev.neon
@@ -0,0 +1,6 @@
+parameters:
+ level: 5
+ paths:
+ - tests
+includes:
+ - phpstan-baseline-dev.neon
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 000000000..e4c4cf7f5
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,6 @@
+parameters:
+ level: 1
+ paths:
+ - src
+includes:
+ - phpstan-baseline.neon
diff --git a/phpunit-interoperability.xml b/phpunit-interoperability.xml
new file mode 100644
index 000000000..f1eb4020c
--- /dev/null
+++ b/phpunit-interoperability.xml
@@ -0,0 +1,8 @@
+
+
+
+
+ ./tests/InterOperability
+
+
+
diff --git a/phpunit.xml b/phpunit.xml
index 83634ebd3..0e18cf073 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,20 +1,19 @@
-
-
-
- ./src
-
+
+
- ./tests
+ ./tests/SAML2
-
-
-
+
diff --git a/src/SAML2/Assertion/Decrypter.php b/src/SAML2/Assertion/Decrypter.php
index a5813b48f..f3a05d56c 100644
--- a/src/SAML2/Assertion/Decrypter.php
+++ b/src/SAML2/Assertion/Decrypter.php
@@ -8,7 +8,6 @@
use Psr\Log\LoggerInterface;
use SimpleSAML\SAML2\Assertion\Exception\NotDecryptedException;
use SimpleSAML\SAML2\Certificate\PrivateKeyLoader;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Configuration\ServiceProvider;
use SimpleSAML\SAML2\XML\saml\Assertion;
@@ -16,7 +15,6 @@
use function count;
use function get_class;
-use function is_null;
use function sprintf;
class Decrypter
diff --git a/src/SAML2/Assertion/ProcessorBuilder.php b/src/SAML2/Assertion/ProcessorBuilder.php
index c05080459..8aa7795a9 100644
--- a/src/SAML2/Assertion/ProcessorBuilder.php
+++ b/src/SAML2/Assertion/ProcessorBuilder.php
@@ -129,12 +129,12 @@ private static function createSubjectConfirmationValidator(
*/
private static function createAssertionTransformerChain(
LoggerInterface $logger,
- PrivateKeyLoader $keyloader,
+ PrivateKeyLoader $keyLoader,
IdentityProvider $identityProvider,
ServiceProvider $serviceProvider,
): TransformerChain {
$chain = new TransformerChain($identityProvider, $serviceProvider);
- $chain->addTransformerStep(new NameIdDecryptionTransformer($logger, $keyloader));
+ $chain->addTransformerStep(new NameIdDecryptionTransformer($logger, $keyLoader));
return $chain;
}
diff --git a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
index be57037ba..008ca995a 100644
--- a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
+++ b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
@@ -9,7 +9,6 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Assertion\Exception\NotDecryptedException;
use SimpleSAML\SAML2\Certificate\PrivateKeyLoader;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Configuration\IdentityProviderAware;
use SimpleSAML\SAML2\Configuration\ServiceProvider;
@@ -20,7 +19,6 @@
use SimpleSAML\SAML2\XML\saml\Subject;
use function get_class;
-use function is_null;
use function sprintf;
final class NameIdDecryptionTransformer implements
diff --git a/src/SAML2/Assertion/Transformer/TransformerChain.php b/src/SAML2/Assertion/Transformer/TransformerChain.php
index a1e67113e..c96572644 100644
--- a/src/SAML2/Assertion/Transformer/TransformerChain.php
+++ b/src/SAML2/Assertion/Transformer/TransformerChain.php
@@ -4,11 +4,11 @@
namespace SimpleSAML\SAML2\Assertion\Transformer;
-use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Configuration\IdentityProviderAware;
use SimpleSAML\SAML2\Configuration\ServiceProvider;
use SimpleSAML\SAML2\Configuration\ServiceProviderAware;
+use SimpleSAML\SAML2\XML\saml\Assertion;
class TransformerChain implements TransformerInterface
{
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php b/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
index 99149efda..b61546302 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
@@ -5,10 +5,10 @@
namespace SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
-use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\Assertion\Validation\AssertionConstraintValidator;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\Assertion;
class NotBefore implements AssertionConstraintValidator
{
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
index e04afdb5b..a14884ea2 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
@@ -5,10 +5,10 @@
namespace SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
-use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\Assertion\Validation\AssertionConstraintValidator;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\Assertion;
class SessionNotOnOrAfter implements AssertionConstraintValidator
{
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
index f42014c82..503d5a2a4 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
@@ -5,11 +5,11 @@
namespace SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\Assertion\Validation\AssertionConstraintValidator;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Configuration\ServiceProvider;
use SimpleSAML\SAML2\Configuration\ServiceProviderAware;
+use SimpleSAML\SAML2\XML\saml\Assertion;
use function implode;
use function sprintf;
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
index d30288d51..ac92d7d70 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator;
-use Psr\Clock\ClockInterface;
use DateInterval;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Assertion\Validation\Result;
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
index 92da5f753..bd3d85025 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
@@ -8,8 +8,8 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
-use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
class SubjectConfirmationNotOnOrAfter implements SubjectConfirmationConstraintValidator
{
diff --git a/src/SAML2/Assertion/Validation/Result.php b/src/SAML2/Assertion/Validation/Result.php
index 3f1283f7e..dff38fc01 100644
--- a/src/SAML2/Assertion/Validation/Result.php
+++ b/src/SAML2/Assertion/Validation/Result.php
@@ -4,8 +4,6 @@
namespace SimpleSAML\SAML2\Assertion\Validation;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
-
/**
* Simple Result object
*/
diff --git a/src/SAML2/Binding.php b/src/SAML2/Binding.php
index e0cdc3a5f..ce28a17f2 100644
--- a/src/SAML2/Binding.php
+++ b/src/SAML2/Binding.php
@@ -4,12 +4,11 @@
namespace SimpleSAML\SAML2;
-use Exception;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
use SimpleSAML\SAML2\Exception\Protocol\UnsupportedBindingException;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
use function array_key_exists;
use function array_keys;
diff --git a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
index 4d5dbf228..aeb3492aa 100644
--- a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
+++ b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
@@ -5,28 +5,11 @@
namespace SimpleSAML\SAML2\Certificate\Exception;
use InvalidArgumentException;
-use SimpleSAML\SAML2\Certificate\Key;
use Throwable;
-use function implode;
-use function sprintf;
-
/**
* Named exception for when a non-existent key-usage is given
*/
class InvalidKeyUsageException extends InvalidArgumentException implements Throwable
{
- /**
- * @param string $usage
- */
- public function __construct(string $usage)
- {
- $message = sprintf(
- 'Invalid key usage given: "%s", usages "%s" allowed',
- $usage,
- implode('", "', Key::getValidKeyUsages())
- );
-
- parent::__construct($message);
- }
}
diff --git a/src/SAML2/Certificate/Key.php b/src/SAML2/Certificate/Key.php
index 18cdab9b4..1bd2d9838 100644
--- a/src/SAML2/Certificate/Key.php
+++ b/src/SAML2/Certificate/Key.php
@@ -4,21 +4,23 @@
namespace SimpleSAML\SAML2\Certificate;
+use ArrayAccess;
+use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Certificate\Exception\InvalidKeyUsageException;
use SimpleSAML\SAML2\Exception\InvalidArgumentException;
use function array_key_exists;
-use function in_array;
use function is_string;
/**
* Simple DTO wrapper for (X509) keys. Implements ArrayAccess
* for easier backwards compatibility.
*/
-class Key implements \ArrayAccess
+class Key implements ArrayAccess
{
// Possible key usages
public const USAGE_SIGNING = 'signing';
+
public const USAGE_ENCRYPTION = 'encryption';
/** @var array */
@@ -42,38 +44,27 @@ public function __construct(array $keyData)
*
* @param string $usage
* @return bool
+ * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException
*/
public function canBeUsedFor(string $usage): bool
{
- if (!in_array($usage, static::getValidKeyUsages(), true)) {
- throw new InvalidKeyUsageException($usage);
- }
+ Assert::oneOf(
+ $usage,
+ [self::USAGE_ENCRYPTION, self::USAGE_SIGNING],
+ 'Invalid key usage given: "%s", usages "%2$s" allowed',
+ InvalidKeyUsageException::class,
+ );
return isset($this->keyData[$usage]) && $this->keyData[$usage];
}
- /**
- * Returns the list of valid key usage options
- * @return array
- */
- public static function getValidKeyUsages(): array
- {
- return [
- self::USAGE_ENCRYPTION,
- self::USAGE_SIGNING
- ];
- }
-
-
/**
* @param mixed $offset
- * @throws InvalidArgumentException
+ * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException
* @return bool
- *
- * Type hint not possible due to upstream method signature
*/
- public function offsetExists($offset): bool
+ public function offsetExists(mixed $offset): bool
{
if (!is_string($offset)) {
throw InvalidArgumentException::invalidType('string', $offset);
@@ -84,13 +75,10 @@ public function offsetExists($offset): bool
/**
* @param mixed $offset
- * @throws InvalidArgumentException
+ * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException
* @return mixed
- *
- * Type hint not possible due to upstream method signature
*/
- #[\ReturnTypeWillChange]
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
if (!is_string($offset)) {
throw InvalidArgumentException::invalidType('string', $offset);
@@ -102,10 +90,9 @@ public function offsetGet($offset)
/**
* @param mixed $offset
* @param mixed $value
- * @throws InvalidArgumentException
- * @return void
+ * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException
*/
- public function offsetSet($offset, $value): void
+ public function offsetSet(mixed $offset, mixed $value): void
{
if (!is_string($offset)) {
throw InvalidArgumentException::invalidType('string', $offset);
@@ -116,12 +103,9 @@ public function offsetSet($offset, $value): void
/**
* @param mixed $offset
- * @throws InvalidArgumentException
- * @return void
- *
- * Type hint not possible due to upstream method signature
+ * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException
*/
- public function offsetUnset($offset): void
+ public function offsetUnset(mixed $offset): void
{
if (!is_string($offset)) {
throw InvalidArgumentException::invalidType('string', $offset);
diff --git a/src/SAML2/Certificate/KeyCollection.php b/src/SAML2/Certificate/KeyCollection.php
index da102404a..8fc8b2526 100644
--- a/src/SAML2/Certificate/KeyCollection.php
+++ b/src/SAML2/Certificate/KeyCollection.php
@@ -4,8 +4,8 @@
namespace SimpleSAML\SAML2\Certificate;
-use SimpleSAML\SAML2\Utilities\ArrayCollection;
use SimpleSAML\Assert\Assert;
+use SimpleSAML\SAML2\Utilities\ArrayCollection;
/**
* Simple collection object for transporting keys
@@ -15,16 +15,16 @@ class KeyCollection extends ArrayCollection
/**
* Add a key to the collection
*
- * @psalm-suppress MoreSpecificImplementedParamType
- * @param \SimpleSAML\SAML2\Certificate\Key $key
- * @return void
+ * @param \SimpleSAML\SAML2\Certificate\Key $element
+ * @throws \SimpleSAML\Assert\AssertionFailedException if assertions are false
*
* Type hint not possible due to upstream method signature
+ * @psalm-suppress MoreSpecificImplementedParamType
*/
- public function add($key): void
+ public function add($element): void
{
/** @psalm-suppress RedundantConditionGivenDocblockType */
- Assert::isInstanceOf($key, Key::class);
- parent::add($key);
+ Assert::isInstanceOf($element, Key::class);
+ parent::add($element);
}
}
diff --git a/src/SAML2/Certificate/KeyLoader.php b/src/SAML2/Certificate/KeyLoader.php
index 828e7962c..a2d14faa6 100644
--- a/src/SAML2/Certificate/KeyLoader.php
+++ b/src/SAML2/Certificate/KeyLoader.php
@@ -8,9 +8,8 @@
use SimpleSAML\SAML2\Certificate\Exception\NoKeysFoundException;
use SimpleSAML\SAML2\Certificate\KeyCollection;
use SimpleSAML\SAML2\Configuration\CertificateProvider;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
-use SimpleSAML\SAML2\Utilities\Certificate;
use SimpleSAML\SAML2\Utilities\File;
+use SimpleSAML\XMLSecurity\Utils\Certificate;
use function count;
use function preg_match;
@@ -48,7 +47,7 @@ public function __construct()
public static function extractPublicKeys(
CertificateProvider $config,
string $usage = null,
- bool $required = false
+ bool $required = false,
): KeyCollection {
$keyLoader = new self();
@@ -65,7 +64,7 @@ public static function extractPublicKeys(
public function loadKeysFromConfiguration(
CertificateProvider $config,
string $usage = null,
- bool $required = false
+ bool $required = false,
): KeyCollection {
$keys = $config->getKeys();
$certificateData = $config->getCertificateData();
@@ -82,7 +81,7 @@ public function loadKeysFromConfiguration(
if ($required && !$this->hasKeys()) {
throw new NoKeysFoundException(
'No keys found in configured metadata, please ensure that either the "keys", "certData" or '
- . '"certificate" entries is available.'
+ . '"certificate" entries is available.',
);
}
@@ -96,7 +95,6 @@ public function loadKeysFromConfiguration(
*
* @param array|\Traversable $configuredKeys
* @param string|null $usage
- * @return void
*/
public function loadKeys($configuredKeys, string $usage = null): void
{
@@ -120,7 +118,6 @@ public function loadKeys($configuredKeys, string $usage = null): void
* Attempts to load a key based on the given certificateData
*
* @param string $certificateData
- * @return void
*/
public function loadCertificateData(string $certificateData): void
{
@@ -132,21 +129,19 @@ public function loadCertificateData(string $certificateData): void
* Loads the certificate in the file given
*
* @param string $certificateFile the full path to the cert file.
- * @return void
*/
public function loadCertificateFile(string $certificateFile): void
{
$certificate = File::getFileContents($certificateFile);
-
if (!Certificate::hasValidStructure($certificate)) {
throw new InvalidCertificateStructureException(sprintf(
'Could not find PEM encoded certificate in "%s"',
- $certificateFile
+ $certificateFile,
));
}
// capture the certificate contents without the delimiters
- preg_match(Certificate::CERTIFICATE_PATTERN, $certificate, $matches);
+ preg_match(Certificate::PUBLIC_KEY_PATTERN, $certificate, $matches);
$this->loadedKeys->add(X509::createFromCertificateData($matches[1]));
}
diff --git a/src/SAML2/Certificate/PrivateKey.php b/src/SAML2/Certificate/PrivateKey.php
index cee447f49..2ced7f246 100644
--- a/src/SAML2/Certificate/PrivateKey.php
+++ b/src/SAML2/Certificate/PrivateKey.php
@@ -4,15 +4,13 @@
namespace SimpleSAML\SAML2\Certificate;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
-
class PrivateKey extends Key
{
/**
* @param string $keyContents
* @param string|null $passphrase
- * @throws InvalidArgumentException
- * @return PrivateKey
+ * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException
+ * @return \SimpleSAML\SAML2\Certificate\PrivateKey
*/
public static function create(string $keyContents, string $passphrase = null): PrivateKey
{
diff --git a/src/SAML2/Certificate/PrivateKeyLoader.php b/src/SAML2/Certificate/PrivateKeyLoader.php
index 1ab27e099..f8c990eb4 100644
--- a/src/SAML2/Certificate/PrivateKeyLoader.php
+++ b/src/SAML2/Certificate/PrivateKeyLoader.php
@@ -4,12 +4,12 @@
namespace SimpleSAML\SAML2\Certificate;
-use RobRichards\XMLSecLibs\XMLSecurityKey;
use SimpleSAML\SAML2\Certificate\PrivateKey;
use SimpleSAML\SAML2\Configuration\DecryptionProvider;
use SimpleSAML\SAML2\Configuration\PrivateKey as PrivateKeyConfiguration;
use SimpleSAML\SAML2\Utilities\ArrayCollection;
use SimpleSAML\SAML2\Utilities\File;
+use SimpleSAML\XMLSecurity\XMLSecurityKey;
class PrivateKeyLoader
{
@@ -39,7 +39,7 @@ public function loadPrivateKey(PrivateKeyConfiguration $key): PrivateKey
*/
public function loadDecryptionKeys(
DecryptionProvider $identityProvider,
- DecryptionProvider $serviceProvider
+ DecryptionProvider $serviceProvider,
): ArrayCollection {
$decryptionKeys = new ArrayCollection();
@@ -69,7 +69,7 @@ public function loadDecryptionKeys(
/**
* @param \SimpleSAML\SAML2\Certificate\PrivateKey $privateKey
* @throws \Exception
- * @return \RobRichards\XMLSecLibs\XMLSecurityKey
+ * @return \SimpleSAML\XMLSecurity\XMLSecurityKey
*/
private function convertPrivateKeyToRsaKey(PrivateKey $privateKey): XMLSecurityKey
{
diff --git a/src/SAML2/Certificate/X509.php b/src/SAML2/Certificate/X509.php
index 06fd80d33..53b382e9d 100644
--- a/src/SAML2/Certificate/X509.php
+++ b/src/SAML2/Certificate/X509.php
@@ -12,13 +12,17 @@
*/
class X509 extends Key
{
+ /**
+ * @param string $certificateContents
+ * @return \SimpleSAML\SAML2\Certificate\X509
+ */
public static function createFromCertificateData(string $certificateContents): X509
{
$data = [
'encryption' => true,
'signing' => true,
'type' => 'X509Certificate',
- 'X509Certificate' => $certificateContents
+ 'X509Certificate' => $certificateContents,
];
return new self($data);
@@ -30,7 +34,6 @@ public static function createFromCertificateData(string $certificateContents): X
*
* @param mixed $offset
* @param mixed $value
- * @return void
*
* Type hint not possible due to upstream method signature
*/
diff --git a/src/SAML2/Compat/AbstractContainer.php b/src/SAML2/Compat/AbstractContainer.php
index ef3bab6b0..69f42858e 100644
--- a/src/SAML2/Compat/AbstractContainer.php
+++ b/src/SAML2/Compat/AbstractContainer.php
@@ -9,6 +9,7 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\XML\ExtensionPointInterface;
use SimpleSAML\XML\AbstractElement;
+use SimpleSAML\XML\Exception\SchemaViolationException;
use function array_key_exists;
use function implode;
@@ -17,13 +18,13 @@
abstract class AbstractContainer
{
/** @var string */
- protected const XSI_TYPE_PREFIX = '';
+ private const XSI_TYPE_PREFIX = '';
/** @var array */
protected array $registry = [];
- /** @var array */
- protected $blacklistedEncryptionAlgorithms = [];
+ /** @var array|null */
+ protected ?array $blacklistedEncryptionAlgorithms;
/**
@@ -47,18 +48,43 @@ public function getBlacklistedEncryptionAlgorithms(): ?array
public function registerExtensionHandler(string $class): void
{
Assert::subclassOf($class, AbstractElement::class);
-
if (is_subclass_of($class, ExtensionPointInterface::class, true)) {
$key = implode(':', [self::XSI_TYPE_PREFIX, $class::getXsiTypeNamespaceURI(), $class::getXsiTypeName()]);
} else {
$className = AbstractElement::getClassName($class);
$key = ($class::NS === null) ? $className : implode(':', [$class::NS, $className]);
}
-
$this->registry[$key] = $class;
}
+ /**
+ * Search for a class that implements an $element in the given $namespace.
+ *
+ * Such classes must have been registered previously by calling registerExtensionHandler(), and they must
+ * extend \SimpleSAML\XML\AbstractElement.
+ *
+ * @param string|null $namespace The namespace URI for the given element.
+ * @param string $element The local name of the element.
+ *
+ * @return string|null The fully-qualified name of a class extending \SimpleSAML\XML\AbstractElement and
+ * implementing support for the given element, or null if no such class has been registered before.
+ * @psalm-return class-string|null
+ */
+ public function getElementHandler(?string $namespace, string $element): ?string
+ {
+ Assert::nullOrValidURI($namespace, SchemaViolationException::class);
+ Assert::validNCName($element, SchemaViolationException::class);
+
+ $key = ($namespace === null) ? $element : implode(':', [$namespace, $element]);
+ if (array_key_exists($key, $this->registry) === true) {
+ return $this->registry[$key];
+ }
+
+ return null;
+ }
+
+
/**
* Search for a class that implements a custom element type.
*
@@ -74,29 +100,29 @@ public function registerExtensionHandler(string $class): void
public function getExtensionHandler(string $type): ?string
{
Assert::notEmpty($type, 'Cannot search for identifier handlers with an empty type.');
-
$type = implode(':', [self::XSI_TYPE_PREFIX, $type]);
if (!array_key_exists($type, $this->registry)) {
return null;
}
-
Assert::implementsInterface($this->registry[$type], ExtensionPointInterface::class);
return $this->registry[$type];
}
/**
- * Get a PSR-3 compatible logger.
- * @return \Psr\Log\LoggerInterface
+ * Set the list of algorithms that are blacklisted for any encryption operation.
+ *
+ * @param string[]|null $algos An array with all algorithm identifiers that are blacklisted,
+ * or null if we want to use the defaults.
*/
- abstract public function getLogger(): LoggerInterface;
+ abstract public function setBlacklistedAlgorithms(?array $algos): void;
/**
- * Generate a random identifier for identifying SAML2 documents.
- * @return string
+ * Get a PSR-3 compatible logger.
+ * @return \Psr\Log\LoggerInterface
*/
- abstract public function generateId(): string;
+ abstract public function getLogger(): LoggerInterface;
/**
@@ -110,7 +136,6 @@ abstract public function generateId(): string;
*
* @param \DOMElement|string $message
* @param string $type
- * @return void
*/
abstract public function debugMessage($message, string $type): void;
@@ -122,7 +147,7 @@ abstract public function debugMessage($message, string $type): void;
* @param array $data
* @return string
*/
- abstract public function getpostRedirectURL(string $url, array $data = []): string;
+ abstract public function getPOSTRedirectURL(string $url, array $data = []): string;
/**
@@ -143,21 +168,11 @@ abstract public function getTempDir(): string;
*
* @param string $filename The path to the file we want to write to.
* @param string $data The data we should write to the file.
- * @param int $mode The permissions to apply to the file. Defaults to 0600.
- * @return void
+ * @param int|null $mode The permissions to apply to the file. Defaults to 0600.
*/
abstract public function writeFile(string $filename, string $data, int $mode = null): void;
- /**
- * Set the list of algorithms that are blacklisted for any encryption operation.
- *
- * @param string[]|null $algos An array with all algorithm identifiers that are blacklisted,
- * or null if we want to use the defaults.
- */
- abstract public function setBlacklistedAlgorithms(?array $algos): void;
-
-
/**
* Get the system clock, using UTC for a timezone
*/
diff --git a/src/SAML2/Compat/ContainerSingleton.php b/src/SAML2/Compat/ContainerSingleton.php
index e44e361c8..1e6f0dae2 100644
--- a/src/SAML2/Compat/ContainerSingleton.php
+++ b/src/SAML2/Compat/ContainerSingleton.php
@@ -8,9 +8,7 @@
class ContainerSingleton
{
- /**
- * @var \SimpleSAML\SAML2\Compat\AbstractContainer
- */
+ /** @var \SimpleSAML\SAML2\Compat\AbstractContainer */
protected static AbstractContainer $container;
@@ -28,7 +26,6 @@ public static function getInstance(): AbstractContainer
* Set a container to use.
*
* @param \SimpleSAML\SAML2\Compat\AbstractContainer $container
- * @return void
*/
public static function setContainer(AbstractContainer $container): void
{
diff --git a/src/SAML2/Compat/MockContainer.php b/src/SAML2/Compat/MockContainer.php
index a9e413763..f03cad57c 100644
--- a/src/SAML2/Compat/MockContainer.php
+++ b/src/SAML2/Compat/MockContainer.php
@@ -9,7 +9,8 @@
use Psr\Log\NullLogger;
use function chmod;
-use function file_get_contents;
+use function file_put_contents;
+use function strval;
use function sys_get_temp_dir;
/**
@@ -20,14 +21,7 @@ class MockContainer extends AbstractContainer
/** @var \Psr\Clock\ClockInterface */
private ClockInterface $clock;
- /**
- * @var string
- */
- private string $id = '123';
-
- /**
- * @var array
- */
+ /** @var array */
private array $debugMessages = [];
@@ -41,16 +35,6 @@ public function getLogger(): LoggerInterface
}
- /**
- * Generate a random identifier for identifying SAML2 documents.
- * @return string
- */
- public function generateId(): string
- {
- return $this->id;
- }
-
-
/**
* Log an incoming message to the debug log.
*
@@ -62,7 +46,6 @@ public function generateId(): string
*
* @param \DOMElement|string $message
* @param string $type
- * @return void
*/
public function debugMessage($message, string $type): void
{
@@ -73,15 +56,15 @@ public function debugMessage($message, string $type): void
/**
* Trigger the user to perform a POST to the given URL with the given data.
*
- * @param string $url
+ * @param string|null $url
* @param array $data
* @return string
*/
- public function getPostRedirectURL(
- /** @scrutinizer ignore-unused */string $url,
+ public function getPOSTRedirectURL(
+ /** @scrutinizer ignore-unused */string $url = null,
/** @scrutinizer ignore-unused */array $data = []
): string {
- return $url;
+ return strval($url);
}
@@ -98,7 +81,6 @@ public function getTempDir(): string
* @param string $filename
* @param string $data
* @param int|null $mode
- * @return void
*/
public function writeFile(string $filename, string $data, int $mode = null): void
{
diff --git a/src/SAML2/Configuration/ArrayAdapter.php b/src/SAML2/Configuration/ArrayAdapter.php
index 0be8fddde..0f6a98777 100644
--- a/src/SAML2/Configuration/ArrayAdapter.php
+++ b/src/SAML2/Configuration/ArrayAdapter.php
@@ -11,16 +11,12 @@
*/
class ArrayAdapter implements Queryable
{
- /** @var array */
- private array $configuration;
-
-
/**
* @param array $configuration
*/
- public function __construct(array $configuration)
- {
- $this->configuration = $configuration;
+ public function __construct(
+ private array $configuration,
+ ) {
}
diff --git a/src/SAML2/Configuration/CertificateProvider.php b/src/SAML2/Configuration/CertificateProvider.php
index 201302028..e90f69623 100644
--- a/src/SAML2/Configuration/CertificateProvider.php
+++ b/src/SAML2/Configuration/CertificateProvider.php
@@ -4,8 +4,6 @@
namespace SimpleSAML\SAML2\Configuration;
-use Traversable;
-
/**
* CertificateProvider interface.
*/
@@ -18,7 +16,7 @@ interface CertificateProvider extends Queryable
*
* @return null|array|\Traversable
*/
- public function getKeys(): Traversable|array|null;
+ public function getKeys();
/**
diff --git a/src/SAML2/Configuration/Destination.php b/src/SAML2/Configuration/Destination.php
index 5865e6e07..3f1d41e57 100644
--- a/src/SAML2/Configuration/Destination.php
+++ b/src/SAML2/Configuration/Destination.php
@@ -4,18 +4,18 @@
namespace SimpleSAML\SAML2\Configuration;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
+use Stringable;
/**
* Value Object representing the current destination
*/
-class Destination
+class Destination implements Stringable
{
/**
* @param string $destination
*/
public function __construct(
- private string $destination
+ private string $destination,
) {
}
diff --git a/src/SAML2/Configuration/IdentityProvider.php b/src/SAML2/Configuration/IdentityProvider.php
index df09cd7af..03f9ac50e 100644
--- a/src/SAML2/Configuration/IdentityProvider.php
+++ b/src/SAML2/Configuration/IdentityProvider.php
@@ -4,8 +4,7 @@
namespace SimpleSAML\SAML2\Configuration;
-use SimpleSAML\SAML2\Exception\RuntimeException;
-use Traversable;
+use RuntimeException;
use function array_filter;
use function array_pop;
@@ -15,12 +14,12 @@
/**
* Basic configuration wrapper
*/
-class IdentityProvider extends ArrayAdapter implements CertificateProvider, DecryptionProvider, EntityIdProvider
+final class IdentityProvider extends ArrayAdapter implements CertificateProvider, DecryptionProvider, EntityIdProvider
{
/**
* @return array|\Traversable|null
*/
- public function getKeys(): Traversable|array|null
+ public function getKeys()
{
return $this->get('keys');
}
@@ -70,16 +69,6 @@ public function getSharedKey(): ?string
return $this->get('sharedKey');
}
-
- /**
- * @return mixed|null
- */
- public function hasBase64EncodedAttributes()
- {
- return $this->get('base64EncodedAttributes');
- }
-
-
/**
* @param string $name
* @param bool $required
@@ -101,7 +90,7 @@ public function getPrivateKey(string $name, bool $required = null)
'Attempted to get privateKey by name "%s", found "%d" keys, where only one was expected. Please '
. 'verify that your configuration is correct',
$name,
- $keyCount
+ $keyCount,
));
}
diff --git a/src/SAML2/Configuration/IdentityProviderAware.php b/src/SAML2/Configuration/IdentityProviderAware.php
index b9084c403..6adea8350 100644
--- a/src/SAML2/Configuration/IdentityProviderAware.php
+++ b/src/SAML2/Configuration/IdentityProviderAware.php
@@ -12,7 +12,6 @@ interface IdentityProviderAware
/**
* @param \SimpleSAML\SAML2\Configuration\IdentityProvider $identityProvider
*
- * @return void
*/
public function setIdentityProvider(IdentityProvider $identityProvider): void;
}
diff --git a/src/SAML2/Configuration/PrivateKey.php b/src/SAML2/Configuration/PrivateKey.php
index 6704faa6c..f92105b5e 100644
--- a/src/SAML2/Configuration/PrivateKey.php
+++ b/src/SAML2/Configuration/PrivateKey.php
@@ -4,15 +4,17 @@
namespace SimpleSAML\SAML2\Configuration;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
-use SimpleSAML\SAML2\Exception\RuntimeException;
+use SimpleSAML\Assert\Assert;
/**
* Configuration of a private key.
*/
class PrivateKey extends ArrayAdapter
{
+ /** @var string */
public const NAME_NEW = 'new';
+
+ /** @var string */
public const NAME_DEFAULT = 'default';
@@ -35,12 +37,12 @@ public function __construct(
/**
* @return string
+ *
+ * @throws \SimpleSAML\Assert\AssertionFailedException if assertions are false
*/
public function getFilePath(): string
{
- if (!$this->isFile()) {
- throw new RuntimeException('No path provided.');
- }
+ Assert::true($this->isFile(), 'No path provided.');
return $this->filePathOrContents;
}
@@ -51,14 +53,14 @@ public function getFilePath(): string
*/
public function hasPassPhrase(): bool
{
- return $this->passphrase !== null;
+ return !empty($this->passphrase);
}
/**
- * @return string|null
+ * @return string
*/
- public function getPassPhrase(): ?string
+ public function getPassPhrase(): string
{
return $this->passphrase;
}
@@ -74,12 +76,12 @@ public function getName(): string
/**
* @return string
+ *
+ * @throws \SimpleSAML\Assert\AssertionFailedException if assertions are false
*/
public function getContents(): string
{
- if ($this->isFile()) {
- throw new RuntimeException('No contents provided');
- }
+ Assert::false($this->isFile(), 'No contents provided.');
return $this->filePathOrContents;
}
diff --git a/src/SAML2/Configuration/Queryable.php b/src/SAML2/Configuration/Queryable.php
index 6dede5c87..a63e4d64b 100644
--- a/src/SAML2/Configuration/Queryable.php
+++ b/src/SAML2/Configuration/Queryable.php
@@ -5,7 +5,7 @@
namespace SimpleSAML\SAML2\Configuration;
/**
- * Interface \SAML2\Configuration\Queryable
+ * Interface \SimpleSAML\SAML2\Configuration\Queryable
*/
interface Queryable
{
diff --git a/src/SAML2/Configuration/ServiceProvider.php b/src/SAML2/Configuration/ServiceProvider.php
index 1c501ad7b..d2e92a2c6 100644
--- a/src/SAML2/Configuration/ServiceProvider.php
+++ b/src/SAML2/Configuration/ServiceProvider.php
@@ -4,9 +4,8 @@
namespace SimpleSAML\SAML2\Configuration;
-use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Exception\RuntimeException;
-use Traversable;
+use RuntimeException;
+use SimpleSAML\XMLSecurity\Constants as C;
use function array_filter;
use function array_pop;
@@ -21,7 +20,7 @@ class ServiceProvider extends ArrayAdapter implements CertificateProvider, Decry
/**
* @return null|array|\Traversable
*/
- public function getKeys(): Traversable|array|null
+ public function getKeys()
{
return $this->get('keys');
}
@@ -102,7 +101,7 @@ public function getPrivateKey(string $name, bool $required = null)
'Attempted to get privateKey by name "%s", found "%d" keys, where only one was expected. Please '
. 'verify that your configuration is correct',
$name,
- $keyCount
+ $keyCount,
));
}
diff --git a/src/SAML2/Configuration/ServiceProviderAware.php b/src/SAML2/Configuration/ServiceProviderAware.php
index 63367b244..564352911 100644
--- a/src/SAML2/Configuration/ServiceProviderAware.php
+++ b/src/SAML2/Configuration/ServiceProviderAware.php
@@ -11,7 +11,6 @@ interface ServiceProviderAware
{
/**
* @param \SimpleSAML\SAML2\Configuration\ServiceProvider $serviceProvider
- * @return void
*/
public function setServiceProvider(ServiceProvider $serviceProvider): void;
}
diff --git a/src/SAML2/Configuration/SimpleSAMLConverter.php b/src/SAML2/Configuration/SimpleSAMLConverter.php
index 86b1c4a2c..6eafa76e6 100644
--- a/src/SAML2/Configuration/SimpleSAMLConverter.php
+++ b/src/SAML2/Configuration/SimpleSAMLConverter.php
@@ -21,7 +21,7 @@ class SimpleSAMLConverter
*/
public static function convertToIdentityProvider(
Configuration $configuration,
- string $certificatePrefix = ''
+ string $certificatePrefix = '',
): IdentityProvider {
$pluckedConfiguration = static::pluckConfiguration($configuration, $certificatePrefix);
static::enrichForDecryptionProvider($configuration, $pluckedConfiguration);
@@ -41,7 +41,7 @@ public static function convertToIdentityProvider(
*/
public static function convertToServiceProvider(
Configuration $configuration,
- string $certificatePrefix = ''
+ string $certificatePrefix = '',
): ServiceProvider {
$pluckedConfiguration = static::pluckConfiguration($configuration, $certificatePrefix);
static::enrichForServiceProvider($configuration, $pluckedConfiguration);
@@ -95,13 +95,11 @@ protected static function pluckConfiguration(Configuration $configuration, strin
* @param \SimpleSAML\Configuration $configuration
* @param array $baseConfiguration
*
- * @return void
*
* @psalm-suppress UndefinedClass
*/
protected static function enrichForIdentityProvider(Configuration $configuration, array &$baseConfiguration): void
{
- $baseConfiguration['base64EncodedAttributes'] = $configuration->getBoolean('base64attributes', false);
$baseConfiguration['entityId'] = $configuration->getString('entityid');
}
@@ -110,7 +108,6 @@ protected static function enrichForIdentityProvider(Configuration $configuration
* @param \SimpleSAML\Configuration $configuration
* @param array $baseConfiguration
*
- * @return void
*
* @psalm-suppress UndefinedClass
*/
@@ -124,13 +121,12 @@ protected static function enrichForServiceProvider(Configuration $configuration,
* @param \SimpleSAML\Configuration $configuration
* @param array $baseConfiguration
*
- * @return void
*
* @psalm-suppress UndefinedClass
*/
protected static function enrichForDecryptionProvider(
Configuration $configuration,
- array &$baseConfiguration
+ array &$baseConfiguration,
): void {
if ($configuration->hasValue('sharedKey')) {
$baseConfiguration['sharedKey'] = $configuration->getString('sharedKey', null);
@@ -140,7 +136,7 @@ protected static function enrichForDecryptionProvider(
$baseConfiguration['privateKeys'][] = new PrivateKey(
$configuration->getString('new_privatekey'),
PrivateKey::NAME_NEW,
- $configuration->getString('new_privatekey_pass', null)
+ $configuration->getString('new_privatekey_pass', null),
);
}
@@ -148,12 +144,13 @@ protected static function enrichForDecryptionProvider(
$baseConfiguration['privateKeys'][] = new PrivateKey(
$configuration->getString('privatekey'),
PrivateKey::NAME_DEFAULT,
- $configuration->getString('privatekey_pass', null)
+ $configuration->getString('privatekey_pass', null),
);
if ($configuration->hasValue('encryption.blacklisted-algorithms')) {
- $baseConfiguration['blacklistedEncryptionAlgorithms'] = $configuration
- ->getValue('encryption.blacklisted-algorithms');
+ $baseConfiguration['blacklistedEncryptionAlgorithms'] = $configuration->getValue(
+ 'encryption.blacklisted-algorithms'
+ );
}
}
}
diff --git a/src/SAML2/Exception/InvalidArgumentException.php b/src/SAML2/Exception/InvalidArgumentException.php
index bde06e809..55214599e 100644
--- a/src/SAML2/Exception/InvalidArgumentException.php
+++ b/src/SAML2/Exception/InvalidArgumentException.php
@@ -5,14 +5,13 @@
namespace SimpleSAML\SAML2\Exception;
use InvalidArgumentException as BuiltinInvalidArgumentException;
-use Throwable;
-use function gettype;
use function get_class;
+use function gettype;
use function is_object;
use function sprintf;
-class InvalidArgumentException extends BuiltinInvalidArgumentException implements Throwable
+class InvalidArgumentException extends BuiltinInvalidArgumentException
{
/**
* @param string $expected description of expected type
@@ -25,7 +24,7 @@ public static function invalidType(string $expected, $parameter): InvalidArgumen
$message = sprintf(
'Invalid Argument type: "%s" expected, "%s" given',
$expected,
- is_object($parameter) ? get_class($parameter) : gettype($parameter)
+ is_object($parameter) ? get_class($parameter) : gettype($parameter),
);
return new self($message);
diff --git a/src/SAML2/Exception/Protocol/AuthnFailedException.php b/src/SAML2/Exception/Protocol/AuthnFailedException.php
index 1aa7452a2..8dd02308f 100644
--- a/src/SAML2/Exception/Protocol/AuthnFailedException.php
+++ b/src/SAML2/Exception/Protocol/AuthnFailedException.php
@@ -13,11 +13,5 @@
*/
class AuthnFailedException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Authentication failed.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Authentication failed.';
}
diff --git a/src/SAML2/Exception/Protocol/InvalidAttrNameOrValueException.php b/src/SAML2/Exception/Protocol/InvalidAttrNameOrValueException.php
index 7a11cbd4a..1f63997b9 100644
--- a/src/SAML2/Exception/Protocol/InvalidAttrNameOrValueException.php
+++ b/src/SAML2/Exception/Protocol/InvalidAttrNameOrValueException.php
@@ -14,11 +14,5 @@
*/
class InvalidAttrNameOrValueException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Invalid attribute name or value.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Invalid attribute name or value.';
}
diff --git a/src/SAML2/Exception/Protocol/InvalidNameIDPolicyException.php b/src/SAML2/Exception/Protocol/InvalidNameIDPolicyException.php
index 08287374f..bd16148f6 100644
--- a/src/SAML2/Exception/Protocol/InvalidNameIDPolicyException.php
+++ b/src/SAML2/Exception/Protocol/InvalidNameIDPolicyException.php
@@ -13,11 +13,5 @@
*/
class InvalidNameIDPolicyException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Invalid NameID policy.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Invalid NameID policy.';
}
diff --git a/src/SAML2/Exception/Protocol/NoAuthnContextException.php b/src/SAML2/Exception/Protocol/NoAuthnContextException.php
index 76be0543f..3a5889ceb 100644
--- a/src/SAML2/Exception/Protocol/NoAuthnContextException.php
+++ b/src/SAML2/Exception/Protocol/NoAuthnContextException.php
@@ -13,11 +13,5 @@
*/
class NoAuthnContextException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'None of the requested AuthnContext can be used.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'None of the requested AuthnContexts can be used.';
}
diff --git a/src/SAML2/Exception/Protocol/NoAvailableIDPException.php b/src/SAML2/Exception/Protocol/NoAvailableIDPException.php
index 47c0751d6..c20718a15 100644
--- a/src/SAML2/Exception/Protocol/NoAvailableIDPException.php
+++ b/src/SAML2/Exception/Protocol/NoAvailableIDPException.php
@@ -14,11 +14,5 @@
*/
class NoAvailableIDPException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'No IDP available.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'No IdP available.';
}
diff --git a/src/SAML2/Exception/Protocol/NoPassiveException.php b/src/SAML2/Exception/Protocol/NoPassiveException.php
index 9e2f6dc06..8a4f4e4a9 100644
--- a/src/SAML2/Exception/Protocol/NoPassiveException.php
+++ b/src/SAML2/Exception/Protocol/NoPassiveException.php
@@ -14,11 +14,5 @@
*/
class NoPassiveException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Cannot perform passive authentication.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Cannot perform passive authentication.';
}
diff --git a/src/SAML2/Exception/Protocol/NoSupportedIDPException.php b/src/SAML2/Exception/Protocol/NoSupportedIDPException.php
index 466f3620d..663fd2af9 100644
--- a/src/SAML2/Exception/Protocol/NoSupportedIDPException.php
+++ b/src/SAML2/Exception/Protocol/NoSupportedIDPException.php
@@ -14,11 +14,5 @@
*/
class NoSupportedIDPException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'No supported IDP.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'No supported IdP.';
}
diff --git a/src/SAML2/Exception/Protocol/PartialLogoutException.php b/src/SAML2/Exception/Protocol/PartialLogoutException.php
index 177807715..5744a146e 100644
--- a/src/SAML2/Exception/Protocol/PartialLogoutException.php
+++ b/src/SAML2/Exception/Protocol/PartialLogoutException.php
@@ -14,11 +14,5 @@
*/
class PartialLogoutException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Unable to propagate logout to all other session participants.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Unable to propagate logout to all other session participants.';
}
diff --git a/src/SAML2/Exception/Protocol/ProxyCountExceededException.php b/src/SAML2/Exception/Protocol/ProxyCountExceededException.php
index 5e4de4709..4277ff816 100644
--- a/src/SAML2/Exception/Protocol/ProxyCountExceededException.php
+++ b/src/SAML2/Exception/Protocol/ProxyCountExceededException.php
@@ -14,11 +14,5 @@
*/
class ProxyCountExceededException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Proxy count exceeded.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Proxy count exceeded.';
}
diff --git a/src/SAML2/Exception/Protocol/RequestDeniedException.php b/src/SAML2/Exception/Protocol/RequestDeniedException.php
index 02c4d247c..f558f03bd 100644
--- a/src/SAML2/Exception/Protocol/RequestDeniedException.php
+++ b/src/SAML2/Exception/Protocol/RequestDeniedException.php
@@ -14,11 +14,5 @@
*/
class RequestDeniedException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Request denied.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Request denied.';
}
diff --git a/src/SAML2/Exception/Protocol/RequestUnsupportedException.php b/src/SAML2/Exception/Protocol/RequestUnsupportedException.php
index fc05aa2a9..6f9f57a45 100644
--- a/src/SAML2/Exception/Protocol/RequestUnsupportedException.php
+++ b/src/SAML2/Exception/Protocol/RequestUnsupportedException.php
@@ -13,11 +13,5 @@
*/
class RequestUnsupportedException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Unsupported request.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Unsupported request.';
}
diff --git a/src/SAML2/Exception/Protocol/RequestVersionDeprecatedException.php b/src/SAML2/Exception/Protocol/RequestVersionDeprecatedException.php
index 995310209..c37c9d482 100644
--- a/src/SAML2/Exception/Protocol/RequestVersionDeprecatedException.php
+++ b/src/SAML2/Exception/Protocol/RequestVersionDeprecatedException.php
@@ -14,11 +14,5 @@
*/
class RequestVersionDeprecatedException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Deprecated version used.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Deprecated version used.';
}
diff --git a/src/SAML2/Exception/Protocol/RequestVersionTooHighException.php b/src/SAML2/Exception/Protocol/RequestVersionTooHighException.php
index 37f618e55..c5567f84d 100644
--- a/src/SAML2/Exception/Protocol/RequestVersionTooHighException.php
+++ b/src/SAML2/Exception/Protocol/RequestVersionTooHighException.php
@@ -14,11 +14,5 @@
*/
class RequestVersionTooHighException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Protocol version too high.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Protocol version too high.';
}
diff --git a/src/SAML2/Exception/Protocol/RequestVersionTooLowException.php b/src/SAML2/Exception/Protocol/RequestVersionTooLowException.php
index 905a82925..f1da23810 100644
--- a/src/SAML2/Exception/Protocol/RequestVersionTooLowException.php
+++ b/src/SAML2/Exception/Protocol/RequestVersionTooLowException.php
@@ -14,11 +14,5 @@
*/
class RequestVersionTooLowException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Protocol version too low.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Protocol version too low.';
}
diff --git a/src/SAML2/Exception/Protocol/ResourceNotRecognizedException.php b/src/SAML2/Exception/Protocol/ResourceNotRecognizedException.php
index b5bc7f33e..15f6abb94 100644
--- a/src/SAML2/Exception/Protocol/ResourceNotRecognizedException.php
+++ b/src/SAML2/Exception/Protocol/ResourceNotRecognizedException.php
@@ -14,11 +14,5 @@
*/
class ResourceNotRecognizedException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Resource not recognized.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Resource not recognized.';
}
diff --git a/src/SAML2/Exception/Protocol/TooManyResponsesException.php b/src/SAML2/Exception/Protocol/TooManyResponsesException.php
index 8ecde382b..10690bff0 100644
--- a/src/SAML2/Exception/Protocol/TooManyResponsesException.php
+++ b/src/SAML2/Exception/Protocol/TooManyResponsesException.php
@@ -14,11 +14,5 @@
*/
class TooManyResponsesException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Too many responses.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Too many responses.';
}
diff --git a/src/SAML2/Exception/Protocol/UnknownAttrProfileException.php b/src/SAML2/Exception/Protocol/UnknownAttrProfileException.php
index fb2551679..0ed751f16 100644
--- a/src/SAML2/Exception/Protocol/UnknownAttrProfileException.php
+++ b/src/SAML2/Exception/Protocol/UnknownAttrProfileException.php
@@ -14,11 +14,5 @@
*/
class UnknownAttrProfileException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Unknown attribute profile.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Unknown attribute profile.';
}
diff --git a/src/SAML2/Exception/Protocol/UnknownPrincipalException.php b/src/SAML2/Exception/Protocol/UnknownPrincipalException.php
index 77a7681f4..c868ad720 100644
--- a/src/SAML2/Exception/Protocol/UnknownPrincipalException.php
+++ b/src/SAML2/Exception/Protocol/UnknownPrincipalException.php
@@ -14,11 +14,5 @@
*/
class UnknownPrincipalException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Unknown principal.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Unknown principal.';
}
diff --git a/src/SAML2/Exception/Protocol/UnsupportedBindingException.php b/src/SAML2/Exception/Protocol/UnsupportedBindingException.php
index 539ee0932..d2d6a0da0 100644
--- a/src/SAML2/Exception/Protocol/UnsupportedBindingException.php
+++ b/src/SAML2/Exception/Protocol/UnsupportedBindingException.php
@@ -14,11 +14,5 @@
*/
class UnsupportedBindingException extends ProtocolViolationException
{
- /**
- * @param string $message
- */
- public function __construct(string $message = 'Unsupported binding.')
- {
- parent::__construct($message);
- }
+ public const DEFAULT_MESSAGE = 'Unsupported binding.';
}
diff --git a/src/SAML2/Exception/ProtocolViolationException.php b/src/SAML2/Exception/ProtocolViolationException.php
index cd264f827..99eb73d37 100644
--- a/src/SAML2/Exception/ProtocolViolationException.php
+++ b/src/SAML2/Exception/ProtocolViolationException.php
@@ -5,10 +5,25 @@
namespace SimpleSAML\SAML2\Exception;
/**
- * This exception may be raised when a violation of the SAML2 is detected
+ * This exception may be raised when a violation of the SAML2 specification is detected
*
* @package simplesamlphp/saml2
*/
class ProtocolViolationException extends RuntimeException
{
+ /**
+ * @param string $message
+ */
+ public function __construct(string $message = null)
+ {
+ if ($message === null) {
+ if (defined('static::DEFAULT_MESSAGE')) {
+ $message = static::DEFAULT_MESSAGE;
+ } else {
+ $message = 'A violation of the SAML2 protocol occurred.';
+ }
+ }
+
+ parent::__construct($message);
+ }
}
diff --git a/src/SAML2/Exception/RuntimeException.php b/src/SAML2/Exception/RuntimeException.php
index f6f0738af..bdc557b29 100644
--- a/src/SAML2/Exception/RuntimeException.php
+++ b/src/SAML2/Exception/RuntimeException.php
@@ -5,11 +5,10 @@
namespace SimpleSAML\SAML2\Exception;
use RuntimeException as BuiltinRuntimeException;
-use Throwable;
/**
* Named exception
*/
-class RuntimeException extends BuiltinRuntimeException implements Throwable
+class RuntimeException extends BuiltinRuntimeException
{
}
diff --git a/src/SAML2/Exception/UnsupportedBindingException.php b/src/SAML2/Exception/UnsupportedBindingException.php
new file mode 100644
index 000000000..7090eb629
--- /dev/null
+++ b/src/SAML2/Exception/UnsupportedBindingException.php
@@ -0,0 +1,14 @@
+getQueryParams();
if (array_key_exists('SAMLart', $query)) {
- Assert::stringPlausibleBase64($query['SAMLart'], 'Error while base64 decoding SAML message.', Exception::class);
- $artifact = base64_decode($query['SAMLart'], true); // Error handling already dealt with by assertion
-
+ $artifact = base64_decode($query['SAMLart'], true);
$endpointIndex = bin2hex(substr($artifact, 2, 2));
$sourceId = bin2hex(substr($artifact, 4, 20));
} else {
diff --git a/src/SAML2/HTTPPost.php b/src/SAML2/HTTPPost.php
index 1a23e3daa..5d4799958 100644
--- a/src/SAML2/HTTPPost.php
+++ b/src/SAML2/HTTPPost.php
@@ -4,8 +4,6 @@
namespace SimpleSAML\SAML2;
-use DOMDocument;
-use DOMElement;
use Exception;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
@@ -90,8 +88,7 @@ public function receive(ServerRequestInterface $request): AbstractMessage
throw new Exception('Missing SAMLRequest or SAMLResponse parameter.');
}
- Assert::stringPlausibleBase64($msgStr, 'Error while base64 decoding SAML message.', Exception::class);
- $msgStr = base64_decode($msgStr, true); // Error handling already dealt with by assertion
+ $msgStr = base64_decode($msgStr, true);
$msgStr = DOMDocumentFactory::fromString($msgStr)->saveXML();
$document = DOMDocumentFactory::fromString($msgStr);
diff --git a/src/SAML2/HTTPRedirect.php b/src/SAML2/HTTPRedirect.php
index b0dafbf60..95a3019ea 100644
--- a/src/SAML2/HTTPRedirect.php
+++ b/src/SAML2/HTTPRedirect.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2;
-use DOMElement;
use Exception;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
@@ -12,15 +11,13 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\XMLSecurity\Exception\SignatureVerificationFailedException;
use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
use SimpleSAML\SAML2\XML\samlp\AbstractRequest;
use SimpleSAML\SAML2\XML\samlp\MessageFactory;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PublicKey;
+use SimpleSAML\XMLSecurity\Exception\SignatureVerificationFailedException;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-use SimpleSAML\XMLSecurity\Utils\Security;
use function array_key_exists;
use function base64_decode;
@@ -28,8 +25,8 @@
use function gzdeflate;
use function gzinflate;
use function sprintf;
-use function strlen;
use function str_contains;
+use function strlen;
use function urlencode;
/**
@@ -139,8 +136,10 @@ public function receive(ServerRequestInterface $request): AbstractMessage
throw new Exception(sprintf('Unknown SAMLEncoding: %s', $query['SAMLEncoding']));
}
- Assert::stringPlausibleBase64($message, 'Error while base64 decoding SAML message.', Exception::class);
- $message = base64_decode($message, true); // Error handling already dealt with by assertion
+ $message = base64_decode($message, true);
+ if ($message === false) {
+ throw new Exception('Error while base64 decoding SAML message.');
+ }
$message = gzinflate($message);
if ($message === false) {
diff --git a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
index 95c54cd7b..23b411ca6 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
@@ -13,7 +13,6 @@
use function implode;
use function sprintf;
use function strlen;
-use function str_contains;
use function substr;
class IsSuccessful implements ConstraintValidator
diff --git a/src/SAML2/SOAP.php b/src/SAML2/SOAP.php
index 7ef5e16c5..de88a5816 100644
--- a/src/SAML2/SOAP.php
+++ b/src/SAML2/SOAP.php
@@ -4,28 +4,24 @@
namespace SimpleSAML\SAML2;
-use DOMDocument;
use Exception;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SimpleSAML\SAML2\Exception\Protocol\UnsupportedBindingException;
use SimpleSAML\SAML2\Utils;
-use SimpleSAML\SOAP11\Utils\XPath;
-use SimpleSAML\SAML2\XML\ecp\Response as ECPResponse;
use SimpleSAML\SAML2\XML\ecp\RequestAuthenticated;
+use SimpleSAML\SAML2\XML\ecp\Response as ECPResponse;
use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
use SimpleSAML\SAML2\XML\samlp\MessageFactory;
use SimpleSAML\SAML2\XML\samlp\Response as SAML2_Response;
-use SimpleSAML\SOAP\Constants as C;
+use SimpleSAML\SOAP11\Utils\XPath;
use SimpleSAML\SOAP11\XML\env\Body;
use SimpleSAML\SOAP11\XML\env\Envelope;
use SimpleSAML\SOAP11\XML\env\Header;
use SimpleSAML\XML\DOMDocumentFactory;
use function file_get_contents;
-use function header;
-use function sprintf;
/**
* Class which implements the SOAP binding.
diff --git a/src/SAML2/SOAPClient.php b/src/SAML2/SOAPClient.php
index b24c0c201..ee20afb2a 100644
--- a/src/SAML2/SOAPClient.php
+++ b/src/SAML2/SOAPClient.php
@@ -8,8 +8,6 @@
use Exception;
use SimpleSAML\Configuration;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
-use SimpleSAML\SAML2\Exception\RuntimeException;
use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
use SimpleSAML\SAML2\XML\samlp\MessageFactory;
use SimpleSAML\SOAP11\Utils\XPath;
@@ -20,7 +18,6 @@
use SimpleSAML\Utils\Crypto;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\UnparseableXMLException;
use SimpleSAML\XMLSecurity\XMLSecurityKey;
use SoapClient as BuiltinSoapClient;
diff --git a/src/SAML2/Signature/AbstractChainedValidator.php b/src/SAML2/Signature/AbstractChainedValidator.php
index eb66d7318..d2f0fea93 100644
--- a/src/SAML2/Signature/AbstractChainedValidator.php
+++ b/src/SAML2/Signature/AbstractChainedValidator.php
@@ -10,7 +10,6 @@
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
use SimpleSAML\XMLSecurity\CryptoEncoding\PEM;
use SimpleSAML\XMLSecurity\Key\X509Certificate as X509;
-use SimpleSAML\XMLSecurity\Utils\Security;
use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
use function sprintf;
diff --git a/src/SAML2/SignedElement.php b/src/SAML2/SignedElement.php
deleted file mode 100644
index 675926bc3..000000000
--- a/src/SAML2/SignedElement.php
+++ /dev/null
@@ -1,92 +0,0 @@
-certificates = $certificates;
- }
-
-
- /**
- * Retrieve the certificates that are included in the message.
- *
- * @return array An array of certificates
- */
- public function getCertificates(): array
- {
- return $this->certificates;
- }
-
-
- /**
- * Retrieve the private key we should use to sign the message.
- *
- * @return \RobRichards\XMLSecLibs\XMLSecurityKey|null The key, or NULL if no key is specified
- */
- public function getSignatureKey(): ?XMLSecurityKey
- {
- return $this->signatureKey;
- }
-
-
- /**
- * Set the private key we should use to sign the message.
- *
- * If the key is null, the message will be sent unsigned.
- *
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey|null $signatureKey
- * @return void
- */
- public function setSignatureKey(XMLSecurityKey $signatureKey = null): void
- {
- $this->signatureKey = $signatureKey;
- }
-}
diff --git a/src/SAML2/SignedElementHelper.php b/src/SAML2/SignedElementHelper.php
deleted file mode 100644
index ca10d37c4..000000000
--- a/src/SAML2/SignedElementHelper.php
+++ /dev/null
@@ -1,280 +0,0 @@
-certificates = [];
- $this->validators = [];
-
- if ($xml === null) {
- return;
- }
-
- /* Validate the signature element of the message. */
- try {
- $sig = Utils::validateElement($xml);
-
- if ($sig) {
- $this->certificates = $sig['Certificates'];
- $this->validators[] = [
- 'Function' => [Utils::class, 'validateSignature'],
- 'Data' => $sig,
- ];
- }
- } catch (Exception $e) {
- /* Ignore signature validation errors. */
- }
- }
-
-
- /**
- * Add a method for validating this element.
- *
- * This function is used for custom validation extensions
- *
- * @param callable $function The function which should be called.
- * @param mixed $data The data that should be included as the first parameter to the function.
- * @return void
- */
- public function addValidator(callable $function, $data): void
- {
- $this->validators[] = [
- 'Function' => $function,
- 'Data' => $data,
- ];
- }
-
-
- /**
- * Validate this element against a public key.
- *
- * true is returned on success, false is returned if we don't have any
- * signature we can validate. An exception is thrown if the signature
- * validation fails.
- *
- * @param XMLSecurityKey $key The key we should check against.
- * @return bool True on success, false when we don't have a signature.
- * @throws \Exception
- * @return bool true on success, false when we don't have a signature.
- */
- public function validate(XMLSecurityKey $key): bool
- {
- if (count($this->validators) === 0) {
- return false;
- }
-
- $exceptions = [];
-
- foreach ($this->validators as $validator) {
- $function = $validator['Function'];
- $data = $validator['Data'];
-
- try {
- call_user_func($function, $data, $key);
- /* We were able to validate the message with this validator. */
-
- return true;
- } catch (Exception $e) {
- $exceptions[] = $e;
- }
- }
-
- /* No validators were able to validate the message. */
- throw $exceptions[0];
- }
-
-
- /**
- * Retrieve the private key we should use to sign the message.
- *
- * @return \RobRichards\XMLSecLibs\XMLSecurityKey|null The key, or NULL if no key is specified.
- */
- public function getSignatureKey(): ?XMLSecurityKey
- {
- return $this->signatureKey;
- }
-
-
- /**
- * Set the private key we should use to sign the message.
- *
- * If the key is null, the message will be sent unsigned.
- *
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey|null $signatureKey
- * @return void
- */
- public function setSignatureKey(XMLSecurityKey $signatureKey = null): void
- {
- $this->signatureKey = $signatureKey;
- }
-
-
- /**
- * Set the certificates that should be included in the message.
- *
- * The certificates should be strings with the PEM encoded data.
- *
- * @param array $certificates An array of certificates.
- * @return void
- */
- public function setCertificates(array $certificates): void
- {
- $this->certificates = $certificates;
- }
-
-
- /**
- * Retrieve the certificates that are included in the message.
- *
- * @return array An array of certificates.
- */
- public function getCertificates(): array
- {
- return $this->certificates;
- }
-
-
- /**
- * Retrieve certificates that sign this element.
- *
- * @return array Array with certificates.
- */
- public function getValidatingCertificates(): array
- {
- $ret = [];
- foreach ($this->certificates as $cert) {
- /* Construct a PEM formatted certificate */
- $pemCert = "-----BEGIN CERTIFICATE-----\n" .
- chunk_split($cert, 64) .
- "-----END CERTIFICATE-----\n";
-
- /* Extract the public key from the certificate for validation. */
- $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']);
- $key->loadKey($pemCert);
-
- try {
- /* Check the signature. */
- if ($this->validate($key)) {
- $ret[] = $cert;
- }
- } catch (Exception $e) {
- /* This certificate does not sign this element. */
- }
- }
-
- return $ret;
- }
-
-
- /**
- * Collect the value of the validUntil property.
- *
- * @return int|null
- */
- public function getValidUntil(): ?int
- {
- return $this->validUntil;
- }
-
- /**
- * Set the value of the validUntil property.
- *
- * @param int|null $validUntil
- * @return void
- */
- public function setValidUntil(int $validUntil = null): void
- {
- $this->validUntil = $validUntil;
- }
-
-
- /**
- * Collect the value of the cacheDuration property.
- *
- * @return string|null
- */
- public function getCacheDuration(): ?string
- {
- return $this->cacheDuration;
- }
-
-
- /**
- * Set the value of the cacheDuration property.
- *
- * @param string|null $cacheDuration
- * @return void
- */
- public function setCacheDuration(string $cacheDuration = null): void
- {
- $this->cacheDuration = $cacheDuration;
- }
-
-
- /**
- * Sign the given XML element.
- *
- * @param \DOMElement $root The element we should sign.
- * @param \DOMNode|null $insertBefore The element we should insert the signature node before.
- * @return \DOMElement|null
- */
- protected function signElement(DOMElement $root, DOMNode $insertBefore = null): ?DOMElement
- {
- if ($this->signatureKey === null) {
- /* We cannot sign this element. */
- return null;
- }
-
- Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);
-
- return $root;
- }
-}
diff --git a/src/SAML2/Utilities/ArrayCollection.php b/src/SAML2/Utilities/ArrayCollection.php
index 595895050..2f07b21ad 100644
--- a/src/SAML2/Utilities/ArrayCollection.php
+++ b/src/SAML2/Utilities/ArrayCollection.php
@@ -9,6 +9,7 @@
use SimpleSAML\SAML2\Exception\RuntimeException;
use function array_filter;
+use function array_map;
use function array_search;
use function count;
use function end;
@@ -32,13 +33,12 @@ public function __construct(
/**
- * @param mixed $key
+ * @param mixed $element
*
- * @return void
*/
- public function add($key): void
+ public function add($element): void
{
- $this->elements[] = $key;
+ $this->elements[] = $element;
}
@@ -67,7 +67,6 @@ public function filter(Closure $filterFunction): Collection
/**
* @param mixed $key
* @param mixed $value
- * @return void
*/
public function set($key, $value): void
{
@@ -76,31 +75,30 @@ public function set($key, $value): void
/**
- * @param mixed $key
+ * @param mixed $element
*
- * @return void
*/
- public function remove($key): void
+ public function remove($element): void
{
- $elt = array_search($key, $this->elements);
- if ($elt === false) {
+ $key = array_search($element, $this->elements);
+ if ($key === false) {
return;
}
- unset($this->elements[$elt]);
+ unset($this->elements[$key]);
}
/**
- * @throws \SimpleSAML\SAML2\Exception\RuntimeException
+ * @throws RuntimeException
* @return bool|mixed
*/
public function getOnlyElement()
{
if ($this->count() !== 1) {
throw new RuntimeException(sprintf(
- __CLASS__ . '::' . __METHOD__ . ' requires that the collection has exactly one element, '
+ __METHOD__ . ' requires that the collection has exactly one element, '
. '"%d" elements found',
- $this->count()
+ $this->count(),
));
}
@@ -181,7 +179,6 @@ public function offsetGet($offset)
/**
* @param mixed $offset
* @param mixed $value
- * @return void
*/
public function offsetSet($offset, $value): void
{
@@ -191,7 +188,6 @@ public function offsetSet($offset, $value): void
/**
* @param $offset
- * @return void
*/
public function offsetUnset($offset): void
{
diff --git a/src/SAML2/Utilities/Collection.php b/src/SAML2/Utilities/Collection.php
index bf06b2a75..4b3f0affb 100644
--- a/src/SAML2/Utilities/Collection.php
+++ b/src/SAML2/Utilities/Collection.php
@@ -14,11 +14,10 @@ interface Collection extends ArrayAccess, Countable, IteratorAggregate
/**
* Add an element to the collection
*
- * @param mixed $key
+ * @param mixed $element
*
- * @return void
*/
- public function add($key): void;
+ public function add($element): void;
/**
@@ -78,9 +77,8 @@ public function get($key);
/**
* @param mixed $element
- * @return void
*/
- public function remove($key): void;
+ public function remove($element): void;
/**
@@ -88,7 +86,6 @@ public function remove($key): void;
*
* @param mixed $key
* @param mixed $value
- * @return void
*/
public function set($key, $value): void;
}
diff --git a/src/SAML2/Utilities/File.php b/src/SAML2/Utilities/File.php
index 7a651d9b4..cab36471d 100644
--- a/src/SAML2/Utilities/File.php
+++ b/src/SAML2/Utilities/File.php
@@ -4,12 +4,11 @@
namespace SimpleSAML\SAML2\Utilities;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
use SimpleSAML\SAML2\Exception\RuntimeException;
+use function file_get_contents;
use function is_readable;
use function sprintf;
-use function file_get_contents;
/**
* Various File Utilities
@@ -26,7 +25,7 @@ public static function getFileContents(string $file): string
if (!is_readable($file)) {
throw new RuntimeException(sprintf(
'File "%s" does not exist or is not readable',
- $file
+ $file,
));
}
@@ -34,7 +33,7 @@ public static function getFileContents(string $file): string
if ($contents === false) {
throw new RuntimeException(sprintf(
'Could not read from existing and readable file "%s"',
- $file
+ $file,
));
}
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index 1d7a203cc..8222e0674 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -4,531 +4,37 @@
namespace SimpleSAML\SAML2;
-use DOMDocument;
-use DOMElement;
-use DOMNode;
-use DOMXPath;
-use Exception;
-use RobRichards\XMLSecLibs\XMLSecEnc;
-use RobRichards\XMLSecLibs\XMLSecurityDSig;
-use RobRichards\XMLSecLibs\XMLSecurityKey;
-use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Exception\RuntimeException;
-use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\md\KeyDescriptor;
-use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\MissingAttributeException;
-use SimpleSAML\XML\Exception\MissingElementException;
-use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XMLSecurity\Exception\NoSignatureFoundException;
-use SimpleSAML\XMLSecurity\Exception\SignatureVerificationFailedException;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
-use SimpleSAML\XMLSecurity\XML\ds\KeyName;
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
-use function count;
-use function in_array;
-use function openssl_pkey_get_details;
-use function serialize;
-use function sha1;
-use function strlen;
-use function str_pad;
-use function str_replace;
-use function strtolower;
-use function strval;
-use function substr;
-use function trim;
-use function var_export;
-
/**
* Helper functions for the SAML2 library.
*
- * @package SimpleSAMLphp
+ * @package simplesamlphp/saml2
*/
class Utils
{
/**
- * Check the Signature in a XML element.
- *
- * This function expects the XML element to contain a Signature element
- * which contains a reference to the XML-element. This is common for both
- * messages and assertions.
- *
- * Note that this function only validates the element itself. It does not
- * check this against any local keys.
- *
- * If no Signature-element is located, this function will return false. All
- * other validation errors result in an exception. On successful validation
- * an array will be returned. This array contains the information required to
- * check the signature against a public key.
- *
- * @param \DOMElement $root The element which should be validated.
- * @throws \Exception
- * @return array|false An array with information about the Signature element.
- */
- public static function validateElement(DOMElement $root): array|false
- {
- /* Create an XML security object. */
- $objXMLSecDSig = new XMLSecurityDSig();
-
- /* Both SAML messages and SAML assertions use the 'ID' attribute. */
- $objXMLSecDSig->idKeys[] = 'ID';
-
- $xpCache = XPath::getXPath($root);
- /* Locate the XMLDSig Signature element to be used. */
- /** @var \DOMElement[] $signatureElement */
- $signatureElement = XPath::xpQuery($root, './ds:Signature', $xpCache);
- if (empty($signatureElement)) {
- /* We don't have a signature element ot validate. */
-
- return false;
- } elseif (count($signatureElement) > 1) {
- throw new TooManyElementsException('XMLSec: more than one signature element in root.');
- }
- $signatureElement = $signatureElement[0];
- $objXMLSecDSig->sigNode = $signatureElement;
-
- /* Canonicalize the XMLDSig SignedInfo element in the message. */
- $objXMLSecDSig->canonicalizeSignedInfo();
-
- /* Validate referenced xml nodes. */
- if (!$objXMLSecDSig->validateReference()) {
- throw new Exception('XMLsec: digest validation failed');
- }
-
- /* Check that $root is one of the signed nodes. */
- $rootSigned = false;
- /** @var \DOMNode $signedNode */
- foreach ($objXMLSecDSig->getValidatedNodes() as $signedNode) {
- if ($signedNode->isSameNode($root)) {
- $rootSigned = true;
- break;
- } elseif ($root->parentNode instanceof DOMDocument && $signedNode->isSameNode($root->ownerDocument)) {
- /* $root is the root element of a signed document. */
- $rootSigned = true;
- break;
- }
- }
- if (!$rootSigned) {
- throw new NoSignatureFoundException('XMLSec: The root element is not signed.');
- }
-
- /* Now we extract all available X509 certificates in the signature element. */
- $xpCache = XPath::getXPath($signatureElement);
- $certificates = [];
- $certNodes = XPath::xpQuery($signatureElement, './ds:KeyInfo/ds:X509Data/ds:X509Certificate', $xpCache);
- foreach ($certNodes as $certNode) {
- $certData = trim($certNode->textContent);
- $certData = str_replace(["\r", "\n", "\t", ' '], '', $certData);
- $certificates[] = $certData;
- }
-
- $ret = [
- 'Signature' => $objXMLSecDSig,
- 'Certificates' => $certificates,
- ];
-
- return $ret;
- }
-
-
- /**
- * Helper function to convert a XMLSecurityKey to the correct algorithm.
- *
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey $key The key.
- * @param string $algorithm The desired algorithm.
- * @param string $type Public or private key, defaults to public.
- * @return \RobRichards\XMLSecLibs\XMLSecurityKey The new key.
- */
- public static function castKey(XMLSecurityKey $key, string $algorithm, string $type = null): XMLSecurityKey
- {
- $type = $type ?: 'public';
- Assert::oneOf($type, ["private", "public"]);
-
- // do nothing if algorithm is already the type of the key
- if ($key->type === $algorithm) {
- return $key;
- }
-
- if (
- !in_array($algorithm, [
- XMLSecurityKey::RSA_1_5,
- XMLSecurityKey::RSA_SHA1,
- XMLSecurityKey::RSA_SHA256,
- XMLSecurityKey::RSA_SHA384,
- XMLSecurityKey::RSA_SHA512
- ], true)
- ) {
- throw new Exception('Unsupported signing algorithm.');
- }
-
- /** @psalm-suppress PossiblyNullArgument */
- $keyInfo = openssl_pkey_get_details($key->key);
- if ($keyInfo === false) {
- throw new Exception('Unable to get key details from XMLSecurityKey.');
- }
- if (!isset($keyInfo['key'])) {
- throw new Exception('Missing key in public key details.');
- }
-
- $newKey = new XMLSecurityKey($algorithm, ['type' => $type]);
- $newKey->loadKey($keyInfo['key']);
-
- return $newKey;
- }
-
-
- /**
- * Check a signature against a key.
- *
- * An exception is thrown if we are unable to validate the signature.
- *
- * @param array $info The information returned by the validateElement() function.
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey $key The publickey that should validate the Signature object.
- * @throws \Exception
- * @return void
- */
- public static function validateSignature(array $info, XMLSecurityKey $key): void
- {
- Assert::keyExists($info, "Signature");
-
- /** @var XMLSecurityDSig $objXMLSecDSig */
- $objXMLSecDSig = $info['Signature'];
-
- $xpCache = XPath::getXPath($objXMLSecDSig->sigNode);
- /** @var \DOMElement[] $sigMethod */
- $sigMethod = XPath::xpQuery($objXMLSecDSig->sigNode, './ds:SignedInfo/ds:SignatureMethod', $xpCache);
- if (empty($sigMethod)) {
- throw new MissingElementException('Missing SignatureMethod element.');
- }
- $sigMethod = $sigMethod[0];
- if (!$sigMethod->hasAttribute('Algorithm')) {
- throw new MissingAttributeException('Missing Algorithm-attribute on SignatureMethod element.');
- }
- $algo = $sigMethod->getAttribute('Algorithm');
-
- if ($key->type === XMLSecurityKey::RSA_SHA256 && $algo !== $key->type) {
- $key = self::castKey($key, $algo);
- }
-
- /* Check the signature. */
- if ($objXMLSecDSig->verify($key) !== 1) {
- throw new SignatureVerificationFailedException("Unable to validate Signature");
- }
- }
-
-
- /**
- * Make an exact copy the specific \DOMElement.
- *
- * @param \DOMElement $element The element we should copy.
- * @param \DOMElement|null $parent The target parent element.
- * @return \DOMElement The copied element.
- */
- public static function copyElement(DOMElement $element, DOMElement $parent = null): DOMElement
- {
- if ($parent === null) {
- $document = DOMDocumentFactory::create();
- } else {
- $document = $parent->ownerDocument;
- }
-
- $namespaces = [];
- for ($e = $element; $e instanceof DOMNode; $e = $e->parentNode) {
- $xpCache = XPath::getXPath($e);
- foreach (XPath::xpQuery($e, './namespace::*', $xpCache) as $ns) {
- $prefix = $ns->localName;
- if ($prefix === 'xml' || $prefix === 'xmlns') {
- continue;
- }
- $uri = $ns->nodeValue;
- if (!isset($namespaces[$prefix])) {
- $namespaces[$prefix] = $uri;
- }
- }
- }
-
- /** @var \DOMElement $newElement */
- $newElement = $document->importNode($element, true);
- if ($parent !== null) {
- /* We need to append the child to the parent before we add the namespaces. */
- $parent->appendChild($newElement);
- }
-
- foreach ($namespaces as $prefix => $uri) {
- $newElement->setAttributeNS($uri, $prefix . ':__ns_workaround__', 'tmp');
- $newElement->removeAttributeNS($uri, '__ns_workaround__');
- }
-
- return $newElement;
- }
-
-
- /**
- * Parse a boolean attribute.
+ * Create a KeyDescriptor with the given certificate.
*
- * @param \DOMElement $node The element we should fetch the attribute from.
- * @param string $attributeName The name of the attribute.
- * @param mixed|null $default The value that should be returned if the attribute doesn't exist.
- * @return bool|mixed The value of the attribute, or $default if the attribute doesn't exist.
+ * @param string $x509Data The certificate, as a base64-encoded PEM data.
+ * @return \SimpleSAML\SAML2\XML\md\KeyDescriptor The keydescriptor.
*/
- public static function parseBoolean(DOMElement $node, string $attributeName, $default = null)
+ public static function createKeyDescriptor(string $x509Data): KeyDescriptor
{
- if (!$node->hasAttribute($attributeName)) {
- return $default;
- }
- $value = $node->getAttribute($attributeName);
- switch (strtolower($value)) {
- case '0':
- case 'false':
- return false;
- case '1':
- case 'true':
- return true;
- default:
- throw new Exception('Invalid value of boolean attribute ' . var_export($attributeName, true)
- . ': ' . var_export($value, true));
- }
- }
-
-
- /**
- * Insert a Signature node.
- *
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey $key The key we should use to sign the message.
- * @param array $certificates The certificates we should add to the signature node.
- * @param \DOMElement $root The XML node we should sign.
- * @param \DOMNode $insertBefore The XML element we should insert the signature element before.
- * @return void
- */
- public static function insertSignature(
- XMLSecurityKey $key,
- array $certificates,
- DOMElement $root,
- DOMNode $insertBefore = null
- ): void {
- $objXMLSecDSig = new XMLSecurityDSig();
- $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
-
- switch ($key->type) {
- case XMLSecurityKey::RSA_SHA256:
- $type = XMLSecurityDSig::SHA256;
- break;
- case XMLSecurityKey::RSA_SHA384:
- $type = XMLSecurityDSig::SHA384;
- break;
- case XMLSecurityKey::RSA_SHA512:
- $type = XMLSecurityDSig::SHA512;
- break;
- default:
- $type = XMLSecurityDSig::SHA1;
- }
-
- $objXMLSecDSig->addReferenceList(
- [$root],
- $type,
- ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N],
- ['id_name' => 'ID', 'overwrite' => false]
- );
-
- $objXMLSecDSig->sign($key);
-
- foreach ($certificates as $certificate) {
- $objXMLSecDSig->add509Cert($certificate, true);
- }
-
- $objXMLSecDSig->insertSignature($root, $insertBefore);
- }
-
-
- /**
- * Decrypt an encrypted element.
- *
- * This is an internal helper function.
- *
- * @param \DOMElement $encryptedData The encrypted data.
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey $inputKey The decryption key.
- * @param array &$blacklist Blacklisted decryption algorithms.
- * @throws \Exception
- * @return \DOMElement The decrypted element.
- */
- private static function doDecryptElement(
- DOMElement $encryptedData,
- XMLSecurityKey $inputKey,
- array &$blacklist
- ): DOMElement {
- $enc = new XMLSecEnc();
-
- $enc->setNode($encryptedData);
- $enc->type = $encryptedData->getAttribute("Type");
-
- $symmetricKey = $enc->locateKey($encryptedData);
- if (!$symmetricKey) {
- throw new Exception('Could not locate key algorithm in encrypted data.');
- }
-
- $symmetricKeyInfo = $enc->locateKeyInfo($symmetricKey);
- if (!$symmetricKeyInfo) {
- throw new Exception('Could not locate for the encrypted key.');
- }
-
- $inputKeyAlgo = $inputKey->getAlgorithm();
- if ($symmetricKeyInfo->isEncrypted) {
- $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorithm();
-
- if (in_array($symKeyInfoAlgo, $blacklist, true)) {
- throw new Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, true));
- }
-
- if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) {
- /*
- * The RSA key formats are equal, so loading an RSA_1_5 key
- * into an RSA_OAEP_MGF1P key can be done without problems.
- * We therefore pretend that the input key is an
- * RSA_OAEP_MGF1P key.
- */
- $inputKeyAlgo = XMLSecurityKey::RSA_OAEP_MGF1P;
- }
-
- /* Make sure that the input key format is the same as the one used to encrypt the key. */
- if ($inputKeyAlgo !== $symKeyInfoAlgo) {
- throw new Exception(
- 'Algorithm mismatch between input key and key used to encrypt ' .
- ' the symmetric key for the message. Key was: ' .
- var_export($inputKeyAlgo, true) . '; message was: ' .
- var_export($symKeyInfoAlgo, true)
- );
- }
-
- /** @var XMLSecEnc $encKey */
- $encKey = $symmetricKeyInfo->encryptedCtx;
- $symmetricKeyInfo->key = $inputKey->key;
-
- $keySize = $symmetricKey->getSymmetricKeySize();
- if ($keySize === null) {
- /* To protect against "key oracle" attacks, we need to be able to create a
- * symmetric key, and for that we need to know the key size.
- */
- throw new Exception(
- 'Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true)
- );
- }
-
- try {
- /**
- * @var string $key
- * @psalm-suppress UndefinedClass
- */
- $key = $encKey->decryptKey($symmetricKeyInfo);
- if (strlen($key) !== $keySize) {
- throw new Exception(
- 'Unexpected key size (' . strval(strlen($key) * 8) . 'bits) for encryption algorithm: ' .
- var_export($symmetricKey->type, true)
- );
- }
- } catch (Exception $e) {
- /* We failed to decrypt this key. Log it, and substitute a "random" key. */
- self::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage());
- /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly
- * padded. */
-
- /* We base the symmetric key on the encrypted key and private key, so that we always behave the
- * same way for a given input key.
- */
- $encryptedKey = $encKey->getCipherValue();
- if ($encryptedKey === null) {
- throw new Exception('No CipherValue available in the encrypted element.');
- }
+ $x509Data = new X509Data([
+ new X509Certificate($x509Data),
+ ]);
- /** @psalm-suppress PossiblyNullArgument */
- $pkey = openssl_pkey_get_details($symmetricKeyInfo->key);
- $pkey = sha1(serialize($pkey), true);
- $key = sha1($encryptedKey . $pkey, true);
+ $keyInfo = new KeyInfo([
+ $x509Data,
+ ]);
- /* Make sure that the key has the correct length. */
- if (strlen($key) > $keySize) {
- $key = substr($key, 0, $keySize);
- } elseif (strlen($key) < $keySize) {
- $key = str_pad($key, $keySize);
- }
- }
- $symmetricKey->loadkey($key);
- } else {
- $symKeyAlgo = $symmetricKey->getAlgorithm();
- /* Make sure that the input key has the correct format. */
- if ($inputKeyAlgo !== $symKeyAlgo) {
- throw new Exception(
- 'Algorithm mismatch between input key and key in message. ' .
- 'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' .
- var_export($symKeyAlgo, true)
- );
- }
- $symmetricKey = $inputKey;
- }
-
- $algorithm = $symmetricKey->getAlgorithm();
- if (in_array($algorithm, $blacklist, true)) {
- throw new Exception('Algorithm disabled: ' . var_export($algorithm, true));
- }
-
- /**
- * @var string $decrypted
- * @psalm-suppress UndefinedClass
- */
- $decrypted = $enc->decryptNode($symmetricKey, false);
-
- /*
- * This is a workaround for the case where only a subset of the XML
- * tree was serialized for encryption. In that case, we may miss the
- * namespaces needed to parse the XML.
- */
- $xml = '' .
- $decrypted . '';
-
- try {
- $newDoc = DOMDocumentFactory::fromString($xml);
- } catch (RuntimeException $e) {
- throw new Exception('Failed to parse decrypted XML. Maybe the wrong sharedkey was used?', 0, $e);
- }
-
- /** @psalm-suppress PossiblyNullPropertyFetch */
- $decryptedElement = $newDoc->firstChild->firstChild;
- if (!($decryptedElement instanceof DOMElement)) {
- throw new Exception('Missing decrypted element or it was not actually a DOMElement.');
- }
-
- return $decryptedElement;
- }
-
-
- /**
- * Decrypt an encrypted element.
- *
- * @param \DOMElement $encryptedData The encrypted data.
- * @param \RobRichards\XMLSecLibs\XMLSecurityKey $inputKey The decryption key.
- * @param array $blacklist Blacklisted decryption algorithms.
- * @throws \Exception
- * @return \DOMElement The decrypted element.
- */
- public static function decryptElement(
- DOMElement $encryptedData,
- XMLSecurityKey $inputKey,
- array $blacklist = []
- ): DOMElement {
- try {
- return self::doDecryptElement($encryptedData, $inputKey, $blacklist);
- } catch (Exception $e) {
- /*
- * Something went wrong during decryption, but for security
- * reasons we cannot tell the user what failed.
- */
- self::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage());
- throw new Exception('Failed to decrypt XML element.', 0, $e);
- }
+ return new KeyDescriptor($keyInfo);
}
diff --git a/src/SAML2/XML/EncryptedElementTrait.php b/src/SAML2/XML/EncryptedElementTrait.php
index a33d5723b..429c4b78a 100644
--- a/src/SAML2/XML/EncryptedElementTrait.php
+++ b/src/SAML2/XML/EncryptedElementTrait.php
@@ -110,7 +110,6 @@ public static function fromXML(DOMElement $xml): static
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = $this->instantiateParentElement($parent);
$this->encryptedData->toXML($e);
foreach ($this->getDecryptionKeys() as $key) {
diff --git a/src/SAML2/XML/ExtensionsTrait.php b/src/SAML2/XML/ExtensionsTrait.php
index 450e50937..6d3400c53 100644
--- a/src/SAML2/XML/ExtensionsTrait.php
+++ b/src/SAML2/XML/ExtensionsTrait.php
@@ -8,8 +8,6 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\XML\saml\AttributeValue;
-use SimpleSAML\SAML2\XML\mdattr\EntityAttributes;
use SimpleSAML\XML\ElementInterface;
use function in_array;
@@ -21,39 +19,23 @@
*/
trait ExtensionsTrait
{
- /**
- * @var (
- * \SimpleSAML\XML\SerializableElementInterface|
- * \SimpleSAML\SAML2\XML\saml\AttributeValue|
- * \SimpleSAML\SAML2\XML\mdattr\EntityAttributes
- * )[] */
+ /** @var \SimpleSAML\XML\SerializableElementInterface[] */
protected array $extensions = [];
/**
* Extensions constructor.
*
- * @param (
- * \SimpleSAML\XML\SerializableElementInterface|
- * \SimpleSAML\SAML2\XML\saml\AttributeValue|
- * \SimpleSAML\SAML2\XML\mdattr\EntityAttributes
- * )[] $extensions
+ * @param \SimpleSAML\XML\SerializableElementInterface[] $extensions
*/
public function __construct(array $extensions)
{
- Assert::allIsInstanceOfAny(
- $extensions,
- [ElementInterface::class, AttributeValue::class, EntityAttributes::class],
- );
+ Assert::maxCount($extensions, C::UNBOUNDED_LIMIT);
+ Assert::allIsInstanceOf($extensions, ElementInterface::class);
foreach ($extensions as $extension) {
- if ($extension instanceof AttributeValue) {
- $namespace = C::NS_SAML;
- } elseif ($extension instanceof EntityAttributes) {
- $namespace = C::NS_MDATTR;
- } else {
- $namespace = $extension->getNamespaceURI();
- }
+ /** @var \SimpleSAML\XML\AbstractElement $extension */
+ $namespace = $extension->getNamespaceURI();
Assert::notNull(
$namespace,
@@ -77,11 +59,7 @@ public function __construct(array $extensions)
/**
* Get an array with all extensions present.
*
- * @return (
- * \SimpleSAML\XML\SerializableElementInterface|
- * \SimpleSAML\SAML2\XML\saml\AttributeValue|
- * \SimpleSAML\SAML2\XML\mdattr\EntityAttributes
- * )[]
+ * @return \SimpleSAML\XML\SerializableElementInterface[]
*/
public function getList(): array
{
@@ -94,8 +72,17 @@ public function getList(): array
*/
public function isEmptyElement(): bool
{
- // We cannot test this relyably until all child-elements are converted to ElementInterface
- return false;
+ if (empty($this->extensions)) {
+ return true;
+ }
+
+ foreach ($this->extensions as $extension) {
+ if ($extension->isEmptyElement() === false) {
+ return false;
+ }
+ }
+
+ return true;
}
@@ -108,9 +95,13 @@ public function isEmptyElement(): bool
public function toXML(DOMElement $parent = null): DOMElement
{
$e = $this->instantiateParentElement($parent);
+
foreach ($this->extensions as $extension) {
- $extension->toXML($e);
+ if (!$extension->isEmptyElement()) {
+ $extension->toXML($e);
+ }
}
+
return $e;
}
diff --git a/src/SAML2/XML/IdentifierTrait.php b/src/SAML2/XML/IdentifierTrait.php
index 6e80f12c1..3a227a70c 100644
--- a/src/SAML2/XML/IdentifierTrait.php
+++ b/src/SAML2/XML/IdentifierTrait.php
@@ -6,11 +6,11 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
-use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\IdentifierInterface;
+use SimpleSAML\SAML2\XML\saml\NameID;
+use SimpleSAML\XML\Exception\TooManyElementsException;
use function array_pop;
diff --git a/src/SAML2/XML/alg/DigestMethod.php b/src/SAML2/XML/alg/DigestMethod.php
index f631be6a8..b52f4bd3c 100644
--- a/src/SAML2/XML/alg/DigestMethod.php
+++ b/src/SAML2/XML/alg/DigestMethod.php
@@ -7,7 +7,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Chunk;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -95,8 +94,8 @@ public function toXML(DOMElement $parent = null): DOMElement
$e = $this->instantiateParentElement($parent);
$e->setAttribute('Algorithm', $this->getAlgorithm());
- /** @var \SimpleSAML\XML\SerializableElementInterface $element */
foreach ($this->getElements() as $element) {
+ /** @var \SimpleSAML\XML\SerializableElementInterface $element */
$element->toXML($e);
}
diff --git a/src/SAML2/XML/alg/SigningMethod.php b/src/SAML2/XML/alg/SigningMethod.php
index 04a0347a0..7bae3926d 100644
--- a/src/SAML2/XML/alg/SigningMethod.php
+++ b/src/SAML2/XML/alg/SigningMethod.php
@@ -7,9 +7,7 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Chunk;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;
diff --git a/src/SAML2/XML/ecp/AbstractEcpElement.php b/src/SAML2/XML/ecp/AbstractEcpElement.php
index 36cd71ada..1e38221b7 100644
--- a/src/SAML2/XML/ecp/AbstractEcpElement.php
+++ b/src/SAML2/XML/ecp/AbstractEcpElement.php
@@ -11,6 +11,8 @@
* Abstract class to be implemented by all the classes in this namespace
*
* @package simplesamlphp/saml2
+ *
+ * @see http://docs.oasis-open.org/security/saml/Post2.0/saml-ecp/v2.0/saml-ecp-v2.0.html
*/
abstract class AbstractEcpElement extends AbstractElement
{
diff --git a/src/SAML2/XML/ecp/RelayState.php b/src/SAML2/XML/ecp/RelayState.php
new file mode 100644
index 000000000..e3c38a208
--- /dev/null
+++ b/src/SAML2/XML/ecp/RelayState.php
@@ -0,0 +1,99 @@
+setContent($relayState);
+ }
+
+
+ /**
+ * Convert XML into a RelayState
+ *
+ * @param \DOMElement $xml The XML element we should load
+ * @return static
+ *
+ * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
+ * if the qualified name of the supplied element is wrong
+ * @throws \SimpleSAML\XML\Exception\MissingAttributeException
+ * if the supplied element is missing any of the mandatory attributes
+ */
+ public static function fromXML(DOMElement $xml): static
+ {
+ Assert::same($xml->localName, 'RelayState', InvalidDOMElementException::class);
+ Assert::same($xml->namespaceURI, RelayState::NS, InvalidDOMElementException::class);
+
+ // Assert required attributes
+ Assert::true(
+ $xml->hasAttributeNS(C::NS_SOAP_ENV_11, 'actor'),
+ 'Missing env:actor attribute in .',
+ MissingAttributeException::class,
+ );
+ Assert::true(
+ $xml->hasAttributeNS(C::NS_SOAP_ENV_11, 'mustUnderstand'),
+ 'Missing env:mustUnderstand attribute in .',
+ MissingAttributeException::class,
+ );
+
+ $mustUnderstand = $xml->getAttributeNS(C::NS_SOAP_ENV_11, 'mustUnderstand');
+ Assert::same(
+ $mustUnderstand,
+ '1',
+ 'Invalid value of env:mustUnderstand attribute in .',
+ ProtocolViolationException::class,
+ );
+
+ $actor = $xml->getAttributeNS(C::NS_SOAP_ENV_11, 'actor');
+ Assert::same(
+ $actor,
+ C::SOAP_ACTOR_NEXT,
+ 'Invalid value of env:actor attribute in .',
+ ProtocolViolationException::class,
+ );
+
+ return new static($xml->textContent);
+ }
+
+
+ /**
+ * Convert this ECP RelayState to XML.
+ *
+ * @param \DOMElement|null $parent The element we should append this element to.
+ * @return \DOMElement
+ */
+ public function toXML(DOMElement $parent = null): DOMElement
+ {
+ $e = $this->instantiateParentElement($parent);
+ $e->setAttributeNS(C::NS_SOAP_ENV_11, 'env:mustUnderstand', '1');
+ $e->setAttributeNS(C::NS_SOAP_ENV_11, 'env:actor', C::SOAP_ACTOR_NEXT);
+ $e->textContent = $this->getContent();
+
+ return $e;
+ }
+}
diff --git a/src/SAML2/XML/ecp/Request.php b/src/SAML2/XML/ecp/Request.php
new file mode 100644
index 000000000..1fe1270c5
--- /dev/null
+++ b/src/SAML2/XML/ecp/Request.php
@@ -0,0 +1,174 @@
+isPassive;
+ }
+
+
+ /**
+ * Collect the value of the providerName-property
+ *
+ * @return string|null
+ */
+ public function getProviderName(): ?string
+ {
+ return $this->providerName;
+ }
+
+
+ /**
+ * Collect the value of the issuer-property
+ *
+ * @return \SimpleSAML\SAML2\XML\saml\Issuer
+ */
+ public function getIssuer(): Issuer
+ {
+ return $this->issuer;
+ }
+ /**
+ * Collect the value of the idpList-property
+ *
+ * @return \SimpleSAML\SAML2\XML\samlp\IDPList|null
+ */
+ public function getIDPList(): ?IDPList
+ {
+ return $this->idpList;
+ }
+
+
+ /**
+ * Convert XML into a Request
+ *
+ * @param \DOMElement $xml The XML element we should load
+ * @return static
+ *
+ * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
+ * if the qualified name of the supplied element is wrong
+ * @throws \SimpleSAML\XML\Exception\MissingAttributeException
+ * if the supplied element is missing any of the mandatory attributes
+ */
+ public static function fromXML(DOMElement $xml): static
+ {
+ Assert::same($xml->localName, 'Request', InvalidDOMElementException::class);
+ Assert::same($xml->namespaceURI, Request::NS, InvalidDOMElementException::class);
+
+ // Assert required attributes
+ Assert::true(
+ $xml->hasAttributeNS(C::NS_SOAP_ENV_11, 'actor'),
+ 'Missing env:actor attribute in .',
+ MissingAttributeException::class,
+ );
+ Assert::true(
+ $xml->hasAttributeNS(C::NS_SOAP_ENV_11, 'mustUnderstand'),
+ 'Missing env:mustUnderstand attribute in .',
+ MissingAttributeException::class,
+ );
+
+ $mustUnderstand = $xml->getAttributeNS(C::NS_SOAP_ENV_11, 'mustUnderstand');
+ Assert::same(
+ $mustUnderstand,
+ '1',
+ 'Invalid value of env:mustUnderstand attribute in .',
+ ProtocolViolationException::class,
+ );
+
+ $actor = $xml->getAttributeNS(C::NS_SOAP_ENV_11, 'actor');
+ Assert::same(
+ $actor,
+ C::SOAP_ACTOR_NEXT,
+ 'Invalid value of env:actor attribute in .',
+ ProtocolViolationException::class,
+ );
+
+ $issuer = Issuer::getChildrenOfClass($xml);
+ Assert::count(
+ $issuer,
+ 1,
+ 'More than one in .',
+ TooManyElementsException::class,
+ );
+
+ $idpList = IDPList::getChildrenOfClass($xml);
+
+ return new static(
+ array_pop($issuer),
+ array_pop($idpList),
+ self::getOptionalAttribute($xml, 'ProviderName', null),
+ self::getOptionalBooleanAttribute($xml, 'IsPassive', null),
+ );
+ }
+
+
+ /**
+ * Convert this ECP SubjectConfirmation to XML.
+ *
+ * @param \DOMElement|null $parent The element we should append this element to.
+ * @return \DOMElement
+ */
+ public function toXML(DOMElement $parent = null): DOMElement
+ {
+ $e = $this->instantiateParentElement($parent);
+ $e->setAttributeNS(C::NS_SOAP_ENV_11, 'env:mustUnderstand', '1');
+ $e->setAttributeNS(C::NS_SOAP_ENV_11, 'env:actor', C::SOAP_ACTOR_NEXT);
+
+ if ($this->getProviderName() !== null) {
+ $e->setAttribute('ProviderName', $this->getProviderName());
+ }
+
+ if ($this->getIsPassive() !== null) {
+ $e->setAttribute('IsPassive', strval(intval($this->getIsPassive())));
+ }
+
+ $this->getIssuer()->toXML($e);
+ $this->getIDPList()?->toXML($e);
+
+ return $e;
+ }
+}
diff --git a/src/SAML2/XML/ecp/RequestAuthenticated.php b/src/SAML2/XML/ecp/RequestAuthenticated.php
index 8708228a9..c7a8021d3 100644
--- a/src/SAML2/XML/ecp/RequestAuthenticated.php
+++ b/src/SAML2/XML/ecp/RequestAuthenticated.php
@@ -12,8 +12,6 @@
use SimpleSAML\XML\Exception\MissingAttributeException;
use function boolval;
-use function is_null;
-use function is_numeric;
use function strval;
/**
diff --git a/src/SAML2/XML/ecp/Response.php b/src/SAML2/XML/ecp/Response.php
index 616055334..99e8b7565 100644
--- a/src/SAML2/XML/ecp/Response.php
+++ b/src/SAML2/XML/ecp/Response.php
@@ -12,8 +12,6 @@
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\Exception\SchemaViolationException;
-use function filter_var;
-
/**
* Class representing the ECP Response element.
*
diff --git a/src/SAML2/XML/ecp/SubjectConfirmation.php b/src/SAML2/XML/ecp/SubjectConfirmation.php
new file mode 100644
index 000000000..c90d6650f
--- /dev/null
+++ b/src/SAML2/XML/ecp/SubjectConfirmation.php
@@ -0,0 +1,136 @@
+method;
+ }
+
+
+ /**
+ * Collect the value of the subjectConfirmationData-property
+ *
+ * @return \SimpleSAML\SAML2\XML\saml\SubjectConfirmationData|null
+ */
+ public function getSubjectConfirmationData(): ?SubjectConfirmationData
+ {
+ return $this->subjectConfirmationData;
+ }
+
+
+ /**
+ * Convert XML into a SubjectConfirmation
+ *
+ * @param \DOMElement $xml The XML element we should load
+ * @return static
+ *
+ * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
+ * if the qualified name of the supplied element is wrong
+ * @throws \SimpleSAML\XML\Exception\MissingAttributeException
+ * if the supplied element is missing any of the mandatory attributes
+ */
+ public static function fromXML(DOMElement $xml): static
+ {
+ Assert::same($xml->localName, 'SubjectConfirmation', InvalidDOMElementException::class);
+ Assert::same($xml->namespaceURI, SubjectConfirmation::NS, InvalidDOMElementException::class);
+
+ // Assert required attributes
+ Assert::true(
+ $xml->hasAttributeNS(C::NS_SOAP_ENV_11, 'actor'),
+ 'Missing env:actor attribute in .',
+ MissingAttributeException::class,
+ );
+ Assert::true(
+ $xml->hasAttributeNS(C::NS_SOAP_ENV_11, 'mustUnderstand'),
+ 'Missing env:mustUnderstand attribute in .',
+ MissingAttributeException::class,
+ );
+
+ $mustUnderstand = $xml->getAttributeNS(C::NS_SOAP_ENV_11, 'mustUnderstand');
+ Assert::same(
+ $mustUnderstand,
+ '1',
+ 'Invalid value of env:mustUnderstand attribute in .',
+ ProtocolViolationException::class,
+ );
+
+ $actor = $xml->getAttributeNS(C::NS_SOAP_ENV_11, 'actor');
+ Assert::same(
+ $actor,
+ C::SOAP_ACTOR_NEXT,
+ 'Invalid value of env:actor attribute in .',
+ ProtocolViolationException::class,
+ );
+
+ $subjectConfirmationData = SubjectConfirmationData::getChildrenOfClass($xml);
+ Assert::maxCount(
+ $subjectConfirmationData,
+ 1,
+ 'More than one in .',
+ TooManyElementsException::class,
+ );
+
+ return new static(
+ self::getAttribute($xml, 'Method'),
+ array_pop($subjectConfirmationData),
+ );
+ }
+
+
+ /**
+ * Convert this ECP SubjectConfirmation to XML.
+ *
+ * @param \DOMElement|null $parent The element we should append this element to.
+ * @return \DOMElement
+ */
+ public function toXML(DOMElement $parent = null): DOMElement
+ {
+ $e = $this->instantiateParentElement($parent);
+ $e->setAttributeNS(C::NS_SOAP_ENV_11, 'env:mustUnderstand', '1');
+ $e->setAttributeNS(C::NS_SOAP_ENV_11, 'env:actor', C::SOAP_ACTOR_NEXT);
+ $e->setAttribute('Method', $this->getMethod());
+
+ $this->getSubjectConfirmationData()?->toXML($e);
+
+ return $e;
+ }
+}
diff --git a/src/SAML2/XML/emd/RepublishTarget.php b/src/SAML2/XML/emd/RepublishTarget.php
index caed885ba..a5035284b 100644
--- a/src/SAML2/XML/emd/RepublishTarget.php
+++ b/src/SAML2/XML/emd/RepublishTarget.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\emd;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/idpdisc/DiscoveryResponse.php b/src/SAML2/XML/idpdisc/DiscoveryResponse.php
index 08e78af1b..3e424a651 100644
--- a/src/SAML2/XML/idpdisc/DiscoveryResponse.php
+++ b/src/SAML2/XML/idpdisc/DiscoveryResponse.php
@@ -35,8 +35,8 @@ final class DiscoveryResponse extends AbstractIndexedEndpointType
* @param string $location
* @param bool|null $isDefault
* @param string|null $unused
- * @param list<\SimpleSAML\XML\Attribute> $attributes
- * @param array $children
+ * @param array<\SimpleSAML\XML\SerializableElementInterface> $children
+ * @param array<\SimpleSAML\XML\Attribute> $attributes
*
* @throws \SimpleSAML\Assert\AssertionFailedException
*/
@@ -46,14 +46,14 @@ public function __construct(
string $location,
?bool $isDefault = null,
?string $unused = null,
- array $attributes = [],
array $children = [],
+ array $attributes = [],
) {
Assert::same($binding, C::BINDING_IDPDISC, ProtocolViolationException::class);
Assert::null(
$unused,
'The \'ResponseLocation\' attribute must be omitted for idpdisc:DiscoveryResponse.',
);
- parent::__construct($index, C::BINDING_IDPDISC, $location, $isDefault, null, $attributes, $children);
+ parent::__construct($index, C::BINDING_IDPDISC, $location, $isDefault, null, $children, $attributes);
}
}
diff --git a/src/SAML2/XML/init/RequestInitiator.php b/src/SAML2/XML/init/RequestInitiator.php
index 66354981e..658fa2111 100644
--- a/src/SAML2/XML/init/RequestInitiator.php
+++ b/src/SAML2/XML/init/RequestInitiator.php
@@ -34,7 +34,7 @@ final class RequestInitiator extends AbstractEndpointType
* @param string $location
* @param string|null $responseLocation
* @param array $children
- * @param list<\SimpleSAML\XML\Attribute> $attributes
+ * @param array<\SimpleSAML\XML\Attribute> $attributes
*
* @throws \InvalidArgumentException
*/
@@ -68,7 +68,6 @@ public static function fromXML(DOMElement $xml): static
);
Assert::eq(
- /** @var string $binding */
self::getAttribute($xml, 'Binding'),
self::NS,
"The Binding of a RequestInitiator must be 'urn:oasis:names:tc:SAML:profiles:SSO:request-init'.",
@@ -77,13 +76,11 @@ public static function fromXML(DOMElement $xml): static
$children = [];
foreach ($xml->childNodes as $child) {
- if ($child->namespaceURI === C::NS_MD) {
+ if (!($child instanceof DOMElement)) {
continue;
- } elseif (!($child instanceof DOMElement)) {
- continue;
- }
-
- $children[] = new Chunk($child);
+ } elseif ($child->namespaceURI !== C::NS_MD) {
+ $children[] = new Chunk($child);
+ } // else continue
}
return new static(
diff --git a/src/SAML2/XML/md/AbstractEndpointType.php b/src/SAML2/XML/md/AbstractEndpointType.php
index e517e9169..3809b943d 100644
--- a/src/SAML2/XML/md/AbstractEndpointType.php
+++ b/src/SAML2/XML/md/AbstractEndpointType.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use CASE_LOWER;
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
@@ -57,7 +56,7 @@ abstract class AbstractEndpointType extends AbstractMdElement implements Arrayiz
* @param string $location
* @param string|null $responseLocation
* @param \SimpleSAML\XML\ElementInterface[] $children
- * @param list<\SimpleSAML\XML\Attribute> $attributes
+ * @param array<\SimpleSAML\XML\Attribute> $attributes
*
* @throws \SimpleSAML\Assert\AssertionFailedException
*/
@@ -133,10 +132,7 @@ public static function fromXML(DOMElement $xml): static
InvalidDOMElementException::class,
);
- /** @var string $binding */
$binding = self::getAttribute($xml, 'Binding');
-
- /** @var string $location */
$location = self::getAttribute($xml, 'Location');
$children = [];
diff --git a/src/SAML2/XML/md/AbstractIndexedEndpointType.php b/src/SAML2/XML/md/AbstractIndexedEndpointType.php
index feab6d233..5550fad61 100644
--- a/src/SAML2/XML/md/AbstractIndexedEndpointType.php
+++ b/src/SAML2/XML/md/AbstractIndexedEndpointType.php
@@ -89,13 +89,11 @@ public static function fromXML(DOMElement $xml): static
$children = [];
foreach ($xml->childNodes as $child) {
- if ($child->namespaceURI === C::NS_MD) {
+ if (!($child instanceof DOMElement)) {
continue;
- } elseif (!($child instanceof DOMElement)) {
- continue;
- }
-
- $children[] = new Chunk($child);
+ } elseif ($child->namespaceURI !== C::NS_MD) {
+ $children[] = new Chunk($child);
+ } // else continue
}
return new static(
diff --git a/src/SAML2/XML/md/AbstractLocalizedName.php b/src/SAML2/XML/md/AbstractLocalizedName.php
index 1db775a00..e208ac5c2 100644
--- a/src/SAML2/XML/md/AbstractLocalizedName.php
+++ b/src/SAML2/XML/md/AbstractLocalizedName.php
@@ -7,10 +7,10 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
+use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingAttributeException;
-use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\StringElementTrait;
use function array_key_first;
diff --git a/src/SAML2/XML/md/AbstractLocalizedURI.php b/src/SAML2/XML/md/AbstractLocalizedURI.php
index fdab1bcbe..4e826db51 100644
--- a/src/SAML2/XML/md/AbstractLocalizedURI.php
+++ b/src/SAML2/XML/md/AbstractLocalizedURI.php
@@ -7,8 +7,6 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
-use function filter_var;
-
/**
* Abstract class implementing LocalizedURIType.
*
diff --git a/src/SAML2/XML/md/AbstractMetadataDocument.php b/src/SAML2/XML/md/AbstractMetadataDocument.php
index 8180a5030..58d7cf262 100644
--- a/src/SAML2/XML/md/AbstractMetadataDocument.php
+++ b/src/SAML2/XML/md/AbstractMetadataDocument.php
@@ -10,7 +10,6 @@
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\ExtendableElementTrait;
use SimpleSAML\XML\Exception\SchemaViolationException;
-use SimpleSAML\XML\ExtendableAttributesTrait;
/**
* Class to represent a metadata document
diff --git a/src/SAML2/XML/md/AbstractRoleDescriptor.php b/src/SAML2/XML/md/AbstractRoleDescriptor.php
index fa9aa2099..7f5ceb437 100644
--- a/src/SAML2/XML/md/AbstractRoleDescriptor.php
+++ b/src/SAML2/XML/md/AbstractRoleDescriptor.php
@@ -75,7 +75,7 @@ public function __construct(
$keyDescriptor,
$organization,
$contactPerson,
- $namespacedAttributes
+ $namespacedAttributes,
);
}
@@ -160,6 +160,7 @@ public static function fromXML(DOMElement $xml): static
KeyDescriptor::getChildrenOfClass($xml),
array_pop($orgs),
ContactPerson::getChildrenOfClass($xml),
+ self::getAttributesNSFromXML($xml),
);
}
diff --git a/src/SAML2/XML/md/AbstractRoleDescriptorType.php b/src/SAML2/XML/md/AbstractRoleDescriptorType.php
index 0399ec2b4..f4f7a3b56 100644
--- a/src/SAML2/XML/md/AbstractRoleDescriptorType.php
+++ b/src/SAML2/XML/md/AbstractRoleDescriptorType.php
@@ -163,6 +163,10 @@ public function toUnsignedXML(?DOMElement $parent = null): DOMElement
$cp->toXML($e);
}
+ foreach ($this->getAttributesNS() as $attr) {
+ $attr->toXML($e);
+ }
+
return $e;
}
}
diff --git a/src/SAML2/XML/md/AbstractSignedMdElement.php b/src/SAML2/XML/md/AbstractSignedMdElement.php
index afd9845cf..2f06cc67a 100644
--- a/src/SAML2/XML/md/AbstractSignedMdElement.php
+++ b/src/SAML2/XML/md/AbstractSignedMdElement.php
@@ -6,10 +6,10 @@
use DOMElement;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\XMLSecurity\XML\SignableElementTrait;
use SimpleSAML\XMLSecurity\XML\SignableElementInterface;
-use SimpleSAML\XMLSecurity\XML\SignedElementTrait;
+use SimpleSAML\XMLSecurity\XML\SignableElementTrait;
use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
+use SimpleSAML\XMLSecurity\XML\SignedElementTrait;
use function method_exists;
diff --git a/src/SAML2/XML/md/AdditionalMetadataLocation.php b/src/SAML2/XML/md/AdditionalMetadataLocation.php
index 3adeb39eb..29a184977 100644
--- a/src/SAML2/XML/md/AdditionalMetadataLocation.php
+++ b/src/SAML2/XML/md/AdditionalMetadataLocation.php
@@ -5,7 +5,6 @@
namespace SimpleSAML\SAML2\XML\md;
use DOMElement;
-use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
diff --git a/src/SAML2/XML/md/AffiliateMember.php b/src/SAML2/XML/md/AffiliateMember.php
index a6e558cb4..122220d01 100644
--- a/src/SAML2/XML/md/AffiliateMember.php
+++ b/src/SAML2/XML/md/AffiliateMember.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
diff --git a/src/SAML2/XML/md/AffiliationDescriptor.php b/src/SAML2/XML/md/AffiliationDescriptor.php
index 64cec9233..8ed63439b 100644
--- a/src/SAML2/XML/md/AffiliationDescriptor.php
+++ b/src/SAML2/XML/md/AffiliationDescriptor.php
@@ -6,7 +6,6 @@
use DateTimeImmutable;
use DOMElement;
-use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
index 2c6712daa..a64dfede2 100644
--- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
@@ -28,7 +28,7 @@ final class AttributeAuthorityDescriptor extends AbstractRoleDescriptorType
*
* @param \SimpleSAML\SAML2\XML\md\AttributeService[] $attributeService
* @param string[] $protocolSupportEnumeration
- * @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $asssertionIDRequestService
+ * @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $assertionIDRequestService
* @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat
* @param \SimpleSAML\SAML2\XML\md\AttributeProfile[] $attributeProfile
* @param \SimpleSAML\SAML2\XML\saml\Attribute[] $attribute
@@ -40,6 +40,7 @@ final class AttributeAuthorityDescriptor extends AbstractRoleDescriptorType
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
* @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptor
* @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contact
+ * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(
protected array $attributeService,
@@ -56,6 +57,7 @@ public function __construct(
?Organization $organization = null,
array $keyDescriptor = [],
array $contact = [],
+ array $namespacedAttributes = []
) {
Assert::maxCount($attributeService, C::UNBOUNDED_LIMIT);
Assert::minCount(
@@ -89,6 +91,7 @@ public function __construct(
$keyDescriptor,
$organization,
$contact,
+ $namespacedAttributes
);
}
@@ -223,6 +226,7 @@ public static function fromXML(DOMElement $xml): static
!empty($orgs) ? $orgs[0] : null,
KeyDescriptor::getChildrenOfClass($xml),
ContactPerson::getChildrenOfClass($xml),
+ self::getAttributesNSFromXML($xml),
);
if (!empty($signature)) {
diff --git a/src/SAML2/XML/md/AttributeConsumingService.php b/src/SAML2/XML/md/AttributeConsumingService.php
index 05973a08c..2cf5ea8d4 100644
--- a/src/SAML2/XML/md/AttributeConsumingService.php
+++ b/src/SAML2/XML/md/AttributeConsumingService.php
@@ -6,7 +6,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
index 91cbc9017..ebc5a1a54 100644
--- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
@@ -36,6 +36,7 @@ final class AuthnAuthorityDescriptor extends AbstractRoleDescriptorType
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
* @param array $keyDescriptor
* @param array $contact
+ * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(
protected array $authnQueryService,
@@ -50,6 +51,7 @@ public function __construct(
?Organization $organization = null,
array $keyDescriptor = [],
array $contact = [],
+ array $namespacedAttributes = [],
) {
Assert::maxCount($authnQueryService, C::UNBOUNDED_LIMIT);
Assert::minCount($authnQueryService, 1, 'Missing at least one AuthnQueryService in AuthnAuthorityDescriptor.');
@@ -77,6 +79,7 @@ public function __construct(
$keyDescriptor,
$organization,
$contact,
+ $namespacedAttributes,
);
}
@@ -178,11 +181,14 @@ public static function fromXML(DOMElement $xml): static
!empty($orgs) ? $orgs[0] : null,
KeyDescriptor::getChildrenOfClass($xml),
ContactPerson::getChildrenOfClass($xml),
+ self::getAttributesNSFromXML($xml),
);
+
if (!empty($signature)) {
$authority->setSignature($signature[0]);
$authority->setXML($xml);
}
+
return $authority;
}
diff --git a/src/SAML2/XML/md/Company.php b/src/SAML2/XML/md/Company.php
index 6e6fda55a..227180131 100644
--- a/src/SAML2/XML/md/Company.php
+++ b/src/SAML2/XML/md/Company.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/md/ContactPerson.php b/src/SAML2/XML/md/ContactPerson.php
index fe1f67e10..4e2d1197d 100644
--- a/src/SAML2/XML/md/ContactPerson.php
+++ b/src/SAML2/XML/md/ContactPerson.php
@@ -4,13 +4,9 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMDocument;
use DOMElement;
-use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\ExtendableElementTrait;
use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\Attribute as XMLAttribute;
@@ -18,20 +14,14 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableAttributesTrait;
-use SimpleSAML\XML\SerializableElementInterface;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XML\XsNamespace as NS;
-use function array_filter;
use function array_change_key_case;
+use function array_filter;
use function array_key_exists;
use function array_keys;
-use function array_map;
use function array_pop;
use function count;
-use function filter_var;
-use function preg_replace;
-use function var_export;
/**
* Class representing SAML 2 ContactPerson.
@@ -40,8 +30,8 @@
*/
final class ContactPerson extends AbstractMdElement implements ArrayizableElementInterface
{
- use ExtendableElementTrait;
use ExtendableAttributesTrait;
+ use ExtendableElementTrait;
/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
@@ -82,7 +72,9 @@ public function __construct(
array $namespacedAttribute = [],
) {
Assert::oneOf($contactType, self::CONTACT_TYPES);
+ Assert::maxCount($emailAddress, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($emailAddress, EmailAddress::class);
+ Assert::maxCount($telephoneNumber, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($telephoneNumber, TelephoneNumber::class);
$this->setExtensions($extensions);
@@ -367,7 +359,6 @@ public function toArray(): array
$data['TelephoneNumber'] = array_merge($data['TelephoneNumber'], $telephone->toArray());
}
- /** @psalm-suppress PossiblyNullReference */
foreach ($this->getAttributesNS() as $attr) {
$data['attributes'][] = $attr->toArray();
}
diff --git a/src/SAML2/XML/md/EmailAddress.php b/src/SAML2/XML/md/EmailAddress.php
index 48c4b7b0a..f5373954c 100644
--- a/src/SAML2/XML/md/EmailAddress.php
+++ b/src/SAML2/XML/md/EmailAddress.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\XML\ArrayizableElementInterface;
@@ -57,7 +56,7 @@ protected function validateContent(string $content): void
*/
protected function sanitizeContent(string $content): string
{
- return trim(preg_replace('/^mailto:/i', '', $content));
+ return trim(preg_replace('/^(mailto:)+/i', '', $content));
}
diff --git a/src/SAML2/XML/md/Extensions.php b/src/SAML2/XML/md/Extensions.php
index 9693ebd9a..9f6a9fccf 100644
--- a/src/SAML2/XML/md/Extensions.php
+++ b/src/SAML2/XML/md/Extensions.php
@@ -6,7 +6,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\alg\AbstractAlgElement as ALG;
use SimpleSAML\SAML2\XML\alg\DigestMethod;
@@ -76,7 +75,7 @@ public static function fromXML(DOMElement $xml): static
Scope::NS => [
'Scope' => Scope::class,
],
- C::NS_MDATTR => [
+ EntityAttributes::NS => [
'EntityAttributes' => EntityAttributes::class,
],
MDRPI::NS => [
diff --git a/src/SAML2/XML/md/GivenName.php b/src/SAML2/XML/md/GivenName.php
index a9eacce88..9b7dda74b 100644
--- a/src/SAML2/XML/md/GivenName.php
+++ b/src/SAML2/XML/md/GivenName.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/md/KeyDescriptor.php b/src/SAML2/XML/md/KeyDescriptor.php
index 6c64ced2a..65e61e64c 100644
--- a/src/SAML2/XML/md/KeyDescriptor.php
+++ b/src/SAML2/XML/md/KeyDescriptor.php
@@ -6,6 +6,7 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
+use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
@@ -35,6 +36,7 @@ public function __construct(
['encryption', 'signing'],
'The "use" attribute of a KeyDescriptor can only be "encryption" or "signing".',
);
+ Assert::maxCount($encryptionMethod, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($encryptionMethod, EncryptionMethod::class);
}
diff --git a/src/SAML2/XML/md/Organization.php b/src/SAML2/XML/md/Organization.php
index 87a649050..9cf41ab9c 100644
--- a/src/SAML2/XML/md/Organization.php
+++ b/src/SAML2/XML/md/Organization.php
@@ -4,10 +4,7 @@
namespace SimpleSAML\SAML2\XML\md;
-use CASE_LOWER;
-use DOMDocument;
use DOMElement;
-use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
@@ -19,8 +16,6 @@
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableAttributesTrait;
-use SimpleSAML\XML\SerializableElementInterface;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XML\XsNamespace as NS;
use function array_change_key_case;
@@ -59,15 +54,19 @@ public function __construct(
?Extensions $extensions = null,
array $namespacedAttributes = [],
) {
- Assert::allIsInstanceOf($organizationName, OrganizationName::class);
- Assert::allIsInstanceOf($organizationDisplayName, OrganizationDisplayName::class);
- Assert::allIsInstanceOf($organizationURL, OrganizationURL::class);
+ Assert::maxCount($organizationName, C::UNBOUNDED_LIMIT);
+ Assert::maxCount($organizationDisplayName, C::UNBOUNDED_LIMIT);
+ Assert::maxCount($organizationURL, C::UNBOUNDED_LIMIT);
// [One or More]
Assert::minCount($organizationName, 1, ProtocolViolationException::class);
Assert::minCount($organizationDisplayName, 1, ProtocolViolationException::class);
Assert::minCount($organizationURL, 1, ProtocolViolationException::class);
+ Assert::allIsInstanceOf($organizationName, OrganizationName::class);
+ Assert::allIsInstanceOf($organizationDisplayName, OrganizationDisplayName::class);
+ Assert::allIsInstanceOf($organizationURL, OrganizationURL::class);
+
$this->setExtensions($extensions);
$this->setAttributesNS($namespacedAttributes);
}
@@ -286,6 +285,7 @@ public function toArray(): array
'OrganizationDisplayName' => [],
'OrganizationURL' => [],
'Extensions' => $this->getExtensions()?->getList(),
+ 'attributes' => [],
];
foreach ($this->getOrganizationName() as $orgName) {
@@ -303,8 +303,8 @@ public function toArray(): array
$data['OrganizationURL'] = array_merge($data['OrganizationURL'], $orgURL->toArray());
}
- foreach ($this->getAttributesNS() as $a) {
- $data['attributes'][] = $a->toArray();
+ foreach ($this->getAttributesNS() as $attr) {
+ $data['attributes'][] = $attr->toArray();
}
return array_filter($data);
diff --git a/src/SAML2/XML/md/OrganizationURL.php b/src/SAML2/XML/md/OrganizationURL.php
index b82183c8d..5ed2b85b2 100644
--- a/src/SAML2/XML/md/OrganizationURL.php
+++ b/src/SAML2/XML/md/OrganizationURL.php
@@ -4,8 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use InvalidArgumentException;
-
/**
* A localized name representing an organization's url.
*
diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php
index d777633c9..7a199f5b4 100644
--- a/src/SAML2/XML/md/PDPDescriptor.php
+++ b/src/SAML2/XML/md/PDPDescriptor.php
@@ -36,6 +36,7 @@ final class PDPDescriptor extends AbstractRoleDescriptorType
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
* @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors
* @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts
+ * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(
protected array $authzService,
@@ -50,6 +51,7 @@ public function __construct(
?Organization $organization = null,
array $keyDescriptors = [],
array $contacts = [],
+ array $namespacedAttributes = [],
) {
Assert::maxCount($authzService, C::UNBOUNDED_LIMIT);
Assert::minCount($authzService, 1, 'At least one md:AuthzService endpoint must be present.');
@@ -77,6 +79,7 @@ public function __construct(
$keyDescriptors,
$organization,
$contacts,
+ $namespacedAttributes,
);
}
@@ -168,6 +171,7 @@ public static function fromXML(DOMElement $xml): static
!empty($orgs) ? $orgs[0] : null,
KeyDescriptor::getChildrenOfClass($xml),
ContactPerson::getChildrenOfClass($xml),
+ self::getAttributesNSFromXML($xml),
);
if (!empty($signature)) {
diff --git a/src/SAML2/XML/md/RequestedAttribute.php b/src/SAML2/XML/md/RequestedAttribute.php
index 67eccc8be..3b86eb7e2 100644
--- a/src/SAML2/XML/md/RequestedAttribute.php
+++ b/src/SAML2/XML/md/RequestedAttribute.php
@@ -7,9 +7,9 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
+use SimpleSAML\XML\Exception\InvalidDOMElementException;
use function is_bool;
diff --git a/src/SAML2/XML/md/RoleDescriptor.php b/src/SAML2/XML/md/RoleDescriptor.php
deleted file mode 100644
index 939089479..000000000
--- a/src/SAML2/XML/md/RoleDescriptor.php
+++ /dev/null
@@ -1,444 +0,0 @@
-elementName = $elementName;
-
- if ($xml === null) {
- return;
- }
-
- if ($xml->hasAttribute('ID')) {
- $this->ID = $xml->getAttribute('ID');
- }
- if ($xml->hasAttribute('validUntil')) {
- $this->validUntil = XMLUtils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
- }
- if ($xml->hasAttribute('cacheDuration')) {
- $this->cacheDuration = $xml->getAttribute('cacheDuration');
- }
-
- if (!$xml->hasAttribute('protocolSupportEnumeration')) {
- throw new MissingAttributeException('Missing protocolSupportEnumeration attribute on ' . $xml->localName);
- }
- $this->protocolSupportEnumeration = preg_split('/[\s]+/', $xml->getAttribute('protocolSupportEnumeration'));
-
- if ($xml->hasAttribute('errorURL')) {
- $this->errorURL = $xml->getAttribute('errorURL');
- }
-
- $extensions = Extensions::getChildrenOfClass($xml);
- Assert::maxCount(
- $extensions,
- 1,
- 'Only one md:Extensions element is allowed.',
- TooManyElementsException::class,
- );
- $this->Extensions = array_pop($extensions);
-
- $this->KeyDescriptor = KeyDescriptor::getChildrenOfClass($xml);
-
- $organization = Organization::getChildrenOfClass($xml);
- Assert::maxCount(
- $organization,
- 1,
- 'Only one md:Organization element is allowed.',
- TooManyElementsException::class,
- );
- $this->Organization = array_pop($organization);
-
- $this->ContactPerson = ContactPerson::getChildrenOfClass($xml);
- }
-
-
- /**
- * Collect the value of the ID property.
- *
- * @return string|null
- */
- public function getID(): ?string
- {
- return $this->ID;
- }
-
-
- /**
- * Set the value of the ID property.
- *
- * @param string|null $Id
- * @return void
- */
- public function setID(string $Id = null): void
- {
- $this->ID = $Id;
- }
-
-
- /**
- * Collect the value of the validUntil-property
- * @return int|null
- */
- public function getValidUntil(): ?int
- {
- return $this->validUntil;
- }
-
-
- /**
- * Set the value of the validUntil-property
- * @param int|null $validUntil
- * @return void
- */
- public function setValidUntil(int $validUntil = null): void
- {
- $this->validUntil = $validUntil;
- }
-
-
- /**
- * Collect the value of the cacheDuration-property
- * @return string|null
- */
- public function getCacheDuration(): ?string
- {
- return $this->cacheDuration;
- }
-
-
- /**
- * Set the value of the cacheDuration-property
- * @param string|null $cacheDuration
- * @return void
- */
- public function setCacheDuration(string $cacheDuration = null): void
- {
- $this->cacheDuration = $cacheDuration;
- }
-
-
- /**
- * Collect the value of the Extensions property.
- *
- * @return \SimpleSAML\SAML2\XML\md\Extensions|null
- */
- public function getExtensions(): ?Extensions
- {
- return $this->Extensions;
- }
-
-
- /**
- * Set the value of the Extensions property.
- *
- * @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions
- * @return void
- */
- public function setExtensions(?Extensions $extensions): void
- {
- $this->Extensions = $extensions;
- }
-
-
- /**
- * Set the value of the errorURL property.
- *
- * @param string|null $errorURL
- * @return void
- */
- public function setErrorURL(string $errorURL = null): void
- {
- if (!is_null($errorURL) && !filter_var($errorURL, FILTER_VALIDATE_URL)) {
- throw new InvalidArgumentException('RoleDescriptor errorURL is not a valid URL.');
- }
- $this->errorURL = $errorURL;
- }
-
-
- /**
- * Collect the value of the errorURL property.
- *
- * @return string|null
- */
- public function getErrorURL(): ?string
- {
- return $this->errorURL;
- }
-
-
- /**
- * Collect the value of the ProtocolSupportEnumeration property.
- *
- * @return string[]
- */
- public function getProtocolSupportEnumeration(): array
- {
- return $this->protocolSupportEnumeration;
- }
-
-
- /**
- * Set the value of the ProtocolSupportEnumeration property.
- *
- * @param array $protocols
- * @return void
- */
- public function setProtocolSupportEnumeration(array $protocols): void
- {
- $this->protocolSupportEnumeration = $protocols;
- }
-
-
- /**
- * Add the value to the ProtocolSupportEnumeration property.
- *
- * @param string $protocol
- * @return void
- */
- public function addProtocolSupportEnumeration(string $protocol): void
- {
- $this->protocolSupportEnumeration[] = $protocol;
- }
-
-
- /**
- * Collect the value of the Organization property.
- *
- * @return \SimpleSAML\SAML2\XML\md\Organization|null
- */
- public function getOrganization(): ?Organization
- {
- return $this->Organization;
- }
-
-
- /**
- * Set the value of the Organization property.
- *
- * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
- * @return void
- */
- public function setOrganization(Organization $organization = null): void
- {
- $this->Organization = $organization;
- }
-
-
- /**
- * Collect the value of the ContactPerson property.
- *
- * @return \SimpleSAML\SAML2\XML\md\ContactPerson[]
- */
- public function getContactPerson(): array
- {
- return $this->ContactPerson;
- }
-
-
- /**
- * Set the value of the ContactPerson property.
- *
- * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contactPerson
- * @return void
- */
- public function setContactPerson(array $contactPerson): void
- {
- $this->ContactPerson = $contactPerson;
- }
-
-
- /**
- * Add the value to the ContactPerson property.
- *
- * @param \SimpleSAML\SAML2\XML\md\ContactPerson $contactPerson
- * @return void
- */
- public function addContactPerson(ContactPerson $contactPerson): void
- {
- $this->ContactPerson[] = $contactPerson;
- }
-
-
- /**
- * Collect the value of the KeyDescriptor property.
- *
- * @return \SimpleSAML\SAML2\XML\md\KeyDescriptor[]
- */
- public function getKeyDescriptor(): array
- {
- return $this->KeyDescriptor;
- }
-
-
- /**
- * Set the value of the KeyDescriptor property.
- *
- * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptor
- * @return void
- */
- public function setKeyDescriptor(array $keyDescriptor): void
- {
- $this->KeyDescriptor = $keyDescriptor;
- }
-
-
- /**
- * Add the value to the KeyDescriptor property.
- *
- * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor $keyDescriptor
- * @return void
- */
- public function addKeyDescriptor(KeyDescriptor $keyDescriptor): void
- {
- $this->KeyDescriptor[] = $keyDescriptor;
- }
-
-
- /**
- * Add this RoleDescriptor to an EntityDescriptor.
- *
- * @param \DOMElement $parent The EntityDescriptor we should append this endpoint to.
- * @return \DOMElement
- */
- public function toXML(DOMElement $parent): DOMElement
- {
- $e = $parent->ownerDocument->createElementNS(C::NS_MD, $this->elementName);
- $parent->appendChild($e);
-
- if ($this->ID !== null) {
- $e->setAttribute('ID', $this->ID);
- }
-
- if ($this->validUntil !== null) {
- $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil));
- }
-
- if ($this->cacheDuration !== null) {
- $e->setAttribute('cacheDuration', $this->cacheDuration);
- }
-
- $e->setAttribute('protocolSupportEnumeration', implode(' ', $this->protocolSupportEnumeration));
-
- if ($this->errorURL !== null) {
- $e->setAttribute('errorURL', $this->errorURL);
- }
-
- if ($this->Extensions !== null) {
- $this->Extensions->toXML($e);
- }
-
- foreach ($this->KeyDescriptor as $kd) {
- $kd->toXML($e);
- }
-
- if ($this->Organization !== null) {
- $this->Organization->toXML($e);
- }
-
- foreach ($this->ContactPerson as $cp) {
- $cp->toXML($e);
- }
-
- return $e;
- }
-}
diff --git a/src/SAML2/XML/md/SPSSODescriptor.php b/src/SAML2/XML/md/SPSSODescriptor.php
index 02b3614b0..7930e812d 100644
--- a/src/SAML2/XML/md/SPSSODescriptor.php
+++ b/src/SAML2/XML/md/SPSSODescriptor.php
@@ -26,23 +26,23 @@ final class SPSSODescriptor extends AbstractSSODescriptor
/**
* SPSSODescriptor constructor.
*
- * @param \SimpleSAML\SAML2\XML\md\AssertionConsumerService[] $assertionConsumerService
+ * @param array<\SimpleSAML\SAML2\XML\md\AssertionConsumerService> $assertionConsumerService
* @param string[] $protocolSupportEnumeration
* @param bool|null $authnRequestsSigned
* @param bool|null $wantAssertionsSigned
- * @param \SimpleSAML\SAML2\XML\md\AttributeConsumingService[] $attributeConsumingService
+ * @param array<\SimpleSAML\SAML2\XML\md\AttributeConsumingService> $attributeConsumingService
* @param string|null $ID
* @param \DateTimeImmutable|null $validUntil
* @param string|null $cacheDuration
* @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions
* @param string|null $errorURL
- * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors
+ * @param array<\SimpleSAML\SAML2\XML\md\KeyDescriptor> $keyDescriptors
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
- * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts
- * @param \SimpleSAML\SAML2\XML\md\ArtifactResolutionService[] $artifactResolutionService
- * @param \SimpleSAML\SAML2\XML\md\SingleLogoutService[] $singleLogoutService
- * @param \SimpleSAML\SAML2\XML\md\ManageNameIDService[] $manageNameIDService
- * @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat
+ * @param array<\SimpleSAML\SAML2\XML\md\ContactPerson> $contacts
+ * @param array<\SimpleSAML\SAML2\XML\md\ArtifactResolutionService> $artifactResolutionService
+ * @param array<\SimpleSAML\SAML2\XML\md\SingleLogoutService> $singleLogoutService
+ * @param array<\SimpleSAML\SAML2\XML\md\ManageNameIDService> $manageNameIDService
+ * @param array<\SimpleSAML\SAML2\XML\md\NameIDFormat> $nameIDFormat
*/
public function __construct(
protected array $assertionConsumerService,
diff --git a/src/SAML2/XML/md/SurName.php b/src/SAML2/XML/md/SurName.php
index 14067cbc7..745890f64 100644
--- a/src/SAML2/XML/md/SurName.php
+++ b/src/SAML2/XML/md/SurName.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/md/TelephoneNumber.php b/src/SAML2/XML/md/TelephoneNumber.php
index 07451b2bd..741328e24 100644
--- a/src/SAML2/XML/md/TelephoneNumber.php
+++ b/src/SAML2/XML/md/TelephoneNumber.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\md;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\XML\ArrayizableElementInterface;
diff --git a/src/SAML2/XML/md/UnknownRoleDescriptor.php b/src/SAML2/XML/md/UnknownRoleDescriptor.php
index 8cbff880e..b675ffd1c 100644
--- a/src/SAML2/XML/md/UnknownRoleDescriptor.php
+++ b/src/SAML2/XML/md/UnknownRoleDescriptor.php
@@ -6,16 +6,7 @@
use DateTimeImmutable;
use DOMElement;
-use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils\XPath;
-use SimpleSAML\XML\AbstractElement;
use SimpleSAML\XML\Chunk;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XMLSecurity\XML\ds\Signature;
-
-use function array_pop;
-use function preg_split;
/**
* Class representing unknown RoleDescriptors.
diff --git a/src/SAML2/XML/mdattr/EntityAttributes.php b/src/SAML2/XML/mdattr/EntityAttributes.php
index 314939c6a..d8993757d 100644
--- a/src/SAML2/XML/mdattr/EntityAttributes.php
+++ b/src/SAML2/XML/mdattr/EntityAttributes.php
@@ -6,15 +6,12 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeStatement;
use SimpleSAML\SAML2\XML\saml\NameID;
-use SimpleSAML\SAML2\XML\saml\Subject;
-use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use function array_filter;
diff --git a/src/SAML2/XML/mdrpi/Publication.php b/src/SAML2/XML/mdrpi/Publication.php
index 3e3658b90..286622b32 100644
--- a/src/SAML2/XML/mdrpi/Publication.php
+++ b/src/SAML2/XML/mdrpi/Publication.php
@@ -4,6 +4,7 @@
namespace SimpleSAML\SAML2\XML\mdrpi;
+use DateTimeImmutable;
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
@@ -11,7 +12,8 @@
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
+
+use function preg_replace;
/**
* Class for handling the mdrpi:Publication element.
@@ -25,14 +27,15 @@ final class Publication extends AbstractMdrpiElement implements ArrayizableEleme
* Create/parse a mdrpi:PublicationInfo element.
*
* @param string $publisher
- * @param int|null $creationInstant
+ * @param \DateTimeImmutable|null $creationInstant
* @param string|null $publicationId
*/
public function __construct(
protected string $publisher,
- protected ?int $creationInstant = null,
+ protected ?DateTimeImmutable $creationInstant = null,
protected ?string $publicationId = null,
) {
+ Assert::nullOrSame($creationInstant?->getTimeZone()->getName(), 'Z', ProtocolViolationException::class);
}
@@ -50,9 +53,9 @@ public function getPublisher(): string
/**
* Collect the value of the creationInstant-property
*
- * @return int|null
+ * @return \DateTimeImmutable|null
*/
- public function getCreationInstant(): ?int
+ public function getCreationInstant(): ?DateTimeImmutable
{
return $this->creationInstant;
}
@@ -94,7 +97,7 @@ public static function fromXML(DOMElement $xml): static
$creationInstant = preg_replace('/([.][0-9]+Z)$/', 'Z', $creationInstant, 1);
Assert::validDateTimeZulu($creationInstant, ProtocolViolationException::class);
- $creationInstant = XMLUtils::xsDateTimeToTimestamp($creationInstant);
+ $creationInstant = new DateTimeImmutable($creationInstant);
}
$publicationId = self::getOptionalAttribute($xml, 'publicationId', null);
@@ -115,7 +118,7 @@ public function toXML(DOMElement $parent = null): DOMElement
$e->setAttribute('publisher', $this->getPublisher());
if ($this->getCreationInstant() !== null) {
- $e->setAttribute('creationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->getCreationInstant()));
+ $e->setAttribute('creationInstant', $this->getCreationInstant()->format(C::DATETIME_FORMAT));
}
if ($this->getPublicationId() !== null) {
@@ -168,7 +171,7 @@ private static function processArrayContents(array $data): array
if (array_key_exists('creationinstant', $data)) {
Assert::string($data['creationinstant'], ArrayValidationException::class);
Assert::validDateTimeZulu($data['creationinstant'], ArrayValidationException::class);
- $retval['creationInstant'] = XMLUtils::xsDateTimeToTimestamp($data['creationinstant']);
+ $retval['creationInstant'] = new DateTimeImmutable($data['creationinstant']);
}
if (array_key_exists('publicationid', $data)) {
@@ -191,7 +194,7 @@ public function toArray(): array
$data['publisher'] = $this->getPublisher();
if ($this->getCreationInstant() !== null) {
- $data['creationInstant'] = gmdate('Y-m-d\TH:i:s\Z', $this->getCreationInstant());
+ $data['creationInstant'] = $this->getCreationInstant()->format(C::DATETIME_FORMAT);
}
if ($this->getPublicationId() !== null) {
diff --git a/src/SAML2/XML/mdrpi/PublicationInfo.php b/src/SAML2/XML/mdrpi/PublicationInfo.php
index 093f42cb2..6230f92c6 100644
--- a/src/SAML2/XML/mdrpi/PublicationInfo.php
+++ b/src/SAML2/XML/mdrpi/PublicationInfo.php
@@ -10,7 +10,6 @@
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
diff --git a/src/SAML2/XML/mdrpi/PublicationPath.php b/src/SAML2/XML/mdrpi/PublicationPath.php
index df350f96f..b032c3c81 100644
--- a/src/SAML2/XML/mdrpi/PublicationPath.php
+++ b/src/SAML2/XML/mdrpi/PublicationPath.php
@@ -7,10 +7,9 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\XML\ArrayizableElementInterface;
+use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
/**
* Class for handling the mdrpi:PublicationPath element.
@@ -28,6 +27,7 @@ final class PublicationPath extends AbstractMdrpiElement implements ArrayizableE
public function __construct(
protected array $publication = [],
) {
+ Assert::maxCount($publication, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($publication, Publication::class);
}
diff --git a/src/SAML2/XML/mdrpi/RegistrationInfo.php b/src/SAML2/XML/mdrpi/RegistrationInfo.php
index 0f4168a63..5e8e472ad 100644
--- a/src/SAML2/XML/mdrpi/RegistrationInfo.php
+++ b/src/SAML2/XML/mdrpi/RegistrationInfo.php
@@ -10,7 +10,6 @@
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
diff --git a/src/SAML2/XML/mdrpi/RegistrationPolicy.php b/src/SAML2/XML/mdrpi/RegistrationPolicy.php
index 331e1889e..e75dbbab8 100644
--- a/src/SAML2/XML/mdrpi/RegistrationPolicy.php
+++ b/src/SAML2/XML/mdrpi/RegistrationPolicy.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdrpi;
-use InvalidArgumentException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
/**
diff --git a/src/SAML2/XML/mdrpi/UsagePolicy.php b/src/SAML2/XML/mdrpi/UsagePolicy.php
index 55590976c..4e138cede 100644
--- a/src/SAML2/XML/mdrpi/UsagePolicy.php
+++ b/src/SAML2/XML/mdrpi/UsagePolicy.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdrpi;
-use InvalidArgumentException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
/**
diff --git a/src/SAML2/XML/mdui/DiscoHints.php b/src/SAML2/XML/mdui/DiscoHints.php
index 397baeb3b..3014f7a75 100644
--- a/src/SAML2/XML/mdui/DiscoHints.php
+++ b/src/SAML2/XML/mdui/DiscoHints.php
@@ -48,6 +48,9 @@ public function __construct(
protected array $domainHint = [],
protected array $geolocationHint = [],
) {
+ Assert::maxCount($ipHint, C::UNBOUNDED_LIMIT);
+ Assert::maxCount($domainHint, C::UNBOUNDED_LIMIT);
+ Assert::maxCount($geolocationHint, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($ipHint, IPHint::class);
Assert::allIsInstanceOf($domainHint, DomainHint::class);
Assert::allIsInstanceOf($geolocationHint, GeolocationHint::class);
@@ -153,11 +156,6 @@ public function toXML(DOMElement $parent = null): DOMElement
{
$e = $this->instantiateParentElement($parent);
- /** @var \SimpleSAML\XML\SerializableElementInterface $child */
- foreach ($this->getElements() as $child) {
- $child->toXML($e);
- }
-
foreach ($this->getIPHint() as $hint) {
$hint->toXML($e);
}
@@ -170,6 +168,11 @@ public function toXML(DOMElement $parent = null): DOMElement
$hint->toXML($e);
}
+ /** @var \SimpleSAML\XML\SerializableElementInterface $child */
+ foreach ($this->getElements() as $child) {
+ $child->toXML($e);
+ }
+
return $e;
}
diff --git a/src/SAML2/XML/mdui/DomainHint.php b/src/SAML2/XML/mdui/DomainHint.php
index f9cff37ed..22111bcaf 100644
--- a/src/SAML2/XML/mdui/DomainHint.php
+++ b/src/SAML2/XML/mdui/DomainHint.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdui;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\InvalidArgumentException;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/mdui/GeolocationHint.php b/src/SAML2/XML/mdui/GeolocationHint.php
index 4d5b74ef4..1b2d0eb34 100644
--- a/src/SAML2/XML/mdui/GeolocationHint.php
+++ b/src/SAML2/XML/mdui/GeolocationHint.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdui;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/mdui/IPHint.php b/src/SAML2/XML/mdui/IPHint.php
index b7ca83cad..a3f41958a 100644
--- a/src/SAML2/XML/mdui/IPHint.php
+++ b/src/SAML2/XML/mdui/IPHint.php
@@ -4,9 +4,7 @@
namespace SimpleSAML\SAML2\XML\mdui;
-use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\XML\StringElementTrait;
/**
diff --git a/src/SAML2/XML/mdui/InformationURL.php b/src/SAML2/XML/mdui/InformationURL.php
index 24712321b..42e19045e 100644
--- a/src/SAML2/XML/mdui/InformationURL.php
+++ b/src/SAML2/XML/mdui/InformationURL.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdui;
-use InvalidArgumentException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
/**
diff --git a/src/SAML2/XML/mdui/Keywords.php b/src/SAML2/XML/mdui/Keywords.php
index 1c5a16755..a8cf1112f 100644
--- a/src/SAML2/XML/mdui/Keywords.php
+++ b/src/SAML2/XML/mdui/Keywords.php
@@ -8,6 +8,7 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\XML\ArrayizableElementInterface;
+use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use function array_key_first;
@@ -33,6 +34,7 @@ public function __construct(
protected string $lang,
protected array $keywords = [],
) {
+ Assert::maxCount($keywords, C::UNBOUNDED_LIMIT);
Assert::allNotContains($keywords, '+', 'Keywords may not contain a "+" character.');
}
@@ -90,8 +92,7 @@ public static function fromXML(DOMElement $xml): static
Assert::same($xml->namespaceURI, Keywords::NS, InvalidDOMElementException::class);
Assert::stringNotEmpty($xml->textContent, 'Missing value for Keywords.');
- $lang = self::getOptionalAttribute($xml, 'xml:lang');
-
+ $lang = self::getAttribute($xml, 'xml:lang');
$Keywords = explode('+', $xml->textContent);
return new static($lang, $Keywords);
diff --git a/src/SAML2/XML/mdui/Logo.php b/src/SAML2/XML/mdui/Logo.php
index 6151ae803..1bb413141 100644
--- a/src/SAML2/XML/mdui/Logo.php
+++ b/src/SAML2/XML/mdui/Logo.php
@@ -10,7 +10,6 @@
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\XML\ArrayizableElementInterface;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\StringElementTrait;
use function filter_var;
@@ -131,7 +130,6 @@ public static function fromXML(DOMElement $xml): static
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = $this->instantiateParentElement($parent);
$e->textContent = $this->getContent();
$e->setAttribute('height', strval($this->getHeight()));
diff --git a/src/SAML2/XML/mdui/PrivacyStatementURL.php b/src/SAML2/XML/mdui/PrivacyStatementURL.php
index a2e0ec822..7e66f7be1 100644
--- a/src/SAML2/XML/mdui/PrivacyStatementURL.php
+++ b/src/SAML2/XML/mdui/PrivacyStatementURL.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdui;
-use InvalidArgumentException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
/**
diff --git a/src/SAML2/XML/mdui/UIInfo.php b/src/SAML2/XML/mdui/UIInfo.php
index 1b6c558ca..e2b0a321a 100644
--- a/src/SAML2/XML/mdui/UIInfo.php
+++ b/src/SAML2/XML/mdui/UIInfo.php
@@ -4,7 +4,6 @@
namespace SimpleSAML\SAML2\XML\mdui;
-use CASE_LOWER;
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
@@ -58,6 +57,7 @@ public function __construct(
protected array $logo = [],
array $children = [],
) {
+ Assert::maxCount($displayName, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($displayName, DisplayName::class);
/**
* 2.1.2: There MUST NOT be more than one ,
@@ -65,6 +65,7 @@ public function __construct(
*/
$this->testLocalizedElements($displayName);
+ Assert::maxCount($description, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($description, Description::class);
/**
* 2.1.3: There MUST NOT be more than one ,
@@ -72,6 +73,7 @@ public function __construct(
*/
$this->testLocalizedElements($description);
+ Assert::maxCount($keywords, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($keywords, Keywords::class);
/**
* 2.1.4: There MUST NOT be more than one ,
@@ -79,6 +81,7 @@ public function __construct(
*/
$this->testLocalizedElements($keywords);
+ Assert::maxCount($informationURL, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($informationURL, InformationURL::class);
/**
* 2.1.6: There MUST NOT be more than one ,
@@ -86,6 +89,7 @@ public function __construct(
*/
$this->testLocalizedElements($informationURL);
+ Assert::maxCount($privacyStatementURL, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($privacyStatementURL, PrivacyStatementURL::class);
/**
* 2.1.7: There MUST NOT be more than one ,
@@ -93,6 +97,7 @@ public function __construct(
*/
$this->testLocalizedElements($privacyStatementURL);
+ Assert::maxCount($logo, C::UNBOUNDED_LIMIT);
Assert::allIsInstanceOf($logo, Logo::class);
$this->setElements($children);
@@ -225,7 +230,7 @@ public function isEmptyElement(): bool
*
* @param (\SimpleSAML\SAML2\XML\md\AbstractLocalizedURL|
* \SimpleSAML\SAML2\XML\md\AbstractLocalizedName|
- * \SimpleSAML\XML\SAML2\mdui\Keywords)[] $items
+ * \SimpleSAML\SAML2\XML\mdui\Keywords)[] $elements
* @return void
*/
private function testLocalizedElements(array $elements)
diff --git a/src/SAML2/XML/saml/AbstractBaseID.php b/src/SAML2/XML/saml/AbstractBaseID.php
index bf3811a47..84a69ea2e 100644
--- a/src/SAML2/XML/saml/AbstractBaseID.php
+++ b/src/SAML2/XML/saml/AbstractBaseID.php
@@ -146,6 +146,7 @@ public function toXML(DOMElement $parent = null): DOMElement
return $e;
}
+
public function getBlacklistedAlgorithms(): ?array
{
$container = ContainerSingleton::getInstance();
diff --git a/src/SAML2/XML/saml/AbstractBaseIDType.php b/src/SAML2/XML/saml/AbstractBaseIDType.php
index c4b880ef5..0484743c3 100644
--- a/src/SAML2/XML/saml/AbstractBaseIDType.php
+++ b/src/SAML2/XML/saml/AbstractBaseIDType.php
@@ -14,44 +14,25 @@
*/
abstract class AbstractBaseIDType extends AbstractSamlElement implements BaseIdentifierInterface
{
+ use IDNameQualifiersTrait;
+
+
/**
* Initialize a saml:BaseIDAbstractType from scratch
*
- * @param string|null $nameQualifier
+ * @param string|null $NameQualifier
* The security or administrative domain that qualifies the identifier.
* This attribute provides a means to federate identifiers from disparate user stores without collision.
- * @param string|null $spNameQualifier
+ * @param string|null $SPNameQualifier
* Further qualifies an identifier with the name of a service provider or affiliation of providers. This
* attribute provides an additional means to federate identifiers on the basis of the relying party or parties.
*/
protected function __construct(
- protected ?string $nameQualifier = null,
- protected ?string $spNameQualifier = null,
+ protected ?string $NameQualifier = null,
+ protected ?string $SPNameQualifier = null,
) {
- Assert::nullOrNotWhitespaceOnly($nameQualifier);
- Assert::nullOrNotWhitespaceOnly($spNameQualifier);
- }
-
-
- /**
- * Collect the value of the NameQualifier-property
- *
- * @return string|null
- */
- public function getNameQualifier(): ?string
- {
- return $this->nameQualifier;
- }
-
-
- /**
- * Collect the value of the SPNameQualifier-property
- *
- * @return string|null
- */
- public function getSPNameQualifier(): ?string
- {
- return $this->spNameQualifier;
+ Assert::nullOrNotWhitespaceOnly($NameQualifier);
+ Assert::nullOrNotWhitespaceOnly($SPNameQualifier);
}
diff --git a/src/SAML2/XML/saml/Action.php b/src/SAML2/XML/saml/Action.php
index 63e89ca1e..7803e00e5 100644
--- a/src/SAML2/XML/saml/Action.php
+++ b/src/SAML2/XML/saml/Action.php
@@ -6,7 +6,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/saml/Assertion.php b/src/SAML2/XML/saml/Assertion.php
index 00d0a8a15..cf52c843b 100644
--- a/src/SAML2/XML/saml/Assertion.php
+++ b/src/SAML2/XML/saml/Assertion.php
@@ -6,21 +6,16 @@
use DateTimeImmutable;
use DOMElement;
-use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
-use SimpleSAML\XML\Chunk;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XML\Utils\Random as RandomUtils;
-use SimpleSAML\XMLSecurity\Utils\Security as SecurityUtils;
+use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use SimpleSAML\XMLSecurity\XML\EncryptableElementInterface;
use SimpleSAML\XMLSecurity\XML\EncryptableElementTrait;
@@ -28,7 +23,6 @@
use SimpleSAML\XMLSecurity\XML\SignableElementTrait;
use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
use SimpleSAML\XMLSecurity\XML\SignedElementTrait;
-use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
use function array_filter;
use function array_merge;
diff --git a/src/SAML2/XML/saml/AttributeStatement.php b/src/SAML2/XML/saml/AttributeStatement.php
index 84f1425cd..05553bb5a 100644
--- a/src/SAML2/XML/saml/AttributeStatement.php
+++ b/src/SAML2/XML/saml/AttributeStatement.php
@@ -8,7 +8,6 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
/**
* Class representing a SAML2 AttributeStatement
@@ -23,7 +22,7 @@ class AttributeStatement extends AbstractStatementType
* @param \SimpleSAML\SAML2\XML\saml\Attribute[] $attributes
* @param \SimpleSAML\SAML2\XML\saml\EncryptedAttribute[] $encryptedAttributes
*/
- public function __construct(
+ final public function __construct(
protected array $attributes = [],
protected array $encryptedAttributes = [],
) {
diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php
index a84e96c63..9a0b1b431 100644
--- a/src/SAML2/XML/saml/AttributeValue.php
+++ b/src/SAML2/XML/saml/AttributeValue.php
@@ -8,19 +8,13 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\XML\AbstractElement;
-use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use function array_pop;
use function class_exists;
use function explode;
use function gettype;
use function intval;
-use function is_array;
-use function is_int;
-use function is_null;
-use function is_string;
use function str_contains;
/**
@@ -33,7 +27,7 @@ class AttributeValue extends AbstractSamlElement
/**
* Create an AttributeValue.
*
- * @param mixed $value The value of this element. Can be one of:
+ * @param string|int|null|\SimpleSAML\XML\AbstractElement $value The value of this element. Can be one of:
* - string
* - int
* - null
@@ -41,7 +35,7 @@ class AttributeValue extends AbstractSamlElement
*
* @throws \SimpleSAML\Assert\AssertionFailedException if the supplied value is neither a string or a DOMElement
*/
- public function __construct(
+ final public function __construct(
protected string|int|null|AbstractElement $value,
) {
}
@@ -62,11 +56,9 @@ public function getXsiType(): string
case "NULL":
return "xs:nil";
case "object":
- /** @var \SimpleSAML\XML\AbstractElement $this->value */
return sprintf(
'%s:%s',
$this->value::getNamespacePrefix(),
- ":",
AbstractElement::getClassName(get_class($this->value)),
);
default:
@@ -78,7 +70,7 @@ public function getXsiType(): string
/**
* Get this attribute value.
*
- * @return string|int|\SimpleSAML\XML\AbstractElement[]|null
+ * @return string|int|\SimpleSAML\XML\AbstractElement|null
*/
public function getValue()
{
diff --git a/src/SAML2/XML/saml/AudienceRestriction.php b/src/SAML2/XML/saml/AudienceRestriction.php
index edabd6bfb..0fbb4c1a3 100644
--- a/src/SAML2/XML/saml/AudienceRestriction.php
+++ b/src/SAML2/XML/saml/AudienceRestriction.php
@@ -7,9 +7,8 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
+use SimpleSAML\XML\Exception\SchemaViolationException;
/**
* SAML AudienceRestriction data type.
@@ -26,8 +25,9 @@ final class AudienceRestriction extends AbstractConditionType
public function __construct(
protected array $audience,
) {
+ Assert::minCount($audience, 1, SchemaViolationException::class);
Assert::maxCount($audience, C::UNBOUNDED_LIMIT);
- Assert::allIsInstanceOf($audience, Audience::class);
+ Assert::allIsInstanceOf($audience, Audience::class, SchemaViolationException::class);
}
@@ -65,7 +65,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this Audience to XML.
*
- * @param \DOMElement|null $element The element we are converting to XML.
+ * @param \DOMElement|null $parent The element we are converting to XML.
* @return \DOMElement The XML element after adding the data corresponding to this AudienceRestriction.
*/
public function toXML(DOMElement $parent = null): DOMElement
diff --git a/src/SAML2/XML/saml/AuthnContext.php b/src/SAML2/XML/saml/AuthnContext.php
index 942382b73..9f63c6d90 100644
--- a/src/SAML2/XML/saml/AuthnContext.php
+++ b/src/SAML2/XML/saml/AuthnContext.php
@@ -10,10 +10,8 @@
use SimpleSAML\SAML2\XML\saml\AuthnContextDecl;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
use SimpleSAML\XML\Constants as C;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
use function array_pop;
use function is_null;
diff --git a/src/SAML2/XML/saml/AuthnContextClassRef.php b/src/SAML2/XML/saml/AuthnContextClassRef.php
index ca8ebb965..a19f59084 100644
--- a/src/SAML2/XML/saml/AuthnContextClassRef.php
+++ b/src/SAML2/XML/saml/AuthnContextClassRef.php
@@ -4,10 +4,7 @@
namespace SimpleSAML\SAML2\XML\saml;
-use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/saml/AuthnContextDecl.php b/src/SAML2/XML/saml/AuthnContextDecl.php
index 1c2b67f04..9cddd5856 100644
--- a/src/SAML2/XML/saml/AuthnContextDecl.php
+++ b/src/SAML2/XML/saml/AuthnContextDecl.php
@@ -6,11 +6,10 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
+use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\XsNamespace as NS;
/**
diff --git a/src/SAML2/XML/saml/AuthnContextDeclRef.php b/src/SAML2/XML/saml/AuthnContextDeclRef.php
index 6178ae4ff..9a6450f49 100644
--- a/src/SAML2/XML/saml/AuthnContextDeclRef.php
+++ b/src/SAML2/XML/saml/AuthnContextDeclRef.php
@@ -4,10 +4,7 @@
namespace SimpleSAML\SAML2\XML\saml;
-use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\StringElementTrait;
diff --git a/src/SAML2/XML/saml/AuthnStatement.php b/src/SAML2/XML/saml/AuthnStatement.php
index 65bb1a9af..a6c307bdb 100644
--- a/src/SAML2/XML/saml/AuthnStatement.php
+++ b/src/SAML2/XML/saml/AuthnStatement.php
@@ -14,7 +14,6 @@
use SimpleSAML\XML\Exception\TooManyElementsException;
use function array_pop;
-use function gmdate;
use function preg_replace;
/**
diff --git a/src/SAML2/XML/saml/AuthzDecisionStatement.php b/src/SAML2/XML/saml/AuthzDecisionStatement.php
index 43a42f3bb..d2a2f1bf3 100644
--- a/src/SAML2/XML/saml/AuthzDecisionStatement.php
+++ b/src/SAML2/XML/saml/AuthzDecisionStatement.php
@@ -13,11 +13,9 @@
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
use ValueError;
use function array_pop;
-use function gmdate;
use function sprintf;
/**
@@ -124,10 +122,11 @@ public static function fromXML(DOMElement $xml): static
TooManyElementsException::class,
);
+ $decision = self::getAttribute($xml, 'Decision');
try {
- $decision = Decision::from(self::getAttribute($xml, 'Decision'));
+ $decision = Decision::from($decision);
} catch (ValueError) {
- throw ProtocolViolationException(sprintf('Unknown value \'%s\' for Decision attribute.', $decision));
+ throw new ProtocolViolationException(sprintf('Unknown value \'%s\' for Decision attribute.', $decision));
}
return new static(
diff --git a/src/SAML2/XML/saml/Conditions.php b/src/SAML2/XML/saml/Conditions.php
index d91f06e9f..fd1140375 100644
--- a/src/SAML2/XML/saml/Conditions.php
+++ b/src/SAML2/XML/saml/Conditions.php
@@ -10,11 +10,8 @@
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
use function array_pop;
-use function gmdate;
-use function is_bool;
/**
* Class representing SAML 2 Conditions element.
diff --git a/src/SAML2/XML/saml/EncryptedAssertion.php b/src/SAML2/XML/saml/EncryptedAssertion.php
index 34e28b8af..9d5e06b53 100644
--- a/src/SAML2/XML/saml/EncryptedAssertion.php
+++ b/src/SAML2/XML/saml/EncryptedAssertion.php
@@ -4,8 +4,6 @@
namespace SimpleSAML\SAML2\XML\saml;
-use DOMElement;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\XML\EncryptedElementTrait;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
diff --git a/src/SAML2/XML/saml/EncryptedAttribute.php b/src/SAML2/XML/saml/EncryptedAttribute.php
index d32a1e95b..87e68675a 100644
--- a/src/SAML2/XML/saml/EncryptedAttribute.php
+++ b/src/SAML2/XML/saml/EncryptedAttribute.php
@@ -6,8 +6,8 @@
use SimpleSAML\SAML2\XML\EncryptedElementTrait;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface;
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
+use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface;
/**
* Class handling encrypted attributes.
diff --git a/src/SAML2/XML/saml/EncryptedID.php b/src/SAML2/XML/saml/EncryptedID.php
index a5ed7c7b0..0b049c813 100644
--- a/src/SAML2/XML/saml/EncryptedID.php
+++ b/src/SAML2/XML/saml/EncryptedID.php
@@ -4,15 +4,10 @@
namespace SimpleSAML\SAML2\XML\saml;
-use DOMElement;
use InvalidArgumentException;
-use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\EncryptedElementTrait;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\SchemaViolationException;
-use SimpleSAML\XML\ElementInterface;
+use SimpleSAML\XML\SerializableElementInterface;
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface;
@@ -31,10 +26,10 @@ class EncryptedID extends AbstractSamlElement implements EncryptedElementInterfa
/**
* @inheritDoc
*
- * @return \SimpleSAML\XML\ElementInterface
+ * @return \SimpleSAML\XML\SerializableElementInterface
* @throws \InvalidArgumentException
*/
- public function decrypt(EncryptionAlgorithmInterface $decryptor): ElementInterface
+ public function decrypt(EncryptionAlgorithmInterface $decryptor): SerializableElementInterface
{
$xml = DOMDocumentFactory::fromString($this->decryptData($decryptor))->documentElement;
diff --git a/src/SAML2/XML/saml/IDNameQualifiersTrait.php b/src/SAML2/XML/saml/IDNameQualifiersTrait.php
new file mode 100644
index 000000000..c321a2370
--- /dev/null
+++ b/src/SAML2/XML/saml/IDNameQualifiersTrait.php
@@ -0,0 +1,34 @@
+NameQualifier;
+ }
+
+
+ /**
+ * Collect the value of the SPNameQualifier-property
+ *
+ * @return string|null
+ */
+ public function getSPNameQualifier(): ?string
+ {
+ return $this->SPNameQualifier;
+ }
+}
diff --git a/src/SAML2/XML/saml/Issuer.php b/src/SAML2/XML/saml/Issuer.php
index 7c18a6a4e..1b094fc06 100644
--- a/src/SAML2/XML/saml/Issuer.php
+++ b/src/SAML2/XML/saml/Issuer.php
@@ -4,11 +4,8 @@
namespace SimpleSAML\SAML2\XML\saml;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
/**
* Class representing the saml:Issuer element.
@@ -53,8 +50,6 @@ public function __construct(
*
* From saml-core-2.0-os 8.3.6, when the entity Format is used: "The NameQualifier, SPNameQualifier, and
* SPProvidedID attributes MUST be omitted."
- *
- * @var string
*/
if ($Format === C::NAMEID_ENTITY || $Format === null) {
Assert::allNull(
@@ -65,27 +60,4 @@ public function __construct(
parent::__construct($value, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
}
-
-
- /**
- * Convert XML into an Issuer
- *
- * @param \DOMElement $xml The XML element we should load
- * @return static
- *
- * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
- * if the qualified name of the supplied element is wrong
- */
- public static function fromXML(DOMElement $xml): static
- {
- Assert::same($xml->localName, 'Issuer', InvalidDOMElementException::class);
- Assert::same($xml->namespaceURI, Issuer::NS, InvalidDOMElementException::class);
-
- $Format = self::getOptionalAttribute($xml, 'Format', null);
- $SPProvidedID = self::getOptionalAttribute($xml, 'SPProvidedID', null);
- $NameQualifier = self::getOptionalAttribute($xml, 'NameQualifier', null);
- $SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', null);
-
- return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
- }
}
diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php
index 1a3882d3a..1c9da4fe2 100644
--- a/src/SAML2/XML/saml/NameID.php
+++ b/src/SAML2/XML/saml/NameID.php
@@ -4,13 +4,10 @@
namespace SimpleSAML\SAML2\XML\saml;
-use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\XML\Exception\ArrayValidationException;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
+use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
-use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\XML\EncryptableElementInterface;
use SimpleSAML\XMLSecurity\XML\EncryptableElementTrait;
@@ -48,29 +45,6 @@ public function __construct(
}
- /**
- * Convert XML into an NameID
- *
- * @param \DOMElement $xml The XML element we should load
- * @return static
- *
- * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
- * if the qualified name of the supplied element is wrong
- */
- public static function fromXML(DOMElement $xml): static
- {
- Assert::same($xml->localName, 'NameID', InvalidDOMElementException::class);
- Assert::same($xml->namespaceURI, NameID::NS, InvalidDOMElementException::class);
-
- $NameQualifier = self::getOptionalAttribute($xml, 'NameQualifier', null);
- $SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', null);
- $Format = self::getOptionalAttribute($xml, 'Format', null);
- $SPProvidedID = self::getOptionalAttribute($xml, 'SPProvidedID', null);
-
- return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
- }
-
-
public function getBlacklistedAlgorithms(): ?array
{
$container = ContainerSingleton::getInstance();
diff --git a/src/SAML2/XML/saml/NameIDType.php b/src/SAML2/XML/saml/NameIDType.php
index 7751c447c..3ea679aaf 100644
--- a/src/SAML2/XML/saml/NameIDType.php
+++ b/src/SAML2/XML/saml/NameIDType.php
@@ -6,9 +6,8 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
+use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\StringElementTrait;
-use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
/**
* SAML NameIDType abstract data type.
@@ -16,8 +15,9 @@
* @package simplesamlphp/saml2
*/
-abstract class NameIDType extends AbstractBaseIDType
+abstract class NameIDType extends AbstractSamlElement implements IdentifierInterface
{
+ use IDNameQualifiersTrait;
use StringElementTrait;
@@ -32,15 +32,15 @@ abstract class NameIDType extends AbstractBaseIDType
*/
protected function __construct(
string $value,
- ?string $nameQualifier = null,
- ?string $spNameQualifier = null,
- protected ?string $format = null,
- protected ?string $spProvidedID = null,
+ protected ?string $NameQualifier = null,
+ protected ?string $SPNameQualifier = null,
+ protected ?string $Format = null,
+ protected ?string $SPProvidedID = null,
) {
- Assert::nullOrValidURI($format); // Covers the empty string
- Assert::nullOrNotWhitespaceOnly($spProvidedID);
-
- parent::__construct($nameQualifier, $spNameQualifier);
+ Assert::nullOrNotWhitespaceOnly($NameQualifier);
+ Assert::nullOrNotWhitespaceOnly($SPNameQualifier);
+ Assert::nullOrValidURI($Format); // Covers the empty string
+ Assert::nullOrNotWhitespaceOnly($SPProvidedID);
$this->setContent($value);
}
@@ -53,7 +53,7 @@ protected function __construct(
*/
public function getFormat(): ?string
{
- return $this->format;
+ return $this->Format;
}
@@ -64,7 +64,7 @@ public function getFormat(): ?string
*/
public function getSPProvidedID(): ?string
{
- return $this->spProvidedID;
+ return $this->SPProvidedID;
}
@@ -81,6 +81,29 @@ protected function validateContent(string $content): void
}
+ /**
+ * Convert XML into an NameID
+ *
+ * @param \DOMElement $xml The XML element we should load
+ * @return static
+ *
+ * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
+ * if the qualified name of the supplied element is wrong
+ */
+ public static function fromXML(DOMElement $xml): static
+ {
+ Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
+ Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
+
+ $NameQualifier = self::getOptionalAttribute($xml, 'NameQualifier', null);
+ $SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', null);
+ $Format = self::getOptionalAttribute($xml, 'Format', null);
+ $SPProvidedID = self::getOptionalAttribute($xml, 'SPProvidedID', null);
+
+ return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
+ }
+
+
/**
* Convert this NameIDType to XML.
*
@@ -89,7 +112,15 @@ protected function validateContent(string $content): void
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- $e = parent::toXML($parent);
+ $e = $this->instantiateParentElement($parent);
+
+ if ($this->getNameQualifier() !== null) {
+ $e->setAttribute('NameQualifier', $this->getNameQualifier());
+ }
+
+ if ($this->getSPNameQualifier() !== null) {
+ $e->setAttribute('SPNameQualifier', $this->getSPNameQualifier());
+ }
if ($this->getFormat() !== null) {
$e->setAttribute('Format', $this->getFormat());
diff --git a/src/SAML2/XML/saml/OneTimeUse.php b/src/SAML2/XML/saml/OneTimeUse.php
index be2972575..a9b357562 100644
--- a/src/SAML2/XML/saml/OneTimeUse.php
+++ b/src/SAML2/XML/saml/OneTimeUse.php
@@ -7,7 +7,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Exception\SchemaViolationException;
/**
* Class representing a saml:OneTimeUse element.
diff --git a/src/SAML2/XML/saml/ProxyRestriction.php b/src/SAML2/XML/saml/ProxyRestriction.php
index d9e38733b..7301d0ccd 100644
--- a/src/SAML2/XML/saml/ProxyRestriction.php
+++ b/src/SAML2/XML/saml/ProxyRestriction.php
@@ -8,7 +8,6 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
use function strval;
diff --git a/src/SAML2/XML/saml/Subject.php b/src/SAML2/XML/saml/Subject.php
index 64190e8a0..175845b33 100644
--- a/src/SAML2/XML/saml/Subject.php
+++ b/src/SAML2/XML/saml/Subject.php
@@ -6,8 +6,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\XML\IdentifierTrait;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
diff --git a/src/SAML2/XML/saml/SubjectConfirmation.php b/src/SAML2/XML/saml/SubjectConfirmation.php
index 405aa3c13..8ecf1e3b6 100644
--- a/src/SAML2/XML/saml/SubjectConfirmation.php
+++ b/src/SAML2/XML/saml/SubjectConfirmation.php
@@ -6,12 +6,10 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Compat\ContainerSingleton;
+use SimpleSAML\SAML2\XML\IdentifierTrait;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\SAML2\Utils;
-use SimpleSAML\SAML2\XML\IdentifierTrait;
use function array_pop;
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index ea5bdf2a6..6ab5fc202 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -18,7 +18,6 @@
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use function filter_var;
-use function gmdate;
use function is_null;
/**
diff --git a/src/SAML2/XML/saml/SubjectLocality.php b/src/SAML2/XML/saml/SubjectLocality.php
index 99bb42abc..b16194199 100644
--- a/src/SAML2/XML/saml/SubjectLocality.php
+++ b/src/SAML2/XML/saml/SubjectLocality.php
@@ -5,9 +5,8 @@
namespace SimpleSAML\SAML2\XML\saml;
use DOMElement;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\Assert\Assert;
+use SimpleSAML\XML\Exception\InvalidDOMElementException;
/**
* Class representing SAML2 SubjectLocality
@@ -27,7 +26,7 @@ public function __construct(
protected ?string $dnsName = null,
) {
Assert::nullOrIp($address, 'Invalid IP address');
- Assert::nullOrnotWhitespaceOnly($dnsName, 'Invalid DNS name');
+ Assert::nullOrNotWhitespaceOnly($dnsName, 'Invalid DNS name');
}
diff --git a/src/SAML2/XML/samlp/AbstractMessage.php b/src/SAML2/XML/samlp/AbstractMessage.php
index 58cea12c9..2c793dec7 100644
--- a/src/SAML2/XML/samlp/AbstractMessage.php
+++ b/src/SAML2/XML/samlp/AbstractMessage.php
@@ -7,7 +7,6 @@
use DateTimeImmutable;
use DOMDocument;
use DOMElement;
-use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Constants as C;
@@ -17,8 +16,6 @@
use SimpleSAML\SAML2\XML\ExtendableElementTrait;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\XML\Utils\Random as RandomUtils;
-use SimpleSAML\XMLSecurity\Exception\NoSignatureFoundException;
-use SimpleSAML\XMLSecurity\Key\PublicKey;
use SimpleSAML\XMLSecurity\XML\SignableElementInterface;
use SimpleSAML\XMLSecurity\XML\SignableElementTrait;
use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
diff --git a/src/SAML2/XML/samlp/AbstractSubjectQuery.php b/src/SAML2/XML/samlp/AbstractSubjectQuery.php
index ab86c6689..a7bf87bf9 100644
--- a/src/SAML2/XML/samlp/AbstractSubjectQuery.php
+++ b/src/SAML2/XML/samlp/AbstractSubjectQuery.php
@@ -6,9 +6,9 @@
use DateTimeImmutable;
use DOMElement;
+use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\Subject;
-use SimpleSAML\Assert\Assert;
/**
* Base class for SAML 2 subject query messages.
diff --git a/src/SAML2/XML/samlp/ArtifactResolve.php b/src/SAML2/XML/samlp/ArtifactResolve.php
index 7752d3b18..f3d88fa39 100644
--- a/src/SAML2/XML/samlp/ArtifactResolve.php
+++ b/src/SAML2/XML/samlp/ArtifactResolve.php
@@ -43,7 +43,7 @@ class ArtifactResolve extends AbstractRequest
*
* @throws \Exception
*/
- public function __construct(
+ final public function __construct(
protected string $artifact,
DateTimeImmutable $issueInstant,
?Issuer $issuer = null,
@@ -151,7 +151,6 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
{
Assert::notEmpty($this->artifact, 'Cannot convert ArtifactResolve to XML without an Artifact set.');
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = parent::toUnsignedXML($parent);
$artifactelement = $e->ownerDocument->createElementNS(C::NS_SAMLP, 'Artifact', $this->getArtifact());
$e->appendChild($artifactelement);
diff --git a/src/SAML2/XML/samlp/ArtifactResponse.php b/src/SAML2/XML/samlp/ArtifactResponse.php
index 9923319c4..fa7a61c5b 100644
--- a/src/SAML2/XML/samlp/ArtifactResponse.php
+++ b/src/SAML2/XML/samlp/ArtifactResponse.php
@@ -42,7 +42,7 @@ class ArtifactResponse extends AbstractStatusResponse
* @param \SimpleSAML\SAML2\XML\samlp\Extensions|null $extensions
* @param \SimpleSAML\SAML2\XML\samlp\AbstractMessage|null $message
*/
- public function __construct(
+ final public function __construct(
Status $status,
DateTimeImmutable $issueInstant,
?Issuer $issuer = null,
diff --git a/src/SAML2/XML/samlp/AttributeQuery.php b/src/SAML2/XML/samlp/AttributeQuery.php
index 3fde70313..4bca73b15 100644
--- a/src/SAML2/XML/samlp/AttributeQuery.php
+++ b/src/SAML2/XML/samlp/AttributeQuery.php
@@ -52,7 +52,7 @@ class AttributeQuery extends AbstractSubjectQuery
* @param string|null $consent
* @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions
*/
- public function __construct(
+ final public function __construct(
Subject $subject,
DateTimeImmutable $issueInstant,
protected array $attributes = [],
diff --git a/src/SAML2/XML/samlp/AuthnQuery.php b/src/SAML2/XML/samlp/AuthnQuery.php
index 03fdf30c7..23d28ad64 100644
--- a/src/SAML2/XML/samlp/AuthnQuery.php
+++ b/src/SAML2/XML/samlp/AuthnQuery.php
@@ -19,7 +19,6 @@
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use function array_pop;
-use function in_array;
use function preg_replace;
use function version_compare;
diff --git a/src/SAML2/XML/samlp/AuthnRequest.php b/src/SAML2/XML/samlp/AuthnRequest.php
index c641dc310..d141192d9 100644
--- a/src/SAML2/XML/samlp/AuthnRequest.php
+++ b/src/SAML2/XML/samlp/AuthnRequest.php
@@ -7,21 +7,17 @@
use DateTimeImmutable;
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Exception\InvalidArgumentException;
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException;
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\saml\Conditions;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\Subject;
-use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use function array_pop;
-use function filter_var;
-use function is_null;
use function strval;
/**
@@ -55,7 +51,7 @@ class AuthnRequest extends AbstractRequest
* @param \SimpleSAML\SAML2\XML\samlp\Scoping|null $scoping
* @throws \Exception
*/
- public function __construct(
+ final public function __construct(
DateTimeImmutable $issueInstant,
protected ?RequestedAuthnContext $requestedAuthnContext = null,
protected ?Subject $subject = null,
@@ -67,7 +63,7 @@ public function __construct(
protected ?int $assertionConsumerServiceIndex = null,
protected ?string $protocolBinding = null,
protected ?int $attributeConsumingServiceIndex = null,
- protected ?string $ProviderName = null,
+ protected ?string $providerName = null,
?Issuer $issuer = null,
?string $id = null,
string $version = '2.0',
@@ -76,7 +72,7 @@ public function __construct(
?Extensions $extensions = null,
protected ?Scoping $scoping = null,
) {
- Assert::nullOrNotWhitespaceOnly($ProviderName);
+ Assert::nullOrNotWhitespaceOnly($providerName);
Assert::oneOf(
null,
[$assertionConsumerServiceURL, $assertionConsumerServiceIndex],
@@ -157,7 +153,7 @@ public function getForceAuthn(): ?bool
*/
public function getProviderName(): ?string
{
- return $this->ProviderName;
+ return $this->providerName;
}
diff --git a/src/SAML2/XML/samlp/AuthzDecisionQuery.php b/src/SAML2/XML/samlp/AuthzDecisionQuery.php
index 9608f991f..b7c40387f 100644
--- a/src/SAML2/XML/samlp/AuthzDecisionQuery.php
+++ b/src/SAML2/XML/samlp/AuthzDecisionQuery.php
@@ -8,9 +8,9 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException;
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException;
+use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\saml\Action;
use SimpleSAML\SAML2\XML\saml\Evidence;
use SimpleSAML\SAML2\XML\saml\Issuer;
@@ -21,7 +21,6 @@
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
-use function preg_match;
use function version_compare;
/**
diff --git a/src/SAML2/XML/samlp/IDPList.php b/src/SAML2/XML/samlp/IDPList.php
index a0dc05be2..97831eed0 100644
--- a/src/SAML2/XML/samlp/IDPList.php
+++ b/src/SAML2/XML/samlp/IDPList.php
@@ -11,14 +11,12 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
use function array_change_key_case;
use function array_filter;
use function array_key_exists;
use function array_keys;
use function array_pop;
-use function is_null;
/**
* Class for handling SAML2 IDPList.
diff --git a/src/SAML2/XML/samlp/LogoutRequest.php b/src/SAML2/XML/samlp/LogoutRequest.php
index 4caef8cfd..e6bb25ff3 100644
--- a/src/SAML2/XML/samlp/LogoutRequest.php
+++ b/src/SAML2/XML/samlp/LogoutRequest.php
@@ -12,21 +12,17 @@
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\IdentifierTrait;
-use SimpleSAML\SAML2\XML\saml\IdentifierInterface;
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
-use SimpleSAML\SAML2\XML\saml\NameID;
+use SimpleSAML\SAML2\XML\saml\IdentifierInterface;
use SimpleSAML\SAML2\XML\saml\Issuer;
+use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
-use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use function array_pop;
-use function gmdate;
/**
* Class for SAML 2 logout request messages.
@@ -209,7 +205,6 @@ public static function fromXML(DOMElement $xml): static
*/
protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = parent::toUnsignedXML($parent);
if ($this->getNotOnOrAfter() !== null) {
@@ -220,7 +215,7 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
$e->setAttribute('Reason', $this->getReason());
}
- /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $identifier */
+ /** @var \SimpleSAML\XML\SerializableElementInterface $identifier */
$identifier = $this->getIdentifier();
$identifier->toXML($e);
diff --git a/src/SAML2/XML/samlp/LogoutResponse.php b/src/SAML2/XML/samlp/LogoutResponse.php
index 3fdb70af7..9b3018eb7 100644
--- a/src/SAML2/XML/samlp/LogoutResponse.php
+++ b/src/SAML2/XML/samlp/LogoutResponse.php
@@ -12,7 +12,6 @@
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use function array_pop;
diff --git a/src/SAML2/XML/samlp/RequestedAuthnContext.php b/src/SAML2/XML/samlp/RequestedAuthnContext.php
index 9bd83fba3..02c9900fa 100644
--- a/src/SAML2/XML/samlp/RequestedAuthnContext.php
+++ b/src/SAML2/XML/samlp/RequestedAuthnContext.php
@@ -6,12 +6,12 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\XML\Comparison;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
+use SimpleSAML\XML\Exception\SchemaViolationException;
use function array_merge;
@@ -36,8 +36,12 @@ public function __construct(
protected ?Comparison $Comparison = null,
) {
Assert::maxCount($requestedAuthnContexts, C::UNBOUNDED_LIMIT);
- Assert::minCount($requestedAuthnContexts, 1);
- Assert::allIsInstanceOfAny($requestedAuthnContexts, [AuthnContextClassRef::class, AuthnContextDeclRef::class]);
+ Assert::minCount($requestedAuthnContexts, 1, SchemaViolationException::class);
+ Assert::allIsInstanceOfAny(
+ $requestedAuthnContexts,
+ [AuthnContextClassRef::class, AuthnContextDeclRef::class],
+ SchemaViolationException::class,
+ );
if ($requestedAuthnContexts[0] instanceof AuthnContextClassRef) {
Assert::allIsInstanceOf(
@@ -69,7 +73,7 @@ public function getRequestedAuthnContexts(): array
/**
* Collect the value of the Comparison-property
*
- * @return SimpleSAML\SAML2\XML\Comparison|null
+ * @return \SimpleSAML\SAML2\XML\Comparison|null
*/
public function getComparison(): ?Comparison
{
@@ -110,7 +114,6 @@ public static function fromXML(DOMElement $xml): static
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = $this->instantiateParentElement($parent);
foreach ($this->getRequestedAuthnContexts() as $context) {
diff --git a/src/SAML2/XML/samlp/Response.php b/src/SAML2/XML/samlp/Response.php
index f36b44c7a..eb0ac2212 100644
--- a/src/SAML2/XML/samlp/Response.php
+++ b/src/SAML2/XML/samlp/Response.php
@@ -11,15 +11,12 @@
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException;
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\EncryptedAssertion;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
-use SimpleSAML\XMLSecurity\Utils\Security;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use function array_pop;
diff --git a/src/SAML2/XML/samlp/Scoping.php b/src/SAML2/XML/samlp/Scoping.php
index a0542e462..fb3a0937e 100644
--- a/src/SAML2/XML/samlp/Scoping.php
+++ b/src/SAML2/XML/samlp/Scoping.php
@@ -8,11 +8,8 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Utils as XMLUtils;
use function array_pop;
-use function is_null;
-use function intval;
/**
* Class for handling SAML2 Scoping.
@@ -98,7 +95,7 @@ public static function fromXML(DOMElement $xml): static
$requesterId = RequesterID::getChildrenOfClass($xml);
return new static(
- is_null($proxyCount) ? null : $proxyCount,
+ $proxyCount,
array_pop($idpList),
$requesterId,
);
diff --git a/src/SAML2/XML/samlp/Status.php b/src/SAML2/XML/samlp/Status.php
index d012c7c8e..ce3d9e75b 100644
--- a/src/SAML2/XML/samlp/Status.php
+++ b/src/SAML2/XML/samlp/Status.php
@@ -11,10 +11,8 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use SimpleSAML\XML\Utils as XMLUtils;
use function array_pop;
-use function is_null;
/**
* SAML Status data type.
diff --git a/src/SAML2/XML/samlp/StatusDetail.php b/src/SAML2/XML/samlp/StatusDetail.php
index db2c665b1..2b13fa5da 100644
--- a/src/SAML2/XML/samlp/StatusDetail.php
+++ b/src/SAML2/XML/samlp/StatusDetail.php
@@ -6,8 +6,8 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Chunk;
+use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;
@@ -76,16 +76,14 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this StatusDetail to XML.
*
- * @param \DOMElement|null $element The element we are converting to XML.
+ * @param \DOMElement|null $parent The element we are converting to XML.
* @return \DOMElement The XML element after adding the data corresponding to this StatusDetail.
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = $this->instantiateParentElement($parent);
foreach ($this->getElements() as $detail) {
- /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $detail */
$detail->toXML($e);
}
diff --git a/src/SAML2/XML/shibmd/KeyAuthority.php b/src/SAML2/XML/shibmd/KeyAuthority.php
index 148ffe42c..2e3cc424d 100644
--- a/src/SAML2/XML/shibmd/KeyAuthority.php
+++ b/src/SAML2/XML/shibmd/KeyAuthority.php
@@ -6,7 +6,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
@@ -33,7 +32,7 @@ final class KeyAuthority extends AbstractShibmdElement
* Create a KeyAuthority.
*
* @param \SimpleSAML\XMLSecurity\XML\ds\KeyInfo[] $keys
- * @param int|null $verifyDepth
+ * @param int|null $VerifyDepth
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(
@@ -41,6 +40,7 @@ public function __construct(
protected ?int $VerifyDepth = null,
array $namespacedAttributes = [],
) {
+ Assert::maxCount($keys, C::UNBOUNDED_LIMIT);
Assert::nullOrRange($VerifyDepth, 0, 255);
$this->setAttributesNS($namespacedAttributes);
@@ -83,7 +83,7 @@ public static function fromXML(DOMElement $xml): static
Assert::same($xml->localName, 'KeyAuthority', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, KeyAuthority::NS, InvalidDOMElementException::class);
- $verifyDepth = self::getOptionalIntegerAttribute($xml, 'VerifyDepth', null);
+ $verifyDepth = self::getOptionalIntegerAttribute($xml, 'VerifyDepth', 1);
Assert::natural($verifyDepth);
$keys = KeyInfo::getChildrenOfClass($xml);
@@ -101,7 +101,6 @@ public static function fromXML(DOMElement $xml): static
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = $this->instantiateParentElement($parent);
foreach ($this->getAttributesNS() as $attr) {
diff --git a/src/SAML2/XML/shibmd/Scope.php b/src/SAML2/XML/shibmd/Scope.php
index da25d2b1b..a2e817549 100644
--- a/src/SAML2/XML/shibmd/Scope.php
+++ b/src/SAML2/XML/shibmd/Scope.php
@@ -6,7 +6,6 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\StringElementTrait;
@@ -88,7 +87,6 @@ public static function fromXML(DOMElement $xml): static
*/
public function toXML(DOMElement $parent = null): DOMElement
{
- /** @psalm-var \DOMDocument $e->ownerDocument */
$e = $this->instantiateParentElement($parent);
$e->textContent = $this->getContent();
$e->setAttribute('regexp', $this->isRegexpScope() ? 'true' : 'false');
diff --git a/tests/InterOperability/EntitiesDescriptorTest.php b/tests/InterOperability/EntitiesDescriptorTest.php
new file mode 100644
index 000000000..1d271e827
--- /dev/null
+++ b/tests/InterOperability/EntitiesDescriptorTest.php
@@ -0,0 +1,55 @@
+assertTrue($shouldPass);
+ } catch (AssertionFailedException $e) {
+ fwrite(STDERR, $e->getFile() . '(' . strval($e->getLine()) . '):' . $e->getMessage());
+ fwrite(STDERR, $e->getTraceAsString());
+ $this->assertFalse($shouldPass);
+ }
+ }
+
+
+ /**
+ * @return array
+ */
+ public static function provideMetadata(): array
+ {
+ return [
+ 'eduGAIN' => [
+ true,
+ DOMDocumentFactory::fromFile('/tmp/metadata/edugain.xml')->documentElement,
+ ],
+ 'GRNET' => [
+ true,
+ DOMDocumentFactory::fromFile('/tmp/metadata/grnet.xml')->documentElement,
+ ],
+ ];
+ }
+}
diff --git a/tests/InterOperability/EntityDescriptorTest.php b/tests/InterOperability/EntityDescriptorTest.php
new file mode 100644
index 000000000..8dc98ef07
--- /dev/null
+++ b/tests/InterOperability/EntityDescriptorTest.php
@@ -0,0 +1,53 @@
+assertTrue($shouldPass);
+ } catch (AssertionFailedException $e) {
+ fwrite(STDERR, $e->getFile() . '(' . strval($e->getLine()) . '):' . $e->getMessage());
+ fwrite(STDERR, $e->getTraceAsString());
+ $this->assertFalse($shouldPass);
+ }
+ }
+
+
+ /**
+ * @return array
+ */
+ public static function provideMetadata(): array
+ {
+ return [
+ // Known bug: Microsoft doensn't produce a schema-valid XML
+ // This was reported to them in 2022: TrackingID#2210040050001949
+ 'MicrosoftOnline' => [
+ true,
+ DOMDocumentFactory::fromFile('/tmp/metadata/microsoftonline.xml')->documentElement,
+ ],
+ ];
+ }
+}
diff --git a/tests/SAML2/AbstractControlledTimeTestCase.php b/tests/SAML2/AbstractControlledTimeTestCase.php
deleted file mode 100644
index 1a592a5b7..000000000
--- a/tests/SAML2/AbstractControlledTimeTestCase.php
+++ /dev/null
@@ -1,29 +0,0 @@
-shouldReceive('getTime')->andReturn($this->currentTime);
- }
-}
diff --git a/tests/SAML2/Assertion/ProcessorTest.php b/tests/SAML2/Assertion/ProcessorTest.php
index ed74fb0c2..073e312e1 100644
--- a/tests/SAML2/Assertion/ProcessorTest.php
+++ b/tests/SAML2/Assertion/ProcessorTest.php
@@ -5,8 +5,9 @@
namespace SimpleSAML\Test\SAML2\Assertion;
use Mockery;
-use Mockery\MockInterface;
use Mockery\Adapter\Phpunit\MockeryTestCase;
+use Mockery\MockInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
use Psr\Log\LoggerInterface;
use SimpleSAML\SAML2\Assertion\Decrypter;
use SimpleSAML\SAML2\Assertion\Exception\InvalidAssertionException;
@@ -23,10 +24,9 @@
use stdClass;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Processor
* @package simplesamlphp/saml2
- * @runTestsInSeparateProcesses
*/
+#[CoversClass(Processor::class)]
final class ProcessorTest extends MockeryTestCase
{
/**
@@ -35,7 +35,7 @@ final class ProcessorTest extends MockeryTestCase
private static Processor $processor;
/**
- * @var m\MockInterface&Decrypter
+ * @var MockInterface&Decrypter
*/
private static MockInterface $decrypter;
@@ -63,9 +63,8 @@ public static function setUpBeforeClass(): void
/**
- * @test
*/
- public function processorCorrectlyEncryptsAssertions(): void
+ public function testProcessorCorrectlyEncryptsAssertions(): void
{
$encryptedAssertion = EncryptedAssertion::fromXML(
DOMDocumentFactory::fromFile(
@@ -101,9 +100,8 @@ public function processorCorrectlyEncryptsAssertions(): void
/**
- * @test
*/
- public function unsuportedAssertionsAreRejected(): void
+ public function testUnsuportedAssertionsAreRejected(): void
{
$this->expectException(InvalidAssertionException::class);
$this->expectExceptionMessage('The assertion must be of type: EncryptedAssertion or Assertion');
diff --git a/tests/SAML2/Assertion/Transformer/NameIdDecryptionTransformerTest.php b/tests/SAML2/Assertion/Transformer/NameIdDecryptionTransformerTest.php
index 13143a2fd..7caa0ee49 100644
--- a/tests/SAML2/Assertion/Transformer/NameIdDecryptionTransformerTest.php
+++ b/tests/SAML2/Assertion/Transformer/NameIdDecryptionTransformerTest.php
@@ -2,15 +2,16 @@
declare(strict_types=1);
-namespace SimpleSAML\Test\SAML2\XML\saml;
+namespace SimpleSAML\Test\SAML2\Assertion\Transformer;
use DateTimeImmutable;
use DOMDocument;
+use PHPUnit\Framework\Attributes\PreserveGlobalState;
+use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
-use SimpleSAML\SAML2\Assertion\Exception\InvalidAssertionException;
use SimpleSAML\SAML2\Assertion\Processor;
use SimpleSAML\SAML2\Assertion\ProcessorBuilder;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
@@ -33,9 +34,7 @@
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
use SimpleSAML\Test\SAML2\Constants as C;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PublicKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use function getcwd;
@@ -71,7 +70,7 @@ final class NameIdDecryptionTransformerTest extends TestCase
/** @var \SimpleSAML\SAML2\Configuration\Destination */
protected static Destination $destination;
- /** @var \SimpleSAML\SAML2\xml\samlp\Response */
+ /** @var \SimpleSAML\SAML2\XML\samlp\Response */
protected static Response $response;
/** @var string */
@@ -150,11 +149,10 @@ public static function setUpBeforeClass(): void
/**
* Verifies that we can create decrypted NameIDs.
- *
- * @runInSeparateProcess
- * @preserveGlobalState disabled
* @return void
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testBasicNameIdDecryption(): void
{
$this->markTestSkipped();
@@ -172,10 +170,10 @@ public function testBasicNameIdDecryption(): void
/**
* Run the decoder through processAssertions.
*
- * @runInSeparateProcess
- * @preserveGlobalState disabled
* @return void
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testDecryptionProcessAssertions(): void
{
$this->markTestSkipped();
diff --git a/tests/SAML2/Assertion/Validation/AssertionValidatorTest.php b/tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
index 779d7abd9..ff31eea85 100644
--- a/tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
+++ b/tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
@@ -2,9 +2,12 @@
declare(strict_types=1);
-namespace SimpleSAML\Test\SAML2\XML\saml;
+namespace SimpleSAML\Test\SAML2\Assertion\Validation;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\PreserveGlobalState;
+use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
@@ -12,6 +15,7 @@
use SimpleSAML\SAML2\Assertion\Exception\InvalidAssertionException;
use SimpleSAML\SAML2\Assertion\Processor;
use SimpleSAML\SAML2\Assertion\ProcessorBuilder;
+use SimpleSAML\SAML2\Assertion\Validation\AssertionValidator;
use SimpleSAML\SAML2\Configuration\Destination;
use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Configuration\ServiceProvider;
@@ -27,9 +31,9 @@
/**
* Tests for the Assertion validators
*
- * @covers \SimpleSAML\SAML2\Assertion\Validation\AssertionValidator
* @package simplesamlphp/saml2
*/
+#[CoversClass(AssertionValidator::class)]
final class AssertionValidatorTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -56,7 +60,7 @@ final class AssertionValidatorTest extends TestCase
/** @var \SimpleSAML\SAML2\Configuration\Destination */
protected static Destination $destination;
- /** @var \SimpleSAML\SAML2\xml\samlp\Response */
+ /** @var \SimpleSAML\SAML2\XML\samlp\Response */
protected static Response $response;
@@ -120,10 +124,9 @@ public static function setUpBeforeClass(): void
/**
* Verifies that the assertion validator works
- *
- * @runInSeparateProcess
- * @preserveGlobalState disabled
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testBasicValidation(): void
{
$assertion = Assertion::fromXML(self::$document->firstChild);
@@ -135,10 +138,9 @@ public function testBasicValidation(): void
/**
* Verifies that violations are caught
- *
- * @runInSeparateProcess
- * @preserveGlobalState disabled
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testAssertionNonValidation(): void
{
$accr = C::AUTHNCONTEXT_CLASS_REF_LOA1;
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
index 7e9bec6e2..ed251808a 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
@@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotBefore;
@@ -19,10 +21,9 @@
use SimpleSAML\Test\SAML2\Constants as C;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotBefore
- *
* @package simplesamlphp/saml2
*/
+#[CoversClass(NotBefore::class)]
final class NotBeforeTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -57,10 +58,9 @@ public static function setUpBeforeClass(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timestampInTheFutureBeyondGraceperiodIsNotValid(): void
+ #[Group('assertion-validation')]
+ public function testTimestampInTheFutureBeyondGraceperiodIsNotValid(): void
{
// Create Conditions
$conditions = new Conditions(self::$clock->now()->add(new DateInterval('PT61S')));
@@ -84,10 +84,9 @@ public function timestampInTheFutureBeyondGraceperiodIsNotValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timeWithinGraceperiodIsValid(): void
+ #[Group('assertion-validation')]
+ public function testTimeWithinGraceperiodIsValid(): void
{
// Create Conditions
$conditions = new Conditions(self::$clock->now()->add(new DateInterval('PT60S')));
@@ -110,10 +109,9 @@ public function timeWithinGraceperiodIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function currentTimeIsValid(): void
+ #[Group('assertion-validation')]
+ public function testCurrentTimeIsValid(): void
{
// Create Conditions
$conditions = new Conditions(self::$clock->now());
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
index 10ed208a5..8c133ccd0 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
@@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter;
@@ -19,10 +21,9 @@
use SimpleSAML\Test\SAML2\Constants as C;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter
- *
* @package simplesamlphp/saml2
*/
+#[CoversClass(NotOnOrAfter::class)]
final class NotOnOrAfterTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -57,10 +58,9 @@ public static function setUpBeforeClass(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timestampInThePastBeforeGraceperiodIsNotValid(): void
+ #[Group('assertion-validation')]
+ public function testTimestampInThePastBeforeGraceperiodIsNotValid(): void
{
// Create Conditions
$conditions = new Conditions(null, self::$clock->now()->sub(new DateInterval('PT60S')));
@@ -84,10 +84,9 @@ public function timestampInThePastBeforeGraceperiodIsNotValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timeWithinGraceperiodIsValid(): void
+ #[Group('assertion-validation')]
+ public function testTimeWithinGraceperiodIsValid(): void
{
// Create Conditions
$conditions = new Conditions(null, self::$clock->now()->sub(new DateInterval('PT59S')));
@@ -110,10 +109,9 @@ public function timeWithinGraceperiodIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function currentTimeIsValid(): void
+ #[Group('assertion-validation')]
+ public function testCurrentTimeIsValid(): void
{
// Create Conditions
$conditions = new Conditions(null, self::$clock->now());
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
index f6695eedd..498605bcc 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
@@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter;
@@ -18,10 +20,9 @@
use SimpleSAML\Test\SAML2\Constants as C;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter
- *
* @package simplesamlphp/saml2
*/
+#[CoversClass(SessionNotOnOrAfter::class)]
final class SessionNotOnOrAfterTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -43,9 +44,8 @@ public static function setUpBeforeClass(): void
/**
- * @group assertion-validation
- * @test
*/
+ #[Group('assertion-validation')]
public function timestampInThePastBeforeGraceperiodIsNotValid(): void
{
// Create the statements
@@ -73,9 +73,8 @@ public function timestampInThePastBeforeGraceperiodIsNotValid(): void
/**
- * @group assertion-validation
- * @test
*/
+ #[Group('assertion-validation')]
public function timeWithinGraceperiodIsValid(): void
{
// Create the statements
@@ -102,10 +101,9 @@ public function timeWithinGraceperiodIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function currentTimeIsValid(): void
+ #[Group('assertion-validation')]
+ public function testCurrentTimeIsValid(): void
{
// Create the statements
$authnStatement = new AuthnStatement(
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
index ec12da351..1faba72b0 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
@@ -4,11 +4,11 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
-use DateTimeImmutable;
-use DateTimeZone;
use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\MockInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience;
use SimpleSAML\SAML2\Assertion\Validation\Result;
@@ -28,9 +28,9 @@
* Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
* tests.
*
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience
* @package simplesamlphp/saml2
*/
+#[CoversClass(SpIsValidAudience::class)]
final class SpIsValidAudienceTest extends MockeryTestCase
{
/** @var \SimpleSAML\SAML2\XML\saml\AuthnStatement */
@@ -39,7 +39,7 @@ final class SpIsValidAudienceTest extends MockeryTestCase
/** @var \SimpleSAML\SAML2\XML\saml\Conditions */
private static Conditions $conditions;
- /** @var \SimpleSAML\SAML2\XML\saml\Isssuer */
+ /** @var \SimpleSAML\SAML2\XML\saml\Issuer */
private static Issuer $issuer;
/** @var \Mockery\MockInterface */
@@ -87,10 +87,9 @@ public function setUp(): void
/**
- * @group assertion-validation
- * @test
*/
- public function whenNoValidAudiencesAreGivenTheAssertionIsValid(): void
+ #[Group('assertion-validation')]
+ public function testWhenNoValidAudiencesAreGivenTheAssertionIsValid(): void
{
// Create an assertion
$assertion = new Assertion(
@@ -112,10 +111,9 @@ public function whenNoValidAudiencesAreGivenTheAssertionIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function ifTheSpEntityIdIsNotInTheValidAudiencesTheAssertionIsInvalid(): void
+ #[Group('assertion-validation')]
+ public function testIfTheSpEntityIdIsNotInTheValidAudiencesTheAssertionIsInvalid(): void
{
// Create an assertion
$assertion = new Assertion(
@@ -139,10 +137,9 @@ public function ifTheSpEntityIdIsNotInTheValidAudiencesTheAssertionIsInvalid():
/**
- * @group assertion-validation
- * @test
*/
- public function theAssertionIsValidWhenTheCurrentSpEntityIdIsAValidAudience(): void
+ #[Group('assertion-validation')]
+ public function testTheAssertionIsValidWhenTheCurrentSpEntityIdIsAValidAudience(): void
{
// Create an assertion
$assertion = new Assertion(
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
index 987a8b246..56bf0d44d 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
@@ -4,6 +4,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationMethod;
use SimpleSAML\SAML2\Assertion\Validation\Result;
@@ -11,16 +13,15 @@
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationMethod
* @package simplesamlphp/saml2
*/
+#[CoversClass(SubjectConfirmationMethod::class)]
final class SubjectConfirmationMethodTest extends TestCase
{
/**
- * @group assertion-validation
- * @test
*/
- public function aSubjectConfirmationWithBearerMethodIsValid(): void
+ #[Group('assertion-validation')]
+ public function testASubjectConfirmationWithBearerMethodIsValid(): void
{
$subjectConfirmation = new SubjectConfirmation(C::CM_BEARER);
@@ -34,10 +35,9 @@ public function aSubjectConfirmationWithBearerMethodIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function aSubjectConfirmationWithHolderOfKeyMethodIsNotValid(): void
+ #[Group('assertion-validation')]
+ public function testASubjectConfirmationWithHolderOfKeyMethodIsNotValid(): void
{
$subjectConfirmation = new SubjectConfirmation(C::CM_HOK);
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
index fdbc834a6..bb5dc11a6 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
@@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotBefore;
@@ -15,10 +17,9 @@
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotBefore
- *
* @package simplesamlphp/saml2
*/
+#[CoversClass(SubjectConfirmationNotBefore::class)]
final class SubjectConfirmationNotBeforeTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -34,10 +35,9 @@ public static function setUpBeforeClass(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timestampInTheFutureBeyondGraceperiodIsNotValid(): void
+ #[Group('assertion-validation')]
+ public function testTimestampInTheFutureBeyondGraceperiodIsNotValid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(self::$clock->now()->add(new DateInterval('PT61S')));
$subjectConfirmation = new SubjectConfirmation(C::CM_HOK, null, $subjectConfirmationData);
@@ -53,10 +53,9 @@ public function timestampInTheFutureBeyondGraceperiodIsNotValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timeWithinGraceperiodIsValid(): void
+ #[Group('assertion-validation')]
+ public function testTimeWithinGraceperiodIsValid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(
null,
@@ -74,10 +73,9 @@ public function timeWithinGraceperiodIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function currentTimeIsValid(): void
+ #[Group('assertion-validation')]
+ public function testCurrentTimeIsValid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(self::$clock->now());
$subjectConfirmation = new SubjectConfirmation(C::CM_HOK, null, $subjectConfirmationData);
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
index 4995016ce..43631ba8e 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
@@ -5,10 +5,12 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
use DateInterval;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
-use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotOnOrAfter;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotBefore;
+use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotOnOrAfter;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils;
@@ -16,10 +18,9 @@
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotOnOrAfter
- *
* @package simplesamlphp/saml2
*/
+#[CoversClass(SubjectConfirmationNotOnOrAfter::class)]
final class SubjectConfirmationNotOnOrAfterTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -35,10 +36,9 @@ public static function setUpBeforeClass(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timestampInThePastBeforeGraceperiodIsNotValid(): void
+ #[Group('assertion-validation')]
+ public function testTimestampInThePastBeforeGraceperiodIsNotValid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(
null,
@@ -57,10 +57,9 @@ public function timestampInThePastBeforeGraceperiodIsNotValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function timeWithinGraceperiodIsValid(): void
+ #[Group('assertion-validation')]
+ public function testTimeWithinGraceperiodIsValid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(
null,
@@ -78,10 +77,9 @@ public function timeWithinGraceperiodIsValid(): void
/**
- * @group assertion-validation
- * @test
*/
- public function currentTimeIsValid(): void
+ #[Group('assertion-validation')]
+ public function testCurrentTimeIsValid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(null, self::$clock->now());
$subjectConfirmation = new SubjectConfirmation(C::CM_HOK, null, $subjectConfirmationData);
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatchesTest.php
index 305715ab3..63835629a 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatchesTest.php
@@ -4,27 +4,26 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationRecipientMatches;
-use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationResponseToMatches;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Configuration\Destination;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
-use SimpleSAML\SAML2\XML\saml\SubjectConfirmationMatches;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationRecipientMatches
* @package simplesamlphp/saml2
*/
+#[CoversClass(SubjectConfirmationRecipientMatches::class)]
final class SubjectConfirmationRecipientMatchesTest extends TestCase
{
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheSubjectConfirmationRecipientDiffersFromTheDestinationTheScIsInvalid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheSubjectConfirmationRecipientDiffersFromTheDestinationTheScIsInvalid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(null, null, 'someDestination');
$subjectConfirmation = new SubjectConfirmation(C::CM_HOK, null, $subjectConfirmationData);
@@ -42,10 +41,9 @@ public function whenTheSubjectConfirmationRecipientDiffersFromTheDestinationTheS
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheSubjectConfirmationRecipientEqualsTheDestinationTheScIsInvalid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheSubjectConfirmationRecipientEqualsTheDestinationTheScIsInvalid(): void
{
$subjectConfirmationData = new SubjectConfirmationData(null, null, 'theSameDestination');
$subjectConfirmation = new SubjectConfirmation(C::CM_HOK, null, $subjectConfirmationData);
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
index 7982a6967..4ecdda6ad 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
@@ -5,19 +5,21 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;
use Mockery;
-use Mockery\MockInterface;
use Mockery\Adapter\Phpunit\MockeryTestCase;
+use Mockery\MockInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationResponseToMatches;
use SimpleSAML\SAML2\Assertion\Validation\Result;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
+use SimpleSAML\SAML2\XML\samlp\Response;
/**
- * @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationResponseToMatches
* @package simplesamlphp/saml2
*/
+#[CoversClass(SubjectConfirmationResponseToMatches::class)]
final class SubjectConfirmationResponseToMatchesTest extends MockeryTestCase
{
/** @var \Mockery\MockInterface */
@@ -33,10 +35,9 @@ public function setUp(): void
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheResponseResponsetoIsNullTheSubjectConfirmationIsValid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheResponseResponsetoIsNullTheSubjectConfirmationIsValid(): void
{
$this->response->shouldReceive('getInResponseTo')->andReturnNull();
$subjectConfirmationData = new SubjectConfirmationData(null, null, null, 'someValue');
@@ -52,10 +53,9 @@ public function whenTheResponseResponsetoIsNullTheSubjectConfirmationIsValid():
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheSubjectconfirmationResponsetoIsNullTheSubjectconfirmationIsValid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheSubjectconfirmationResponsetoIsNullTheSubjectconfirmationIsValid(): void
{
$this->response->shouldReceive('getInResponseTo')->andReturn('someValue');
$subjectConfirmationData = new SubjectConfirmationData();
@@ -71,10 +71,9 @@ public function whenTheSubjectconfirmationResponsetoIsNullTheSubjectconfirmation
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheSubjectconfirmationAndResponseResponsetoAreNullTheSubjectconfirmationIsValid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheSubjectconfirmationAndResponseResponsetoAreNullTheSubjectconfirmationIsValid(): void
{
$this->response->shouldReceive('getInResponseTo')->andReturnNull();
$subjectConfirmationData = new SubjectConfirmationData();
@@ -90,10 +89,9 @@ public function whenTheSubjectconfirmationAndResponseResponsetoAreNullTheSubject
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheSubjectconfirmationAndResponseResponsetoAreEqualTheSubjectconfirmationIsValid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheSubjectconfirmationAndResponseResponsetoAreEqualTheSubjectconfirmationIsValid(): void
{
$this->response->shouldReceive('getInResponseTo')->andReturn('theSameValue');
$subjectConfirmationData = new SubjectConfirmationData(null, null, null, 'theSameValue');
@@ -109,10 +107,9 @@ public function whenTheSubjectconfirmationAndResponseResponsetoAreEqualTheSubjec
/**
- * @group assertion-validation
- * @test
*/
- public function whenTheSubjectconfirmationAndResponseResponsetoDifferTheSubjectconfirmationIsInvalid(): void
+ #[Group('assertion-validation')]
+ public function testWhenTheSubjectconfirmationAndResponseResponsetoDifferTheSubjectconfirmationIsInvalid(): void
{
$this->response->shouldReceive('getInResponseTo')->andReturn('someValue');
$subjectConfirmationData = new SubjectConfirmationData(null, null, null, 'anotherValue');
diff --git a/tests/SAML2/Assertion/Validation/SubjectConfirmationValidatorTest.php b/tests/SAML2/Assertion/Validation/SubjectConfirmationValidatorTest.php
index d6fa43afc..9559803b6 100644
--- a/tests/SAML2/Assertion/Validation/SubjectConfirmationValidatorTest.php
+++ b/tests/SAML2/Assertion/Validation/SubjectConfirmationValidatorTest.php
@@ -5,6 +5,7 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
@@ -12,14 +13,13 @@
use SimpleSAML\SAML2\Assertion\Exception\InvalidSubjectConfirmationException;
use SimpleSAML\SAML2\Assertion\Processor;
use SimpleSAML\SAML2\Assertion\ProcessorBuilder;
+use SimpleSAML\SAML2\Assertion\Validation\SubjectConfirmationValidator;
use SimpleSAML\SAML2\Configuration\Destination;
use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Configuration\ServiceProvider;
use SimpleSAML\SAML2\Signature\Validator;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\XML\saml\Assertion;
-use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
-use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
@@ -29,9 +29,9 @@
/**
* Tests for the SubjectConfirmation validators
*
- * @covers \SimpleSAML\SAML2\Assertion\Validation\SubjectConfirmationValidator
* @package simplesamlphp/saml2
*/
+#[CoversClass(SubjectConfirmationValidator::class)]
final class SubjectConfirmationValidatorTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -58,7 +58,7 @@ final class SubjectConfirmationValidatorTest extends TestCase
/** @var \SimpleSAML\SAML2\Configuration\Destination */
private static Destination $destination;
- /** @var \SimpleSAML\SAML2\xml\samlp\Response */
+ /** @var \SimpleSAML\SAML2\XML\samlp\Response */
private static Response $response;
diff --git a/tests/SAML2/BindingTest.php b/tests/SAML2/BindingTest.php
index 9277f8ce0..b71cc22c2 100644
--- a/tests/SAML2/BindingTest.php
+++ b/tests/SAML2/BindingTest.php
@@ -4,8 +4,8 @@
namespace SimpleSAML\Test\SAML2;
-use Exception;
use Nyholm\Psr7\ServerRequest;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Binding;
use SimpleSAML\SAML2\Constants as C;
@@ -16,9 +16,9 @@
use SimpleSAML\SAML2\SOAP;
/**
- * @covers \SimpleSAML\SAML2\Binding
* @package simplesamlphp\saml2
*/
+#[CoversClass(Binding::class)]
final class BindingTest extends TestCase
{
/**
@@ -120,7 +120,8 @@ public function testBindingGuesserPOST(): void
$q = ['AAP' => 'Noot'];
$request = new ServerRequest('POST', 'http://tnyholm.se');
$request = $request->withParsedBody($q);
- $this->expectException(UnsupportedBindingException::class, 'Unable to find the current binding.');
+ $this->expectException(UnsupportedBindingException::class);
+ $this->expectExceptionMessage('Unable to find the SAML 2 binding used for this request.');
Binding::getCurrentBinding($request);
}
diff --git a/tests/SAML2/Certificate/KeyCollectionTest.php b/tests/SAML2/Certificate/KeyCollectionTest.php
index 2b0109c5f..373f6a7ca 100644
--- a/tests/SAML2/Certificate/KeyCollectionTest.php
+++ b/tests/SAML2/Certificate/KeyCollectionTest.php
@@ -4,17 +4,21 @@
namespace SimpleSAML\Test\SAML2\Certificate;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Certificate\KeyCollection;
-class KeyCollectionTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(KeyCollection::class)]
+final class KeyCollectionTest extends TestCase
{
/**
- * @group certificate
- * @test
- * @return void
*/
+ #[Group('certificate')]
public function testKeyCollectionAddWrongType(): void
{
$this->expectException(AssertionFailedException::class);
diff --git a/tests/SAML2/Certificate/KeyLoaderTest.php b/tests/SAML2/Certificate/KeyLoaderTest.php
index f0e539eaf..dc20ebd92 100644
--- a/tests/SAML2/Certificate/KeyLoaderTest.php
+++ b/tests/SAML2/Certificate/KeyLoaderTest.php
@@ -7,37 +7,32 @@
use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\MockInterface;
-use SimpleSAML\SAML2\Utilities\Certificate;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use SimpleSAML\SAML2\Certificate\Exception\InvalidCertificateStructureException;
use SimpleSAML\SAML2\Certificate\Exception\NoKeysFoundException;
use SimpleSAML\SAML2\Certificate\Key;
use SimpleSAML\SAML2\Certificate\KeyLoader;
use SimpleSAML\SAML2\Certificate\X509;
use SimpleSAML\SAML2\Configuration\CertificateProvider;
+use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-use function dirname;
use function preg_replace;
-class KeyLoaderTest extends MockeryTestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(KeyLoader::class)]
+final class KeyLoaderTest extends MockeryTestCase
{
/** @var \SimpleSAML\SAML2\Certificate\KeyLoader */
private KeyLoader $keyLoader;
- /**
- * Known to be valid certificate string
- *
- * @var string
- */
- private string $certificate = "-----BEGIN CERTIFICATE-----\nMIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMC\nTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYD\nVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG\n9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4\nMTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xi\nZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2Zl\naWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5v\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LO\nNoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHIS\nKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d\n1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8\nBUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7n\nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2Qar\nQ4/67OZfHd7R+POBXhophSMv1ZOo\n-----END CERTIFICATE-----\n";
-
- /**
- * @var \Mockery\MockInterface
- */
+ /** @var \Mockery\MockInterface */
private MockInterface $configurationMock;
/**
- * @return void
*/
protected function setUp(): void
{
@@ -47,11 +42,9 @@ protected function setUp(): void
/**
- * @group certificate
- * @test
- * @return void
*/
- public function load_keys_checks_for_usage_of_key(): void
+ #[Group('certificate')]
+ public function testLoadKeysChecksForUsageOfKey(): void
{
$signing = [Key::USAGE_SIGNING => true];
$encryption = [Key::USAGE_ENCRYPTION => true];
@@ -67,14 +60,12 @@ public function load_keys_checks_for_usage_of_key(): void
/**
- * @group certificate
- * @test
- * @return void
*/
- public function load_keys_constructs_x509_certificate(): void
+ #[Group('certificate')]
+ public function testLoadKeysConstructsX509Certificate(): void
{
$keys = [[
- 'X509Certificate' => $this->certificate
+ 'X509Certificate' => PEMCertificatesMock::getPlainCertificateContents(PEMCertificatesMock::CERTIFICATE),
]];
$this->keyLoader->loadKeys($keys, null);
@@ -86,13 +77,13 @@ public function load_keys_constructs_x509_certificate(): void
/**
- * @group certificate
- * @test
- * @return void
*/
- public function certificate_data_is_loaded_as_key(): void
+ #[Group('certificate')]
+ public function testCertificateDataIsLoadedAsKey(): void
{
- $this->keyLoader->loadCertificateData($this->certificate);
+ $this->keyLoader->loadCertificateData(
+ PEMCertificatesMock::getPlainCertificateContents(PEMCertificatesMock::CERTIFICATE),
+ );
$loadedKeys = $this->keyLoader->getKeys();
$loadedKey = $loadedKeys->get(0);
@@ -100,51 +91,55 @@ public function certificate_data_is_loaded_as_key(): void
$this->assertTrue($this->keyLoader->hasKeys());
$this->assertCount(1, $loadedKeys);
- $this->assertEquals(preg_replace('~\s+~', '', $this->certificate), $loadedKey['X509Certificate']);
+ $this->assertEquals(
+ preg_replace(
+ '~\s+~',
+ '',
+ PEMCertificatesMock::getPlainCertificateContents(PEMCertificatesMock::CERTIFICATE),
+ ),
+ $loadedKey['X509Certificate'],
+ );
}
/**
- * @group certificate
- * @test
- * @return void
*/
- public function loading_a_file_with_the_wrong_format_throws_an_exception(): void
+ #[Group('certificate')]
+ public function testLoadingAFileWithTheWrongFormatThrowsAnException(): void
{
- $filePath = dirname(__FILE__) . '/File/';
$this->expectException(InvalidCertificateStructureException::class);
- $this->keyLoader->loadCertificateFile($filePath . 'not_a_key.crt');
+ $this->keyLoader->loadCertificateFile(
+ PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::BROKEN_PUBLIC_KEY),
+ );
}
/**
- * @group certificate
- * @test
- * @return void
*/
- public function loading_a_certificate_from_file_creates_a_key(): void
+ #[Group('certificate')]
+ public function testLoadingACertificateFromFileCreatesAKey(): void
{
- $file = dirname(__FILE__) . '/File/example.org.crt';
- $this->keyLoader->loadCertificateFile($file);
+ $this->keyLoader->loadCertificateFile(
+ PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::PUBLIC_KEY),
+ );
$loadedKeys = $this->keyLoader->getKeys();
$loadedKey = $loadedKeys->get(0);
- $fileContents = file_get_contents($file);
- preg_match(Certificate::CERTIFICATE_PATTERN, $fileContents, $matches);
- $expected = preg_replace('~\s+~', '', $matches[1]);
+
$this->assertTrue($this->keyLoader->hasKeys());
$this->assertCount(1, $loadedKeys);
- $this->assertEquals($expected, $loadedKey['X509Certificate']);
+ $this->assertEquals(
+ PEMCertificatesMock::getPlainPublicKeyContents(PEMCertificatesMock::PUBLIC_KEY),
+ $loadedKey['X509Certificate'],
+ );
}
/**
- * @group certificate
- * @test
- * @return void
*/
- public function loading_a_required_certificate_from_an_empty_configuration_throws_an_exception(): void
+ #[Group('certificate')]
+ public function testLoadingARequiredCertificateFromAnEmptyConfigurationThrowsAnException(): void
{
$this->configurationMock
->shouldReceive('getKeys')
@@ -163,13 +158,11 @@ public function loading_a_required_certificate_from_an_empty_configuration_throw
/**
- * @group certificate
- * @test
- * @return void
*/
- public function loading_a_certificate_file_from_configuration_creates_key(): void
+ #[Group('certificate')]
+ public function testLoadingACertificateFileFromConfigurationCreatesKey(): void
{
- $file = dirname(__FILE__) . '/File/example.org.crt';
+ $file = PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::PUBLIC_KEY);
$this->configurationMock
->shouldReceive('getKeys')
->atMost()
@@ -190,13 +183,11 @@ public function loading_a_certificate_file_from_configuration_creates_key(): voi
/**
- * @group certificate
- * @test
- * @return void
*/
- public function loading_an_invalid_certificate_file_from_configuration_throws_exception(): void
+ #[Group('certificate')]
+ public function testLoadingAnInvalidCertificateFileFromConfigurationThrowsException(): void
{
- $file = dirname(__FILE__) . '/File/not_a_key.crt';
+ $file = PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::BROKEN_PUBLIC_KEY);
$this->configurationMock
->shouldReceive('getKeys')
->atMost()
diff --git a/tests/SAML2/Certificate/KeyTest.php b/tests/SAML2/Certificate/KeyTest.php
index b78d35b16..6af97893d 100644
--- a/tests/SAML2/Certificate/KeyTest.php
+++ b/tests/SAML2/Certificate/KeyTest.php
@@ -4,19 +4,26 @@
namespace SimpleSAML\Test\SAML2\Certificate;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Certificate\Key;
use SimpleSAML\SAML2\Certificate\Exception\InvalidKeyUsageException;
+use SimpleSAML\SAML2\Certificate\Key;
use SimpleSAML\SAML2\Exception\InvalidArgumentException;
-class KeyTest extends TestCase
+use function call_user_func_array;
+
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(Key::class)]
+#[Group('certificate')]
+final class KeyTest extends TestCase
{
/**
- * @group certificate
- * @test
- * @return void
*/
- public function invalid_key_usage_should_throw_an_exception(): void
+ public function testInvalidKeyUsageShouldThrowAnException(): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
$this->expectException(InvalidKeyUsageException::class);
@@ -25,12 +32,9 @@ public function invalid_key_usage_should_throw_an_exception(): void
/**
- * @group certificate
- * @dataProvider functionProvider
- * @test
- * @return void
*/
- public function invalid_offset_type_should_throw_an_exception($function, $params): void
+ #[DataProvider('functionProvider')]
+ public function testInvalidOffsetTypeShouldThrowAnException($function, $params): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
$this->expectException(InvalidArgumentException::class);
@@ -39,11 +43,8 @@ public function invalid_offset_type_should_throw_an_exception($function, $params
/**
- * @group certificate
- * @test
- * @return void
*/
- public function assert_that_key_usage_check_works_correctly(): void
+ public function testAssertThatKeyUsageCheckWorksCorrectly(): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
@@ -56,11 +57,8 @@ public function assert_that_key_usage_check_works_correctly(): void
/**
- * @group certificate
- * @test
- * @return void
*/
- public function assert_that_offsetget_works_correctly(): void
+ public function testAssertThatOffsetgetWorksCorrectly(): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
$this->assertTrue($key->offsetGet(Key::USAGE_SIGNING));
@@ -68,11 +66,8 @@ public function assert_that_offsetget_works_correctly(): void
/**
- * @group certificate
- * @test
- * @return void
*/
- public function assert_that_offsetunset_unsets_offset(): void
+ public function testAssertThatOffsetunsetUnsetsOffset(): void
{
$key = new Key([Key::USAGE_SIGNING => true, Key::USAGE_ENCRYPTION => true]);
$this->assertTrue($key->offsetExists(Key::USAGE_SIGNING));
@@ -95,7 +90,7 @@ public static function functionProvider(): array
'offsetGet' => ['offsetGet', [0]],
'offsetExists' => ['offsetExists', [0]],
'offsetSet' => ['offsetSet', [0, 2]],
- 'offsetUnset' => ['offsetUnset', [0]]
+ 'offsetUnset' => ['offsetUnset', [0]],
];
}
}
diff --git a/tests/SAML2/Certificate/PrivateKeyLoaderTest.php b/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
index 311bf848b..ece0c0e4f 100644
--- a/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
+++ b/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
@@ -4,19 +4,26 @@
namespace SimpleSAML\Test\SAML2\Certificate;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Configuration\PrivateKey as ConfPrivateKey;
use SimpleSAML\SAML2\Certificate\PrivateKey;
use SimpleSAML\SAML2\Certificate\PrivateKeyLoader;
+use SimpleSAML\SAML2\Configuration\PrivateKey as ConfPrivateKey;
+use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-class PrivateKeyLoaderTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(PrivateKeyLoader::class)]
+final class PrivateKeyLoaderTest extends TestCase
{
/** @var \SimpleSAML\SAML2\Certificate\PrivateKeyLoader */
private static PrivateKeyLoader $privateKeyLoader;
/**
- * @return void
*/
public static function setUpBeforeClass(): void
{
@@ -25,52 +32,52 @@ public static function setUpBeforeClass(): void
/**
- * @group certificate
- * @test
- * @dataProvider privateKeyTestProvider
- *
* @param \SimpleSAML\SAML2\Configuration\PrivateKey $configuredKey
- * @return void
*/
- public function loading_a_configured_private_key_returns_a_certificate_private_key(
+ #[Group('certificate')]
+ #[DataProvider('privateKeyTestProvider')]
+ public function testLoadingAConfiguredPrivateKeyReturnsACertificatePrivateKey(
ConfPrivateKey $configuredKey
): void {
$resultingKey = self::$privateKeyLoader->loadPrivateKey($configuredKey);
$this->assertInstanceOf(PrivateKey::class, $resultingKey);
- $this->assertEquals($resultingKey->getKeyAsString(), "This would normally contain the private key data.\n");
+ $this->assertEquals(
+ trim($resultingKey->getKeyAsString()),
+ PEMCertificatesMock::loadPlainKeyFile(PEMCertificatesMock::BROKEN_PRIVATE_KEY),
+ );
$this->assertEquals($resultingKey->getPassphrase(), $configuredKey->getPassPhrase());
}
/**
- * Dataprovider for 'loading_a_configured_private_key_returns_a_certificate_private_key'
+ * Dataprovider for 'loadingAConfiguredPrivateKeyReturnsACertificatePrivateKey'
*
* @return array
*/
public static function privateKeyTestProvider(): array
{
return [
- 'no passphrase' => [
+ 'no passphrase' => [
new ConfPrivateKey(
- dirname(__FILE__) . '/File/a_fake_private_key_file.pem',
- ConfPrivateKey::NAME_DEFAULT
- )
+ PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::BROKEN_PRIVATE_KEY),
+ ConfPrivateKey::NAME_DEFAULT,
+ ),
],
'with passphrase' => [
new ConfPrivateKey(
- dirname(__FILE__) . '/File/a_fake_private_key_file.pem',
+ PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::BROKEN_PRIVATE_KEY),
ConfPrivateKey::NAME_DEFAULT,
- 'foo bar baz'
- )
+ 'foo bar baz',
+ ),
],
'private key as contents' => [
new ConfPrivateKey(
- file_get_contents(dirname(__FILE__) . '/File/a_fake_private_key_file.pem'),
+ PEMCertificatesMock::loadPlainKeyFile(PEMCertificatesMock::BROKEN_PRIVATE_KEY),
ConfPrivateKey::NAME_DEFAULT,
'',
- false
- )
+ false,
+ ),
],
];
}
diff --git a/tests/SAML2/Certificate/PrivateKeyTest.php b/tests/SAML2/Certificate/PrivateKeyTest.php
index f262b7995..11451ff42 100644
--- a/tests/SAML2/Certificate/PrivateKeyTest.php
+++ b/tests/SAML2/Certificate/PrivateKeyTest.php
@@ -4,20 +4,24 @@
namespace SimpleSAML\Test\SAML2\Certificate;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Certificate\PrivateKey;
-use SimpleSAML\Test\SAML2\CertificatesMock;
+use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-class PrivateKeyTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(PrivateKey::class)]
+final class PrivateKeyTest extends TestCase
{
/**
- * @group certificate
- * @test
- * @return void
*/
- public function test_create_from_key(): void
+ #[Group('certificate')]
+ public function testCreateFromKey(): void
{
- $key = CertificatesMock::getPlainPrivateKey();
+ $key = PEMCertificatesMock::getPlainPrivateKey();
$pk_nopass = PrivateKey::create($key);
$this->assertEquals($key, $pk_nopass->getKeyAsString());
diff --git a/tests/SAML2/Certificate/X509Test.php b/tests/SAML2/Certificate/X509Test.php
index 628f0a463..e66fe16e7 100644
--- a/tests/SAML2/Certificate/X509Test.php
+++ b/tests/SAML2/Certificate/X509Test.php
@@ -4,26 +4,30 @@
namespace SimpleSAML\Test\SAML2\Certificate;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Certificate\X509;
-class X509Test extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(X509::class)]
+final class X509Test extends TestCase
{
/**
- * @group certificate
- * @test
- * @return void
*/
- public function x509_certificate_contents_must_be_stripped_of_whitespace(): void
+ #[Group('certificate')]
+ public function testX509CertificateContentsMustBeStrippedOfWhitespace(): void
{
$toTest = [
- 'X509Certificate' => ' Should No Longer Have Whitespaces'
+ 'X509Certificate' => ' Should No Longer Have Whitespaces',
];
- $viaConstructor = new X509($toTest);
- $viaSetting = new X509([]);
+ $viaConstructor = new X509($toTest);
+ $viaSetting = new X509([]);
$viaSetting['X509Certificate'] = $toTest['X509Certificate'];
- $viaFactory = X509::createFromCertificateData($toTest['X509Certificate']);
+ $viaFactory = X509::createFromCertificateData($toTest['X509Certificate']);
$this->assertEquals($viaConstructor['X509Certificate'], 'ShouldNoLongerHaveWhitespaces');
$this->assertEquals($viaSetting['X509Certificate'], 'ShouldNoLongerHaveWhitespaces');
diff --git a/tests/SAML2/CertificatesMock.php b/tests/SAML2/CertificatesMock.php
deleted file mode 100644
index 06c64d1d8..000000000
--- a/tests/SAML2/CertificatesMock.php
+++ /dev/null
@@ -1,213 +0,0 @@
- 'public']);
- $publicKey->loadKey(self::PUBLIC_KEY_PEM);
- return $publicKey;
- }
-
-
- /**
- * @return XMLSecurityKey
- */
- public static function getPrivateKey(): XMLSecurityKey
- {
- $privateKey = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, ['type' => 'private']);
- $privateKey->loadKey(self::PRIVATE_KEY_PEM);
- return $privateKey;
- }
-
-
- /**
- * @return XMLSecurityKey
- */
- public static function getPublicKey2(): XMLSecurityKey
- {
- $publicKey = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, ['type' => 'public']);
- $publicKey->loadKey(self::PUBLIC_KEY_2_PEM);
- return $publicKey;
- }
-
-
- /**
- * @return XMLSecurityKey
- */
- public static function getPublicKey3(): XMLSecurityKey
- {
- $publicKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, ['type' => 'public']);
- $publicKey->loadKey(self::PUBLIC_KEY_3_PEM);
- return $publicKey;
- }
-
-
- /**
- * @return XMLSecurityKey
- */
- public static function getPublicKeySha256(): XMLSecurityKey
- {
- $publicKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']);
- $publicKey->loadKey(self::PUBLIC_KEY_PEM);
- return $publicKey;
- }
-
-
- /**
- * @return XMLSecurityKey
- */
- public static function getPublicKey2Sha256(): XMLSecurityKey
- {
- $publicKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']);
- $publicKey->loadKey(self::PUBLIC_KEY_2_PEM);
- return $publicKey;
- }
-
-
- /**
- * Load a X.509 certificate with a DSA public key as RSA key
- * @return XMLSecurityKey
- */
- public static function getPublicKeyDSAasRSA(): XMLSecurityKey
- {
- $publicKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']);
- $publicKey->loadKey(self::PUBLIC_KEY_DSA_PEM);
- return $publicKey;
- }
-
-
- /**
- * @return string
- */
- public static function getPlainPublicKey(): string
- {
- return self::PUBLIC_KEY_PEM;
- }
-
-
- /**
- * @return string
- */
- public static function getPlainPrivateKey(): string
- {
- return self::PRIVATE_KEY_PEM;
- }
-
-
- /**
- * Returns just the certificate contents without the begin and end markings
- * @return string
- */
- public static function getPlainPublicKeyContents(): string
- {
- return self::PUBLIC_KEY_PEM_CONTENTS;
- }
-
-
- /**
- * Returns malformed public key by truncating it.
- * @return string
- */
- public static function getPlainInvalidPublicKey(): string
- {
- return substr(self::PUBLIC_KEY_PEM, 200);
- }
-}
diff --git a/tests/SAML2/Configuration/ArrayAdapterTest.php b/tests/SAML2/Configuration/ArrayAdapterTest.php
index 65425eabc..02ec1377d 100644
--- a/tests/SAML2/Configuration/ArrayAdapterTest.php
+++ b/tests/SAML2/Configuration/ArrayAdapterTest.php
@@ -4,17 +4,21 @@
namespace SimpleSAML\Test\SAML2\Configuration;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Configuration\ArrayAdapter;
-class ArrayAdapterTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(ArrayAdapter::class)]
+final class ArrayAdapterTest extends TestCase
{
/**
- * @group configuration
- * @test
- * @return void
*/
- public function setConfigurationCanBeQueried(): void
+ #[Group('configuration')]
+ public function testSetConfigurationCanBeQueried(): void
{
$configuration = new ArrayAdapter(['foo' => 'bar']);
@@ -25,11 +29,9 @@ public function setConfigurationCanBeQueried(): void
/**
- * @group configuration
- * @test
- * @return void
*/
- public function defaultValuesAreReturnedForUnavailableConfiguration(): void
+ #[Group('configuration')]
+ public function testDefaultValuesAreReturnedForUnavailableConfiguration(): void
{
$configuration = ['foo' => 'bar'];
diff --git a/tests/SAML2/Configuration/DestinationTest.php b/tests/SAML2/Configuration/DestinationTest.php
index 7d469f982..b59c30a01 100644
--- a/tests/SAML2/Configuration/DestinationTest.php
+++ b/tests/SAML2/Configuration/DestinationTest.php
@@ -4,17 +4,21 @@
namespace SimpleSAML\Test\SAML2\Configuration;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Configuration\Destination;
-class DestinationTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(Destination::class)]
+final class DestinationTest extends TestCase
{
/**
- * @group configuration
- * @test
- * @return void
*/
- public function twoDestinationsWithTheSameValueAreEqual(): void
+ #[Group('configuration')]
+ public function testTwoDestinationsWithTheSameValueAreEqual(): void
{
$destinationOne = new Destination('a');
$destinationTwo = new Destination('a');
@@ -24,11 +28,9 @@ public function twoDestinationsWithTheSameValueAreEqual(): void
/**
- * @group configuration
- * @test
- * @return void
*/
- public function twoDestinationsWithDifferentValuesAreNotEqual(): void
+ #[Group('configuration')]
+ public function testTwoDestinationsWithTheDifferentValuesAreNotEqual(): void
{
$destinationOne = new Destination('a');
$destinationTwo = new Destination('a');
diff --git a/tests/SAML2/CustomBaseID.php b/tests/SAML2/CustomBaseID.php
index 0d2216e96..e54cd43fe 100644
--- a/tests/SAML2/CustomBaseID.php
+++ b/tests/SAML2/CustomBaseID.php
@@ -6,11 +6,11 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
+use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\Test\SAML2\Constants as C;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
+use SimpleSAML\XML\Exception\SchemaViolationException;
/**
* Example class to demonstrate how BaseID can be extended.
diff --git a/tests/SAML2/CustomCondition.php b/tests/SAML2/CustomCondition.php
index 5a5c80358..a0889690b 100644
--- a/tests/SAML2/CustomCondition.php
+++ b/tests/SAML2/CustomCondition.php
@@ -6,8 +6,8 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AbstractCondition;
+use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
@@ -57,7 +57,7 @@ public function getAudience(): array
* Convert XML into a Condition
*
* @param \DOMElement $xml The XML element we should load
- * @return \SimpleSAML\SAML2\XML\saml\AbstractCondition
+ * @return static
*
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
diff --git a/tests/SAML2/CustomRoleDescriptor.php b/tests/SAML2/CustomRoleDescriptor.php
index ab65de7b0..ba506fb10 100644
--- a/tests/SAML2/CustomRoleDescriptor.php
+++ b/tests/SAML2/CustomRoleDescriptor.php
@@ -49,7 +49,7 @@ final class CustomRoleDescriptor extends AbstractRoleDescriptor
* Defaults to an empty array.
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
* The organization running this entity. Defaults to null.
- * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts
+ * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contact
* An array of contacts for this entity. Defaults to an empty array.
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
@@ -161,7 +161,8 @@ public static function fromXML(DOMElement $xml): static
self::getOptionalAttribute($xml, 'errorURL', null),
KeyDescriptor::getChildrenOfClass($xml),
!empty($orgs) ? $orgs[0] : null,
- ContactPerson::getChildrenOfClass($xml)
+ ContactPerson::getChildrenOfClass($xml),
+ self::getAttributesNSFromXML($xml),
);
}
diff --git a/tests/SAML2/CustomStatement.php b/tests/SAML2/CustomStatement.php
index b2ba246a9..019920964 100644
--- a/tests/SAML2/CustomStatement.php
+++ b/tests/SAML2/CustomStatement.php
@@ -6,8 +6,8 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
-use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AbstractStatement;
+use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
@@ -86,7 +86,7 @@ public static function fromXML(DOMElement $xml): static
* Convert this Statement to XML.
*
* @param \DOMElement $parent The element we are converting to XML.
- * @return \DOMElement The XML element after adding the data corresponding to this BaseID.
+ * @return \DOMElement The XML element after adding the data corresponding to this Statement.
*/
public function toXML(DOMElement $parent = null): DOMElement
{
diff --git a/tests/SAML2/HTTPArtifactTest.php b/tests/SAML2/HTTPArtifactTest.php
index 17d16252b..282ea64e1 100644
--- a/tests/SAML2/HTTPArtifactTest.php
+++ b/tests/SAML2/HTTPArtifactTest.php
@@ -6,13 +6,14 @@
use Exception;
use Nyholm\Psr7\ServerRequest;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\HTTPArtifact;
/**
- * @covers \SimpleSAML\SAML2\HTTPArtifact
* @package simplesamlphp\saml2
*/
+#[CoversClass(HTTPArtifact::class)]
final class HTTPArtifactTest extends TestCase
{
/**
diff --git a/tests/SAML2/HTTPPostTest.php b/tests/SAML2/HTTPPostTest.php
index 74af423c2..0fd9c177d 100644
--- a/tests/SAML2/HTTPPostTest.php
+++ b/tests/SAML2/HTTPPostTest.php
@@ -5,9 +5,11 @@
namespace SimpleSAML\Test\SAML2;
use Exception;
+use Nyholm\Psr7\ServerRequest;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
-use Nyholm\Psr7\ServerRequest;
use SimpleSAML\SAML2\HTTPPost;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\XML\saml\Issuer;
@@ -15,16 +17,14 @@
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
-use SimpleSAML\Utils\HTTP;
-use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
+use SimpleSAML\XMLSecurity\Constants as C;
+use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
/**
- * @covers \SimpleSAML\SAML2\HTTPPost
* @package simplesamlphp\saml2
*/
+#[CoversClass(HTTPPost::class)]
final class HTTPPostTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -117,8 +117,8 @@ public function testSendMissingDestination(): void
/**
* Construct an authnrequest and send it to the destination set in the binding.
- * @doesNotPerformAssertions
*/
+ #[DoesNotPerformAssertions]
public function testSendAuthnRequestWithDestinationInBinding(): void
{
$request = new AuthnRequest(
@@ -132,8 +132,8 @@ public function testSendAuthnRequestWithDestinationInBinding(): void
/**
* Construct an authnrequest with a destination set and try to send it.
- * @doesNotPerformAssertions
*/
+ #[DoesNotPerformAssertions]
public function testSendAuthnRequestWithDestination(): void
{
$request = new AuthnRequest(
@@ -148,8 +148,8 @@ public function testSendAuthnRequestWithDestination(): void
/**
* Construct an authnresponse and send it.
* Also test setting a relaystate and destination for the response.
- * @doesNotPerformAssertions
*/
+ #[DoesNotPerformAssertions]
public function testSendAuthnResponse(): void
{
$status = new Status(new StatusCode());
diff --git a/tests/SAML2/HTTPRedirectTest.php b/tests/SAML2/HTTPRedirectTest.php
index 4db6b9911..968e22f14 100644
--- a/tests/SAML2/HTTPRedirectTest.php
+++ b/tests/SAML2/HTTPRedirectTest.php
@@ -5,9 +5,11 @@
namespace SimpleSAML\Test\SAML2;
use Exception;
+use Nyholm\Psr7\ServerRequest;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
-use Nyholm\Psr7\ServerRequest;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\HTTPRedirect;
@@ -17,17 +19,13 @@
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
-use SimpleSAML\SAML2\Utils;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-use function urldecode;
-
/**
- * @covers \SimpleSAML\SAML2\HTTPRedirect
* @package simplesamlphp\saml2
*/
+#[CoversClass(HTTPRedirect::class)]
final class HTTPRedirectTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -300,8 +298,8 @@ public function testSendWithoutDestination(): void
/**
* Construct an authnrequest and send it.
- * @doesNotPerformAssertions
*/
+ #[DoesNotPerformAssertions]
public function testSendAuthnrequest(): void
{
$request = new AuthnRequest(self::$clock->now());
@@ -314,8 +312,8 @@ public function testSendAuthnrequest(): void
/**
* Construct an authnresponse and send it.
* Also test setting a relaystate and destination for the response.
- * @doesNotPerformAssertions
*/
+ #[DoesNotPerformAssertions]
public function testSendAuthnResponse(): void
{
$status = new Status(new StatusCode());
@@ -335,8 +333,8 @@ public function testSendAuthnResponse(): void
/**
* Test setting destination in the HR binding.
- * @doesNotPerformAssertions
*/
+ #[DoesNotPerformAssertions]
public function testSendAuthnResponseBespokeDestination(): void
{
$status = new Status(new StatusCode());
diff --git a/tests/SAML2/Response/SignatureValidationTest.php b/tests/SAML2/Response/SignatureValidationTest.php
index fc28aac2c..89a5113c1 100644
--- a/tests/SAML2/Response/SignatureValidationTest.php
+++ b/tests/SAML2/Response/SignatureValidationTest.php
@@ -5,8 +5,11 @@
namespace SimpleSAML\Test\SAML2\Response;
use Mockery;
-use Mockery\MockInterface;
use Mockery\Adapter\Phpunit\MockeryTestCase;
+use Mockery\MockInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\PreserveGlobalState;
+use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use Psr\Log\NullLogger;
use SimpleSAML\SAML2\Assertion\Processor as AssertionProcessor;
use SimpleSAML\SAML2\Configuration\Destination;
@@ -27,9 +30,9 @@
/**
* Test that ensures that either the response or the assertion(s) or both must be signed.
*
- * @covers \SimpleSAML\SAML2\Response\Processor
* @package simplesamlphp/saml2
*/
+#[CoversClass(ResponseProcessor::class)]
final class SignatureValidationTest extends MockeryTestCase
{
/**
@@ -77,9 +80,9 @@ protected function setUp(): void
/**
- * @runInSeparateProcess
- * @preserveGlobalState disabled
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testThatAnUnsignedResponseWithASignedAssertionCanBeProcessed(): void
{
$this->assertionProcessor->shouldReceive('decryptAssertions')
@@ -100,9 +103,9 @@ public function testThatAnUnsignedResponseWithASignedAssertionCanBeProcessed():
/**
- * @runInSeparateProcess
- * @preserveGlobalState disabled
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testThatASignedResponseWithAnUnsignedAssertionCanBeProcessed(): void
{
$this->assertionProcessor->shouldReceive('decryptAssertions')
@@ -123,9 +126,9 @@ public function testThatASignedResponseWithAnUnsignedAssertionCanBeProcessed():
/**
- * @runInSeparateProcess
- * @preserveGlobalState disabled
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testThatASignedResponseWithASignedAssertionIsValid(): void
{
$this->assertionProcessor->shouldReceive('decryptAssertions')
@@ -146,9 +149,9 @@ public function testThatASignedResponseWithASignedAssertionIsValid(): void
/**
- * @runInSeparateProcess
- * @preserveGlobalState disabled
*/
+ #[PreserveGlobalState(false)]
+ #[RunInSeparateProcess]
public function testThatAnUnsignedResponseWithNoSignedAssertionsThrowsAnException(): void
{
$assertion = Assertion::fromXML(
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
index 9ab642bb8..513ef100d 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
@@ -5,17 +5,19 @@
namespace SimpleSAML\Test\SAML2\Response\Validation\ConstraintValidator;
use Mockery;
-use Mockery\MockInterface;
use Mockery\Adapter\Phpunit\MockeryTestCase;
+use Mockery\MockInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use SimpleSAML\SAML2\Configuration\Destination;
-use SimpleSAML\SAML2\Response\Validation\Result;
use SimpleSAML\SAML2\Response\Validation\ConstraintValidator\DestinationMatches;
+use SimpleSAML\SAML2\Response\Validation\Result;
use SimpleSAML\SAML2\XML\samlp\Response;
/**
- * @covers \SimpleSAML\SAML2\Response\Validation\ConstraintValidator\DestinationMatches
* @package simplesamlphp/saml2
*/
+#[CoversClass(DestinationMatches::class)]
final class DestinationMatchesTest extends MockeryTestCase
{
/** @var \Mockery\MockInterface */
@@ -31,10 +33,9 @@ public function setUp(): void
/**
- * @group response-validation
- * @test
*/
- public function aResponseIsValidWhenTheDestinationsMatch(): void
+ #[Group('response-validation')]
+ public function testAResponseIsValidWhenTheDestinationsMatch(): void
{
$expectedDestination = new Destination('VALID DESTINATION');
$this->response->shouldReceive('getDestination')->once()->andReturn('VALID DESTINATION');
@@ -48,10 +49,9 @@ public function aResponseIsValidWhenTheDestinationsMatch(): void
/**
- * @group response-validation
- * @test
*/
- public function aResponseIsNotValidWhenTheDestinationsAreNotEqual(): void
+ #[Group('response-validation')]
+ public function testAResponseIsNotValidWhenTheDestinationsAreNotEqual(): void
{
$this->response->shouldReceive('getDestination')->once()->andReturn('FOO');
$validator = new DestinationMatches(
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
index 722c2dbd3..b231c2c91 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
@@ -5,20 +5,22 @@
namespace SimpleSAML\Test\SAML2\Response\Validation\ConstraintValidator;
use Mockery;
-use Mockery\MockInterface;
use Mockery\Adapter\Phpunit\MockeryTestCase;
+use Mockery\MockInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Response\Validation\Result;
use SimpleSAML\SAML2\Response\Validation\ConstraintValidator\IsSuccessful;
+use SimpleSAML\SAML2\Response\Validation\Result;
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
use SimpleSAML\SAML2\XML\samlp\StatusMessage;
/**
- * @covers \SimpleSAML\SAML2\Response\Validation\ConstraintValidator\IsSuccessful
* @package simplesamlphp/saml2
*/
+#[CoversClass(IsSuccessful::class)]
final class IsSuccessfulTest extends MockeryTestCase
{
/** @var \Mockery\MockInterface */
@@ -34,10 +36,9 @@ public function setUp(): void
/**
- * @group response-validation
- * @test
*/
- public function validatingASuccessfulResponseGivesAValidValidationResult(): void
+ #[Group('response-validation')]
+ public function testValidatingASuccessfulResponseGivesAValidValidationResult(): void
{
$this->response->shouldReceive('isSuccess')->once()->andReturn(true);
@@ -51,10 +52,9 @@ public function validatingASuccessfulResponseGivesAValidValidationResult(): void
/**
- * @group response-validation
- * @test
*/
- public function anUnsuccessfulResponseIsNotValidAndGeneratesAProperErrorMessage(): void
+ #[Group('response-validation')]
+ public function testAnUnsuccessfulResponseIsNotValidAndGeneratesAProperErrorMessage(): void
{
$responseStatus = new Status(
new StatusCode(
diff --git a/tests/SAML2/Response/Validation/ResultTest.php b/tests/SAML2/Response/Validation/ResultTest.php
index 524e9c966..a1c1b21b0 100644
--- a/tests/SAML2/Response/Validation/ResultTest.php
+++ b/tests/SAML2/Response/Validation/ResultTest.php
@@ -4,20 +4,21 @@
namespace SimpleSAML\Test\SAML2\Response\Validation;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Response\Validation\Result;
/**
- * @covers \SimpleSAML\SAML2\Response\Validation\Result
* @package simplesamlphp/saml2
*/
+#[CoversClass(Result::class)]
final class ResultTest extends TestCase
{
/**
- * @group response-validation
- * @test
*/
- public function addedErrorsCanBeRetrieved(): void
+ #[Group('response-validation')]
+ public function testAddedErrorsCanBeRetrieved(): void
{
$error = 'This would be an error message';
$result = new Result();
@@ -31,10 +32,9 @@ public function addedErrorsCanBeRetrieved(): void
/**
- * @group response-validation
- * @test
*/
- public function theResultCorrectlyReportsWhetherOrNotItIsValid(): void
+ #[Group('response-validation')]
+ public function testTheResultCorrectlyReportsWhetherOrNotItIsValid(): void
{
$result = new Result();
diff --git a/tests/SAML2/Response/XmlSignatureWrappingTest.php b/tests/SAML2/Response/XmlSignatureWrappingTest.php
index 138f52a7f..f76c8881e 100644
--- a/tests/SAML2/Response/XmlSignatureWrappingTest.php
+++ b/tests/SAML2/Response/XmlSignatureWrappingTest.php
@@ -12,9 +12,6 @@
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Exception\ReferenceValidationFailedException;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-use SimpleSAML\XMLSecurity\Utils\Certificate;
-
-use function preg_match;
/**
* @package simplesamlphp/saml2
diff --git a/tests/SAML2/SOAPTest.php b/tests/SAML2/SOAPTest.php
index c744b16d6..dc6077478 100644
--- a/tests/SAML2/SOAPTest.php
+++ b/tests/SAML2/SOAPTest.php
@@ -4,11 +4,9 @@
namespace SimpleSAML\Test\SAML2;
-use DOMDocument;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Nyholm\Psr7\ServerRequest;
-use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use PHPUnit\Framework\Attributes\CoversClass;
use SimpleSAML\SAML2\Exception\Protocol\UnsupportedBindingException;
use SimpleSAML\SAML2\SOAP;
use SimpleSAML\SAML2\XML\ecp\RequestAuthenticated;
@@ -19,12 +17,11 @@
use SimpleSAML\XML\DOMDocumentFactory;
use function dirname;
-use function sprintf;
/**
- * @covers \SimpleSAML\SAML2\SOAP
* @package simplesamlphp\saml2
*/
+#[CoversClass(SOAP::class)]
final class SOAPTest extends MockeryTestCase
{
/**
diff --git a/tests/SAML2/Signature/MockChainedValidator.php b/tests/SAML2/Signature/MockChainedValidator.php
index d15a4e14f..566a16f0d 100644
--- a/tests/SAML2/Signature/MockChainedValidator.php
+++ b/tests/SAML2/Signature/MockChainedValidator.php
@@ -5,8 +5,8 @@
namespace SimpleSAML\Test\SAML2\Signature;
use Psr\Log\NullLogger;
-use SimpleSAML\SAML2\Signature\AbstractChainedValidator;
use SimpleSAML\SAML2\Configuration\CertificateProvider;
+use SimpleSAML\SAML2\Signature\AbstractChainedValidator;
use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
/**
diff --git a/tests/SAML2/Signature/PublicKeyValidatorTest.php b/tests/SAML2/Signature/PublicKeyValidatorTest.php
index da7b46ee5..e9e4226ad 100644
--- a/tests/SAML2/Signature/PublicKeyValidatorTest.php
+++ b/tests/SAML2/Signature/PublicKeyValidatorTest.php
@@ -5,36 +5,34 @@
namespace SimpleSAML\Test\SAML2\Signature;
use Mockery;
-use Mockery\MockInterface;
use Mockery\Adapter\Phpunit\MockeryTestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use Psr\Log\NullLogger;
use SimpleSAML\SAML2\Certificate\Key;
use SimpleSAML\SAML2\Certificate\KeyCollection;
use SimpleSAML\SAML2\Certificate\KeyLoader;
-use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Configuration\CertificateProvider;
-use SimpleSAML\SAML2\Constants;
+use SimpleSAML\SAML2\Configuration\IdentityProvider;
use SimpleSAML\SAML2\Signature\PublicKeyValidator;
use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\TestUtils\SimpleTestLogger;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
-use SimpleSAML\XMLSecurity\Utils\Certificate;
+use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
/**
- * @covers \SimpleSAML\SAML2\Signature\PublicKeyValidator
* @package simplesamlphp/saml2
*/
+#[CoversClass(PublicKeyValidator::class)]
final class PublicKeyValidatorTest extends MockeryTestCase
{
- /** @var \Mockery\MockInterface */
- private MockInterface $mockSignedElement;
+ /** @var \SimpleSAML\XMLSecurity\XML\SignedElementInterface */
+ private SignedElementInterface $mockSignedElement;
- /** @var \Mockery\MockInterface */
- private MockInterface $mockConfiguration;
+ /** @var \SimpleSAML\SAML2\Configuration\CertificateProvider */
+ private CertificateProvider $mockConfiguration;
/**
@@ -47,10 +45,9 @@ public function setUp(): void
/**
- * @test
- * @group signature
*/
- public function itCannotValidateIfNoKeysCanBeLoaded(): void
+ #[Group('signature')]
+ public function testItCannotValidateIfNoKeysCanBeLoaded(): void
{
$keyloaderMock = $this->prepareKeyLoader(new KeyCollection());
$validator = new PublicKeyValidator(new NullLogger(), $keyloaderMock);
@@ -60,10 +57,9 @@ public function itCannotValidateIfNoKeysCanBeLoaded(): void
/**
- * @test
- * @group signature
*/
- public function itWillValidateWhenKeysCanBeLoaded(): void
+ #[Group('signature')]
+ public function testItWillValidateWhenKeysCanBeLoaded(): void
{
$keyloaderMock = $this->prepareKeyLoader(new KeyCollection([1, 2]));
$validator = new PublicKeyValidator(new NullLogger(), $keyloaderMock);
@@ -73,10 +69,9 @@ public function itWillValidateWhenKeysCanBeLoaded(): void
/**
- * @test
- * @group signature
*/
- public function nonX509KeysAreNotUsedForValidation(): void
+ #[Group('signature')]
+ public function testNonX509KeysAreNotUsedForValidation(): void
{
$controlledCollection = new KeyCollection([
new Key(['type' => 'not_X509']),
@@ -96,10 +91,9 @@ public function nonX509KeysAreNotUsedForValidation(): void
/**
- * @test
- * @group signature
*/
- public function signedMessageWithValidSignatureIsValidatedCorrectly(): void
+ #[Group('signature')]
+ public function testSignedMessageWithValidSignatureIsValidatedCorrectly(): void
{
$config = new IdentityProvider(
['certificateData' => PEMCertificatesMock::getPlainCertificateContents(PEMCertificatesMock::CERTIFICATE)],
@@ -118,9 +112,6 @@ public function signedMessageWithValidSignatureIsValidatedCorrectly(): void
}
- /**
- * @return \SimpleSAML\SAML2\Certificate\KeyLoader
- */
private function prepareKeyLoader($returnValue)
{
return Mockery::mock(KeyLoader::class)
diff --git a/tests/SAML2/Signature/ValidatorChainTest.php b/tests/SAML2/Signature/ValidatorChainTest.php
index 168a0197f..441e02a2b 100644
--- a/tests/SAML2/Signature/ValidatorChainTest.php
+++ b/tests/SAML2/Signature/ValidatorChainTest.php
@@ -4,22 +4,23 @@
namespace SimpleSAML\Test\SAML2\Signature;
-use DateTimeImmutable;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use Psr\Log\NullLogger;
use SimpleSAML\SAML2\Configuration\IdentityProvider;
+use SimpleSAML\SAML2\Signature\MissingConfigurationException;
use SimpleSAML\SAML2\Signature\ValidatorChain;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
-use SimpleSAML\SAML2\Signature\MissingConfigurationException;
/**
- * @covers \SimpleSAML\SAML2\Signature\ValidatorChain
* @package simplesamlphp/saml2
*/
+#[CoversClass(ValidatorChain::class)]
final class ValidatorChainTest extends TestCase
{
/** @var \SimpleSAML\SAML2\Signature\ValidatorChain */
@@ -39,10 +40,9 @@ public static function setUpBeforeClass(): void
/**
- * @group signature
- * @test
*/
- public function ifNoValidatorsCanValidateAnExceptionIsThrown(): void
+ #[Group('signature')]
+ public function testIfNoValidatorsCanValidateAnExceptionIsThrown(): void
{
self::$chain->appendValidator(new MockChainedValidator(false, true));
self::$chain->appendValidator(new MockChainedValidator(false, true));
@@ -56,10 +56,9 @@ public function ifNoValidatorsCanValidateAnExceptionIsThrown(): void
/**
- * @group signature
- * @test
*/
- public function allRegisteredValidatorsShouldBeTried(): void
+ #[Group('signature')]
+ public function testAllRegisteredValidatorsShouldBeTried(): void
{
self::$chain->appendValidator(new MockChainedValidator(false, true));
self::$chain->appendValidator(new MockChainedValidator(false, true));
@@ -74,10 +73,9 @@ public function allRegisteredValidatorsShouldBeTried(): void
/**
- * @group signature
- * @test
*/
- public function itUsesTheResultOfTheFirstValidatorThatCanValidate(): void
+ #[Group('signature')]
+ public function testItUsesTheResultOfTheFirstValidatorThatCanValidate(): void
{
self::$chain->appendValidator(new MockChainedValidator(false, true));
self::$chain->appendValidator(new MockChainedValidator(true, false));
diff --git a/tests/SAML2/SignedElementHelperMock.php b/tests/SAML2/SignedElementHelperMock.php
deleted file mode 100644
index 4d706799f..000000000
--- a/tests/SAML2/SignedElementHelperMock.php
+++ /dev/null
@@ -1,44 +0,0 @@
-createElement('root');
- $doc->appendChild($root);
-
- $child = $doc->createElement('child');
- $root->appendChild($child);
-
- $txt = $doc->createTextNode('sometext');
- $child->appendChild($txt);
-
- $this->signElement($root, $child);
-
- return $root;
- }
-}
diff --git a/tests/SAML2/SignedElementHelperTest.php b/tests/SAML2/SignedElementHelperTest.php
deleted file mode 100644
index 6809c12c0..000000000
--- a/tests/SAML2/SignedElementHelperTest.php
+++ /dev/null
@@ -1,170 +0,0 @@
-setSignatureKey(CertificatesMock::getPrivateKey());
- $mock->setCertificates([CertificatesMock::PUBLIC_KEY_PEM]);
- $this->signedMockElement = $mock->toSignedXML();
- }
-
-
- /**
- * First check that we are able to validate with no modifications.
- *
- * To do this we first need to copy the element and add it to it's own document again
- * @todo explain why we need to copy the element?
- * @return void
- */
- public function testValidateWithoutModification(): void
- {
- $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
- $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
- $tmp = new SignedElementHelperMock($signedMockElementCopy);
- $this->assertTrue($tmp->validate(CertificatesMock::getPublicKey()));
- }
-
-
- /**
- * Test the modification of references.
- * @return void
- */
- public function testValidateWithReferenceTampering(): void
- {
- // Test modification of reference.
- $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
- $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
- $xpCache = XPath::getXPath($signedMockElementCopy);
- $digestValueElements = XPath::xpQuery(
- $signedMockElementCopy,
- '/root/ds:Signature/ds:SignedInfo/ds:Reference/ds:DigestValue',
- $xpCache,
- );
- $this->assertCount(1, $digestValueElements);
- $digestValueElements[0]->firstChild->data = 'invalid';
- $tmp = new SignedElementHelperMock($signedMockElementCopy);
- $this->assertFalse(
- $tmp->validate(CertificatesMock::getPublicKey()),
- 'When the DigestValue has been tampered with, a signature should no longer be valid'
- );
- }
-
-
- /**
- * Test that signatures no longer validate if the value has been tampered with.
- * @return void
- */
- public function testValidateWithValueTampering(): void
- {
- // Test modification of SignatureValue.
- $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
- $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
- $xpCache = XPath::getXPath($signedMockElementCopy);
- $digestValueElements = XPath::xpQuery(
- $signedMockElementCopy,
- '/root/ds:Signature/ds:SignatureValue',
- $xpCache,
- );
- $this->assertCount(1, $digestValueElements);
- $digestValueElements[0]->firstChild->data = 'invalid';
- $tmp = new SignedElementHelperMock($signedMockElementCopy);
-
- $this->expectException(\Exception::class, 'Unable to validate Signature');
- $tmp->validate(CertificatesMock::getPublicKey());
- }
-
-
- /**
- * Test that signatures contain the corresponding public keys.
- * @return void
- */
- public function testGetValidatingCertificates(): void
- {
- $certData = XMLSecurityDSig::staticGet509XCerts(CertificatesMock::PUBLIC_KEY_PEM);
- $certData = $certData[0];
-
- $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
- $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
- $tmp = new SignedElementHelperMock($signedMockElementCopy);
- $certs = $tmp->getValidatingCertificates();
- $this->assertCount(1, $certs);
- $this->assertEquals($certData, $certs[0]);
-
- // Test with two certificates.
- $tmpCert = '-----BEGIN CERTIFICATE-----
-MIICsDCCAhmgAwIBAgIJALU2mjA9ULI2MA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQwHhcNMTAwODAzMDYzNTQ4WhcNMjAwODAyMDYzNTQ4WjBF
-MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50
-ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
-gQDG6q53nl3Gn/9JE+ZiCgEB+EPcGbvzi0NrBDkKz9SKBNflxKQ+De/OAVQ9RQZO
-tEm/j0hoSCGO7maemOm1PVNtDuMchSroPs0L4szLhh6m1uMhw9RXqq34C+Cr7Wee
-ZNPQTFnQhBYqnYM03/e3SeUawiZ7rGeAMJ/8BSk0CB1GAQIDAQABo4GnMIGkMB0G
-A1UdDgQWBBRnHHPiQ/pV/xDZg3EBmU3ik64ORDB1BgNVHSMEbjBsgBRnHHPiQ/pV
-/xDZg3EBmU3ik64ORKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt
-U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJALU2mjA9
-ULI2MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAScv7ee6QajoSM4c4
-+fX+eYdjHFsvtqHD0ng987viS8eGjIrRfKAMHVzzs1jSU0TxMM7WUFDf6FpjW+Do
-r+X+X2Al/n6aDn7qAxXbl0RZuB+saxn+yFR6HFKggwkR1L2pimCuD0gTr6LlrNgf
-edF1YfJgq35hcMMLY9RE/0C0bCI=
------END CERTIFICATE-----';
- $mock = new SignedElementHelperMock();
- $mock->setSignatureKey(CertificatesMock::getPrivateKey());
- $mock->setCertificates([$tmpCert, CertificatesMock::PUBLIC_KEY_PEM]);
- $this->signedMockElement = $mock->toSignedXML();
- $tmp = new SignedElementHelperMock($this->signedMockElement);
- $certs = $tmp->getValidatingCertificates();
- $this->assertCount(1, $certs);
- $this->assertEquals($certData, $certs[0]);
- }
-
-
- /**
- * @return void
- */
- public function testGetSignatureKeyCertificates(): void
- {
- $seh = new SignedElementHelperMock();
- $origkey = CertificatesMock::getPrivateKey();
- $origcerts = [CertificatesMock::PUBLIC_KEY_PEM];
-
- $seh->setSignatureKey($origkey);
- $seh->setCertificates($origcerts);
-
- $key = $seh->getSignatureKey();
-
- $this->assertInstanceOf(\RobRichards\XMLSecLibs\XMLSecurityKey::class, $key);
- $this->assertEquals($origkey, $key);
-
- $certs = $seh->getCertificates();
- $this->assertEquals($origcerts, $certs);
- }
-}
diff --git a/tests/SAML2/Utilities/ArrayCollectionTest.php b/tests/SAML2/Utilities/ArrayCollectionTest.php
index 0dccf7c34..eee98f8a4 100644
--- a/tests/SAML2/Utilities/ArrayCollectionTest.php
+++ b/tests/SAML2/Utilities/ArrayCollectionTest.php
@@ -5,18 +5,22 @@
namespace SimpleSAML\Test\SAML2\Utilities;
use ArrayIterator;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Utilities\ArrayCollection;
use SimpleSAML\SAML2\Exception\RuntimeException;
+use SimpleSAML\SAML2\Utilities\ArrayCollection;
use function ucfirst;
-class ArrayCollectionTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(ArrayCollection::class)]
+final class ArrayCollectionTest extends TestCase
{
/**
- * @return void
*/
- public function test_construct_get_add_set(): void
+ public function testConstructGetAddSet(): void
{
$arc = new ArrayCollection(['aap', 'aap', 'noot']);
@@ -40,9 +44,8 @@ public function test_construct_get_add_set(): void
/**
- * @return void
*/
- public function test_remove(): void
+ public function testRemove(): void
{
$arc = new ArrayCollection(['aap', 'aap', 'noot', 'mies']);
@@ -73,9 +76,8 @@ public function test_remove(): void
/**
- * @return void
*/
- public function test_first_last_count(): void
+ public function testFirstLastCount(): void
{
$arc = new ArrayCollection(['aap', 'aap', 'noot', 'mies']);
@@ -86,9 +88,8 @@ public function test_first_last_count(): void
/**
- * @return void
*/
- public function test_offset(): void
+ public function testOffset(): void
{
$arc = new ArrayCollection(['aap', 'aap', 'noot', 'mies']);
@@ -109,9 +110,8 @@ public function test_offset(): void
/**
- * @return void
*/
- public function test_onlyelement(): void
+ public function testOnlyElement(): void
{
$arc = new ArrayCollection(['aap']);
$this->assertEquals($arc->getOnlyElement(), 'aap');
@@ -119,20 +119,22 @@ public function test_onlyelement(): void
/**
- * @return void
*/
- public function test_onlyelement_fail(): void
+ public function testOnlyElementFail(): void
{
- $this->expectException(RuntimeException::class, 'SAML2\Utilities\ArrayCollection::SAML2\Utilities\ArrayCollection::getOnlyElement requires that the collection has exactly one element, "2" elements found');
+ $this->expectException(RuntimeException::class);
+ $this->expectExceptionMessage(sprintf(
+ '%s::getOnlyElement requires that the collection has exactly one element, "2" elements found',
+ ArrayCollection::class,
+ ));
$arc = new ArrayCollection(['aap', 'noot']);
$arc->getOnlyElement();
}
/**
- * @return void
*/
- public function test_getiterator(): void
+ public function testGetiterator(): void
{
$arc = new ArrayCollection(['aap', 'noot']);
$this->assertInstanceOf(ArrayIterator::class, $arc->getIterator());
@@ -140,16 +142,15 @@ public function test_getiterator(): void
/**
- * @return void
*/
- public function test_filter_map(): void
+ public function testFilterMap(): void
{
$arc = new ArrayCollection(['aap', 'aap', 'noot', 'mies']);
$filtered = $arc->filter(
function ($i) {
return $i != 'aap';
- }
+ },
);
$this->assertInstanceOf(ArrayCollection::class, $filtered);
$this->assertEquals($filtered->get(0), null);
@@ -160,7 +161,7 @@ function ($i) {
$mapped = $arc->map(
function ($i) {
return ucfirst($i);
- }
+ },
);
$this->assertInstanceOf(ArrayCollection::class, $mapped);
$this->assertEquals($mapped->get(0), 'Aap');
diff --git a/tests/SAML2/Utilities/CertificateTest.php b/tests/SAML2/Utilities/CertificateTest.php
deleted file mode 100644
index 5b9e918b0..000000000
--- a/tests/SAML2/Utilities/CertificateTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-assertTrue($result);
- $result = Certificate::hasValidStructure(CertificatesMock::getPlainInvalidPublicKey());
- $this->assertFalse($result);
- }
-
-
- /**
- * @group utilities
- * @test
- * @return void
- */
- public function testConvertToCertificate(): void
- {
- $result = Certificate::convertToCertificate(CertificatesMock::getPlainPublicKeyContents());
- // the formatted public key in CertificatesMock is stored with unix newlines
- $this->assertEquals(CertificatesMock::getPlainPublicKey() . "\n", str_replace("\r", "", $result));
- }
-}
diff --git a/tests/SAML2/Utilities/FileTest.php b/tests/SAML2/Utilities/FileTest.php
index f36862481..ee65cbf9f 100644
--- a/tests/SAML2/Utilities/FileTest.php
+++ b/tests/SAML2/Utilities/FileTest.php
@@ -4,29 +4,32 @@
namespace SimpleSAML\Test\SAML2\Utilities;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Utilities\File;
use SimpleSAML\SAML2\Exception\RuntimeException;
+use SimpleSAML\SAML2\Utilities\File;
-class FileTest extends TestCase
+/**
+ * @package simplesamlphp/saml2
+ */
+#[CoversClass(File::class)]
+final class FileTest extends TestCase
{
/**
- * @group utilities
- * @test
- * @return void
*/
- public function when_loading_a_non_existant_file_an_exception_is_thrown(): void
+ #[Group('utilities')]
+ public function testWhenLoadingANonExistantFileAnExceptionIsThrown(): void
{
- $this->expectException(RuntimeException::class, 'File "/foo/bar/baz/quux" does not exist or is not readable');
+ $this->expectException(RuntimeException::class);
+ $this->expectExceptionMessage('File "/foo/bar/baz/quux" does not exist or is not readable');
File::getFileContents('/foo/bar/baz/quux');
}
/**
- * @group utilities
- * @test
- * @return void
*/
- public function an_existing_readable_file_can_be_loaded(): void
+ #[Group('utilities')]
+ public function testAnExistingReadableFileCanBeLoaded(): void
{
$contents = File::getFileContents(__DIR__ . '/File/can_be_loaded.txt');
diff --git a/tests/SAML2/UtilsTest.php b/tests/SAML2/UtilsTest.php
index 82512f4d7..990f35229 100644
--- a/tests/SAML2/UtilsTest.php
+++ b/tests/SAML2/UtilsTest.php
@@ -4,77 +4,62 @@
namespace SimpleSAML\Test\SAML2;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\AttributeQuery;
-use SimpleSAML\SAML2\XML\saml\NameID;
+use Psr\Clock\ClockInterface;
+use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
-use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Utils as XMLUtils;
+use SimpleSAML\SAML2\XML\saml\NameID;
+use SimpleSAML\SAML2\XML\saml\Subject;
+use SimpleSAML\SAML2\XML\samlp\AttributeQuery;
+
+use function count;
/**
- * Class \SimpleSAML\SAML2\UtilsTest
+ * Class \SAML2\UtilsTest
+ *
+ * @package simplesamlphp\saml2
*/
-class UtilsTest extends TestCase
+#[CoversClass(Utils::class)]
+final class UtilsTest extends TestCase
{
+ /** @var \Psr\Clock\ClockInterface */
+ private static ClockInterface $clock;
+
+
/**
- * Test parseBoolean, XML allows both 1 and true as values.
- * @return void
*/
- public function testParseBoolean(): void
+ public static function setUpBeforeClass(): void
{
- // variations of true: "true", 1, and captalizations
- $document = DOMDocumentFactory::fromString(
- ''
- );
- $result = Utils::parseBoolean($document->firstChild, 'anattribute');
- $this->assertTrue($result);
-
- $document = DOMDocumentFactory::fromString(
- ''
- );
- $result = Utils::parseBoolean($document->firstChild, 'anattribute');
- $this->assertTrue($result);
-
- $document = DOMDocumentFactory::fromString(
- ''
- );
-
- // variations of false: "false", 0
- $result = Utils::parseBoolean($document->firstChild, 'anattribute');
- $this->assertTrue($result);
+ self::$clock = Utils::getContainer()->getClock();
+ }
- $document = DOMDocumentFactory::fromString(
- ''
- );
- $result = Utils::parseBoolean($document->firstChild, 'anattribute');
- $this->assertFalse($result);
- $document = DOMDocumentFactory::fromString(
- ''
+ /**
+ * Test querying a SAML XML document.
+ */
+ public function testXpQuery(): void
+ {
+ $nameId_before = new NameID(
+ 'NameIDValue',
+ 'OurNameQualifier',
+ 'TheSPNameQualifier',
+ C::NAMEID_TRANSIENT,
);
- $result = Utils::parseBoolean($document->firstChild, 'anattribute');
- $this->assertFalse($result);
- // Usage of the default if attribute not found
- $document = DOMDocumentFactory::fromString(
- ''
- );
- $result = Utils::parseBoolean($document->firstChild, 'otherattribute');
- $this->assertNull($result);
+ $aq = new AttributeQuery(new Subject($nameId_before), self::$clock->now());
- $document = DOMDocumentFactory::fromString(
- ''
- );
- $result = Utils::parseBoolean($document->firstChild, 'otherattribute', '404');
- $this->assertEquals($result, '404');
+ $xml = $aq->toXML();
- // Exception on invalid value
- $this->expectException(\Exception::class, "Invalid value of boolean attribute 'anattribute': 'yes'");
+ $xpCache = XPath::getXPath($xml);
+ $nameId_after = XPath::xpQuery($xml, './saml_assertion:Subject/saml_assertion:NameID', $xpCache);
+ $this->assertTrue(count($nameId_after) === 1);
- $document = DOMDocumentFactory::fromString(
- ''
- );
- $result = Utils::parseBoolean($document->firstChild, 'anattribute');
+ /** @var \DOMNode $nameId_after[0] */
+ $this->assertEquals('NameIDValue', $nameId_after[0]->textContent);
+ $this->assertEquals(C::NAMEID_TRANSIENT, $nameId_after[0]->getAttribute("Format"));
+ $this->assertEquals('OurNameQualifier', $nameId_after[0]->getAttribute("NameQualifier"));
+ $this->assertEquals('TheSPNameQualifier', $nameId_after[0]->getAttribute("SPNameQualifier"));
}
}
diff --git a/tests/SAML2/XML/alg/DigestMethodTest.php b/tests/SAML2/XML/alg/DigestMethodTest.php
index bc523179f..0f0033752 100644
--- a/tests/SAML2/XML/alg/DigestMethodTest.php
+++ b/tests/SAML2/XML/alg/DigestMethodTest.php
@@ -4,28 +4,29 @@
namespace SimpleSAML\Test\SAML2\XML\alg;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\alg\AbstractAlgElement;
use SimpleSAML\SAML2\XML\alg\DigestMethod;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
-use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
+use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\alg\DigestMethodTest
- *
- * @covers \SimpleSAML\SAML2\XML\alg\AbstractAlgElement
- * @covers \SimpleSAML\SAML2\XML\alg\DigestMethod
+ * Class \SimpleSAML\SAML2\XML\alg\DigestMethodTest
*
* @package simplesamlphp/saml2
*/
+#[Group('alg')]
+#[CoversClass(DigestMethod::class)]
+#[CoversClass(AbstractAlgElement::class)]
final class DigestMethodTest extends TestCase
{
use SerializableElementTestTrait;
@@ -67,19 +68,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $digestMethod = DigestMethod::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($digestMethod),
- );
- }
-
-
/**
*/
public function testUnmarshallingMissingAlgorithmThrowsException(): void
diff --git a/tests/SAML2/XML/alg/SigningMethodTest.php b/tests/SAML2/XML/alg/SigningMethodTest.php
index b273a1ac4..5379911dd 100644
--- a/tests/SAML2/XML/alg/SigningMethodTest.php
+++ b/tests/SAML2/XML/alg/SigningMethodTest.php
@@ -4,28 +4,29 @@
namespace SimpleSAML\Test\SAML2\XML\alg;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\alg\AbstractAlgElement;
use SimpleSAML\SAML2\XML\alg\SigningMethod;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
-use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
+use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\alg\SigningMethodTest
- *
- * @covers \SimpleSAML\SAML2\XML\alg\AbstractAlgElement
- * @covers \SimpleSAML\SAML2\XML\alg\SigningMethod
+ * Class \SimpleSAML\SAML2\XML\alg\SigningMethodTest
*
* @package simplesamlphp/saml2
*/
+#[Group('alg')]
+#[CoversClass(SigningMethod::class)]
+#[CoversClass(AbstractAlgElement::class)]
final class SigningMethodTest extends TestCase
{
use SerializableElementTestTrait;
@@ -69,19 +70,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $signingMethod = SigningMethod::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($signingMethod),
- );
- }
-
-
/**
*/
public function testMissingAlgorithmThrowsException(): void
diff --git a/tests/SAML2/XML/ecp/RelayStateTest.php b/tests/SAML2/XML/ecp/RelayStateTest.php
new file mode 100644
index 000000000..444b85fdd
--- /dev/null
+++ b/tests/SAML2/XML/ecp/RelayStateTest.php
@@ -0,0 +1,86 @@
+assertEquals(
+ self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
+ strval($relayState),
+ );
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingMustUnderstandThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttributeNS(SOAP::NS_SOAP_ENV_11, 'mustUnderstand');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing env:mustUnderstand attribute in .');
+
+ RelayState::fromXML($document);
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingActorThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttributeNS(SOAP::NS_SOAP_ENV_11, 'actor');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing env:actor attribute in .');
+
+ RelayState::fromXML($document);
+ }
+}
diff --git a/tests/SAML2/XML/ecp/RequestAuthenticatedTest.php b/tests/SAML2/XML/ecp/RequestAuthenticatedTest.php
index ec2e0db70..78905eff9 100644
--- a/tests/SAML2/XML/ecp/RequestAuthenticatedTest.php
+++ b/tests/SAML2/XML/ecp/RequestAuthenticatedTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\ecp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SOAP\Constants as C;
+use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\RequestAuthenticated;
+use SimpleSAML\SOAP\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,9 +20,10 @@
/**
* @package simplesamlphp/saml2
- * @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
- * @covers \SimpleSAML\SAML2\XML\ecp\RequestAuthenticated
*/
+#[Group('ecp')]
+#[CoversClass(RequestAuthenticated::class)]
+#[CoversClass(AbstractEcpElement::class)]
final class RequestAuthenticatedTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -54,19 +57,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $ra = RequestAuthenticated::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($ra),
- );
- }
-
-
/**
*/
public function testUnmarshallingWithMissingActorThrowsException(): void
diff --git a/tests/SAML2/XML/ecp/RequestTest.php b/tests/SAML2/XML/ecp/RequestTest.php
new file mode 100644
index 000000000..2c14c3fe7
--- /dev/null
+++ b/tests/SAML2/XML/ecp/RequestTest.php
@@ -0,0 +1,102 @@
+assertEquals(
+ self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
+ strval($request),
+ );
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingMustUnderstandThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttributeNS(SOAP::NS_SOAP_ENV_11, 'mustUnderstand');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing env:mustUnderstand attribute in .');
+
+ Request::fromXML($document);
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingActorThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttributeNS(SOAP::NS_SOAP_ENV_11, 'actor');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing env:actor attribute in .');
+
+ Request::fromXML($document);
+ }
+}
diff --git a/tests/SAML2/XML/ecp/ResponseTest.php b/tests/SAML2/XML/ecp/ResponseTest.php
index cca54fc61..d1346394b 100644
--- a/tests/SAML2/XML/ecp/ResponseTest.php
+++ b/tests/SAML2/XML/ecp/ResponseTest.php
@@ -5,10 +5,11 @@
namespace SimpleSAML\Test\SAML2\XML\ecp;
use DOMDocument;
-use DOMElement;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\Response;
use SimpleSAML\SOAP\Constants as SOAP;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -21,10 +22,11 @@
use function strval;
/**
- * @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
- * @covers \SimpleSAML\SAML2\XML\ecp\Response
* @package simplesamlphp/saml2
*/
+#[Group('ecp')]
+#[CoversClass(Response::class)]
+#[CoversClass(AbstractEcpElement::class)]
final class ResponseTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -85,19 +87,6 @@ public function testInvalidACSThrowsException(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $response = Response::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($response),
- );
- }
-
-
/**
*/
public function testUnmarshallingWithMissingMustUnderstandThrowsException(): void
diff --git a/tests/SAML2/XML/ecp/SubjectConfirmationTest.php b/tests/SAML2/XML/ecp/SubjectConfirmationTest.php
new file mode 100644
index 000000000..5c1e0dfce
--- /dev/null
+++ b/tests/SAML2/XML/ecp/SubjectConfirmationTest.php
@@ -0,0 +1,125 @@
+Arbitrary Element');
+
+ $attr1 = new XMLAttribute('urn:test:something', 'test', 'attr1', 'testval1');
+ $attr2 = new XMLAttribute('urn:test:something', 'test', 'attr2', 'testval2');
+
+ $subjectConfirmationData = new SubjectConfirmationData(
+ new DateTimeImmutable('2001-04-19T04:25:21Z'),
+ new DateTimeImmutable('2009-02-13T23:31:30Z'),
+ C::ENTITY_SP,
+ 'SomeRequestID',
+ '127.0.0.1',
+ [
+ new KeyInfo([new KeyName('SomeKey')]),
+ new Chunk($arbitrary->documentElement),
+ ],
+ [$attr1, $attr2]
+ );
+
+ $subjectConfirmation = new SubjectConfirmation(C::CM_BEARER, $subjectConfirmationData);
+
+ $this->assertEquals(
+ self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
+ strval($subjectConfirmation),
+ );
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingMustUnderstandThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttributeNS(SOAP::NS_SOAP_ENV_11, 'mustUnderstand');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing env:mustUnderstand attribute in .');
+
+ SubjectConfirmation::fromXML($document);
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingActorThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttributeNS(SOAP::NS_SOAP_ENV_11, 'actor');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing env:actor attribute in .');
+
+ SubjectConfirmation::fromXML($document);
+ }
+
+
+ /**
+ */
+ public function testUnmarshallingWithMissingMethodThrowsException(): void
+ {
+ $document = clone self::$xmlRepresentation->documentElement;
+ $document->removeAttribute('Method');
+
+ $this->expectException(MissingAttributeException::class);
+ $this->expectExceptionMessage('Missing \'Method\' attribute on ecp:SubjectConfirmation.');
+
+ SubjectConfirmation::fromXML($document);
+ }
+}
diff --git a/tests/SAML2/XML/emd/RepublishRequestTest.php b/tests/SAML2/XML/emd/RepublishRequestTest.php
index 1d3c0c733..d434efeee 100644
--- a/tests/SAML2/XML/emd/RepublishRequestTest.php
+++ b/tests/SAML2/XML/emd/RepublishRequestTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\emd;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\emd\AbstractEmdElement;
use SimpleSAML\SAML2\XML\emd\RepublishRequest;
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -19,10 +21,11 @@
/**
* Class \SimpleSAML\SAML2\XML\emd\RepublishRequest
*
- * @covers \SimpleSAML\SAML2\XML\emd\RepublishRequest
- * @covers \SimpleSAML\SAML2\XML\emd\AbstractEmdElement
* @package simplesamlphp/saml2
*/
+#[Group('emd')]
+#[CoversClass(RepublishRequest::class)]
+#[CoversClass(AbstractEmdElement::class)]
final class RepublishRequestTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -62,18 +65,4 @@ public function testMarshalling(): void
strval($republishRequest),
);
}
-
-
- /**
- * Unmarshalling
- */
- public function testUnmarshalling(): void
- {
- $republishRequest = RepublishRequest::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($republishRequest),
- );
- }
}
diff --git a/tests/SAML2/XML/emd/RepublishTargetTest.php b/tests/SAML2/XML/emd/RepublishTargetTest.php
index 9f963584a..2906a500e 100644
--- a/tests/SAML2/XML/emd/RepublishTargetTest.php
+++ b/tests/SAML2/XML/emd/RepublishTargetTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\emd;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\emd\AbstractEmdElement;
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -17,10 +19,11 @@
/**
* Class \SimpleSAML\SAML2\XML\emd\RepublishTarget
*
- * @covers \SimpleSAML\SAML2\XML\emd\RepublishTarget
- * @covers \SimpleSAML\SAML2\XML\emd\AbstractEmdElement
* @package simplesamlphp/saml2
*/
+#[Group('emd')]
+#[CoversClass(RepublishTarget::class)]
+#[CoversClass(AbstractEmdElement::class)]
final class RepublishTargetTest extends TestCase
{
use SerializableElementTestTrait;
@@ -63,15 +66,4 @@ public function testMarshallingIncorrectValueThrowsException(): void
new RepublishTarget('http://example.org/');
}
-
-
- /**
- * Unmarshalling
- */
- public function testUnmarshalling(): void
- {
- $republishTarget = RepublishTarget::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals('http://edugain.org/', $republishTarget->getContent());
- }
}
diff --git a/tests/SAML2/XML/idpdisc/DiscoveryResponseTest.php b/tests/SAML2/XML/idpdisc/DiscoveryResponseTest.php
index 3db9fdc4b..67a30fea1 100644
--- a/tests/SAML2/XML/idpdisc/DiscoveryResponseTest.php
+++ b/tests/SAML2/XML/idpdisc/DiscoveryResponseTest.php
@@ -4,16 +4,17 @@
namespace SimpleSAML\Test\SAML2\XML\idpdisc;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponse;
+use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -22,13 +23,14 @@
use function strval;
/**
- * Class \SAML2\XML\idpdisc\DiscoveryResponseTest
+ * Class \SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponseTest
*
- * @covers \SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponse
- * @covers \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('idpdisc')]
+#[CoversClass(DiscoveryResponse::class)]
+#[CoversClass(AbstractIndexedEndpointType::class)]
+#[CoversClass(AbstractMdElement::class)]
final class DiscoveryResponseTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -36,10 +38,10 @@ final class DiscoveryResponseTest extends TestCase
use SerializableElementTestTrait;
/** @var \SimpleSAML\XML\Chunk */
- protected static Chunk $ext;
+ private static Chunk $ext;
/** @var \SimpleSAML\XML\Attribute */
- protected static XMLAttribute $attr;
+ private static XMLAttribute $attr;
/**
@@ -83,7 +85,7 @@ public function testMarshalling(): void
$discoResponse = new DiscoveryResponse(
43,
C::BINDING_IDPDISC,
- 'https://simplesamlphp.org/some/endpoint',
+ C::LOCATION_A,
false,
null,
[self::$ext],
@@ -109,7 +111,7 @@ public function testMarshallingWithResponseLocation(): void
new DiscoveryResponse(
42,
C::BINDING_IDPDISC,
- 'https://simplesamlphp.org/some/endpoint',
+ C::LOCATION_A,
false,
'https://response.location/',
);
@@ -119,20 +121,6 @@ public function testMarshallingWithResponseLocation(): void
// test unmarshalling
- /**
- * Test creating a DiscoveryResponse from XML.
- */
- public function testUnmarshalling(): void
- {
- $discoResponse = DiscoveryResponse::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($discoResponse),
- );
- }
-
-
/**
* Test that creating a DiscoveryResponse from XML fails when ResponseLocation is present.
*/
diff --git a/tests/SAML2/XML/init/RequestInitiatorTest.php b/tests/SAML2/XML/init/RequestInitiatorTest.php
index 336a1fdef..4af8eb159 100644
--- a/tests/SAML2/XML/init/RequestInitiatorTest.php
+++ b/tests/SAML2/XML/init/RequestInitiatorTest.php
@@ -4,13 +4,13 @@
namespace SimpleSAML\Test\SAML2\XML\init;
-use DOMDocument;
-use Exception;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\XML\init\RequestInitiator;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -21,12 +21,13 @@
use function strval;
/**
- * Class \SAML2\XML\init\RequestInitiatorTest
- *
- * @covers \SimpleSAML\SAML2\XML\init\RequestInitiator
+ * Class \SimpleSAML\SAML2\XML\init\RequestInitiatorTest
*
* @package simplesamlphp/saml2
*/
+#[Group('init')]
+#[CoversClass(RequestInitiator::class)]
+#[CoversClass(AbstractMdElement::class)]
final class RequestInitiatorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -62,14 +63,8 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $attr = new XMLAttribute('urn:x-simplesamlphp:namespace', 'test', 'attr', 'value');
-
- $requestInitiator = new RequestInitiator(
- 'https://simplesamlphp.org/some/endpoint',
- 'https://simplesamlphp.org/other/endpoint',
- [self::$ext],
- [$attr],
- );
+ $attr = new XMLAttribute(C::NAMESPACE, 'test', 'attr', 'value');
+ $requestInitiator = new RequestInitiator(C::LOCATION_A, C::LOCATION_B, [self::$ext], [$attr]);
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
@@ -81,20 +76,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a RequestInitiator from XML.
- */
- public function testUnmarshalling(): void
- {
- $requestInitiator = RequestInitiator::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requestInitiator),
- );
- }
-
-
/**
* Test that creating a RequestInitiator from XML with an invalid Binding fails.
*/
diff --git a/tests/SAML2/XML/md/AbstractLocalizedNameTest.php b/tests/SAML2/XML/md/AbstractLocalizedNameTest.php
new file mode 100644
index 000000000..bd25ac7d6
--- /dev/null
+++ b/tests/SAML2/XML/md/AbstractLocalizedNameTest.php
@@ -0,0 +1,118 @@
+expectException(AssertionFailedException::class);
+ $this->expectExceptionMessage('xml:lang cannot be empty.');
+
+ new ServiceDescription('', 'Academic Journals R US and only us');
+ }
+
+
+ /**
+ * Test that creating a ServiceDescription from scratch with an empty value works.
+ */
+ public function testMarshallingWithEmptyValue(): void
+ {
+ $this->expectException(AssertionFailedException::class);
+ $this->expectExceptionMessage('Expected a non-empty value. Got: ""');
+
+ new ServiceDescription('en', '');
+ }
+
+
+ // test unmarshalling
+
+
+ /**
+ * Test that creating a ServiceDescription from XML fails when xml:lang is missing.
+ */
+ public function testUnmarshallingWithoutLang(): void
+ {
+ $xmlRepresentation = clone self::$xmlRepresentation;
+ $xmlRepresentation->documentElement->removeAttributeNS(C::NS_XML, 'lang');
+
+ $this->expectException(AssertionFailedException::class);
+ $this->expectExceptionMessage('Missing xml:lang from ServiceDescription');
+
+ ServiceDescription::fromXML($xmlRepresentation->documentElement);
+ }
+
+
+ /**
+ * Test that creating a ServiceDescription from XML fails when xml:lang is empty.
+ */
+ public function testUnmarshallingWithEmptyLang(): void
+ {
+ $xmlRepresentation = clone self::$xmlRepresentation;
+ $xmlRepresentation->documentElement->setAttributeNS(C::NS_XML, 'lang', '');
+
+ $this->expectException(AssertionFailedException::class);
+ $this->expectExceptionMessage('xml:lang cannot be empty.');
+
+ ServiceDescription::fromXML($xmlRepresentation->documentElement);
+ }
+
+
+ /**
+ * Test that creating a ServiceDescription from XML works for empty values.
+ */
+ public function testUnmarshallingWithEmptyValue(): void
+ {
+ $xmlRepresentation = clone self::$xmlRepresentation;
+ $xmlRepresentation->documentElement->textContent = '';
+
+ $this->expectException(AssertionFailedException::class);
+ $this->expectExceptionMessage('Expected a non-empty value. Got: ""');
+
+ ServiceDescription::fromXML($xmlRepresentation->documentElement);
+ }
+}
diff --git a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
index 91244bfce..81ff53ecc 100644
--- a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
+++ b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\AdditionalMetadataLocation;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -20,10 +22,11 @@
/**
* Tests for the AdditionalMetadataLocation class
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AdditionalMetadataLocation
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AdditionalMetadataLocation::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AdditionalMetadataLocationTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -52,10 +55,7 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $additionalMetadataLocation = new AdditionalMetadataLocation(
- 'urn:x-simplesamlphp:namespace',
- 'https://simplesamlphp.org/some/endpoint',
- );
+ $additionalMetadataLocation = new AdditionalMetadataLocation(C::NAMESPACE, C::LOCATION_A);
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
@@ -70,27 +70,13 @@ public function testMarshalling(): void
public function testMarshallingWithEmptyNamespace(): void
{
$this->expectException(SchemaViolationException::class);
- new AdditionalMetadataLocation('', 'https://simplesamlphp.org/some/endpoint');
+ new AdditionalMetadataLocation('', C::LOCATION_A);
}
// test unmarshalling
- /**
- * Test creating an AdditionalMetadataLocation object from XML.
- */
- public function testUnmarshalling(): void
- {
- $additionalMetadataLocation = AdditionalMetadataLocation::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($additionalMetadataLocation),
- );
- }
-
-
/**
* Test that creating an AdditionalMetadataLocation from XML fails if "namespace" is missing.
*/
diff --git a/tests/SAML2/XML/md/AffiliateMemberTest.php b/tests/SAML2/XML/md/AffiliateMemberTest.php
index 96ed9648b..3c754b20a 100644
--- a/tests/SAML2/XML/md/AffiliateMemberTest.php
+++ b/tests/SAML2/XML/md/AffiliateMemberTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\AffiliateMember;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -22,10 +24,11 @@
/**
* Tests for AffiliateMember.
*
- * @covers \SimpleSAML\SAML2\XML\md\AffiliateMember
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AffiliateMember::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AffiliateMemberTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -84,21 +87,4 @@ public function testMarshallingTooLongContentThrowsException(): void
new AffiliateMember(str_pad('https://some.entity.org/id', C::ENTITYID_MAX_LENGTH + 1, 'a'));
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a AffiliateMember from XML.
- */
- public function testUnmarshalling(): void
- {
- $affiliateMember = AffiliateMember::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($affiliateMember),
- );
- }
}
diff --git a/tests/SAML2/XML/md/AffiliationDescriptorTest.php b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
index e4cf3eabd..668663550 100644
--- a/tests/SAML2/XML/md/AffiliationDescriptorTest.php
+++ b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
@@ -6,8 +6,12 @@
use DateTimeImmutable;
use Exception;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\AffiliateMember;
use SimpleSAML\SAML2\XML\md\AffiliationDescriptor;
use SimpleSAML\SAML2\XML\md\KeyDescriptor;
@@ -18,7 +22,6 @@
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
@@ -29,12 +32,13 @@
/**
* Tests for the AffiliationDescriptor class.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AffiliationDescriptor
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AffiliationDescriptor::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AffiliationDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -120,20 +124,6 @@ public function testMarshallingWithEmptyMemberList(): void
// test unmarshalling
- /**
- * Test creating an AffiliationDescriptor from XML.
- */
- public function testUnmarshalling(): void
- {
- $affiliationDescriptor = AffiliationDescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($affiliationDescriptor),
- );
- }
-
-
/**
* Test failure to create an AffiliationDescriptor from XML when there's no affiliation members.
*/
diff --git a/tests/SAML2/XML/md/ArtifactResolutionServiceTest.php b/tests/SAML2/XML/md/ArtifactResolutionServiceTest.php
index 3c271c8a2..3ba22feb3 100644
--- a/tests/SAML2/XML/md/ArtifactResolutionServiceTest.php
+++ b/tests/SAML2/XML/md/ArtifactResolutionServiceTest.php
@@ -4,11 +4,14 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\ArtifactResolutionService;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -23,11 +26,12 @@
/**
* Tests for md:ArtifactResolutionService.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType
- * @covers \SimpleSAML\SAML2\XML\md\ArtifactResolutionService
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(ArtifactResolutionService::class)]
+#[CoversClass(AbstractIndexedEndpointType::class)]
+#[CoversClass(AbstractMdElement::class)]
final class ArtifactResolutionServiceTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -35,10 +39,10 @@ final class ArtifactResolutionServiceTest extends TestCase
use SerializableElementTestTrait;
/** @var \SimpleSAML\XML\Chunk */
- protected static Chunk $ext;
+ private static Chunk $ext;
/** @var \SimpleSAML\XML\Attribute */
- protected static XMLAttribute $attr;
+ private static XMLAttribute $attr;
/**
@@ -104,33 +108,13 @@ public function testMarshallingWithResponseLocation(): void
$this->expectExceptionMessage(
'The \'ResponseLocation\' attribute must be omitted for md:ArtifactResolutionService.',
);
- new ArtifactResolutionService(
- 42,
- C::BINDING_HTTP_ARTIFACT,
- 'https://simplesamlphp.org/some/endpoint',
- false,
- 'https://response.location/',
- );
+ new ArtifactResolutionService(42, C::BINDING_HTTP_ARTIFACT, C::LOCATION_A, false, 'https://response.location/');
}
// test unmarshalling
- /**
- * Test creating a ArtifactResolutionService from XML.
- */
- public function testUnmarshalling(): void
- {
- $ars = ArtifactResolutionService::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($ars),
- );
- }
-
-
/**
* Test that creating a ArtifactResolutionService from XML fails when ResponseLocation is present.
*/
diff --git a/tests/SAML2/XML/md/AssertionConsumerServiceTest.php b/tests/SAML2/XML/md/AssertionConsumerServiceTest.php
index 483abb4b6..131792925 100644
--- a/tests/SAML2/XML/md/AssertionConsumerServiceTest.php
+++ b/tests/SAML2/XML/md/AssertionConsumerServiceTest.php
@@ -4,15 +4,16 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\AssertionConsumerService;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
-use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Chunk;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
-use SimpleSAML\XML\Exception\MissingAttributeException;
+use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -23,11 +24,12 @@
/**
* Class \SimpleSAML\SAML2\XML\md\AssertionConsumerServiceTest
*
- * @covers \SimpleSAML\SAML2\XML\md\AssertionConsumerService
- * @covers \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AssertionConsumerService::class)]
+#[CoversClass(AbstractIndexedEndpointType::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AssertionConsumerServiceTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -35,10 +37,10 @@ final class AssertionConsumerServiceTest extends TestCase
use SerializableElementTestTrait;
/** @var \SimpleSAML\XML\Chunk */
- protected static Chunk $ext;
+ private static Chunk $ext;
/** @var \SimpleSAML\XML\Attribute */
- protected static XMLAttribute $attr;
+ private static XMLAttribute $attr;
/**
@@ -82,7 +84,7 @@ public function testMarshalling(): void
$idxep = new AssertionConsumerService(
42,
C::BINDING_HTTP_POST,
- 'https://simplesamlphp.org/some/endpoint',
+ C::LOCATION_A,
false,
'https://foo.bar/',
[self::$ext],
@@ -94,21 +96,4 @@ public function testMarshalling(): void
strval($idxep),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating an IndexedEndpointType from XML.
- */
- public function testUnmarshalling(): void
- {
- $idxep = AssertionConsumerService::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($idxep),
- );
- }
}
diff --git a/tests/SAML2/XML/md/AttributeAuthorityDescriptorTest.php b/tests/SAML2/XML/md/AttributeAuthorityDescriptorTest.php
index c4423e307..c7e6ffa29 100644
--- a/tests/SAML2/XML/md/AttributeAuthorityDescriptorTest.php
+++ b/tests/SAML2/XML/md/AttributeAuthorityDescriptorTest.php
@@ -5,8 +5,15 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use Exception;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\AssertionIDRequestService;
use SimpleSAML\SAML2\XML\md\AttributeAuthorityDescriptor;
use SimpleSAML\SAML2\XML\md\AttributeProfile;
@@ -16,11 +23,9 @@
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
use function dirname;
@@ -29,14 +34,15 @@
/**
* Tests for the AttributeAuthorityDescriptor class.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AttributeAuthorityDescriptor
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AttributeAuthorityDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptorType::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AttributeAuthorityDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -158,19 +164,6 @@ public function testMarshallingWithoutAttributeServices(): void
}
- /**
- * Test that creating an AttributeAuthorityDescriptor with an AttributeService of the wrong type fails.
- */
- public function testMarshallingWithWrongAttributeService(): void
- {
- $this->expectException(InvalidDOMElementException::class);
- $this->expectExceptionMessage('AttributeService is not an instance of EndpointType.');
-
- /** @psalm-suppress InvalidArgument */
- new AttributeAuthorityDescriptor(['string'], [C::NS_SAMLP]);
- }
-
-
/**
* Test that creating an AttributeAuthorityDescriptor without optional parameters works.
*/
@@ -209,21 +202,6 @@ public function testMarshallingWithEmptyAssertionIDRequestService(): void
}
- /**
- * Test that creating an AttributeAuthorityDescriptor with wrong AssertionIDRequestService fails.
- */
- public function testMarshallingWithWrongAssertionIDRequestService(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'Expected an instance of SimpleSAML\SAML2\XML\md\AssertionIDRequestService. Got: string',
- );
-
- /** @psalm-suppress InvalidArgument */
- new AttributeAuthorityDescriptor([self::$as], [C::NS_SAMLP], ['x']);
- }
-
-
/**
* Test that creating an AttributeAuthorityDescriptor with an empty NameIDFormat fails.
*/
@@ -250,45 +228,9 @@ public function testMarshallingWithEmptyAttributeProfile(): void
}
- /**
- * Test that creating an AttributeAuthorityDescriptor with wrong Attribute fails.
- */
- public function testMarshallingWithWrongAttribute(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'Expected an instance of SimpleSAML\SAML2\XML\saml\Attribute. Got: string',
- );
-
- /** @psalm-suppress InvalidArgument */
- new AttributeAuthorityDescriptor(
- [self::$as],
- [C::NS_SAMLP],
- [self::$aidrs],
- [new NameIDFormat(C::NAMEID_PERSISTENT)],
- [new AttributeProfile(C::PROFILE_1)],
- ['x'],
- );
- }
-
-
// test unmarshalling
- /**
- * Test creating an AttributeAuthorityDescriptor from XML
- */
- public function testUnmarshalling(): void
- {
- $aad = AttributeAuthorityDescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($aad),
- );
- }
-
-
/**
* Test that creating an AttributeAuthorityDescriptor without any optional element works.
*/
diff --git a/tests/SAML2/XML/md/AttributeConsumingServiceTest.php b/tests/SAML2/XML/md/AttributeConsumingServiceTest.php
index 547598377..5f06fcfd2 100644
--- a/tests/SAML2/XML/md/AttributeConsumingServiceTest.php
+++ b/tests/SAML2/XML/md/AttributeConsumingServiceTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\AttributeConsumingService;
use SimpleSAML\SAML2\XML\md\RequestedAttribute;
use SimpleSAML\SAML2\XML\md\ServiceDescription;
@@ -18,7 +20,6 @@
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
@@ -26,10 +27,11 @@
/**
* Tests for the AttributeConsumingService class.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AttributeConsumingService
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AttributeConsumingService::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AttributeConsumingServiceTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -171,20 +173,6 @@ public function testMarshallingWithEmptyRequestedAttributes(): void
// test unmarshalling
- /**
- * Test creating an AssertionConsumerService from XML.
- */
- public function testUnmarshalling(): void
- {
- $acs = AttributeConsumingService::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($acs),
- );
- }
-
-
/**
* Test that creating an AssertionConsumerService from XML fails if index is missing.
*/
diff --git a/tests/SAML2/XML/md/AttributeProfileTest.php b/tests/SAML2/XML/md/AttributeProfileTest.php
index 33fa3a315..2e9ff3976 100644
--- a/tests/SAML2/XML/md/AttributeProfileTest.php
+++ b/tests/SAML2/XML/md/AttributeProfileTest.php
@@ -4,12 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
-use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\AttributeProfile;
-use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -20,10 +20,11 @@
/**
* Class \SimpleSAML\SAML2\XML\md\AttributeProfileTest
*
- * @covers \SimpleSAML\SAML2\XML\md\AttributeProfile
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AttributeProfile::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AttributeProfileTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -51,23 +52,7 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $attributeProfile = new AttributeProfile('urn:x-simplesamlphp:profile:one');
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($attributeProfile),
- );
- }
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $attributeProfile = AttributeProfile::fromXML(self::$xmlRepresentation->documentElement);
+ $attributeProfile = new AttributeProfile(C::PROFILE_1);
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
diff --git a/tests/SAML2/XML/md/AuthnAuthorityDescriptorTest.php b/tests/SAML2/XML/md/AuthnAuthorityDescriptorTest.php
index 6f7cd869b..9ffcc1bbc 100644
--- a/tests/SAML2/XML/md/AuthnAuthorityDescriptorTest.php
+++ b/tests/SAML2/XML/md/AuthnAuthorityDescriptorTest.php
@@ -4,8 +4,15 @@
namespace SimpleSAML\Test\SAML2\XML\md;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\AssertionIDRequestService;
use SimpleSAML\SAML2\XML\md\AuthnAuthorityDescriptor;
use SimpleSAML\SAML2\XML\md\AuthnQueryService;
@@ -15,21 +22,21 @@
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
use function dirname;
use function strval;
/**
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AuthnAuthorityDescriptor
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AuthnAuthorityDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptorType::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMdElement::class)]
final class AuthnAuthorityDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -163,20 +170,6 @@ public function testMarshallingWithWrongAssertionIDRequestService(): void
// test unmarshalling
- /**
- * Test creating an AuthnAuthorityDescriptor from XML.
- */
- public function testUnmarshalling(): void
- {
- $aad = AuthnAuthorityDescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($aad),
- );
- }
-
-
/**
* Test that creating an AuthnAuthorityDescriptor from XML fails if no AuthnQueryService was provided.
*/
diff --git a/tests/SAML2/XML/md/CompanyTest.php b/tests/SAML2/XML/md/CompanyTest.php
index 8b182c8fe..ee82ee6d0 100644
--- a/tests/SAML2/XML/md/CompanyTest.php
+++ b/tests/SAML2/XML/md/CompanyTest.php
@@ -4,9 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\Company;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,10 +19,11 @@
/**
* Tests for Company.
*
- * @covers \SimpleSAML\SAML2\XML\md\Company
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(Company::class)]
+#[CoversClass(AbstractMdElement::class)]
final class CompanyTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -57,21 +59,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a Company from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = Company::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/md/ContactPersonTest.php b/tests/SAML2/XML/md/ContactPersonTest.php
index 493644e03..63500d7d4 100644
--- a/tests/SAML2/XML/md/ContactPersonTest.php
+++ b/tests/SAML2/XML/md/ContactPersonTest.php
@@ -5,12 +5,14 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\XML\md\ContactPerson;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\Company;
+use SimpleSAML\SAML2\XML\md\ContactPerson;
use SimpleSAML\SAML2\XML\md\EmailAddress;
use SimpleSAML\SAML2\XML\md\Extensions;
use SimpleSAML\SAML2\XML\md\GivenName;
@@ -23,7 +25,6 @@
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
@@ -31,10 +32,11 @@
/**
* Tests for the ContactPerson class.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\ContactPerson
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(ContactPerson::class)]
+#[CoversClass(AbstractMdElement::class)]
final class ContactPersonTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -42,7 +44,7 @@ final class ContactPersonTest extends TestCase
use SerializableElementTestTrait;
/** @var \DOMDocument */
- protected static DOMDocument $ext;
+ private static DOMDocument $ext;
/**
@@ -130,20 +132,6 @@ public function testMarshallingWithWrongType(): void
// test unmarshalling
- /**
- * Test creating a ContactPerson from XML.
- */
- public function testUnmarshalling(): void
- {
- $contactPerson = ContactPerson::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($contactPerson),
- );
- }
-
-
/**
* Test that creating a ContactPerson from XML without a contactType attribute fails.
*/
diff --git a/tests/SAML2/XML/md/EmailAddressTest.php b/tests/SAML2/XML/md/EmailAddressTest.php
index bf369fddc..638eb35c5 100644
--- a/tests/SAML2/XML/md/EmailAddressTest.php
+++ b/tests/SAML2/XML/md/EmailAddressTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\EmailAddress;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -16,10 +18,11 @@
/**
* Tests for EmailAddress.
*
- * @covers \SimpleSAML\SAML2\XML\md\EmailAddress
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(EmailAddress::class)]
+#[CoversClass(AbstractMdElement::class)]
final class EmailAddressTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -51,11 +54,11 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $name = new EmailAddress('john.doe@example.org');
+ $email = new EmailAddress('john.doe@example.org');
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
+ strval($email),
);
}
@@ -73,20 +76,6 @@ public function testInvalidEmailThrowsException(): void
// test unmarshalling
- /**
- * Test creating a EmailAddress from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = EmailAddress::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating an EmailAddress from XML fails when an invalid email address is found.
*/
@@ -100,4 +89,17 @@ public function testUnmarshallingWithInvalidEmail(): void
EmailAddress::fromXML($document->documentElement);
}
+
+
+ /**
+ * Test that creating an EmailAddress from XML succeeds when multiple mailto: prefixes are in place.
+ */
+ public function testUnmarshallingWithMultipleMailtoUri(): void
+ {
+ $document = clone self::$xmlRepresentation;
+ $document->documentElement->textContent = 'mailto:mailto:mailto:john.doe@example.org';
+
+ $email = EmailAddress::fromXML($document->documentElement);
+ $this->assertEquals('mailto:john.doe@example.org', $email->getContent());
+ }
}
diff --git a/tests/SAML2/XML/md/EncryptionMethodTest.php b/tests/SAML2/XML/md/EncryptionMethodTest.php
index d16c15ede..455990dbb 100644
--- a/tests/SAML2/XML/md/EncryptionMethodTest.php
+++ b/tests/SAML2/XML/md/EncryptionMethodTest.php
@@ -4,11 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\EncryptionMethod;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -24,11 +25,11 @@
/**
* Tests for the md:EncryptionMethod element.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\EncryptionMethod
- * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractEncryptionMethod
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(EncryptionMethod::class)]
+#[CoversClass(AbstractMdElement::class)]
final class EncryptionMethodTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -122,20 +123,6 @@ public function testMarshallingElementOrdering(): void
// test unmarshalling
- /**
- * Test creating an EncryptionMethod object from XML.
- */
- public function testUnmarshalling(): void
- {
- $encryptionMethod = EncryptionMethod::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($encryptionMethod),
- );
- }
-
-
/**
* Test that creating an EncryptionMethod object from XML without an Algorithm attribute fails.
*/
diff --git a/tests/SAML2/XML/md/EndpointTypeTest.php b/tests/SAML2/XML/md/EndpointTypeTest.php
index 8a05d85c1..941e68b67 100644
--- a/tests/SAML2/XML/md/EndpointTypeTest.php
+++ b/tests/SAML2/XML/md/EndpointTypeTest.php
@@ -5,31 +5,35 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractEndpointType;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\AssertionIDRequestService;
use SimpleSAML\SAML2\XML\md\AttributeService;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\Exception\SchemaViolationException;
-use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
+use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\md\EndpointTypeTest
+ * Class \SimpleSAML\SAML2\XML\md\EndpointTypeTest
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractEndpointType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AbstractEndpointType::class)]
+#[CoversClass(AbstractMdElement::class)]
final class EndpointTypeTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -37,7 +41,7 @@ final class EndpointTypeTest extends TestCase
use SerializableElementTestTrait;
/** @var \DOMDocument */
- protected static DOMDocument $ext;
+ private static DOMDocument $ext;
/**
@@ -74,7 +78,7 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $attr = new XMLAttribute('urn:x-simplesamlphp:namespace', 'test', 'attr', 'value');
+ $attr = new XMLAttribute(C::NAMESPACE, 'test', 'attr', 'value');
$endpointType = new AttributeService(
C::BINDING_HTTP_POST,
@@ -97,7 +101,7 @@ public function testMarshalling(): void
public function testMarshallingWithEmptyBinding(): void
{
$this->expectException(SchemaViolationException::class);
- new AttributeService('', 'https://simplesamlphp.org/some/endpoint');
+ new AttributeService('', C::LOCATION_A);
}
@@ -116,7 +120,7 @@ public function testMarshallingWithEmptyLocation(): void
*/
public function testMarshallingWithoutOptionalAttributes(): void
{
- $endpointType = new AttributeService(C::BINDING_HTTP_POST, 'https://simplesamlphp.org/some/endpoint');
+ $endpointType = new AttributeService(C::BINDING_HTTP_POST, C::LOCATION_A);
$this->assertNull($endpointType->getResponseLocation());
$this->assertEmpty($endpointType->getAttributesNS());
}
@@ -125,20 +129,6 @@ public function testMarshallingWithoutOptionalAttributes(): void
// test unmarshalling
- /**
- * Test creating an EndpointType from XML.
- */
- public function testUnmarshalling(): void
- {
- $endpointType = AttributeService::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($endpointType),
- );
- }
-
-
/**
* Test that creating an EndpointType from XML checks the actual name of the endpoint.
*/
@@ -216,7 +206,7 @@ public function testUnmarshallingWithEmptyLocation(): void
public function testUnmarshallingWithoutOptionalAttributes(): void
{
$mdNamespace = C::NS_MD;
- $location = 'https://simplesamlphp.org/some/endpoint';
+ $location = C::LOCATION_A;
$document = DOMDocumentFactory::fromString(<<
diff --git a/tests/SAML2/XML/md/EntitiesDescriptorTest.php b/tests/SAML2/XML/md/EntitiesDescriptorTest.php
index e0421df64..6f4d86443 100644
--- a/tests/SAML2/XML/md/EntitiesDescriptorTest.php
+++ b/tests/SAML2/XML/md/EntitiesDescriptorTest.php
@@ -5,20 +5,23 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use DateTimeImmutable;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\XML\md\EntityDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\EntitiesDescriptor;
+use SimpleSAML\SAML2\XML\md\EntityDescriptor;
use SimpleSAML\SAML2\XML\md\Extensions;
use SimpleSAML\SAML2\XML\mdrpi\PublicationInfo;
use SimpleSAML\SAML2\XML\mdrpi\UsagePolicy;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
-use SimpleSAML\XMLSecurity\XMLSecurityDSig;
use function dirname;
use function strval;
@@ -26,12 +29,13 @@
/**
* Tests for the md:EntitiesDescriptor element.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\EntitiesDescriptor
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(EntitiesDescriptor::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractMdElement::class)]
final class EntitiesDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -149,20 +153,6 @@ public function testMarshallingEmpty(): void
// test unmarshalling
- /**
- * Test creating an EntitiesDescriptor from XML.
- */
- public function testUnmarshalling(): void
- {
- $entitiesd = EntitiesDescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($entitiesd),
- );
- }
-
-
/**
* Test that creating an EntitiesDescriptor without Name from XML works.
*/
diff --git a/tests/SAML2/XML/md/EntityDescriptorTest.php b/tests/SAML2/XML/md/EntityDescriptorTest.php
index 0f6293ef0..63c8f18bd 100644
--- a/tests/SAML2/XML/md/EntityDescriptorTest.php
+++ b/tests/SAML2/XML/md/EntityDescriptorTest.php
@@ -6,12 +6,17 @@
use DateTimeImmutable;
use DOMText;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\AdditionalMetadataLocation;
-use SimpleSAML\SAML2\XML\md\AffiliationDescriptor;
use SimpleSAML\SAML2\XML\md\AffiliateMember;
+use SimpleSAML\SAML2\XML\md\AffiliationDescriptor;
use SimpleSAML\SAML2\XML\md\AttributeAuthorityDescriptor;
use SimpleSAML\SAML2\XML\md\AttributeService;
use SimpleSAML\SAML2\XML\md\AuthnAuthorityDescriptor;
@@ -39,7 +44,6 @@
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
use function dirname;
@@ -47,15 +51,15 @@
use function strval;
/**
- * Class \SAML2\XML\md\EntityDescriptorTest
- *
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\EntityDescriptor
+ * Class \SimpleSAML\SAML2\XML\md\EntityDescriptorTest
*
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(EntityDescriptor::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractMdElement::class)]
final class EntityDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
diff --git a/tests/SAML2/XML/md/ExtensionsTest.php b/tests/SAML2/XML/md/ExtensionsTest.php
index 4437a1416..d305ac897 100644
--- a/tests/SAML2/XML/md/ExtensionsTest.php
+++ b/tests/SAML2/XML/md/ExtensionsTest.php
@@ -4,7 +4,8 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
@@ -13,10 +14,11 @@
use SimpleSAML\SAML2\XML\emd\RepublishRequest;
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
use SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponse;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\Extensions;
use SimpleSAML\SAML2\XML\mdattr\EntityAttributes;
-use SimpleSAML\SAML2\XML\mdrpi\PublicationInfo;
use SimpleSAML\SAML2\XML\mdrpi\Publication;
+use SimpleSAML\SAML2\XML\mdrpi\PublicationInfo;
use SimpleSAML\SAML2\XML\mdrpi\PublicationPath;
use SimpleSAML\SAML2\XML\mdrpi\RegistrationInfo;
use SimpleSAML\SAML2\XML\mdui\DiscoHints;
@@ -34,14 +36,15 @@
use function strval;
/**
- * Class \SAML2\XML\md\ExtensionsTest.
+ * Class \SimpleSAML\SAML2\XML\md\ExtensionsTest.
*
* This class tests for currently supported metadata extensions.
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- * @covers \SimpleSAML\SAML2\XML\md\Extensions
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(Extensions::class)]
+#[CoversClass(AbstractMdElement::class)]
final class ExtensionsTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -116,7 +119,7 @@ public function testMarshallingWithNoExtensions(): void
'',
strval($extensions),
);
- //$this->assertTrue($extensions->isEmptyElement());
+ $this->assertTrue($extensions->isEmptyElement());
}
@@ -175,7 +178,8 @@ public function testUnmarshalling(): void
127.0.0.1
+ Location="https://example.org/authenticate/sp"
+ index="1"/>
@@ -200,7 +204,7 @@ public function testUnmarshalling(): void
$this->assertInstanceOf(SigningMethod::class, $list[9]);
$this->assertInstanceOf(RepublishRequest::class, $list[10]);
$this->assertInstanceOf(Chunk::class, $list[11]);
- //$this->assertFalse($extensions->isEmptyElement());
+ $this->assertFalse($extensions->isEmptyElement());
}
diff --git a/tests/SAML2/XML/md/GivenNameTest.php b/tests/SAML2/XML/md/GivenNameTest.php
index b43aeb8cb..fa8fe6b43 100644
--- a/tests/SAML2/XML/md/GivenNameTest.php
+++ b/tests/SAML2/XML/md/GivenNameTest.php
@@ -4,9 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\GivenName;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,10 +19,11 @@
/**
* Tests for GivenName.
*
- * @covers \SimpleSAML\SAML2\XML\md\GivenName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(GivenName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class GivenNameTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -57,21 +59,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a GivenName from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = GivenName::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/md/IDPSSODescriptorTest.php b/tests/SAML2/XML/md/IDPSSODescriptorTest.php
index 5d30febbe..527bd40cc 100644
--- a/tests/SAML2/XML/md/IDPSSODescriptorTest.php
+++ b/tests/SAML2/XML/md/IDPSSODescriptorTest.php
@@ -4,17 +4,23 @@
namespace SimpleSAML\Test\SAML2\XML\md;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
+use SimpleSAML\SAML2\XML\md\ArtifactResolutionService;
use SimpleSAML\SAML2\XML\md\AssertionIDRequestService;
use SimpleSAML\SAML2\XML\md\AttributeProfile;
-use SimpleSAML\SAML2\XML\md\ArtifactResolutionService;
use SimpleSAML\SAML2\XML\md\IDPSSODescriptor;
use SimpleSAML\SAML2\XML\md\KeyDescriptor;
use SimpleSAML\SAML2\XML\md\ManageNameIDService;
-use SimpleSAML\SAML2\XML\md\NameIDMappingService;
use SimpleSAML\SAML2\XML\md\NameIDFormat;
+use SimpleSAML\SAML2\XML\md\NameIDMappingService;
use SimpleSAML\SAML2\XML\md\SingleLogoutService;
use SimpleSAML\SAML2\XML\md\SingleSignOnService;
use SimpleSAML\SAML2\XML\saml\Attribute;
@@ -34,14 +40,15 @@
/**
* Tests for IDPSSODescriptor.
*
- * @covers \SimpleSAML\SAML2\XML\md\IDPSSODescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSSODescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(IDPSSODescriptor::class)]
+#[CoversClass(AbstractRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptorType::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMdElement::class)]
final class IDPSSODescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -185,25 +192,6 @@ public function testMarshallingWithEmptySingleSignOnService(): void
}
- /**
- * Test that creating an IDPSSODescriptor from scratch fails if SingleSignOnService endpoints passed have the
- * wrong type.
- */
- public function testMarshallingWithWrongSingleSignOnService(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'All md:SingleSignOnService endpoints must be an instance of SingleSignOnService.',
- );
-
- /** @psalm-suppress InvalidArgument */
- new IDPSSODescriptor(
- [new AssertionIDRequestService(C::BINDING_HTTP_POST, C::LOCATION_A)],
- [C::NS_SAMLP],
- );
- }
-
-
/**
* Test that creating an IDPSSODescriptor from scratch fails if no protocol is passed.
*/
@@ -212,7 +200,6 @@ public function testMarshallingWithoutProtocolSupportThrowsException(): void
$this->expectException(AssertionFailedException::class);
$this->expectExceptionMessage('At least one protocol must be supported by this md:IDPSSODescriptor.');
- /** @psalm-suppress InvalidArgument */
new IDPSSODescriptor(
[new SingleSignOnService(C::BINDING_HTTP_POST, C::LOCATION_A)],
[],
@@ -220,47 +207,6 @@ public function testMarshallingWithoutProtocolSupportThrowsException(): void
}
- /**
- * Test that creating an IDPSSODescriptor from scratch fails if NameIDMappingService endpoints passed have the
- * wrong type.
- */
- public function testMarshallingWithWrongNameIDMappingService(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'All md:NameIDMappingService endpoints must be an instance of NameIDMappingService.',
- );
-
- /** @psalm-suppress InvalidArgument */
- new IDPSSODescriptor(
- singleSignOnService: [new SingleSignOnService(C::BINDING_HTTP_POST, C::LOCATION_A)],
- protocolSupportEnumeration: [C::NS_SAMLP],
- nameIDMappingService: [new SingleSignOnService(C::BINDING_HTTP_REDIRECT, C::LOCATION_B)],
- );
- }
-
-
- /**
- * Test that creating an IDPSSODescriptor from scratch fails if AssertionIDRequestService endpoints passed have the
- * wrong type.
- */
- public function testMarshallingWithWrongAssertionIDRequestService(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'All md:AssertionIDRequestService endpoints must be an instance of AssertionIDRequestService.',
- );
-
- /** @psalm-suppress InvalidArgument */
- new IDPSSODescriptor(
- singleSignOnService: [new SingleSignOnService(C::BINDING_HTTP_POST, C::LOCATION_A)],
- protocolSupportEnumeration: [C::NS_SAMLP],
- nameIDMappingService: [],
- assertionIDRequestService: [new SingleSignOnService(C::BINDING_HTTP_REDIRECT, C::LOCATION_B)],
- );
- }
-
-
/**
* Test that creating an IDPSSODescriptor from scratch fails if an empty AttributeProfile is provided.
*/
@@ -275,23 +221,6 @@ public function testMarshallingWithEmptyAttributeProfile(): void
}
- /**
- * Test that creating an IDPSSODescriptor from scratch fails if attributes passed have the wrong type.
- */
- public function testMarshallingWithWrongAttributes(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage('All md:Attribute elements must be an instance of Attribute.');
-
- /** @psalm-suppress InvalidArgument */
- new IDPSSODescriptor(
- singleSignOnService: [new SingleSignOnService(C::BINDING_HTTP_POST, C::LOCATION_A)],
- protocolSupportEnumeration: [C::NS_SAMLP],
- attribute: [new SingleSignOnService(C::BINDING_HTTP_REDIRECT, C::LOCATION_B)]
- );
- }
-
-
/**
* Test that creating an IDPSSODescriptor from scratch works if no optional arguments are provided.
*/
@@ -314,20 +243,6 @@ public function testMarshallingWithoutOptionalArguments(): void
// test unmarshalling
- /**
- * Test creating an IDPSSODescriptor from XML.
- */
- public function testUnmarshalling(): void
- {
- $idpssod = IDPSSODescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($idpssod),
- );
- }
-
-
/**
* Test that creating an IDPSSODescriptor from XML fails if no SingleSignOnService endpoint is provided.
*/
@@ -335,9 +250,7 @@ public function testUnmarshallingWithoutSingleSignOnService(): void
{
$xmlRepresentation = clone self::$xmlRepresentation;
$ssoServiceEps = $xmlRepresentation->getElementsByTagNameNS(C::NS_MD, 'SingleSignOnService');
- /** @psalm-suppress PossiblyNullArgument */
$xmlRepresentation->documentElement->removeChild($ssoServiceEps->item(1));
- /** @psalm-suppress PossiblyNullArgument */
$xmlRepresentation->documentElement->removeChild($ssoServiceEps->item(0));
$this->expectException(AssertionFailedException::class);
@@ -371,7 +284,6 @@ public function testUnmarshallingWithEmptyAttributeProfile(): void
{
$xmlRepresentation = clone self::$xmlRepresentation;
$attrProfiles = $xmlRepresentation->getElementsByTagNameNS(C::NS_MD, 'AttributeProfile');
- /** @psalm-suppress PossiblyNullPropertyAssignment */
$attrProfiles->item(0)->textContent = '';
$this->expectException(SchemaViolationException::class);
diff --git a/tests/SAML2/XML/md/IndexedEndpointTypeTest.php b/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
index ef267594a..9007a7ab4 100644
--- a/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
+++ b/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
@@ -4,33 +4,35 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponse;
+use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\ArtifactResolutionService;
use SimpleSAML\SAML2\XML\md\AssertionConsumerService;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingAttributeException;
use function dirname;
use function sprintf;
-use function strval;
/**
- * Class \SAML2\XML\md\IndexedEndpointTypeTest
+ * Class \SimpleSAML\SAML2\XML\md\IndexedEndpointTypeTest
*
- * @covers \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(AbstractIndexedEndpointType::class)]
+#[CoversClass(AbstractMdElement::class)]
final class IndexedEndpointTypeTest extends TestCase
{
- protected static string $resourcePath;
-
- protected DOMDocument $xmlRepresentation;
+ private static string $resourcePath;
/**
@@ -48,13 +50,12 @@ public static function setUpBeforeClass(): void
* Test that creating an IndexedEndpointType from scratch without specifying isDefault works.
*
* @param class-string $class
- *
- * @dataProvider classProvider
*/
+ #[DataProvider('classProvider')]
public function testMarshallingWithoutIsDefault(string $class): void
{
$binding = ($class === DiscoveryResponse::class) ? C::BINDING_IDPDISC : C::BINDING_HTTP_POST;
- $idxep = new $class(42, $binding, 'https://simplesamlphp.org/some/endpoint');
+ $idxep = new $class(42, $binding, C::LOCATION_A);
$this->assertNull($idxep->getIsDefault());
}
@@ -67,9 +68,8 @@ public function testMarshallingWithoutIsDefault(string $class): void
*
* @param class-string $class
* @param string $xmlRepresentation
- *
- * @dataProvider classProvider
*/
+ #[DataProvider('classProvider')]
public function testUnmarshallingWithNumericString(string $class, string $xmlRepresentation): void
{
$xmlRepresentation = DOMDocumentFactory::fromFile(
@@ -87,7 +87,7 @@ public function testUnmarshallingWithNumericString(string $class, string $xmlRep
*/
public function testUnmarshallingUnexpectedEndpoint(): void
{
- $this->xmlRepresentation = DOMDocumentFactory::fromFile(
+ $xmlRepresentation = DOMDocumentFactory::fromFile(
self::$resourcePath . 'md_AssertionConsumerService.xml',
);
@@ -95,7 +95,8 @@ public function testUnmarshallingUnexpectedEndpoint(): void
$this->expectExceptionMessage(
'Unexpected name for endpoint: AssertionConsumerService. Expected: ArtifactResolutionService.',
);
- ArtifactResolutionService::fromXML($this->xmlRepresentation->documentElement);
+
+ ArtifactResolutionService::fromXML($xmlRepresentation->documentElement);
}
@@ -104,14 +105,14 @@ public function testUnmarshallingUnexpectedEndpoint(): void
*
* @param class-string $class
* @param string $xmlRepresentation
- *
- * @dataProvider classProvider
*/
+ #[DataProvider('classProvider')]
public function testUnmarshallingWithoutIndex(string $class, string $xmlRepresentation): void
{
- $this->xmlRepresentation = DOMDocumentFactory::fromFile(
+ $xmlRepresentation = DOMDocumentFactory::fromFile(
self::$resourcePath . $xmlRepresentation,
);
+ $xmlRepresentation->documentElement->removeAttribute('index');
$this->expectException(MissingAttributeException::class);
$this->expectExceptionMessage(sprintf(
@@ -119,8 +120,8 @@ public function testUnmarshallingWithoutIndex(string $class, string $xmlRepresen
$class::getNamespacePrefix(),
$class::getLocalName(),
));
- $this->xmlRepresentation->documentElement->removeAttribute('index');
- $class::fromXML($this->xmlRepresentation->documentElement);
+
+ $class::fromXML($xmlRepresentation->documentElement);
}
@@ -129,14 +130,14 @@ public function testUnmarshallingWithoutIndex(string $class, string $xmlRepresen
*
* @param class-string $class
* @param string $xmlRepresentation
- *
- * @dataProvider classProvider
*/
+ #[DataProvider('classProvider')]
public function testUnmarshallingWithWrongIndex(string $class, string $xmlRepresentation): void
{
- $this->xmlRepresentation = DOMDocumentFactory::fromFile(
+ $xmlRepresentation = DOMDocumentFactory::fromFile(
self::$resourcePath . $xmlRepresentation,
);
+ $xmlRepresentation->documentElement->setAttribute('index', 'value');
$this->expectException(AssertionFailedException::class);
$this->expectExceptionMessage(sprintf(
@@ -144,8 +145,8 @@ public function testUnmarshallingWithWrongIndex(string $class, string $xmlRepres
$class::getNamespacePrefix(),
$class::getLocalName(),
));
- $this->xmlRepresentation->documentElement->setAttribute('index', 'value');
- $class::fromXML($this->xmlRepresentation->documentElement);
+
+ $class::fromXML($xmlRepresentation->documentElement);
}
@@ -154,18 +155,16 @@ public function testUnmarshallingWithWrongIndex(string $class, string $xmlRepres
*
* @param class-string $class
* @param string $xmlRepresentation
- *
- * @dataProvider classProvider
*/
+ #[DataProvider('classProvider')]
public function testUnmarshallingWithoutIsDefault(string $class, string $xmlRepresentation): void
{
- $this->xmlRepresentation = DOMDocumentFactory::fromFile(
+ $xmlRepresentation = DOMDocumentFactory::fromFile(
self::$resourcePath . $xmlRepresentation,
);
-
- $this->xmlRepresentation->documentElement->removeAttribute('isDefault');
- $acs = $class::fromXML($this->xmlRepresentation->documentElement);
+ $xmlRepresentation->documentElement->removeAttribute('isDefault');
+ $acs = $class::fromXML($xmlRepresentation->documentElement);
$this->assertNull($acs->getIsDefault());
}
@@ -175,14 +174,14 @@ public function testUnmarshallingWithoutIsDefault(string $class, string $xmlRepr
*
* @param class-string $class
* @param string $xmlRepresentation
- *
- * @dataProvider classProvider
*/
+ #[DataProvider('classProvider')]
public function testUnmarshallingWithWrongIsDefault(string $class, string $xmlRepresentation): void
{
- $this->xmlRepresentation = DOMDocumentFactory::fromFile(
+ $xmlRepresentation = DOMDocumentFactory::fromFile(
self::$resourcePath . $xmlRepresentation,
);
+ $xmlRepresentation->documentElement->setAttribute('isDefault', 'non-bool');
$this->expectException(AssertionFailedException::class);
$this->expectExceptionMessage(sprintf(
@@ -190,8 +189,8 @@ public function testUnmarshallingWithWrongIsDefault(string $class, string $xmlRe
$class::getNamespacePrefix(),
$class::getLocalName(),
));
- $this->xmlRepresentation->documentElement->setAttribute('isDefault', 'non-bool');
- $class::fromXML($this->xmlRepresentation->documentElement);
+
+ $class::fromXML($xmlRepresentation->documentElement);
}
diff --git a/tests/SAML2/XML/md/KeyDescriptorTest.php b/tests/SAML2/XML/md/KeyDescriptorTest.php
index 1a92809e5..77a6ed38d 100644
--- a/tests/SAML2/XML/md/KeyDescriptorTest.php
+++ b/tests/SAML2/XML/md/KeyDescriptorTest.php
@@ -4,15 +4,16 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\EncryptionMethod;
use SimpleSAML\SAML2\XML\md\KeyDescriptor;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
@@ -22,10 +23,11 @@
/**
* A set of tests for the md:KeyDescriptor element
*
- * @covers \SimpleSAML\SAML2\XML\md\KeyDescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(KeyDescriptor::class)]
+#[CoversClass(AbstractMdElement::class)]
final class KeyDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -109,20 +111,6 @@ public function testMarshallingWithoutOptionalParameters(): void
// test unmarshalling
- /**
- * Test creating a KeyDescriptor from XML.
- */
- public function testUnmarshalling(): void
- {
- $kd = KeyDescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($kd),
- );
- }
-
-
/**
* Test that creating a KeyDescriptor from XML with a wrong use fails.
*/
diff --git a/tests/SAML2/XML/md/NameIDFormatTest.php b/tests/SAML2/XML/md/NameIDFormatTest.php
index e6e7570ac..91d100277 100644
--- a/tests/SAML2/XML/md/NameIDFormatTest.php
+++ b/tests/SAML2/XML/md/NameIDFormatTest.php
@@ -4,11 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
-use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\NameIDFormat;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -20,10 +20,11 @@
/**
* Class \SimpleSAML\SAML2\XML\md\NameIDFormatTest
*
- * @covers \SimpleSAML\SAML2\XML\md\NameIDFormat
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(NameIDFormat::class)]
+#[CoversClass(AbstractMdElement::class)]
final class NameIDFormatTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -58,20 +59,4 @@ public function testMarshalling(): void
strval($nameIdFormat),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $nameIdFormat = NameIDFormat::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($nameIdFormat),
- );
- }
}
diff --git a/tests/SAML2/XML/md/NameIDMappingServiceTest.php b/tests/SAML2/XML/md/NameIDMappingServiceTest.php
index 625d62a7d..a2293b998 100644
--- a/tests/SAML2/XML/md/NameIDMappingServiceTest.php
+++ b/tests/SAML2/XML/md/NameIDMappingServiceTest.php
@@ -4,11 +4,13 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\NameIDMappingService;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -19,10 +21,11 @@
/**
* Tests for md:NameIDMappingService.
*
- * @covers \SimpleSAML\SAML2\XML\md\NameIDMappingService
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(NameIDMappingService::class)]
+#[CoversClass(AbstractMdElement::class)]
final class NameIDMappingServiceTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -51,7 +54,7 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $nidmsep = new NameIDMappingService(C::BINDING_HTTP_POST, 'https://simplesamlphp.org/some/endpoint');
+ $nidmsep = new NameIDMappingService(C::BINDING_HTTP_POST, C::LOCATION_A);
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
@@ -69,31 +72,13 @@ public function testMarshallingWithResponseLocation(): void
$this->expectExceptionMessage(
'The \'ResponseLocation\' attribute must be omitted for md:NameIDMappingService.',
);
- new NameIDMappingService(
- C::BINDING_HTTP_POST,
- 'https://simplesamlphp.org/some/endpoint',
- 'https://response.location/',
- );
+ new NameIDMappingService(C::BINDING_HTTP_POST, C::LOCATION_A, 'https://response.location/');
}
// test unmarshalling
- /**
- * Test creating a NameIDMappingService from XML.
- */
- public function testUnmarshalling(): void
- {
- $nidmsep = NameIDMappingService::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($nidmsep),
- );
- }
-
-
/**
* Test that creating a NameIDMappingService from XML fails when ResponseLocation is present.
*/
diff --git a/tests/SAML2/XML/md/OrganizationDisplayNameTest.php b/tests/SAML2/XML/md/OrganizationDisplayNameTest.php
index 82b5f2e39..3c0cdb9fc 100644
--- a/tests/SAML2/XML/md/OrganizationDisplayNameTest.php
+++ b/tests/SAML2/XML/md/OrganizationDisplayNameTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\OrganizationDisplayName;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -20,11 +21,12 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\md\OrganizationDisplayName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(OrganizationDisplayName::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class OrganizationDisplayNameTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -63,21 +65,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a OrganizationDisplayName from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = OrganizationDisplayName::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/md/OrganizationNameTest.php b/tests/SAML2/XML/md/OrganizationNameTest.php
index d0f0bfc84..7e332aeed 100644
--- a/tests/SAML2/XML/md/OrganizationNameTest.php
+++ b/tests/SAML2/XML/md/OrganizationNameTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\OrganizationName;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -20,11 +21,12 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\md\OrganizationName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(OrganizationName::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class OrganizationNameTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -63,21 +65,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a OrganizationName from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = OrganizationName::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/md/OrganizationTest.php b/tests/SAML2/XML/md/OrganizationTest.php
index 164f3a67b..9578b3966 100644
--- a/tests/SAML2/XML/md/OrganizationTest.php
+++ b/tests/SAML2/XML/md/OrganizationTest.php
@@ -5,16 +5,19 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\Extensions;
use SimpleSAML\SAML2\XML\md\Organization;
use SimpleSAML\SAML2\XML\md\OrganizationDisplayName;
use SimpleSAML\SAML2\XML\md\OrganizationName;
use SimpleSAML\SAML2\XML\md\OrganizationURL;
-use SimpleSAML\XML\Attribute;
+use SimpleSAML\Test\SAML2\Constants as C;
+use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -25,10 +28,11 @@
/**
* Test for the Organization metadata element.
*
- * @covers \SimpleSAML\SAML2\XML\md\Organization
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(Organization::class)]
+#[CoversClass(AbstractMdElement::class)]
final class OrganizationTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -36,7 +40,7 @@ final class OrganizationTest extends TestCase
use SerializableElementTestTrait;
/** @var \DOMDocument */
- protected static DOMDocument $ext;
+ private static DOMDocument $ext;
/**
@@ -89,6 +93,7 @@ public function testMarshalling(): void
new Chunk(self::$ext->documentElement),
],
),
+ [new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1')],
);
$root = DOMDocumentFactory::fromString('');
$root->formatOutput = true;
@@ -98,21 +103,4 @@ public function testMarshalling(): void
strval($org),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating an Organization object from XML
- */
- public function testUnmarshalling(): void
- {
- $org = Organization::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($org),
- );
- }
}
diff --git a/tests/SAML2/XML/md/OrganizationURLTest.php b/tests/SAML2/XML/md/OrganizationURLTest.php
index c810c4555..32c641280 100644
--- a/tests/SAML2/XML/md/OrganizationURLTest.php
+++ b/tests/SAML2/XML/md/OrganizationURLTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\OrganizationURL;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -21,13 +23,13 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\md\OrganizationURL
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedURI
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(OrganizationURL::class)]
+#[CoversClass(AbstractLocalizedURI::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class OrganizationURLTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -71,20 +73,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a OrganizationURL from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = OrganizationURL::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating a OrganizationURL with an invalid url throws an exception
*/
diff --git a/tests/SAML2/XML/md/PDPDescriptorTest.php b/tests/SAML2/XML/md/PDPDescriptorTest.php
index db6fa4a42..c53bdfec8 100644
--- a/tests/SAML2/XML/md/PDPDescriptorTest.php
+++ b/tests/SAML2/XML/md/PDPDescriptorTest.php
@@ -4,10 +4,16 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\AssertionIDRequestService;
use SimpleSAML\SAML2\XML\md\AuthzService;
use SimpleSAML\SAML2\XML\md\NameIDFormat;
@@ -23,13 +29,15 @@
/**
* Tests for md:PDPDescriptor
*
- * @covers \SimpleSAML\SAML2\XML\md\PDPDescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(PDPDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptorType::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMdElement::class)]
final class PDPDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -146,20 +154,6 @@ public function testMarshallingWithoutOptionalArguments(): void
// test unmarshalling
- /**
- * Test creating a PDPDescriptor object from XML.
- */
- public function testUnmarshalling(): void
- {
- $pdpd = PDPDescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($pdpd),
- );
- }
-
-
/**
* Test that creating a PDPDescriptor from XML fails when there's no AuthzService endpoint.
*/
diff --git a/tests/SAML2/XML/md/RequestedAttributeTest.php b/tests/SAML2/XML/md/RequestedAttributeTest.php
index fa861a076..7474edc2f 100644
--- a/tests/SAML2/XML/md/RequestedAttributeTest.php
+++ b/tests/SAML2/XML/md/RequestedAttributeTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\RequestedAttribute;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -20,10 +22,11 @@
/**
* Test for the RequestedAttribute metadata element.
*
- * @covers \SimpleSAML\SAML2\XML\md\RequestedAttribute
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(RequestedAttribute::class)]
+#[CoversClass(AbstractMdElement::class)]
final class RequestedAttributeTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -84,20 +87,6 @@ public function testMarshallingWithoutOptionalArguments(): void
// test unmarshalling
- /**
- * Test creating a RequestedAttribute object from XML
- */
- public function testUnmarshalling(): void
- {
- $ra = RequestedAttribute::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($ra),
- );
- }
-
-
/**
* Test that creating a RequestedAttribute object from XML works when isRequired is missing.
*/
diff --git a/tests/SAML2/XML/md/RoleDescriptorTest.php b/tests/SAML2/XML/md/RoleDescriptorTest.php
index 0be052d02..041d6bbfc 100644
--- a/tests/SAML2/XML/md/RoleDescriptorTest.php
+++ b/tests/SAML2/XML/md/RoleDescriptorTest.php
@@ -5,14 +5,16 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use DateTimeImmutable;
-use DOMAttr;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\Company;
use SimpleSAML\SAML2\XML\md\ContactPerson;
use SimpleSAML\SAML2\XML\md\EmailAddress;
@@ -27,7 +29,6 @@
use SimpleSAML\SAML2\XML\md\SurName;
use SimpleSAML\SAML2\XML\md\TelephoneNumber;
use SimpleSAML\SAML2\XML\md\UnknownRoleDescriptor;
-use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\Test\SAML2\CustomRoleDescriptor;
use SimpleSAML\XML\Attribute as XMLAttribute;
@@ -46,15 +47,15 @@
/**
* This is a test for the UnknownRoleDescriptor class.
*
- * @covers \SimpleSAML\SAML2\XML\md\UnknownRoleDescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(UnknownRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptorType::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMdElement::class)]
final class RoleDescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
diff --git a/tests/SAML2/XML/md/SPSSODescriptorTest.php b/tests/SAML2/XML/md/SPSSODescriptorTest.php
index 0c95f224f..c1c1ffa9f 100644
--- a/tests/SAML2/XML/md/SPSSODescriptorTest.php
+++ b/tests/SAML2/XML/md/SPSSODescriptorTest.php
@@ -5,9 +5,15 @@
namespace SimpleSAML\Test\SAML2\XML\md;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
+use SimpleSAML\SAML2\XML\md\AbstractMetadataDocument;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor;
+use SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType;
+use SimpleSAML\SAML2\XML\md\AbstractSignedMdElement;
use SimpleSAML\SAML2\XML\md\ArtifactResolutionService;
use SimpleSAML\SAML2\XML\md\AssertionConsumerService;
use SimpleSAML\SAML2\XML\md\AttributeConsumingService;
@@ -32,7 +38,6 @@
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
@@ -43,14 +48,15 @@
/**
* Tests for the md:SPSSODescriptor element.
*
- * @covers \SimpleSAML\SAML2\XML\md\SPSSODescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSSODescriptor
- * @covers \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMetadataDocument
- * @covers \SimpleSAML\SAML2\XML\md\AbstractSignedMdElement
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(SPSSODescriptor::class)]
+#[CoversClass(AbstractRoleDescriptor::class)]
+#[CoversClass(AbstractRoleDescriptorType::class)]
+#[CoversClass(AbstractMetadataDocument::class)]
+#[CoversClass(AbstractSignedMdElement::class)]
+#[CoversClass(AbstractMdElement::class)]
final class SPSSODescriptorTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -179,44 +185,6 @@ public function testMarshallingWithoutAssertionConsumerService(): void
}
- /**
- * Test that creating an SPSSODescriptor from scratch fails with an AssertionConsumerService of the wrong class.
- */
- public function testMarshallingWithWrongAssertionConsumerService(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'All md:AssertionConsumerService endpoints must be an instance of AssertionConsumerService.',
- );
-
- /** @psalm-suppress InvalidArgument */
- new SPSSODescriptor(
- [new ArtifactResolutionService(0, C::BINDING_HTTP_POST, C::LOCATION_A)],
- [C::NS_SAMLP],
- );
- }
-
-
- /**
- * Test that creating an SPSSODescriptor from scratch fails with an AttributeConsumingService of the wrong class.
- */
- public function testMarshallingWithWrongAttributeConsumingService(): void
- {
- $this->expectException(AssertionFailedException::class);
- $this->expectExceptionMessage(
- 'All md:AttributeConsumingService endpoints must be an instance of AttributeConsumingService.',
- );
-
- /** @psalm-suppress InvalidArgument */
- new SPSSODescriptor(
- assertionConsumerService: [new AssertionConsumerService(0, C::BINDING_HTTP_POST, C::LOCATION_A)],
- protocolSupportEnumeration: [C::NS_SAMLP],
- authnRequestsSigned: true,
- attributeConsumingService: [new AssertionConsumerService(0, C::BINDING_HTTP_POST, C::LOCATION_B)],
- );
- }
-
-
/**
* Test that creating an SPSSODescriptor from scratch works without any optional arguments.
*/
@@ -226,6 +194,7 @@ public function testMarshallingWithoutOptionalArguments(): void
[new AssertionConsumerService(0, C::BINDING_HTTP_POST, C::LOCATION_A)],
[C::NS_SAMLP],
);
+
$this->assertNull($spssod->getAuthnRequestsSigned());
$this->assertNull($spssod->getWantAssertionsSigned());
$this->assertEmpty($spssod->getAttributeConsumingService());
@@ -235,20 +204,6 @@ public function testMarshallingWithoutOptionalArguments(): void
// test unmarshalling
- /**
- * Test creating an SPSSODescriptor from XML.
- */
- public function testUnmarshalling(): void
- {
- $spssod = SPSSODescriptor::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($spssod),
- );
- }
-
-
/**
* Test that creating an SPSSODescriptor from XML fails if no AssertionConsumerService is specified.
*/
@@ -257,10 +212,7 @@ public function testUnmarshallingWithoutAssertionConsumerService(): void
$xmlRepresentation = clone self::$xmlRepresentation;
$acseps = $xmlRepresentation->getElementsByTagNameNS(C::NS_MD, 'AssertionConsumerService');
- /** @psalm-suppress PossiblyNullArgument */
$xmlRepresentation->documentElement->removeChild($acseps->item(1));
-
- /** @psalm-suppress PossiblyNullArgument */
$xmlRepresentation->documentElement->removeChild($acseps->item(0));
$this->expectException(AssertionFailedException::class);
@@ -331,7 +283,6 @@ public function testUnmarshallingTwoDefaultACS(): void
{
$xmlRepresentation = clone self::$xmlRepresentation;
$acs = $xmlRepresentation->getElementsByTagNameNS(C::NS_MD, 'AttributeConsumingService');
- /** @psalm-suppress PossiblyNullReference */
$acs->item(1)->setAttribute('isDefault', 'true');
$this->expectException(AssertionFailedException::class);
diff --git a/tests/SAML2/XML/md/ServiceDescriptionTest.php b/tests/SAML2/XML/md/ServiceDescriptionTest.php
index c205e91e2..1f1966599 100644
--- a/tests/SAML2/XML/md/ServiceDescriptionTest.php
+++ b/tests/SAML2/XML/md/ServiceDescriptionTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\ServiceDescription;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -20,11 +21,12 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\md\ServiceDescription
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(ServiceDescription::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class ServiceDescriptionTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -63,21 +65,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a ServiceDescription from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = ServiceDescription::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/md/ServiceNameTest.php b/tests/SAML2/XML/md/ServiceNameTest.php
index fa13f780c..3147598e9 100644
--- a/tests/SAML2/XML/md/ServiceNameTest.php
+++ b/tests/SAML2/XML/md/ServiceNameTest.php
@@ -4,11 +4,13 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\ServiceName;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -21,11 +23,12 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\md\ServiceName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(ServiceName::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class ServiceNameTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -81,20 +84,6 @@ public function testMarshallingWithEmptyLang(): void
// test unmarshalling
- /**
- * Test creating a ServiceName from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = ServiceName::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating a ServiceName from XML fails when xml:lang is missing.
*/
diff --git a/tests/SAML2/XML/md/SingleSignOnServiceTest.php b/tests/SAML2/XML/md/SingleSignOnServiceTest.php
index 950cad1d2..8769d912c 100644
--- a/tests/SAML2/XML/md/SingleSignOnServiceTest.php
+++ b/tests/SAML2/XML/md/SingleSignOnServiceTest.php
@@ -4,11 +4,13 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\SingleSignOnService;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -19,10 +21,11 @@
/**
* Tests for md:SingleSignOnService.
*
- * @covers \SimpleSAML\SAML2\XML\md\SingleSignOnService
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(SingleSignOnService::class)]
+#[CoversClass(AbstractMdElement::class)]
final class SingleSignOnServiceTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -51,7 +54,7 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
- $ssoep = new SingleSignOnService(C::BINDING_HTTP_POST, 'https://simplesamlphp.org/some/endpoint');
+ $ssoep = new SingleSignOnService(C::BINDING_HTTP_POST, C::LOCATION_A);
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
@@ -70,31 +73,13 @@ public function testMarshallingWithResponseLocation(): void
'The \'ResponseLocation\' attribute must be omitted for md:SingleSignOnService.',
);
- new SingleSignOnService(
- C::BINDING_HTTP_POST,
- 'https://simplesamlphp.org/some/endpoint',
- 'https://response.location/',
- );
+ new SingleSignOnService(C::BINDING_HTTP_POST, C::LOCATION_A, 'https://response.location/');
}
// test unmarshalling
- /**
- * Test creating a SingleSignOnService from XML.
- */
- public function testUnmarshalling(): void
- {
- $ssoep = SingleSignOnService::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($ssoep),
- );
- }
-
-
/**
* Test that creating a SingleSignOnService from XML fails when ResponseLocation is present.
*/
diff --git a/tests/SAML2/XML/md/SurNameTest.php b/tests/SAML2/XML/md/SurNameTest.php
index 3e288a9ed..f791c90f8 100644
--- a/tests/SAML2/XML/md/SurNameTest.php
+++ b/tests/SAML2/XML/md/SurNameTest.php
@@ -4,9 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\SurName;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,10 +19,11 @@
/**
* Tests for SurName.
*
- * @covers \SimpleSAML\SAML2\XML\md\SurName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(SurName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class SurNameTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -57,21 +59,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a SurName from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = SurName::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/md/TelephoneNumberTest.php b/tests/SAML2/XML/md/TelephoneNumberTest.php
index 3ec2e2b8d..4c50fbf9d 100644
--- a/tests/SAML2/XML/md/TelephoneNumberTest.php
+++ b/tests/SAML2/XML/md/TelephoneNumberTest.php
@@ -4,22 +4,24 @@
namespace SimpleSAML\Test\SAML2\XML\md;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\md\TelephoneNumber;
+use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\DOMDocumentFactory;
/**
* Tests for SurName.
*
- * @covers \SimpleSAML\SAML2\XML\md\TelephoneNumber
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('md')]
+#[CoversClass(TelephoneNumber::class)]
+#[CoversClass(AbstractMdElement::class)]
final class TelephoneNumberTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -58,21 +60,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a TelephoneNumber from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = TelephoneNumber::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/mdattr/EntityAttributesTest.php b/tests/SAML2/XML/mdattr/EntityAttributesTest.php
index 7661ec5fd..0a71a67d5 100644
--- a/tests/SAML2/XML/mdattr/EntityAttributesTest.php
+++ b/tests/SAML2/XML/mdattr/EntityAttributesTest.php
@@ -5,44 +5,39 @@
namespace SimpleSAML\Test\SAML2\XML\mdattr;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\mdattr\AbstractMdattrElement;
+use SimpleSAML\SAML2\XML\mdattr\EntityAttributes;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeStatement;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
-use SimpleSAML\SAML2\XML\saml\AuthnContext;
-use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
-use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AudienceRestriction;
use SimpleSAML\SAML2\XML\saml\Conditions;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\Subject;
-use SimpleSAML\SAML2\XML\mdattr\EntityAttributes;
use SimpleSAML\Test\SAML2\Constants as C;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdattr\EntityAttributesTest
+ * Class \SimpleSAML\SAML2\XML\mdattr\EntityAttributesTest
*
- * @covers \SimpleSAML\SAML2\XML\mdattr\EntityAttributes
- * @covers \SimpleSAML\SAML2\XML\mdattr\AbstractMdattrElement
- * @requires PHP >= 8.1
* @package simplesamlphp/saml2
*/
-
+#[Group('mdattr')]
+#[CoversClass(EntityAttributes::class)]
+#[CoversClass(AbstractMdattrElement::class)]
final class EntityAttributesTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -168,17 +163,4 @@ public function testMarshalling(): void
strval($entityAttributes),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $entityAttributes = EntityAttributes::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($entityAttributes),
- );
- }
}
diff --git a/tests/SAML2/XML/mdrpi/PublicationInfoTest.php b/tests/SAML2/XML/mdrpi/PublicationInfoTest.php
index 563919bea..c469f71d1 100644
--- a/tests/SAML2/XML/mdrpi/PublicationInfoTest.php
+++ b/tests/SAML2/XML/mdrpi/PublicationInfoTest.php
@@ -5,29 +5,30 @@
namespace SimpleSAML\Test\SAML2\XML\mdrpi;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement;
use SimpleSAML\SAML2\XML\mdrpi\PublicationInfo;
use SimpleSAML\SAML2\XML\mdrpi\UsagePolicy;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
+use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdrpi\PublicationInfoTest
- *
- * @covers \SimpleSAML\SAML2\XML\mdrpi\PublicationInfo
- * @covers \SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement
+ * Class \SimpleSAML\SAML2\XML\mdrpi\PublicationInfoTest
*
* @package simplesamlphp/saml2
*/
+#[Group('mdrpi')]
+#[CoversClass(PublicationInfo::class)]
+#[CoversClass(AbstractMdrpiElement::class)]
final class PublicationInfoTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -77,19 +78,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $publicationInfo = PublicationInfo::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($publicationInfo),
- );
- }
-
-
/**
*/
public function testCreationInstantTimezoneNotZuluThrowsException(): void
@@ -125,17 +113,17 @@ public function testMissingPublisherThrowsException(): void
*/
public function testMultipleUsagePoliciesWithSameLanguageThrowsException(): void
{
- $document = clone self::$xmlRepresentation;
+ $document = clone self::$xmlRepresentation->documentElement;
// Append another 'en' UsagePolicy to the document
$x = new UsagePolicy('en', 'https://example.org');
- $x->toXML($document->documentElement);
+ $x->toXML($document);
$this->expectException(ProtocolViolationException::class);
$this->expectExceptionMessage(
'There MUST NOT be more than one ,'
. ' within a given , for a given language'
);
- PublicationInfo::fromXML($document->documentElement);
+ PublicationInfo::fromXML($document);
}
}
diff --git a/tests/SAML2/XML/mdrpi/PublicationPathTest.php b/tests/SAML2/XML/mdrpi/PublicationPathTest.php
index 1e451887d..fe8730037 100644
--- a/tests/SAML2/XML/mdrpi/PublicationPathTest.php
+++ b/tests/SAML2/XML/mdrpi/PublicationPathTest.php
@@ -4,30 +4,29 @@
namespace SimpleSAML\Test\SAML2\XML\mdrpi;
-use DOMDocument;
+use DateTimeImmutable;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants;
-use SimpleSAML\SAML2\Exception\ProtocolViolationException;
-use SimpleSAML\SAML2\XML\mdrpi\PublicationPath;
+use SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement;
use SimpleSAML\SAML2\XML\mdrpi\Publication;
+use SimpleSAML\SAML2\XML\mdrpi\PublicationPath;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdrpi\PublicationPathTest
- *
- * @covers \SimpleSAML\SAML2\XML\mdrpi\PublicationPath
- * @covers \SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement
+ * Class \SimpleSAML\SAML2\XML\mdrpi\PublicationPathTest
*
* @package simplesamlphp/saml2
*/
+#[Group('mdrpi')]
+#[CoversClass(PublicationPath::class)]
+#[CoversClass(AbstractMdrpiElement::class)]
final class PublicationPathTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -67,8 +66,12 @@ public static function setUpBeforeClass(): void
public function testMarshalling(): void
{
$publicationPath = new PublicationPath([
- new Publication('SomePublisher', 1293840000, 'SomePublicationId'),
- new Publication('SomeOtherPublisher', 1293840000, 'SomeOtherPublicationId'),
+ new Publication('SomePublisher', new DateTimeImmutable('2011-01-01T00:00:00Z'), 'SomePublicationId'),
+ new Publication(
+ 'SomeOtherPublisher',
+ new DateTimeImmutable('2011-01-01T00:00:00Z'),
+ 'SomeOtherPublicationId',
+ ),
]);
$this->assertEquals(
@@ -92,16 +95,4 @@ public function testMarshallingWithNoPublications(): void
);
$this->assertTrue($publicationPath->isEmptyElement());
}
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $publicationPath = PublicationPath::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($publicationPath),
- );
- }
}
diff --git a/tests/SAML2/XML/mdrpi/PublicationTest.php b/tests/SAML2/XML/mdrpi/PublicationTest.php
index 390c57ca8..b2dd3755d 100644
--- a/tests/SAML2/XML/mdrpi/PublicationTest.php
+++ b/tests/SAML2/XML/mdrpi/PublicationTest.php
@@ -4,28 +4,30 @@
namespace SimpleSAML\Test\SAML2\XML\mdrpi;
-use DOMDocument;
+use DateTimeImmutable;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement;
use SimpleSAML\SAML2\XML\mdrpi\Publication;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdrpi\PublicationTest
- *
- * @covers \SimpleSAML\SAML2\XML\mdrpi\Publication
- * @covers \SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement
+ * Class \SimpleSAML\SAML2\XML\mdrpi\PublicationTest
*
* @package simplesamlphp/saml2
*/
+#[Group('mdrpi')]
+#[CoversClass(Publication::class)]
+#[CoversClass(AbstractMdrpiElement::class)]
final class PublicationTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -59,7 +61,7 @@ public function testMarshalling(): void
{
$publication = new Publication(
'SomePublisher',
- 1293840000,
+ new DateTimeImmutable('2011-01-01T00:00:00Z'),
'SomePublicationId',
);
@@ -70,19 +72,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $publication = Publication::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($publication),
- );
- }
-
-
/**
*/
public function testCreationInstantTimezoneNotZuluThrowsException(): void
diff --git a/tests/SAML2/XML/mdrpi/RegistrationInfoTest.php b/tests/SAML2/XML/mdrpi/RegistrationInfoTest.php
index ffd5f0d2c..3ae53db50 100644
--- a/tests/SAML2/XML/mdrpi/RegistrationInfoTest.php
+++ b/tests/SAML2/XML/mdrpi/RegistrationInfoTest.php
@@ -5,9 +5,11 @@
namespace SimpleSAML\Test\SAML2\XML\mdrpi;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
+use SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement;
use SimpleSAML\SAML2\XML\mdrpi\RegistrationInfo;
use SimpleSAML\SAML2\XML\mdrpi\RegistrationPolicy;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -15,19 +17,18 @@
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdrpi\RegistrationInfoTest
- *
- * @covers \SimpleSAML\SAML2\XML\mdrpi\RegistrationInfo
- * @covers \SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement
+ * Class \SimpleSAML\SAML2\XML\mdrpi\RegistrationInfoTest
*
* @package simplesamlphp/saml2
*/
+#[Group('mdrpi')]
+#[CoversClass(RegistrationInfo::class)]
+#[CoversClass(AbstractMdrpiElement::class)]
final class RegistrationInfoTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -78,19 +79,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $registrationInfo = RegistrationInfo::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($registrationInfo),
- );
- }
-
-
/**
*/
public function testMissingPublisherThrowsException(): void
@@ -125,17 +113,17 @@ public function testRegistrationInstantTimezoneNotZuluThrowsException(): void
*/
public function testMultipleRegistrationPoliciesWithSameLanguageThrowsException(): void
{
- $document = clone self::$xmlRepresentation;
+ $document = clone self::$xmlRepresentation->documentElement;
// Append another 'en' RegistrationPolicy to the document
$x = new RegistrationPolicy('en', 'https://example.org');
- $x->toXML($document->documentElement);
+ $x->toXML($document);
$this->expectException(ProtocolViolationException::class);
$this->expectExceptionMessage(
'There MUST NOT be more than one ,'
. ' within a given , for a given language'
);
- RegistrationInfo::fromXML($document->documentElement);
+ RegistrationInfo::fromXML($document);
}
}
diff --git a/tests/SAML2/XML/mdrpi/RegistrationPolicyTest.php b/tests/SAML2/XML/mdrpi/RegistrationPolicyTest.php
index 9bb39c7bd..abc0348a1 100644
--- a/tests/SAML2/XML/mdrpi/RegistrationPolicyTest.php
+++ b/tests/SAML2/XML/mdrpi/RegistrationPolicyTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\mdrpi;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
+use SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement;
use SimpleSAML\SAML2\XML\mdrpi\RegistrationPolicy;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -21,13 +23,13 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\mdrpi\RegistrationPolicy
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedURI
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('mdrpi')]
+#[CoversClass(RegistrationPolicy::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractLocalizedURI::class)]
+#[CoversClass(AbstractMdrpiElement::class)]
final class RegistrationPolicyTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -71,20 +73,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a RegistrationPolicy from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = RegistrationPolicy::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating a RegistrationPolicy with an invalid url throws an exception
*/
diff --git a/tests/SAML2/XML/mdrpi/UsagePolicyTest.php b/tests/SAML2/XML/mdrpi/UsagePolicyTest.php
index 05a00101d..43aeee096 100644
--- a/tests/SAML2/XML/mdrpi/UsagePolicyTest.php
+++ b/tests/SAML2/XML/mdrpi/UsagePolicyTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\mdrpi;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
+use SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement;
use SimpleSAML\SAML2\XML\mdrpi\UsagePolicy;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -21,13 +23,13 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\mdrpi\UsagePolicy
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedURI
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('mdrpi')]
+#[CoversClass(UsagePolicy::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractLocalizedURI::class)]
+#[CoversClass(AbstractMdrpiElement::class)]
final class UsagePolicyTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -71,20 +73,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a UsagePolicy from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = UsagePolicy::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating a UsagePolicy with an invalid url throws an exception
*/
diff --git a/tests/SAML2/XML/mdui/DescriptionTest.php b/tests/SAML2/XML/mdui/DescriptionTest.php
index 45b9ead15..e683f41e0 100644
--- a/tests/SAML2/XML/mdui/DescriptionTest.php
+++ b/tests/SAML2/XML/mdui/DescriptionTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\mdui\Description;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -20,11 +21,12 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\Description
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(Description::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class DescriptionTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -63,21 +65,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a Description from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = Description::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/mdui/DiscoHintsTest.php b/tests/SAML2/XML/mdui/DiscoHintsTest.php
index 5e519bcfa..fbd521897 100644
--- a/tests/SAML2/XML/mdui/DiscoHintsTest.php
+++ b/tests/SAML2/XML/mdui/DiscoHintsTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\DiscoHints;
use SimpleSAML\SAML2\XML\mdui\DomainHint;
use SimpleSAML\SAML2\XML\mdui\GeolocationHint;
@@ -22,12 +24,13 @@
use function strval;
/**
- * Class \SAML2\XML\mdui\DiscoHintsTest
+ * Class \SimpleSAML\SAML2\XML\mdui\DiscoHintsTest
*
- * @covers \SimpleSAML\SAML2\XML\mdui\DiscoHints
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(DiscoHints::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class DiscoHintsTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -91,20 +94,6 @@ public function testMarshallingEmptyElement(): void
}
- /**
- * Test unmarshalling a basic DiscoHints element
- */
- public function testUnmarshalling(): void
- {
- $discoHints = DiscoHints::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($discoHints),
- );
- }
-
-
/**
* Add a Keywords element to the children attribute
*/
@@ -113,6 +102,7 @@ public function testMarshallingChildren(): void
$keywords = new Keywords("nl", ["voorbeeld", "specimen"]);
$discoHints = new DiscoHints();
$discoHints->addChild(new Chunk($keywords->toXML()));
+ $this->assertCount(1, $discoHints->getElements());
$document = DOMDocumentFactory::fromString('');
$xml = $discoHints->toXML($document->documentElement);
@@ -150,6 +140,8 @@ public function testUnmarshallingChildren(): void
$this->assertCount(1, $disco->getGeolocationHint());
$this->assertEquals('geo:47.37328,8.531126', $disco->getGeolocationHint()[0]->getContent());
$this->assertCount(1, $disco->getElements());
- $this->assertEquals('content of tag', $disco->getElements()[0]->getXML()->textContent);
+ /** @var \SimpleSAML\XML\Chunk[] $elements */
+ $elements = $disco->getElements();
+ $this->assertEquals('content of tag', $elements[0]->getXML()->textContent);
}
}
diff --git a/tests/SAML2/XML/mdui/DisplayNameTest.php b/tests/SAML2/XML/mdui/DisplayNameTest.php
index 12cbdb9d3..af7b3fb6b 100644
--- a/tests/SAML2/XML/mdui/DisplayNameTest.php
+++ b/tests/SAML2/XML/mdui/DisplayNameTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\mdui\DisplayName;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -20,11 +21,12 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\DisplayName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(DisplayName::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class DisplayNameTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -63,21 +65,4 @@ public function testMarshalling(): void
strval($name),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a DisplayName from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = DisplayName::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
}
diff --git a/tests/SAML2/XML/mdui/DomainHintTest.php b/tests/SAML2/XML/mdui/DomainHintTest.php
index e352b9615..d8c98147f 100644
--- a/tests/SAML2/XML/mdui/DomainHintTest.php
+++ b/tests/SAML2/XML/mdui/DomainHintTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\InvalidArgumentException;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\DomainHint;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,10 +20,11 @@
/**
* Tests for DomainHint.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\DomainHint
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(DomainHint::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class DomainHintTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -62,20 +65,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a DomainHint from XML.
- */
- public function testUnmarshalling(): void
- {
- $hint = DomainHint::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($hint),
- );
- }
-
-
/**
* Test creating a DomainHint from XML with false domain
*/
diff --git a/tests/SAML2/XML/mdui/GeolocationHintTest.php b/tests/SAML2/XML/mdui/GeolocationHintTest.php
index 071f19ca5..b02300fef 100644
--- a/tests/SAML2/XML/mdui/GeolocationHintTest.php
+++ b/tests/SAML2/XML/mdui/GeolocationHintTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\GeolocationHint;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,10 +19,11 @@
/**
* Tests for GeolocationHint.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\GeolocationHint
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(GeoLocationHint::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class GeolocationHintTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -56,21 +59,4 @@ public function testMarshalling(): void
strval($hint),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a GeolocationHint from XML.
- */
- public function testUnmarshalling(): void
- {
- $hint = GeolocationHint::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($hint),
- );
- }
}
diff --git a/tests/SAML2/XML/mdui/IPHintTest.php b/tests/SAML2/XML/mdui/IPHintTest.php
index 8879c47e2..91d7968d7 100644
--- a/tests/SAML2/XML/mdui/IPHintTest.php
+++ b/tests/SAML2/XML/mdui/IPHintTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\IPHint;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,10 +19,11 @@
/**
* Tests for IPHint.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\IPHint
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(IPHint::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class IPHintTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -56,21 +59,4 @@ public function testMarshalling(): void
strval($hint),
);
}
-
-
- // test unmarshalling
-
-
- /**
- * Test creating a IPHint from XML.
- */
- public function testUnmarshalling(): void
- {
- $hint = IPHint::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($hint),
- );
- }
}
diff --git a/tests/SAML2/XML/mdui/InformationURLTest.php b/tests/SAML2/XML/mdui/InformationURLTest.php
index 90bdb50d7..5214c1edc 100644
--- a/tests/SAML2/XML/mdui/InformationURLTest.php
+++ b/tests/SAML2/XML/mdui/InformationURLTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\mdui\InformationURL;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -21,13 +23,13 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\InformationURL
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedURI
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(InformationURL::class)]
+#[CoversClass(AbstractLocalizedURI::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class InformationURLTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -71,20 +73,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a InformationURL from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = InformationURL::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating a InformationURL with an invalid url throws an exception
*/
diff --git a/tests/SAML2/XML/mdui/KeywordsTest.php b/tests/SAML2/XML/mdui/KeywordsTest.php
index e4b2a4037..bea4f508c 100644
--- a/tests/SAML2/XML/mdui/KeywordsTest.php
+++ b/tests/SAML2/XML/mdui/KeywordsTest.php
@@ -4,27 +4,28 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\Keywords;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdui\KeywordsTest
+ * Class \SimpleSAML\SAML2\XML\mdui\KeywordsTest
*
- * @covers \SimpleSAML\SAML2\XML\mdui\Keywords
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(Keywords::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class KeywordsTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -77,20 +78,6 @@ public function testKeywordWithPlusSignThrowsException(): void
}
- /**
- * Unmarshalling of a keywords tag
- */
- public function testUnmarshalling(): void
- {
- $keywords = Keywords::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($keywords),
- );
- }
-
-
/**
* Unmarshalling fails if attribute is empty
*/
diff --git a/tests/SAML2/XML/mdui/LogoTest.php b/tests/SAML2/XML/mdui/LogoTest.php
index 1ac304fd9..fe2f24777 100644
--- a/tests/SAML2/XML/mdui/LogoTest.php
+++ b/tests/SAML2/XML/mdui/LogoTest.php
@@ -4,28 +4,30 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\Logo;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\mdui\LogoTest
+ * Class \SimpleSAML\SAML2\XML\mdui\LogoTest
*
- * @covers \SimpleSAML\SAML2\XML\mdui\Logo
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(Logo::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class LogoTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -77,20 +79,6 @@ public function testMarshalling(): void
}
- /**
- * Unmarshalling of a logo tag
- */
- public function testUnmarshalling(): void
- {
- $logo = Logo::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($logo),
- );
- }
-
-
/**
* Unmarshalling of a logo tag without a language
*/
diff --git a/tests/SAML2/XML/mdui/PrivacyStatementURLTest.php b/tests/SAML2/XML/mdui/PrivacyStatementURLTest.php
index 70600ba8f..faa7edc99 100644
--- a/tests/SAML2/XML/mdui/PrivacyStatementURLTest.php
+++ b/tests/SAML2/XML/mdui/PrivacyStatementURLTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\AbstractLocalizedName;
+use SimpleSAML\SAML2\XML\md\AbstractLocalizedURI;
+use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\SAML2\XML\mdui\PrivacyStatementURL;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\SchemaViolationException;
@@ -21,12 +23,13 @@
/**
* Tests for localized names.
*
- * @covers \SimpleSAML\SAML2\XML\mdui\PrivacyStatementURL
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedURI
- * @covers \SimpleSAML\SAML2\XML\md\AbstractLocalizedName
- * @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(PrivacyStatementURL::class)]
+#[CoversClass(AbstractLocalizedURI::class)]
+#[CoversClass(AbstractLocalizedName::class)]
+#[CoversClass(AbstractMdElement::class)]
final class PrivacyStatementURLTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -70,20 +73,6 @@ public function testMarshalling(): void
// test unmarshalling
- /**
- * Test creating a PrivacyStatementURL from XML.
- */
- public function testUnmarshalling(): void
- {
- $name = PrivacyStatementURL::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($name),
- );
- }
-
-
/**
* Test that creating a PrivacyStatementURL with an invalid url throws an exception
*/
diff --git a/tests/SAML2/XML/mdui/UIInfoTest.php b/tests/SAML2/XML/mdui/UIInfoTest.php
index 68d252cb7..10d9edff9 100644
--- a/tests/SAML2/XML/mdui/UIInfoTest.php
+++ b/tests/SAML2/XML/mdui/UIInfoTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\mdui;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\mdui\AbstractMduiElement;
use SimpleSAML\SAML2\XML\mdui\Description;
use SimpleSAML\SAML2\XML\mdui\DiscoHints;
use SimpleSAML\SAML2\XML\mdui\DisplayName;
@@ -27,12 +29,13 @@
use function strval;
/**
- * Class \SAML2\XML\mdui\UIInfoTest
+ * Class \SimpleSAML\SAML2\XML\mdui\UIInfoTest
*
- * @covers \SimpleSAML\SAML2\XML\mdui\UIInfo
- * @covers \SimpleSAML\SAML2\XML\mdui\AbstractMduiElement
* @package simplesamlphp/saml2
*/
+#[Group('mdui')]
+#[CoversClass(UIInfo::class)]
+#[CoversClass(AbstractMduiElement::class)]
final class UIInfoTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -124,7 +127,7 @@ public function testMarshallingChildren(): void
[new IPHint("192.168.6.0/24"), new IPHint("fd00:0123:aa:1001::/64")],
);
- // keywords appears twice, direcyly under UIinfo and as child of DiscoHints
+ // keywords appears twice, directly under UIinfo and as child of DiscoHints
$discohints->addChild(new Chunk($keywords->toXML()));
$uiinfo = new UIInfo(
@@ -194,20 +197,6 @@ public function testMarshallingEmptyElement(): void
}
- /**
- * Test unmarshalling a basic UIInfo element
- */
- public function testUnmarshalling(): void
- {
- $uiinfo = UIInfo::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($uiinfo),
- );
- }
-
-
/**
*/
public function testMultipleDescriptionWithSameLanguageThrowsException(): void
diff --git a/tests/SAML2/XML/saml/ActionTest.php b/tests/SAML2/XML/saml/ActionTest.php
index bcd32dee7..3ba83267d 100644
--- a/tests/SAML2/XML/saml/ActionTest.php
+++ b/tests/SAML2/XML/saml/ActionTest.php
@@ -4,10 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Action;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -17,12 +17,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\ActionTest
+ * Class \SimpleSAML\SAML2\XML\saml\ActionTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Action
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Action::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class ActionTest extends TestCase
{
use SerializableElementTestTrait;
@@ -57,20 +58,4 @@ public function testMarshalling(): void
strval($action),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $action = Action::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($action),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AdviceTest.php b/tests/SAML2/XML/saml/AdviceTest.php
index b9d9a2e0b..3a818fa92 100644
--- a/tests/SAML2/XML/saml/AdviceTest.php
+++ b/tests/SAML2/XML/saml/AdviceTest.php
@@ -5,7 +5,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Advice;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\AssertionIDRef;
@@ -22,11 +25,11 @@
/**
* Class \SimpleSAML\SAML2\XML\saml\AdviceTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Advice
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Advice::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AdviceTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -112,17 +115,4 @@ public function testMarshallingWithNoContent(): void
);
$this->assertTrue($advice->isEmptyElement());
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $advice = Advice::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($advice),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AssertionIDRefTest.php b/tests/SAML2/XML/saml/AssertionIDRefTest.php
index 9358c207a..190a994e7 100644
--- a/tests/SAML2/XML/saml/AssertionIDRefTest.php
+++ b/tests/SAML2/XML/saml/AssertionIDRefTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AssertionIDRef;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,11 +19,11 @@
/**
* Class \SimpleSAML\SAML2\XML\saml\AssertionIDRefTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AssertionIDRef
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AssertionIDRef::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AssertionIDRefTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -52,17 +54,4 @@ public function testMarshalling(): void
strval($assertionIDRef),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $assertionIDRef = AssertionIDRef::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($assertionIDRef),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AssertionTest.php b/tests/SAML2/XML/saml/AssertionTest.php
index 13d81899b..67aebe593 100644
--- a/tests/SAML2/XML/saml/AssertionTest.php
+++ b/tests/SAML2/XML/saml/AssertionTest.php
@@ -5,26 +5,27 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DateTimeImmutable;
-use DOMDocument;
-use DOMNodeList;
use Exception;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeStatement;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
+use SimpleSAML\SAML2\XML\saml\Audience;
+use SimpleSAML\SAML2\XML\saml\AudienceRestriction;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
use SimpleSAML\SAML2\XML\saml\AuthnStatement;
-use SimpleSAML\SAML2\XML\saml\Audience;
-use SimpleSAML\SAML2\XML\saml\AudienceRestriction;
use SimpleSAML\SAML2\XML\saml\Conditions;
use SimpleSAML\SAML2\XML\saml\EncryptedAssertion;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
@@ -35,21 +36,17 @@
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
use SimpleSAML\SAML2\XML\saml\SubjectLocality;
use SimpleSAML\Test\SAML2\Constants as C;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingElementException;
-use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
use SimpleSAML\XMLSecurity\Exception\SignatureVerificationFailedException;
-use SimpleSAML\XMLSecurity\Key\PublicKey;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
+use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
-use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use function dirname;
use function strval;
@@ -57,10 +54,11 @@
/**
* Class \SimpleSAML\SAML2\AssertionTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Assertion
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Assertion::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AssertionTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -465,8 +463,8 @@ public function testMarshallingUnmarshallingAttributeValTypes(): void
/**
- * @group Assertion
*/
+ #[Group("Assertion")]
public function testCorrectSignatureMethodCanBeExtracted(): void
{
$document = DOMDocumentFactory::fromString(<<documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($assertionURIRef),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AttributeStatementTest.php b/tests/SAML2/XML/saml/AttributeStatementTest.php
index a72817535..ca9b77316 100644
--- a/tests/SAML2/XML/saml/AttributeStatementTest.php
+++ b/tests/SAML2/XML/saml/AttributeStatementTest.php
@@ -4,27 +4,29 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeStatement;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XMLSecurity\PEMCertificatesMock;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\saml\AttributeStatementTest
+ * Class \SimpleSAML\SAML2\XML\saml\AttributeStatementTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AttributeStatement
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AttributeStatement::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AttributeStatementTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -88,23 +90,6 @@ public function testMarshallingMissingAttributesThrowsException(): void
// unmarshalling
- /**
- */
- public function testUnmarshalling(): void
- {
- $attrStatement = AttributeStatement::fromXML(self::$xmlRepresentation->documentElement);
-
- $attributes = $attrStatement->getAttributes();
- $this->assertCount(3, $attributes);
- $this->assertEquals('urn:ServiceID', $attributes[0]->getName());
- $this->assertEquals('urn:EntityConcernedID', $attributes[1]->getName());
- $this->assertEquals('urn:EntityConcernedSubID', $attributes[2]->getName());
-
- $this->assertEmpty($attrStatement->getEncryptedAttributes());
- $this->assertFalse($attrStatement->hasEncryptedAttributes());
- }
-
-
/**
*/
public function testUnmarshallingMissingAttributesThrowsException(): void
diff --git a/tests/SAML2/XML/saml/AttributeTest.php b/tests/SAML2/XML/saml/AttributeTest.php
index 70eb48fb8..c96f58cf8 100644
--- a/tests/SAML2/XML/saml/AttributeTest.php
+++ b/tests/SAML2/XML/saml/AttributeTest.php
@@ -4,11 +4,13 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\SAML2\XML\saml\EncryptedAttribute;
@@ -18,20 +20,19 @@
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
-use SimpleSAML\XMLSecurity\Key\PublicKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\saml\AttributeTest
+ * Class \SimpleSAML\SAML2\XML\saml\AttributeTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Attribute
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Attribute::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AttributeTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -101,20 +102,6 @@ public function testMarshalling(): void
// unmarshalling
- /**
- * Test creating of an Attribute from XML.
- */
- public function testUnmarshalling(): void
- {
- $attribute = Attribute::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($attribute),
- );
- }
-
-
/**
* Test that creating an Attribute from XML fails if no Name is provided.
*/
diff --git a/tests/SAML2/XML/saml/AttributeValueTest.php b/tests/SAML2/XML/saml/AttributeValueTest.php
index 7905fc3e9..5bf034376 100644
--- a/tests/SAML2/XML/saml/AttributeValueTest.php
+++ b/tests/SAML2/XML/saml/AttributeValueTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -19,10 +21,11 @@
/**
* Tests for AttributeValue elements.
*
- * @covers \SimpleSAML\SAML2\XML\saml\AttributeValue
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AttributeValue::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AttributeValueTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -115,24 +118,6 @@ public function testEmptyStringAttribute(): void
// unmarshalling
- /**
- * Verifies that we can create an AttributeValue from a DOMElement.
- *
- */
- public function testUnmarshalling(): void
- {
- $av = AttributeValue::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertIsInt($av->getValue());
- $this->assertEquals(2, $av->getValue());
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($av),
- );
- }
-
-
/**
* Verifies that we can create an AttributeValue containing a NameID from a DOMElement.
*
diff --git a/tests/SAML2/XML/saml/AudienceRestrictionTest.php b/tests/SAML2/XML/saml/AudienceRestrictionTest.php
index 62b3aeb0a..1eae93eb3 100644
--- a/tests/SAML2/XML/saml/AudienceRestrictionTest.php
+++ b/tests/SAML2/XML/saml/AudienceRestrictionTest.php
@@ -4,25 +4,27 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AudienceRestriction;
+use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\DOMDocumentFactory;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\saml\AudienceRestrictionTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\AudienceRestriction
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\AudienceRestrictionTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AudienceRestriction::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AudienceRestrictionTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -61,20 +63,4 @@ public function testMarshalling(): void
strval($condition),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $condition = AudienceRestriction::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($condition),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AudienceTest.php b/tests/SAML2/XML/saml/AudienceTest.php
index cac4b30c7..37ffddfbe 100644
--- a/tests/SAML2/XML/saml/AudienceTest.php
+++ b/tests/SAML2/XML/saml/AudienceTest.php
@@ -4,8 +4,11 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractConditionType;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,12 +20,12 @@
/**
* Class \SimpleSAML\SAML2\XML\saml\AudienceTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Audience
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractConditionType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Audience::class)]
+#[CoversClass(AbstractConditionType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AudienceTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -53,17 +56,4 @@ public function testMarshalling(): void
strval($audience),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $audience = Audience::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($audience),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthenticatingAuthorityTest.php b/tests/SAML2/XML/saml/AuthenticatingAuthorityTest.php
index 79d3267a0..df6957600 100644
--- a/tests/SAML2/XML/saml/AuthenticatingAuthorityTest.php
+++ b/tests/SAML2/XML/saml/AuthenticatingAuthorityTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,11 +19,11 @@
/**
* Class \SimpleSAML\SAML2\XML\saml\AuthenticatingAuthorityTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthenticatingAuthority::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthenticatingAuthorityTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -52,17 +54,4 @@ public function testMarshalling(): void
strval($authenticatingAuthority),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authenticatingAuthority = AuthenticatingAuthority::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authenticatingAuthority),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextClassRefTest.php b/tests/SAML2/XML/saml/AuthnContextClassRefTest.php
index a0496bbd8..17996d728 100644
--- a/tests/SAML2/XML/saml/AuthnContextClassRefTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextClassRefTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,12 +18,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextClassRefTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextClassRefTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContextClassRef
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContextClassRef::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextClassRefTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -54,20 +56,4 @@ public function testMarshalling(): void
strval($authnContextClassRef),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContextClassRef = AuthnContextClassRef::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContextClassRef),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextDeclRefTest.php b/tests/SAML2/XML/saml/AuthnContextDeclRefTest.php
index 5db95544f..08e029585 100644
--- a/tests/SAML2/XML/saml/AuthnContextDeclRefTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextDeclRefTest.php
@@ -4,24 +4,26 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
+use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\DOMDocumentFactory;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextDeclRefTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextDeclRefTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContextDeclRef::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextDeclRefTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -55,20 +57,4 @@ public function testMarshalling(): void
strval($authnContextDeclRef),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContextDeclRef = AuthnContextDeclRef::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContextDeclRef),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextDeclTest.php b/tests/SAML2/XML/saml/AuthnContextDeclTest.php
index f3400d609..f2c3530fe 100644
--- a/tests/SAML2/XML/saml/AuthnContextDeclTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextDeclTest.php
@@ -4,9 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthnContextDecl;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
@@ -18,12 +19,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextDeclTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextDeclTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContextDecl
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContextDecl::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextDeclTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -71,20 +73,4 @@ public function testMarshalling(): void
strval($authnContextDecl),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContextDecl = AuthnContextDecl::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContextDecl),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextTest.php b/tests/SAML2/XML/saml/AuthnContextTest.php
index 6786499f1..5ff944a98 100644
--- a/tests/SAML2/XML/saml/AuthnContextTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextTest.php
@@ -5,64 +5,43 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
+use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\SAML2\XML\saml\AuthnContextDecl;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
-use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\TooManyElementsException;
-use XMLReader;
use function dirname;
-use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContext
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContext::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextTest extends TestCase
{
- /** @var \DOMDocument */
- private static DOMDocument $classRef;
-
- /** @var \DOMDocument */
- private static DOMDocument $declRef;
-
/** @var \DOMDocument */
private static DOMDocument $decl;
- /** @var \DOMDocument */
- private static DOMDocument $authority;
-
/**
*/
public static function setUpBeforeClass(): void
{
- self::$classRef = DOMDocumentFactory::fromFile(
- dirname(__FILE__, 4) . '/resources/xml/saml_AuthnContextClassRef.xml',
- );
-
- self::$declRef = DOMDocumentFactory::fromFile(
- dirname(__FILE__, 4) . '/resources/xml/saml_AuthnContextDeclRef.xml',
- );
-
self::$decl = DOMDocumentFactory::fromFile(
dirname(__FILE__, 4) . '/resources/xml/saml_AuthnContextDecl.xml',
);
-
- self::$authority = DOMDocumentFactory::fromFile(
- dirname(__FILE__, 4) . '/resources/xml/saml_AuthenticatingAuthority.xml',
- );
}
diff --git a/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclRefTest.php b/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclRefTest.php
index 19dcf2e0d..0bd8b96bc 100644
--- a/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclRefTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclRefTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
@@ -20,12 +21,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextWithClassRefAndDeclRefTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextWithClassRefAndDeclRefTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContext
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContext::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextWithClassRefAndDeclRefTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -62,20 +64,4 @@ public function testMarshalling(): void
strval($authnContext),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContext = AuthnContext::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContext),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclTest.php b/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclTest.php
index 9a7ce8b24..50f18cc90 100644
--- a/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextWithClassRefAndDeclTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
@@ -22,12 +23,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextWithClassRefAndDeclTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextWithClassRefAndDeclTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContext
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContext::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextWithClassRefAndDeclTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -80,20 +82,4 @@ public function testMarshalling(): void
strval($authnContext),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContext = AuthnContext::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContext),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextWithClassRefTest.php b/tests/SAML2/XML/saml/AuthnContextWithClassRefTest.php
index 818e69947..53feee851 100644
--- a/tests/SAML2/XML/saml/AuthnContextWithClassRefTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextWithClassRefTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
@@ -19,12 +20,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextWithClassRefTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextWithClassRefTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContext
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContext::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextWithClassRefTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -61,20 +63,4 @@ public function testMarshalling(): void
strval($authnContext),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContext = AuthnContext::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContext),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextWithDeclRefTest.php b/tests/SAML2/XML/saml/AuthnContextWithDeclRefTest.php
index 95e284d0d..b71485d8a 100644
--- a/tests/SAML2/XML/saml/AuthnContextWithDeclRefTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextWithDeclRefTest.php
@@ -4,10 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
@@ -19,12 +19,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextWithDeclRefTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextWithDeclRefTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContext
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContext::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextWithDeclRefTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -61,20 +62,4 @@ public function testMarshalling(): void
strval($authnContext),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContext = AuthnContext::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContext),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnContextWithDeclTest.php b/tests/SAML2/XML/saml/AuthnContextWithDeclTest.php
index 33b47ed4e..c69b549b6 100644
--- a/tests/SAML2/XML/saml/AuthnContextWithDeclTest.php
+++ b/tests/SAML2/XML/saml/AuthnContextWithDeclTest.php
@@ -4,10 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextDecl;
@@ -21,12 +21,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnContextWithDeclTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnContextWithDeclTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnContext
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnContext::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnContextWithDeclTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -79,20 +80,4 @@ public function testMarshalling(): void
strval($authnContext),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnContext = AuthnContext::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnContext),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/AuthnStatementTest.php b/tests/SAML2/XML/saml/AuthnStatementTest.php
index 34a18542c..b1d03c026 100644
--- a/tests/SAML2/XML/saml/AuthnStatementTest.php
+++ b/tests/SAML2/XML/saml/AuthnStatementTest.php
@@ -5,33 +5,35 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DateTimeImmutable;
-use DOMDocument;
-use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority;
use SimpleSAML\SAML2\XML\saml\AuthnContext;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\SAML2\XML\saml\AuthnStatement;
use SimpleSAML\SAML2\XML\saml\SubjectLocality;
-use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
-use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingAttributeException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
+use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
+use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\saml\AuthnStatementTest
+ * Class \SimpleSAML\SAML2\XML\saml\AuthnStatementTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\AuthnStatement
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthnStatement::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthnStatementTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -118,19 +120,6 @@ public function testMarshallingElementOrdering(): void
// unmarshalling
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnStatement = AuthnStatement::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnStatement),
- );
- }
-
-
/**
*/
public function testUnmarshallingWithoutAuthnContextThrowsException(): void
diff --git a/tests/SAML2/XML/saml/AuthzDecisionStatementTest.php b/tests/SAML2/XML/saml/AuthzDecisionStatementTest.php
index b76b02a56..c8c52098b 100644
--- a/tests/SAML2/XML/saml/AuthzDecisionStatementTest.php
+++ b/tests/SAML2/XML/saml/AuthzDecisionStatementTest.php
@@ -5,8 +5,12 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\Decision;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
+use SimpleSAML\SAML2\XML\saml\AbstractStatement;
use SimpleSAML\SAML2\XML\saml\Action;
use SimpleSAML\SAML2\XML\saml\AuthzDecisionStatement;
use SimpleSAML\SAML2\XML\saml\Evidence;
@@ -18,14 +22,14 @@
use function strval;
/**
- * Class \SimpleSAML\SAML2\XML\saml\AuthzDecisionStatementTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\AuthzDecisionStatement
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractStatement
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SimpleSAML\SAML2\XML\saml\AuthzDecisionStatementTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(AuthzDecisionStatement::class)]
+#[CoversClass(AbstractStatement::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class AuthzDecisionStatementTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -72,17 +76,4 @@ public function testMarshalling(): void
strval($authzDecisionStatement),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authzDecisionStatement = AuthzDecisionStatement::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authzDecisionStatement),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/BaseIDTest.php b/tests/SAML2/XML/saml/BaseIDTest.php
index 7f02123a5..9db502dd0 100644
--- a/tests/SAML2/XML/saml/BaseIDTest.php
+++ b/tests/SAML2/XML/saml/BaseIDTest.php
@@ -4,15 +4,18 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
+use SimpleSAML\SAML2\XML\saml\AbstractBaseIDType;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
+use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\UnknownID;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\Test\SAML2\CustomBaseID;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -21,15 +24,15 @@
use function strval;
/**
- * Class \SAML2\XML\saml\BaseIDTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\UnknownID
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractBaseID
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractBaseIDType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\BaseIDTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(UnknownID::class)]
+#[CoversClass(AbstractBaseID::class)]
+#[CoversClass(AbstractBaseIDType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class BaseIDTest extends TestCase
{
use SchemaValidationTestTrait;
diff --git a/tests/SAML2/XML/saml/ConditionTest.php b/tests/SAML2/XML/saml/ConditionTest.php
index 90ea11318..429eb87ea 100644
--- a/tests/SAML2/XML/saml/ConditionTest.php
+++ b/tests/SAML2/XML/saml/ConditionTest.php
@@ -4,10 +4,14 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\XML\saml\AbstractCondition;
+use SimpleSAML\SAML2\XML\saml\AbstractConditionType;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\UnknownCondition;
use SimpleSAML\Test\SAML2\Constants as C;
@@ -20,15 +24,15 @@
use function strval;
/**
- * Class \SAML2\XML\saml\ConditionTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\UnknownCondition
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractCondition
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractConditionType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\ConditionTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(UnknownCondition::class)]
+#[CoversClass(AbstractCondition::class)]
+#[CoversClass(AbstractConditionType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class ConditionTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -88,20 +92,6 @@ public function testMarshalling(): void
// unmarshalling
- /**
- * Test unmarshalling a registered class
- */
- public function testUnmarshalling(): void
- {
- $condition = CustomCondition::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($condition),
- );
- }
-
-
/**
*/
public function testUnmarshallingUnregistered(): void
diff --git a/tests/SAML2/XML/saml/ConditionsTest.php b/tests/SAML2/XML/saml/ConditionsTest.php
index 673bbbc38..561b29838 100644
--- a/tests/SAML2/XML/saml/ConditionsTest.php
+++ b/tests/SAML2/XML/saml/ConditionsTest.php
@@ -5,29 +5,31 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AudienceRestriction;
use SimpleSAML\SAML2\XML\saml\Conditions;
use SimpleSAML\SAML2\XML\saml\OneTimeUse;
use SimpleSAML\SAML2\XML\saml\ProxyRestriction;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
+use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\saml\ConditionsTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\Conditions
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\ConditionsTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Conditions::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class ConditionsTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -95,20 +97,4 @@ public function testMarshallingWithNoElements(): void
);
$this->assertTrue($conditions->isEmptyElement());
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $conditions = Conditions::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($conditions),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/EncryptedAssertionTest.php b/tests/SAML2/XML/saml/EncryptedAssertionTest.php
index 857f17b2c..f5f1b0d77 100644
--- a/tests/SAML2/XML/saml/EncryptedAssertionTest.php
+++ b/tests/SAML2/XML/saml/EncryptedAssertionTest.php
@@ -4,18 +4,19 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\EncryptedAssertion;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\Subject;
use SimpleSAML\Test\SAML2\Constants as C;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -28,22 +29,21 @@
use SimpleSAML\XMLSecurity\XML\ds\XPath;
use SimpleSAML\XMLSecurity\XML\xenc\CipherData;
use SimpleSAML\XMLSecurity\XML\xenc\CipherValue;
-use SimpleSAML\XMLSecurity\XML\xenc\DataReference;
use SimpleSAML\XMLSecurity\XML\xenc\EncryptedData;
use SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey;
use SimpleSAML\XMLSecurity\XML\xenc\EncryptionMethod;
-use SimpleSAML\XMLSecurity\XML\xenc\ReferenceList;
use function dirname;
use function strval;
/**
- * Class \SAML2\EncryptedAssertionTest
+ * Class \SimpleSAML\SAML2\XML\saml\EncryptedAssertionTest
*
* @package simplesamlphp/saml2
- * @covers \SimpleSAML\SAML2\XML\saml\EncryptedAssertion
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
*/
+#[Group('saml')]
+#[CoversClass(EncryptedAssertion::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class EncryptedAssertionTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -125,19 +125,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $encryptedAssertion = EncryptedAssertion::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($encryptedAssertion),
- );
- }
-
-
/**
* Test encryption / decryption
*/
diff --git a/tests/SAML2/XML/saml/EncryptedAttributeTest.php b/tests/SAML2/XML/saml/EncryptedAttributeTest.php
index ec7c91ccd..3cf845808 100644
--- a/tests/SAML2/XML/saml/EncryptedAttributeTest.php
+++ b/tests/SAML2/XML/saml/EncryptedAttributeTest.php
@@ -4,11 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\SAML2\XML\saml\EncryptedAttribute;
@@ -17,19 +18,18 @@
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
use SimpleSAML\XMLSecurity\Constants as C;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use function dirname;
-use function strval;
/**
- * Class \SAML2\XML\saml\EncryptedAttributeTest
+ * Class \SimpleSAML\SAML2\XML\saml\EncryptedAttributeTest
*
* @package simplesamlphp/saml2
- * @covers \SimpleSAML\SAML2\XML\saml\EncryptedAttribute
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
*/
+#[Group('saml')]
+#[CoversClass(EncryptedAttribute::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class EncryptedAttributeTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -94,17 +94,6 @@ public function testMarshalling(): void
// unmarshalling
- /**
- */
- public function testUnmarshalling(): void
- {
- $encryptedAttribute = EncryptedAttribute::fromXML(self::$xmlRepresentation->documentElement);
-
- $encryptedData = $encryptedAttribute->getEncryptedData();
- $this->assertEquals(C::XMLENC_ELEMENT, $encryptedData->getType());
- }
-
-
/**
*/
public function testDecryptAttribute(): void
diff --git a/tests/SAML2/XML/saml/EncryptedIDTest.php b/tests/SAML2/XML/saml/EncryptedIDTest.php
index 58f4da0eb..67c695784 100644
--- a/tests/SAML2/XML/saml/EncryptedIDTest.php
+++ b/tests/SAML2/XML/saml/EncryptedIDTest.php
@@ -5,21 +5,20 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Configuration;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Attribute;
-use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
-use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\UnknownID;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\Test\SAML2\CustomBaseID;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -41,10 +40,11 @@
/**
* Class EncryptedIDTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\EncryptedID
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(EncryptedID::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class EncryptedIDTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -172,19 +172,6 @@ public function testMarshallingElementOrdering(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $eid = EncryptedID::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($eid),
- );
- }
-
-
/**
* Test encryption / decryption
*/
diff --git a/tests/SAML2/XML/saml/EvidenceTest.php b/tests/SAML2/XML/saml/EvidenceTest.php
index b801b90ee..35629072b 100644
--- a/tests/SAML2/XML/saml/EvidenceTest.php
+++ b/tests/SAML2/XML/saml/EvidenceTest.php
@@ -5,7 +5,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\AssertionIDRef;
use SimpleSAML\SAML2\XML\saml\AssertionURIRef;
@@ -21,11 +24,11 @@
/**
* Class \SimpleSAML\SAML2\XML\saml\EvidenceTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Evidence
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Evidence::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class EvidenceTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -105,17 +108,4 @@ public function testMarshallingWithNoContent(): void
);
$this->assertTrue($evidence->isEmptyElement());
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $evidence = Evidence::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($evidence),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/IssuerTest.php b/tests/SAML2/XML/saml/IssuerTest.php
index 0be1cbb02..5b881c313 100644
--- a/tests/SAML2/XML/saml/IssuerTest.php
+++ b/tests/SAML2/XML/saml/IssuerTest.php
@@ -4,12 +4,14 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Issuer;
+use SimpleSAML\SAML2\XML\saml\NameIDType;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -18,13 +20,14 @@
use function strval;
/**
- * Class \SAML2\XML\saml\IssuerTest
+ * Class \SimpleSAML\SAML2\XML\saml\IssuerTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\Issuer
- * @covers \SimpleSAML\SAML2\XML\saml\NameIDType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(Issuer::class)]
+#[CoversClass(NameIDType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class IssuerTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -105,19 +108,6 @@ public function testMarshallingNoFormat(): void
// unmarshalling
- /**
- */
- public function testUnmarshalling(): void
- {
- $issuer = Issuer::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($issuer),
- );
- }
-
-
/**
* Test that creating an Issuer from XML contains no attributes when format is "entity".
*/
diff --git a/tests/SAML2/XML/saml/NameIDTest.php b/tests/SAML2/XML/saml/NameIDTest.php
index 8b051d4fe..0be63d97f 100644
--- a/tests/SAML2/XML/saml/NameIDTest.php
+++ b/tests/SAML2/XML/saml/NameIDTest.php
@@ -4,9 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\NameID;
+use SimpleSAML\SAML2\XML\saml\NameIDType;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -16,14 +19,14 @@
use function strval;
/**
- * Class \SAML2\XML\saml\NameIDTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\NameID
- * @covers \SimpleSAML\SAML2\XML\saml\NameIDType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\NameIDTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(NameID::class)]
+#[CoversClass(NameIDType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class NameIDTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -73,20 +76,4 @@ public function testMarshalling(): void
strval($nameId),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $nameId = NameID::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($nameId),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/OneTimeUseTest.php b/tests/SAML2/XML/saml/OneTimeUseTest.php
index 4d90c9d3b..30842b729 100644
--- a/tests/SAML2/XML/saml/OneTimeUseTest.php
+++ b/tests/SAML2/XML/saml/OneTimeUseTest.php
@@ -4,8 +4,11 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractConditionType;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\OneTimeUse;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,12 +20,12 @@
/**
* Class \SimpleSAML\SAML2\XML\saml\OneTimeUseTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\OneTimeUse
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractConditionType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(OneTimeUse::class)]
+#[CoversClass(AbstractConditionType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class OneTimeUseTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -53,17 +56,4 @@ public function testMarshalling(): void
strval($oneTimeUse),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $oneTimeUse = OneTimeUse::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($oneTimeUse),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/ProxyRestrictionTest.php b/tests/SAML2/XML/saml/ProxyRestrictionTest.php
index a26b33f46..b1c729678 100644
--- a/tests/SAML2/XML/saml/ProxyRestrictionTest.php
+++ b/tests/SAML2/XML/saml/ProxyRestrictionTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\ProxyRestriction;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -16,13 +18,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\ProxyRestrictionTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\ProxyRestriction
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\ProxyRestrictionTest
*
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(ProxyRestriction::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class ProxyRestrictionTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -62,20 +64,4 @@ public function testMarshalling(): void
strval($condition),
);
}
-
-
- // unmarshalling
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $condition = ProxyRestriction::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($condition),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/StatementTest.php b/tests/SAML2/XML/saml/StatementTest.php
index cdd22131f..6742910b1 100644
--- a/tests/SAML2/XML/saml/StatementTest.php
+++ b/tests/SAML2/XML/saml/StatementTest.php
@@ -4,12 +4,14 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
-use DOMElement;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Compat\AbstractContainer;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\AbstractStatement;
+use SimpleSAML\SAML2\XML\saml\AbstractStatementType;
use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\UnknownStatement;
use SimpleSAML\Test\SAML2\Constants as C;
@@ -22,14 +24,15 @@
use function strval;
/**
- * Class \SAML2\XML\saml\StatementTest
+ * Class \SimpleSAML\SAML2\XML\saml\StatementTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\UnknownStatement
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractStatement
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractStatementType
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(UnknownStatement::class)]
+#[CoversClass(AbstractStatement::class)]
+#[CoversClass(AbstractStatementType::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class StatementTest extends TestCase
{
use SchemaValidationTestTrait;
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
index f0b345e7e..9051e0338 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
@@ -5,8 +5,10 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
@@ -21,12 +23,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\SubjectConfirmationDataTest
+ * Class \SimpleSAML\SAML2\XML\saml\SubjectConfirmationDataTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\SubjectConfirmationData
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(SubjectConfirmationData::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class SubjectConfirmationDataTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -130,19 +133,6 @@ public function testMarshallingWithNonIPAddress(): void
// unmarshalling
- /**
- */
- public function testUnmarshalling(): void
- {
- $subjectConfirmationData = SubjectConfirmationData::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($subjectConfirmationData),
- );
- }
-
-
/**
*/
public function testUnmarshallingEmpty(): void
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationTest.php b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
index 822c580f8..c5cb4ecfc 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
@@ -5,11 +5,13 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
use DateTimeImmutable;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
-use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
@@ -28,12 +30,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\SubjectConfirmationTest
+ * Class \SimpleSAML\SAML2\XML\saml\SubjectConfirmationTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\SubjectConfirmation
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(SubjectConfirmation::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class SubjectConfirmationTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -154,19 +157,6 @@ public function testMarshallingElementOrdering(): void
// unmarshalling
- /**
- */
- public function testUnmarshalling(): void
- {
- $subjectConfirmation = SubjectConfirmation::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($subjectConfirmation),
- );
- }
-
-
/**
*/
public function testMethodMissingThrowsException(): void
diff --git a/tests/SAML2/XML/saml/SubjectLocalityTest.php b/tests/SAML2/XML/saml/SubjectLocalityTest.php
index 25c74e0a9..f8d6708c9 100644
--- a/tests/SAML2/XML/saml/SubjectLocalityTest.php
+++ b/tests/SAML2/XML/saml/SubjectLocalityTest.php
@@ -4,11 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\saml;
-use DOMDocument;
-use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
use SimpleSAML\SAML2\XML\saml\SubjectLocality;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,12 +18,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\SubjectLocalityTest
+ * Class \SimpleSAML\SAML2\XML\saml\SubjectLocalityTest
*
- * @covers \SimpleSAML\SAML2\XML\saml\SubjectLocality
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
* @package simplesamlphp/saml2
*/
+#[Group('saml')]
+#[CoversClass(SubjectLocality::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class SubjectLocalityTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -79,17 +80,4 @@ public function testMarshallingWithNoElements(): void
);
$this->assertTrue($subjectLocality->isEmptyElement());
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $subjectLocality = SubjectLocality::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($subjectLocality),
- );
- }
}
diff --git a/tests/SAML2/XML/saml/SubjectTest.php b/tests/SAML2/XML/saml/SubjectTest.php
index 4a6562e9c..320a17ec1 100644
--- a/tests/SAML2/XML/saml/SubjectTest.php
+++ b/tests/SAML2/XML/saml/SubjectTest.php
@@ -6,10 +6,13 @@
use DateTimeImmutable;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Utils\XPath;
-use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
+use SimpleSAML\SAML2\XML\saml\AbstractSamlElement;
+use SimpleSAML\SAML2\XML\saml\Audience;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\Subject;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
@@ -29,13 +32,13 @@
use function strval;
/**
- * Class \SAML2\XML\saml\SubjectTest
- *
- * @covers \SimpleSAML\SAML2\XML\saml\Subject
- * @covers \SimpleSAML\SAML2\XML\saml\AbstractSamlElement
+ * Class \SimpleSAML\SAML2\XML\saml\SubjectTest
*
* @package SimpleSAMLphp
*/
+#[Group('saml')]
+#[CoversClass(Subject::class)]
+#[CoversClass(AbstractSamlElement::class)]
final class SubjectTest extends TestCase
{
use SchemaValidationTestTrait;
diff --git a/tests/SAML2/XML/samlp/AbstractMessageTest.php b/tests/SAML2/XML/samlp/AbstractMessageTest.php
index 0501abb48..0d6f1611e 100644
--- a/tests/SAML2/XML/samlp/AbstractMessageTest.php
+++ b/tests/SAML2/XML/samlp/AbstractMessageTest.php
@@ -6,15 +6,17 @@
use DOMElement;
use Exception;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\Extensions;
use SimpleSAML\SAML2\XML\samlp\MessageFactory;
use SimpleSAML\SAML2\XML\samlp\Response;
@@ -23,20 +25,18 @@
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingElementException;
-use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
-use SimpleSAML\XMLSecurity\XMLSecurityKey;
use function dirname;
/**
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class AbstractMessageTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
@@ -52,8 +52,8 @@ public static function setUpBeforeClass(): void
/**
- * @group Message
*/
+ #[Group('Message')]
public function testCorrectSignatureMethodCanBeExtractedFromAuthnRequest(): void
{
$authnRequest = DOMDocumentFactory::fromString(<<documentElement);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($ar),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/ArtifactResponseTest.php b/tests/SAML2/XML/samlp/ArtifactResponseTest.php
index 5df1f8ea9..273af8001 100644
--- a/tests/SAML2/XML/samlp/ArtifactResponseTest.php
+++ b/tests/SAML2/XML/samlp/ArtifactResponseTest.php
@@ -5,13 +5,16 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\saml\Issuer;
-use SimpleSAML\SAML2\XML\samlp\AuthnRequest;
-use SimpleSAML\SAML2\XML\samlp\ArtifactResolve;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
+use SimpleSAML\SAML2\XML\samlp\AbstractStatusResponse;
use SimpleSAML\SAML2\XML\samlp\ArtifactResponse;
+use SimpleSAML\SAML2\XML\samlp\AuthnRequest;
use SimpleSAML\SAML2\XML\samlp\NameIDPolicy;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
@@ -24,12 +27,13 @@
use function strval;
/**
- * @covers \SimpleSAML\SAML2\XML\samlp\ArtifactResponse
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractStatusResponse
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(ArtifactResponse::class)]
+#[CoversClass(AbstractStatusResponse::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class ArtifactResponseTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -92,17 +96,4 @@ public function testMarshalling(): void
strval($artifactResponse),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $ar = ArtifactResponse::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($ar),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/AssertionIDRequestTest.php b/tests/SAML2/XML/samlp/AssertionIDRequestTest.php
index f24c28b93..426097854 100644
--- a/tests/SAML2/XML/samlp/AssertionIDRequestTest.php
+++ b/tests/SAML2/XML/samlp/AssertionIDRequestTest.php
@@ -5,12 +5,14 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\saml\AssertionIDRef;
use SimpleSAML\SAML2\XML\saml\Issuer;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractRequest;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\AssertionIDRequest;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -21,14 +23,15 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\AssertionIDRequestTest
+ * Class \SimpleSAML\SAML2\XML\samlp\AssertionIDRequestTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\AssertionIDRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(AssertionIDRequest::class)]
+#[CoversClass(AbstractRequest::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class AssertionIDRequestTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -70,17 +73,4 @@ public function testMarshalling(): void
strval($assertionIDRequest),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $assertionIDRequest = AssertionIDRequest::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($assertionIDRequest),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/AttributeQueryTest.php b/tests/SAML2/XML/samlp/AttributeQueryTest.php
index dbb3237e8..dd9365e86 100644
--- a/tests/SAML2/XML/samlp/AttributeQueryTest.php
+++ b/tests/SAML2/XML/samlp/AttributeQueryTest.php
@@ -5,7 +5,8 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Constants as C;
@@ -16,10 +17,14 @@
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\Subject;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractRequest;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
+use SimpleSAML\SAML2\XML\samlp\AbstractSubjectQuery;
use SimpleSAML\SAML2\XML\samlp\AttributeQuery;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\MissingAttributeException;
+use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -29,15 +34,16 @@
use function strval;
/**
- * Class \SAML2\AttributeQueryTest
+ * Class \SimpleSAML\SAML2\XML\samlp\AttributeQueryTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\AttributeQuery
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSubjectQuery
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(AttributeQuery::class)]
+#[CoversClass(AbstractSubjectQuery::class)]
+#[CoversClass(AbstractRequest::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class AttributeQueryTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -115,17 +121,6 @@ public function testMarshalling(): void
}
- public function testUnmarshalling(): void
- {
- $aq = AttributeQuery::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($aq),
- );
- }
-
-
public function testAttributeNameFormat(): void
{
$nameId = new NameID('NameIDValue');
diff --git a/tests/SAML2/XML/samlp/AuthnQueryTest.php b/tests/SAML2/XML/samlp/AuthnQueryTest.php
index 9fe5e1718..16f61b5a0 100644
--- a/tests/SAML2/XML/samlp/AuthnQueryTest.php
+++ b/tests/SAML2/XML/samlp/AuthnQueryTest.php
@@ -5,21 +5,22 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\Comparison;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\Subject;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractRequest;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
+use SimpleSAML\SAML2\XML\samlp\AbstractSubjectQuery;
use SimpleSAML\SAML2\XML\samlp\AuthnQuery;
use SimpleSAML\SAML2\XML\samlp\RequestedAuthnContext;
use SimpleSAML\XML\DOMDocumentFactory;
-use SimpleSAML\XML\Exception\MissingElementException;
-use SimpleSAML\XML\Exception\MissingAttributeException;
-use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
@@ -30,13 +31,14 @@
/**
* Class \SimpleSAML\SAML2\XML\samlp\AuthnQueryTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\AuthnQuery
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSubjectQuery
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(AuthnQuery::class)]
+#[CoversClass(AbstractSubjectQuery::class)]
+#[CoversClass(AbstractRequest::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class AuthnQueryTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -83,15 +85,4 @@ public function testMarshalling(): void
strval($authnQuery),
);
}
-
-
- public function testUnmarshalling(): void
- {
- $authnQuery = AuthnQuery::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnQuery),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/AuthnRequestTest.php b/tests/SAML2/XML/samlp/AuthnRequestTest.php
index c3b4fbc5b..e5b72a5d0 100644
--- a/tests/SAML2/XML/samlp/AuthnRequestTest.php
+++ b/tests/SAML2/XML/samlp/AuthnRequestTest.php
@@ -5,12 +5,11 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
-use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Compat\MockContainer;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
@@ -25,6 +24,8 @@
use SimpleSAML\SAML2\XML\saml\OneTimeUse;
use SimpleSAML\SAML2\XML\saml\ProxyRestriction;
use SimpleSAML\SAML2\XML\saml\Subject;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\AuthnRequest;
use SimpleSAML\SAML2\XML\samlp\GetComplete;
use SimpleSAML\SAML2\XML\samlp\IDPEntry;
@@ -39,26 +40,22 @@
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
-use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmFactory;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
-use SimpleSAML\XMLSecurity\Key\PublicKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
-use SimpleSAML\XMLSecurity\XMLSecurityKey;
use function dirname;
use function strval;
/**
- * Class \SAML2\XML\samlp\AuthnRequestTest
+ * Class \SimpleSAML\SAML2\XML\samlp\AuthnRequestTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\AuthnRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(AuthnRequest::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class AuthnRequestTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -457,17 +454,4 @@ public function testEmptySubjectThrowsException(): void
);
AuthnRequest::fromXML(DOMDocumentFactory::fromString($xml)->documentElement);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $authnRequest = AuthnRequest::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authnRequest),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/AuthzDecisionQueryTest.php b/tests/SAML2/XML/samlp/AuthzDecisionQueryTest.php
index 1c29541f5..1ed53ad08 100644
--- a/tests/SAML2/XML/samlp/AuthzDecisionQueryTest.php
+++ b/tests/SAML2/XML/samlp/AuthzDecisionQueryTest.php
@@ -6,15 +6,21 @@
use DateTimeImmutable;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\saml\Action;
use SimpleSAML\SAML2\XML\saml\Assertion;
use SimpleSAML\SAML2\XML\saml\Evidence;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\saml\Subject;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractRequest;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
+use SimpleSAML\SAML2\XML\samlp\AbstractSubjectQuery;
use SimpleSAML\SAML2\XML\samlp\AuthzDecisionQuery;
+use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -26,13 +32,14 @@
/**
* Class \SimpleSAML\SAML2\XML\samlp\AuthzDecisionQueryTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\AuthzDecisionQuery
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSubjectQuery
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(AuthzDecisionQuery::class)]
+#[CoversClass(AbstractSubjectQuery::class)]
+#[CoversClass(AbstractRequest::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class AuthzDecisionQueryTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -91,15 +98,4 @@ public function testMarshalling(): void
strval($authzDecisionQuery),
);
}
-
-
- public function testUnmarshalling(): void
- {
- $authzDecisionQuery = AuthzDecisionQuery::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($authzDecisionQuery),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/ExtensionsTest.php b/tests/SAML2/XML/samlp/ExtensionsTest.php
index 104ee6a2e..e2699102c 100644
--- a/tests/SAML2/XML/samlp/ExtensionsTest.php
+++ b/tests/SAML2/XML/samlp/ExtensionsTest.php
@@ -4,12 +4,13 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\Extensions;
-use SimpleSAML\SAML2\XML\shibmd\Scope;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -19,12 +20,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\ExtensionsTest
+ * Class \SimpleSAML\SAML2\XML\samlp\ExtensionsTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\Extensions
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(Extensions::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class ExtensionsTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -72,19 +74,6 @@ public function testMarshalling(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $extensions = Extensions::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($extensions),
- );
- }
-
-
/**
* Adding a non-namespaced element to an md:Extensions element should throw an exception
*/
diff --git a/tests/SAML2/XML/samlp/GetCompleteTest.php b/tests/SAML2/XML/samlp/GetCompleteTest.php
index 64c26a020..965cc944e 100644
--- a/tests/SAML2/XML/samlp/GetCompleteTest.php
+++ b/tests/SAML2/XML/samlp/GetCompleteTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\GetComplete;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -18,11 +20,11 @@
/**
* Class \SimpleSAML\SAML2\XML\samlp\GetCompleteTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\GetComplete
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(GetComplete::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class GetCompleteTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -59,17 +61,4 @@ public function testMarshalling(): void
strval($getComplete),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $getComplete = GetComplete::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($getComplete),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/IDPEntryTest.php b/tests/SAML2/XML/samlp/IDPEntryTest.php
index 0338eb928..da9709a36 100644
--- a/tests/SAML2/XML/samlp/IDPEntryTest.php
+++ b/tests/SAML2/XML/samlp/IDPEntryTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\IDPEntry;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -16,13 +18,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\IDPEntryTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\IDPEntry
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\samlp\IDPEntryTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(IDPEntry::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class IDPEntryTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -82,17 +84,4 @@ public function testMarshallingNullables(): void
strval($entry),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $entry = IDPEntry::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($entry),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/IDPListTest.php b/tests/SAML2/XML/samlp/IDPListTest.php
index 5740ed573..eb3686137 100644
--- a/tests/SAML2/XML/samlp/IDPListTest.php
+++ b/tests/SAML2/XML/samlp/IDPListTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\GetComplete;
use SimpleSAML\SAML2\XML\samlp\IDPEntry;
use SimpleSAML\SAML2\XML\samlp\IDPList;
@@ -20,13 +22,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\IDPListTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\IDPList
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\samlp\IDPListTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(IDPList::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class IDPListTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -125,19 +127,6 @@ public function testMarshallingNullables(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $list = IDPList::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($list),
- );
- }
-
-
/**
*/
public function testZeroIDPEntriesThrowsException(): void
diff --git a/tests/SAML2/XML/samlp/LogoutRequestTest.php b/tests/SAML2/XML/samlp/LogoutRequestTest.php
index 92dfe3f1c..6d69c0517 100644
--- a/tests/SAML2/XML/samlp/LogoutRequestTest.php
+++ b/tests/SAML2/XML/samlp/LogoutRequestTest.php
@@ -4,44 +4,43 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
-use DOMElement;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
-use SimpleSAML\SAML2\Compat\MockContainer;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils;
use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractRequest;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\LogoutRequest;
use SimpleSAML\SAML2\XML\samlp\SessionIndex;
-use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmFactory;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
-use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait;
use function dirname;
-use function strval;
/**
- * Class \SAML2\XML\samlp\LogoutRequestTest
+ * Class \SimpleSAML\SAML2\XML\samlp\LogoutRequestTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\LogoutRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractRequest
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(LogoutRequest::class)]
+#[CoversClass(AbstractRequest::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class LogoutRequestTest extends TestCase
{
use SchemaValidationTestTrait;
diff --git a/tests/SAML2/XML/samlp/LogoutResponseTest.php b/tests/SAML2/XML/samlp/LogoutResponseTest.php
index af6feede8..673026cd7 100644
--- a/tests/SAML2/XML/samlp/LogoutResponseTest.php
+++ b/tests/SAML2/XML/samlp/LogoutResponseTest.php
@@ -5,10 +5,14 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\saml\Issuer;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
+use SimpleSAML\SAML2\XML\samlp\AbstractStatusResponse;
use SimpleSAML\SAML2\XML\samlp\LogoutResponse;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
@@ -21,14 +25,15 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\LogoutResponseTest
+ * Class \SimpleSAML\SAML2\XML\samlp\LogoutResponseTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\LogoutResponse
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractStatusResponse
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(LogoutResponse::class)]
+#[CoversClass(AbstractStatusResponse::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class LogoutResponseTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -71,17 +76,4 @@ public function testMarshalling(): void
strval($logoutResponse)
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $logoutResponse = LogoutResponse::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($logoutResponse),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/MessageFactoryTest.php b/tests/SAML2/XML/samlp/MessageFactoryTest.php
index 1722bc50a..d62f82277 100644
--- a/tests/SAML2/XML/samlp/MessageFactoryTest.php
+++ b/tests/SAML2/XML/samlp/MessageFactoryTest.php
@@ -4,27 +4,29 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\saml\Attribute;
-use SimpleSAML\SAML2\XML\samlp\AttributeQuery;
use SimpleSAML\SAML2\XML\samlp\ArtifactResolve;
use SimpleSAML\SAML2\XML\samlp\ArtifactResponse;
+use SimpleSAML\SAML2\XML\samlp\AttributeQuery;
use SimpleSAML\SAML2\XML\samlp\AuthnRequest;
use SimpleSAML\SAML2\XML\samlp\LogoutRequest;
use SimpleSAML\SAML2\XML\samlp\LogoutResponse;
use SimpleSAML\SAML2\XML\samlp\MessageFactory;
use SimpleSAML\SAML2\XML\samlp\Response;
-use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use function dirname;
-use function strval;
/**
- * @covers \SimpleSAML\SAML2\XML\samlp\MessageFactory
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(MessageFactory::class)]
final class MessageFactoryTest extends TestCase
{
/**
@@ -48,9 +50,9 @@ public static function provideMessages(): array
/**
* @param string $file
- * @param class-string class
- * @dataProvider provideMessages
+ * @param class-string $class
*/
+ #[DataProvider('provideMessages')]
public function testMessageFactory(string $file, string $class): void
{
$document = DOMDocumentFactory::fromFile($file);
diff --git a/tests/SAML2/XML/samlp/NameIDPolicyTest.php b/tests/SAML2/XML/samlp/NameIDPolicyTest.php
index e91141bc0..f12eedbfc 100644
--- a/tests/SAML2/XML/samlp/NameIDPolicyTest.php
+++ b/tests/SAML2/XML/samlp/NameIDPolicyTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\NameIDPolicy;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
@@ -17,13 +19,13 @@
use function strval;
/**
- * Class \SAML2\XML\md\NameIDPolicyTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\NameIDPolicy
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\md\NameIDPolicyTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(NameIDPolicy::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class NameIDPolicyTest extends TestCase
{
use ArrayizableElementTestTrait;
@@ -100,17 +102,4 @@ public function testMarshallingEmptyElement(): void
);
$this->assertTrue($nameIdPolicy->isEmptyElement());
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $nameIdPolicy = NameIDPolicy::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($nameIdPolicy),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/RequestedAuthnContextTest.php b/tests/SAML2/XML/samlp/RequestedAuthnContextTest.php
index 908998cc0..4db5e2974 100644
--- a/tests/SAML2/XML/samlp/RequestedAuthnContextTest.php
+++ b/tests/SAML2/XML/samlp/RequestedAuthnContextTest.php
@@ -4,13 +4,15 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\Comparison;
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef;
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\RequestedAuthnContext;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -20,12 +22,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\RequestedAuthnContextTest
+ * Class \SimpleSAML\SAML2\XML\samlp\RequestedAuthnContextTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\RequestedAuthnContext
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(RequestedAuthnContext::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class RequestedAuthnContextTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -98,19 +101,6 @@ public function testMarshallingWithInvalidContentFails(): void
}
- /**
- */
- public function testUnmarshalling(): void
- {
- $requestedAuthnContext = RequestedAuthnContext::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requestedAuthnContext),
- );
- }
-
-
/**
*/
public function testUnmarshallingWithMixedContextsFails(): void
diff --git a/tests/SAML2/XML/samlp/RequesterIDTest.php b/tests/SAML2/XML/samlp/RequesterIDTest.php
index 7bab01007..d65dfa86b 100644
--- a/tests/SAML2/XML/samlp/RequesterIDTest.php
+++ b/tests/SAML2/XML/samlp/RequesterIDTest.php
@@ -4,10 +4,13 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\RequesterID;
use SimpleSAML\XML\DOMDocumentFactory;
+use SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -17,13 +20,14 @@
/**
* Class \SimpleSAML\SAML2\XML\samlp\RequesterIDTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\RequesterID
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(RequesterID::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class RequesterIDTest extends TestCase
{
+ use ArrayizableElementTestTrait;
use SchemaValidationTestTrait;
use SerializableElementTestTrait;
@@ -38,6 +42,8 @@ public static function setUpBeforeClass(): void
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 4) . '/resources/xml/samlp_RequesterID.xml',
);
+
+ self::$arrayRepresentation = ['urn:some:requester'];
}
@@ -52,17 +58,4 @@ public function testMarshalling(): void
strval($requesterId),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $requesterId = RequesterID::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requesterId),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/ResponseTest.php b/tests/SAML2/XML/samlp/ResponseTest.php
index 7cf4c9374..bf5a1f8df 100644
--- a/tests/SAML2/XML/samlp/ResponseTest.php
+++ b/tests/SAML2/XML/samlp/ResponseTest.php
@@ -5,14 +5,18 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DateTimeImmutable;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils\XPath;
use SimpleSAML\SAML2\XML\saml\Assertion;
+use SimpleSAML\SAML2\XML\saml\Issuer;
+use SimpleSAML\SAML2\XML\samlp\AbstractMessage;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
+use SimpleSAML\SAML2\XML\samlp\AbstractStatusResponse;
use SimpleSAML\SAML2\XML\samlp\Response;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
-use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -22,14 +26,15 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\ResponseTest
+ * Class \SimpleSAML\SAML2\XML\samlp\ResponseTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\Response
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractStatusResponse
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(Response::class)]
+#[CoversClass(AbstractStatusResponse::class)]
+#[CoversClass(AbstractMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class ResponseTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -77,18 +82,4 @@ public function testMarshalling(): void
strval($response),
);
}
-
-
- /**
- * Unmarshalling of a response tag
- */
- public function testUnmarshalling(): void
- {
- $response = Response::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($response),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/ScopingTest.php b/tests/SAML2/XML/samlp/ScopingTest.php
index 0b30302d4..9d01c8118 100644
--- a/tests/SAML2/XML/samlp/ScopingTest.php
+++ b/tests/SAML2/XML/samlp/ScopingTest.php
@@ -4,10 +4,12 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\GetComplete;
use SimpleSAML\SAML2\XML\samlp\IDPEntry;
use SimpleSAML\SAML2\XML\samlp\IDPList;
@@ -21,13 +23,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\ScopingTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\Scoping
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\samlp\ScopingTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(Scoping::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class ScopingTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -107,17 +109,4 @@ public function testMarshallingWithNoElements(): void
);
$this->assertTrue($scoping->isEmptyElement());
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $scoping = Scoping::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($scoping),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/SessionIndexTest.php b/tests/SAML2/XML/samlp/SessionIndexTest.php
index e9ceec49d..cf2360b51 100644
--- a/tests/SAML2/XML/samlp/SessionIndexTest.php
+++ b/tests/SAML2/XML/samlp/SessionIndexTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\SessionIndex;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,11 +19,11 @@
/**
* Class \SimpleSAML\SAML2\XML\samlp\SessionIndexTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\SessionIndex
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(SessionIndex::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class SessionIndexTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -52,17 +54,4 @@ public function testMarshalling(): void
strval($sessionIndex),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $sessionIndex = SessionIndex::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($sessionIndex),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/StatusCodeTest.php b/tests/SAML2/XML/samlp/StatusCodeTest.php
index 4c0c3edc7..8893ee583 100644
--- a/tests/SAML2/XML/samlp/StatusCodeTest.php
+++ b/tests/SAML2/XML/samlp/StatusCodeTest.php
@@ -4,10 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
-use SimpleSAML\SAML2\Utils;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,13 +18,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\StatusCodeTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\StatusCode
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\samlp\StatusCodeTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(StatusCode::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class StatusCodeTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -61,17 +62,4 @@ public function testMarshalling(): void
strval($statusCode),
);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $statusCode = StatusCode::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($statusCode),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/StatusDetailTest.php b/tests/SAML2/XML/samlp/StatusDetailTest.php
index c233e8593..c16fcd969 100644
--- a/tests/SAML2/XML/samlp/StatusDetailTest.php
+++ b/tests/SAML2/XML/samlp/StatusDetailTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\StatusDetail;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
@@ -17,13 +19,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\StatusDetailTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\StatusDetail
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\samlp\StatusDetailTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(StatusDetail::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class StatusDetailTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -74,17 +76,4 @@ public function testMarshallingEmptyElement(): void
);
$this->assertTrue($statusDetail->isEmptyElement());
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $statusDetail = StatusDetail::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($statusDetail),
- );
- }
}
diff --git a/tests/SAML2/XML/samlp/StatusMessageTest.php b/tests/SAML2/XML/samlp/StatusMessageTest.php
index 251dfb6f2..9cd31ff64 100644
--- a/tests/SAML2/XML/samlp/StatusMessageTest.php
+++ b/tests/SAML2/XML/samlp/StatusMessageTest.php
@@ -4,8 +4,10 @@
namespace SimpleSAML\SAML2\Test\SAML2\XML\samlp;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\StatusMessage;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -17,11 +19,11 @@
/**
* Class \SimpleSAML\SAML2\XML\samlp\StatusMessageTest
*
- * @covers \SimpleSAML\SAML2\XML\samlp\StatusMessage
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
- *
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(StatusMessage::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class StatusMessageTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -47,20 +49,6 @@ public function testMarshalling(): void
{
$statusMessage = new StatusMessage('Something went wrong');
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($statusMessage),
- );
- }
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $statusMessage = StatusMessage::fromXML(self::$xmlRepresentation->documentElement);
-
-
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($statusMessage),
diff --git a/tests/SAML2/XML/samlp/StatusTest.php b/tests/SAML2/XML/samlp/StatusTest.php
index 6ff602a90..dd89c1366 100644
--- a/tests/SAML2/XML/samlp/StatusTest.php
+++ b/tests/SAML2/XML/samlp/StatusTest.php
@@ -5,9 +5,12 @@
namespace SimpleSAML\Test\SAML2\XML\samlp;
use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
use SimpleSAML\SAML2\XML\samlp\Status;
use SimpleSAML\SAML2\XML\samlp\StatusCode;
use SimpleSAML\SAML2\XML\samlp\StatusDetail;
@@ -21,13 +24,13 @@
use function strval;
/**
- * Class \SAML2\XML\samlp\StatusTest
- *
- * @covers \SimpleSAML\SAML2\XML\samlp\Status
- * @covers \SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement
+ * Class \SimpleSAML\SAML2\XML\samlp\StatusTest
*
* @package simplesamlphp/saml2
*/
+#[Group('samlp')]
+#[CoversClass(Status::class)]
+#[CoversClass(AbstractSamlpElement::class)]
final class StatusTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -118,17 +121,4 @@ public function testMarshallingElementOrdering(): void
$this->assertEquals('samlp:StatusMessage', $statusElements[0]->tagName);
$this->assertEquals('samlp:StatusDetail', $statusElements[1]->tagName);
}
-
-
- /**
- */
- public function testUnmarshalling(): void
- {
- $status = Status::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($status),
- );
- }
}
diff --git a/tests/SAML2/XML/shibmd/KeyAuthorityTest.php b/tests/SAML2/XML/shibmd/KeyAuthorityTest.php
index bdf8200d6..fc390f87d 100644
--- a/tests/SAML2/XML/shibmd/KeyAuthorityTest.php
+++ b/tests/SAML2/XML/shibmd/KeyAuthorityTest.php
@@ -4,29 +4,30 @@
namespace SimpleSAML\Test\SAML2\XML\shibmd;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
+use SimpleSAML\SAML2\XML\shibmd\AbstractShibmdElement;
use SimpleSAML\SAML2\XML\shibmd\KeyAuthority;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
-use SimpleSAML\XML\Utils as XMLUtils;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
-use function array_pop;
use function dirname;
use function strval;
/**
* Class \SimpleSAML\SAML2\XML\shibmd\KeyAuthority
*
- * @covers \SimpleSAML\SAML2\XML\shibmd\KeyAuthority
- * @covers \SimpleSAML\SAML2\XML\shibmd\AbstractShibmdElement
* @package simplesamlphp/saml2
*/
+#[Group('shibmd')]
+#[CoversClass(KeyAuthority::class)]
+#[CoversClass(AbstractShibmdElement::class)]
final class KeyAuthorityTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -82,34 +83,4 @@ public function testMarshalling(): void
strval($keyAuthority),
);
}
-
-
- /**
- * Unmarshalling a KeyAuthority.
- */
- public function testUnmarshalling(): void
- {
- $keyAuthority = KeyAuthority::fromXML(self::$xmlRepresentation->documentElement);
- $this->assertEquals(2, $keyAuthority->getVerifyDepth());
-
- $keys = $keyAuthority->getKeys();
- $this->assertCount(2, $keys);
-
- $this->assertEquals('abc123', $keys[0]->getId());
- $this->assertEquals('def456', $keys[1]->getId());
-
- $attributes = $keyAuthority->getAttributesNS();
- $this->assertCount(1, $attributes);
-
- $attribute = array_pop($attributes);
- $this->assertEquals(
- [
- 'namespaceURI' => 'urn:test:something',
- 'namespacePrefix' => 'test',
- 'attrName' => 'attr1',
- 'attrValue' => 'testval1',
- ],
- $attribute->toArray(),
- );
- }
}
diff --git a/tests/SAML2/XML/shibmd/ScopeTest.php b/tests/SAML2/XML/shibmd/ScopeTest.php
index c1604939d..04fc0fde1 100644
--- a/tests/SAML2/XML/shibmd/ScopeTest.php
+++ b/tests/SAML2/XML/shibmd/ScopeTest.php
@@ -4,9 +4,11 @@
namespace SimpleSAML\Test\SAML2\XML\shibmd;
-use DOMDocument;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Utils\XPath;
+use SimpleSAML\SAML2\XML\shibmd\AbstractShibmdElement;
use SimpleSAML\SAML2\XML\shibmd\Scope;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
@@ -18,10 +20,11 @@
/**
* Class \SimpleSAML\SAML2\XML\shibmd\Scope
*
- * @covers \SimpleSAML\SAML2\XML\shibmd\Scope
- * @covers \SimpleSAML\SAML2\XML\shibmd\AbstractShibmdElement
* @package simplesamlphp/saml2
*/
+#[Group('shibmd')]
+#[CoversClass(Scope::class)]
+#[CoversClass(AbstractShibmdElement::class)]
final class ScopeTest extends TestCase
{
use SchemaValidationTestTrait;
@@ -101,18 +104,6 @@ public function testMarshallingRegexp(): void
}
- /**
- * Unmarshalling a scope in literal (non-regexp) form.
- */
- public function testUnmarshalling(): void
- {
- $scope = Scope::fromXML(self::$xmlRepresentation->documentElement);
-
- $this->assertEquals('example.org', $scope->getContent());
- $this->assertFalse($scope->isRegexpScope());
- }
-
-
/**
* Unmarshalling a scope that does not specify an explicit
* regexp value (assumed to be false).
diff --git a/tests/bin/authnrequest.php b/tests/bin/authnrequest.php
new file mode 100644
index 000000000..8e936dc1d
--- /dev/null
+++ b/tests/bin/authnrequest.php
@@ -0,0 +1,44 @@
+#!/usr/bin/env php
+setBlacklistedAlgorithms(null);
+ContainerSingleton::setContainer($container);
+
+$encryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
+ C::KEY_TRANSPORT_OAEP,
+ PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY),
+);
+
+$nid = new NameID('very secret');
+$eid = new EncryptedID($nid->encrypt($encryptor));
+
+$issuer = new Issuer('https://gateway.example.org/saml20/sp/metadata');
+$subject = new Subject($eid);
+
+$authnRequest = new AuthnRequest(
+ subject: $subject,
+ issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
+ issuer: $issuer,
+ id: '123',
+ destination: 'https://tiqr.example.org/idp/profile/saml2/Redirect/SSO',
+);
+
+$authnRequest = $authnRequest->toXML();
+
+echo $authnRequest->ownerDocument->saveXML();
diff --git a/tests/bin/encryptedassertion.php b/tests/bin/encryptedassertion.php
new file mode 100644
index 000000000..581b50a8a
--- /dev/null
+++ b/tests/bin/encryptedassertion.php
@@ -0,0 +1,28 @@
+#!/usr/bin/env php
+setBlacklistedAlgorithms(null);
+ContainerSingleton::setContainer($container);
+
+$encryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
+ C::KEY_TRANSPORT_OAEP_MGF1P,
+ PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY)
+);
+
+$document = DOMDocumentFactory::fromFile(dirname(__FILE__, 2) . '/resources/xml/saml_Assertion.xml');
+$assertion = Assertion::fromXML($document->documentElement);
+$eassertion = new EncryptedAssertion($assertion->encrypt($encryptor));
+
+echo $eassertion->toXML()->ownerDocument->saveXML();
diff --git a/tests/bin/encryptedattribute.php b/tests/bin/encryptedattribute.php
new file mode 100644
index 000000000..ecf42c96d
--- /dev/null
+++ b/tests/bin/encryptedattribute.php
@@ -0,0 +1,29 @@
+#!/usr/bin/env php
+setBlacklistedAlgorithms(null);
+ContainerSingleton::setContainer($container);
+
+$encryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
+ C::KEY_TRANSPORT_OAEP,
+ PEMCertificatesMock::getPublicKey(PEMCertificatesMock::PUBLIC_KEY)
+);
+$attribute = new Attribute(
+ name: 'urn:encrypted:attribute',
+ attributeValue: [new AttributeValue('very secret data')],
+);
+$encAttribute = new EncryptedAttribute($attribute->encrypt($encryptor));
+
+echo $encAttribute->toXML()->ownerDocument->saveXML();
diff --git a/tests/bin/encryptedid.php b/tests/bin/encryptedid.php
new file mode 100644
index 000000000..79ac81228
--- /dev/null
+++ b/tests/bin/encryptedid.php
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+setBlacklistedAlgorithms(null);
+ContainerSingleton::setContainer($container);
+
+$encryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
+ C::KEY_TRANSPORT_OAEP,
+ PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY)
+);
+$nid = new NameID('very secret');
+$eid = new EncryptedID($nid->encrypt($encryptor));
+
+echo $eid->toXML()->ownerDocument->saveXML();
diff --git a/tests/bin/entityattributes.php b/tests/bin/entityattributes.php
new file mode 100644
index 000000000..9b85ee59e
--- /dev/null
+++ b/tests/bin/entityattributes.php
@@ -0,0 +1,89 @@
+#!/usr/bin/env php
+getAlgorithm(
+ C::SIG_RSA_SHA256,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::SELFSIGNED_PRIVATE_KEY),
+);
+
+$unsignedAssertion = new Assertion(
+ issuer: new Issuer('testIssuer'),
+ issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
+ id: '_93af655219464fb403b34436cfb0c5cb1d9a5502',
+ subject: new Subject(new NameID(
+ value: 'some:entity',
+ Format: C::NAMEID_ENTITY,
+ )),
+ conditions: new Conditions(
+ condition: [],
+ audienceRestriction: [
+ new AudienceRestriction([
+ new Audience('https://simplesamlphp.org/idp/metadata'),
+ new Audience('urn:x-simplesamlphp:phpunit:entity'),
+ ]),
+ ],
+ ),
+ statements: [new AttributeStatement([
+ new Attribute(
+ name: 'urn:mace:dir:attribute-def:uid',
+ nameFormat: C::NAMEFORMAT_URI,
+ attributeValue: [new AttributeValue('student2')],
+ ),
+ new Attribute(
+ name: 'urn:mace:terena.org:attribute-def:schacHomeOrganization',
+ nameFormat: C::NAMEFORMAT_URI,
+ attributeValue: [new AttributeValue('university.example.org'), new AttributeValue('bbb.cc')],
+ ),
+ new Attribute(
+ name: 'urn:schac:attribute-def:schacPersonalUniqueCode',
+ nameFormat: C::NAMEFORMAT_URI,
+ attributeValue: [
+ new AttributeValue('urn:schac:personalUniqueCode:nl:local:uvt.nl:memberid:524020'),
+ new AttributeValue('urn:schac:personalUniqueCode:nl:local:surfnet.nl:studentid:12345'),
+ ],
+ ),
+ new Attribute(
+ name: 'urn:mace:dir:attribute-def:eduPersonAffiliation',
+ nameFormat: C::NAMEFORMAT_URI,
+ attributeValue: [new AttributeValue('member'), new AttributeValue('student')],
+ ),
+ ])],
+);
+$unsignedAssertion->sign($signer);
+$signedAssertion = Assertion::fromXML($unsignedAssertion->toXML());
+$entityAttributes = new EntityAttributes([
+ new Attribute(
+ name: 'attrib1',
+ nameFormat: C::NAMEFORMAT_URI,
+ attributeValue: [new AttributeValue('is'), new AttributeValue('really'), new AttributeValue('cool')],
+ ),
+ $signedAssertion,
+ new Attribute(
+ name: 'foo',
+ nameFormat: 'urn:simplesamlphp:v1:simplesamlphp',
+ attributeValue: [new AttributeValue('is'), new AttributeValue('really'), new AttributeValue('cool')],
+ ),
+]);
+
+echo $entityAttributes->toXML()->ownerDocument?->saveXML();
diff --git a/tests/bin/logoutrequest.php b/tests/bin/logoutrequest.php
new file mode 100644
index 000000000..e3b913c65
--- /dev/null
+++ b/tests/bin/logoutrequest.php
@@ -0,0 +1,39 @@
+#!/usr/bin/env php
+setBlacklistedAlgorithms(null);
+ContainerSingleton::setContainer($container);
+
+$encryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
+ C::KEY_TRANSPORT_OAEP,
+ PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY)
+);
+$nid = new NameID('very secret');
+$eid = new EncryptedID($nid->encrypt($encryptor));
+
+$logoutRequest = new LogoutRequest(
+ identifier: $eid,
+ issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
+ sessionIndexes: [new SessionIndex('SomeSessionIndex1'), new SessionIndex('SomeSessionIndex2')],
+ issuer: new Issuer('urn:test:TheIssuer')
+);
+
+$logoutRequest = $logoutRequest->toXML();
+
+echo $logoutRequest->ownerDocument->saveXML();
diff --git a/tests/bin/signedassertion.php b/tests/bin/signedassertion.php
new file mode 100644
index 000000000..e5d08dc12
--- /dev/null
+++ b/tests/bin/signedassertion.php
@@ -0,0 +1,22 @@
+#!/usr/bin/env php
+documentElement);
+
+$signer = (new SignatureAlgorithmFactory())->getAlgorithm(
+ C::SIG_RSA_SHA256,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::SELFSIGNED_PRIVATE_KEY),
+);
+
+$unsignedAssertion = Assertion::fromXML($document->documentElement);
+$unsignedAssertion->sign($signer);
+echo $unsignedAssertion->toXML()->ownerDocument->saveXML();
diff --git a/tests/bin/signedassertion_tampered.php b/tests/bin/signedassertion_tampered.php
new file mode 100644
index 000000000..5a58becc5
--- /dev/null
+++ b/tests/bin/signedassertion_tampered.php
@@ -0,0 +1,22 @@
+#!/usr/bin/env php
+documentElement);
+
+$signer = (new SignatureAlgorithmFactory())->getAlgorithm(
+ C::SIG_RSA_SHA256,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::SELFSIGNED_PRIVATE_KEY),
+);
+
+$unsignedAssertion = Assertion::fromXML($document->documentElement);
+$unsignedAssertion->sign($signer);
+echo str_replace('127.0.0.1', '127.0.0.2', strval($unsignedAssertion->toXML()->ownerDocument->saveXML()));
diff --git a/tests/bin/signedassertion_with_comments.php b/tests/bin/signedassertion_with_comments.php
new file mode 100644
index 000000000..51ad81396
--- /dev/null
+++ b/tests/bin/signedassertion_with_comments.php
@@ -0,0 +1,26 @@
+#!/usr/bin/env php
+documentElement);
+
+$signer = (new SignatureAlgorithmFactory())->getAlgorithm(
+ C::SIG_RSA_SHA256,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::SELFSIGNED_PRIVATE_KEY),
+);
+
+$unsignedAssertion = Assertion::fromXML($document->documentElement);
+$unsignedAssertion->sign($signer);
+echo str_replace(
+ 'SomeNameIDValue',
+ 'SomeNameIDValue',
+ strval($unsignedAssertion->toXML()->ownerDocument->saveXML()),
+);
diff --git a/tests/bin/signedresponse_with_signedassertion.php b/tests/bin/signedresponse_with_signedassertion.php
new file mode 100644
index 000000000..3a47d14b8
--- /dev/null
+++ b/tests/bin/signedresponse_with_signedassertion.php
@@ -0,0 +1,45 @@
+#!/usr/bin/env php
+getAlgorithm(
+ C::SIG_RSA_SHA256,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::OTHER_PRIVATE_KEY),
+);
+
+$document = DOMDocumentFactory::fromFile(dirname(__FILE__, 2) . '/resources/xml/saml_Assertion.xml');
+$unsignedAssertion = Assertion::fromXML($document->documentElement);
+$unsignedAssertion->sign($assertionSigner);
+$signedAssertion = Assertion::fromXML($unsignedAssertion->toXML());
+
+$unsignedResponse = new Response(
+ status: new Status(new StatusCode(C::STATUS_SUCCESS)),
+ issuer: new Issuer('https://IdentityProvider.com'),
+ issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
+ id: 'abc123',
+ inResponseTo: 'PHPUnit',
+ destination: C::ENTITY_OTHER,
+ consent: C::ENTITY_SP,
+ assertions: [$signedAssertion],
+);
+
+$responseSigner = (new SignatureAlgorithmFactory())->getAlgorithm(
+ C::SIG_RSA_SHA512,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::PRIVATE_KEY),
+);
+
+$unsignedResponse->sign($responseSigner);
+echo $unsignedResponse->toXML()->ownerDocument->saveXML();
diff --git a/tests/bin/signedresponse_with_unsignedassertion.php b/tests/bin/signedresponse_with_unsignedassertion.php
new file mode 100644
index 000000000..b5ff6b252
--- /dev/null
+++ b/tests/bin/signedresponse_with_unsignedassertion.php
@@ -0,0 +1,38 @@
+#!/usr/bin/env php
+documentElement);
+
+$unsignedResponse = new Response(
+ status: new Status(new StatusCode(C::STATUS_SUCCESS)),
+ issuer: new Issuer('https://IdentityProvider.com'),
+ issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
+ id: 'abc123',
+ inResponseTo: 'PHPUnit',
+ destination: C::ENTITY_OTHER,
+ consent: C::ENTITY_SP,
+ assertions: [$unsignedAssertion],
+);
+
+$responseSigner = (new SignatureAlgorithmFactory())->getAlgorithm(
+ C::SIG_RSA_SHA512,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::PRIVATE_KEY),
+);
+
+$unsignedResponse->sign($responseSigner);
+echo $unsignedResponse->toXML()->ownerDocument->saveXML();
diff --git a/tests/bin/unsignedresponse_with_signedassertion.php b/tests/bin/unsignedresponse_with_signedassertion.php
new file mode 100644
index 000000000..546c32562
--- /dev/null
+++ b/tests/bin/unsignedresponse_with_signedassertion.php
@@ -0,0 +1,40 @@
+#!/usr/bin/env php
+documentElement);
+
+$signer = (new SignatureAlgorithmFactory())->getAlgorithm(
+ C::SIG_RSA_SHA256,
+ PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::SELFSIGNED_PRIVATE_KEY),
+);
+
+$unsignedAssertion = Assertion::fromXML($document->documentElement);
+$unsignedAssertion->sign($signer);
+
+$unsignedResponse = new Response(
+ issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
+ status: new Status(new StatusCode(C::STATUS_SUCCESS)),
+ issuer: new Issuer('https://IdentityProvider.com'),
+ id: 'abc123',
+ inResponseTo: 'PHPUnit',
+ destination: C::ENTITY_OTHER,
+ consent: C::ENTITY_SP,
+ assertions: [$unsignedAssertion],
+);
+
+echo $unsignedResponse->toXML()->ownerDocument->saveXML();
diff --git a/tests/resources/schemas/simplesamlphp.xsd b/tests/resources/schemas/simplesamlphp.xsd
index 942f2b393..3324f6255 100644
--- a/tests/resources/schemas/simplesamlphp.xsd
+++ b/tests/resources/schemas/simplesamlphp.xsd
@@ -19,12 +19,17 @@
targetNamespace="urn:x-simplesamlphp:namespace"
version="0.1" elementFormDefault="qualified">
-
+
+
+
+
+
+
diff --git a/tests/resources/xml/ecp_RelayState.xml b/tests/resources/xml/ecp_RelayState.xml
new file mode 100644
index 000000000..d008c399a
--- /dev/null
+++ b/tests/resources/xml/ecp_RelayState.xml
@@ -0,0 +1 @@
+AGDY854379dskssda
diff --git a/tests/resources/xml/ecp_Request.xml b/tests/resources/xml/ecp_Request.xml
new file mode 100644
index 000000000..819c75e28
--- /dev/null
+++ b/tests/resources/xml/ecp_Request.xml
@@ -0,0 +1,8 @@
+
+ TheIssuerValue
+
+
+
+ https://some/location
+
+
diff --git a/tests/resources/xml/ecp_SubjectConfirmation.xml b/tests/resources/xml/ecp_SubjectConfirmation.xml
new file mode 100644
index 000000000..aa3465f75
--- /dev/null
+++ b/tests/resources/xml/ecp_SubjectConfirmation.xml
@@ -0,0 +1,8 @@
+
+
+
+ SomeKey
+
+ Arbitrary Element
+
+
diff --git a/tests/resources/xml/md_Organization.xml b/tests/resources/xml/md_Organization.xml
index 9153ab087..eee992c91 100644
--- a/tests/resources/xml/md_Organization.xml
+++ b/tests/resources/xml/md_Organization.xml
@@ -1,4 +1,4 @@
-
+
SomeExtension
diff --git a/tests/resources/xml/md_RoleDescriptor.xml b/tests/resources/xml/md_RoleDescriptor.xml
index 681bb9253..946c7f5a2 100644
--- a/tests/resources/xml/md_RoleDescriptor.xml
+++ b/tests/resources/xml/md_RoleDescriptor.xml
@@ -1,4 +1,4 @@
-
+
Some
diff --git a/tests/resources/xml/metadata/unsigned-metadata.xml b/tests/resources/xml/metadata/unsigned-metadata.xml
new file mode 100644
index 000000000..e34ec6e12
--- /dev/null
+++ b/tests/resources/xml/metadata/unsigned-metadata.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ MIIGHzCCBAegAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBiTELMAkGA1UEBhMCTkwxFTATBgNVBAgTDFp1aWQtSG9sbGFuZDESMBAGA1UEBxMJUGlqbmFja2VyMRQwEgYDVQQKEwtNT08tQXJjaGl2ZTEgMB4GCSqGSIb3DQEJARYRdHZkaWplbkBnbWFpbC5jb20xFzAVBgNVBAMTDk1PTy1BcmNoaXZlLm5sMB4XDTE3MDYyOTEzNTcxMFoXDTI3MDYyNzEzNTcxMFowgZUxCzAJBgNVBAYTAk5MMRUwEwYDVQQIEwxadWlkLUhvbGxhbmQxEjAQBgNVBAcTCVBpam5hY2tlcjEUMBIGA1UEChMLTU9PLUFyY2hpdmUxIDAeBgkqhkiG9w0BCQEWEXR2ZGlqZW5AZ21haWwuY29tMSMwIQYDVQQDExpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKw8a1UbecDb9297f4RD3gDB1CG+Lzlz771u6wv+gGH3slSzV3VsCoARtAXjJExl8RJWRzD1J39UwLnalEyOklD/5tBT9oWMLppCFX4d1O0oszj5DUs9KIEYJ6pPB7ddqGTk/1q8nwlwKsrMIXFJ3yZOAybVPE33najzpMSKqXq23OuyXs6F/AQ1WxQdpCGeI408guhXYycsOcARtIAS4b9W4qw0FXP5sipJafB453McQMjuJ/nX19Uu4vjqAbndZxl7DDpnuPBE0BIFlGSOl2RDgJ0mWuYSZyBiaGio4SqUqMLy4evsNX3An9mplAQYgxH3QQoamismbChw3bBqqZMCAwEAAaOCAYIwggF+MAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgZAMDMGCWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBTZXJ2ZXIgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFKmdvXHiKRfPK7Ril7HHtWjgC4y+MIG2BgNVHSMEga4wgauAFLv3Qlv+TKAu5aYX4JPeHDPHYsasoYGPpIGMMIGJMQswCQYDVQQGEwJOTDEVMBMGA1UECBMMWnVpZC1Ib2xsYW5kMRIwEAYDVQQHEwlQaWpuYWNrZXIxFDASBgNVBAoTC01PTy1BcmNoaXZlMSAwHgYJKoZIhvcNAQkBFhF0dmRpamVuQGdtYWlsLmNvbTEXMBUGA1UEAxMOTU9PLUFyY2hpdmUubmyCAQAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFCAICMAsGA1UdDwQEAwIFoDAlBgNVHREEHjAcghpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDANBgkqhkiG9w0BAQsFAAOCAgEACcl027bjDDJJfB3u/amNPRGNgy/Yir+kMoRyDCDHYN9+bqwtY+5N1I/SwfeWcCJepe96CsZPrHypHzPOKNHEKyUwM8KrKF9rFI1ySRjEdeB/9FUbKCkXpTZTXT7OCqh1hxEjWGxfHQWj0uXeqS56zvDXY3uZECqexuO6xNNzS+ArRFePB/6tbm1tshdioRjHFGSNR6gG4YqSdZCJOzHSNqA2uwdnPR2kwbu2n60jL20hw9F9FDSj1GhccRuq3SurXZ+M/AJJ7fnVQdGREKgvfhisIWWvIagAns7DZ/r3VUvPmuGxee2ZSLgYVN8mfx3A/WEAAfKb/SgRUvpOa8z7sFV6sUx/9hbfustdDb3jTGRzplhpz403HXXQmf/P7MNM5zOg0TEWJsLsv7lmMbBY796x6rafJ5WFxvhyGCr2mDqRP6H2y1kmoVNEIAeSHhJGIj9Kki+fqChSQFNWmtNzz11C88TNnr6Iol5g/pHiFhGcvnpFSiCQ4gXNoHzHAfPZ9gwZyARuwRjKR3u0D2PtRUAe8YYddpL51GzHmNF9yQyaPagqLcdWbPlMb2Gjs5faWjpAhiVyCR8zlzvN9+5ZbQK8hpp4S/aV1XsXINJMHf7QA0KZfgnIg91lda4siaQbuNYWg4jCkUBe9ugqhOL8RKkJPGevlEvFMh74VHrQjjA=
+
+
+
+
+
+
+ MIIGHzCCBAegAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBiTELMAkGA1UEBhMCTkwxFTATBgNVBAgTDFp1aWQtSG9sbGFuZDESMBAGA1UEBxMJUGlqbmFja2VyMRQwEgYDVQQKEwtNT08tQXJjaGl2ZTEgMB4GCSqGSIb3DQEJARYRdHZkaWplbkBnbWFpbC5jb20xFzAVBgNVBAMTDk1PTy1BcmNoaXZlLm5sMB4XDTE3MDYyOTEzNTcxMFoXDTI3MDYyNzEzNTcxMFowgZUxCzAJBgNVBAYTAk5MMRUwEwYDVQQIEwxadWlkLUhvbGxhbmQxEjAQBgNVBAcTCVBpam5hY2tlcjEUMBIGA1UEChMLTU9PLUFyY2hpdmUxIDAeBgkqhkiG9w0BCQEWEXR2ZGlqZW5AZ21haWwuY29tMSMwIQYDVQQDExpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKw8a1UbecDb9297f4RD3gDB1CG+Lzlz771u6wv+gGH3slSzV3VsCoARtAXjJExl8RJWRzD1J39UwLnalEyOklD/5tBT9oWMLppCFX4d1O0oszj5DUs9KIEYJ6pPB7ddqGTk/1q8nwlwKsrMIXFJ3yZOAybVPE33najzpMSKqXq23OuyXs6F/AQ1WxQdpCGeI408guhXYycsOcARtIAS4b9W4qw0FXP5sipJafB453McQMjuJ/nX19Uu4vjqAbndZxl7DDpnuPBE0BIFlGSOl2RDgJ0mWuYSZyBiaGio4SqUqMLy4evsNX3An9mplAQYgxH3QQoamismbChw3bBqqZMCAwEAAaOCAYIwggF+MAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgZAMDMGCWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBTZXJ2ZXIgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFKmdvXHiKRfPK7Ril7HHtWjgC4y+MIG2BgNVHSMEga4wgauAFLv3Qlv+TKAu5aYX4JPeHDPHYsasoYGPpIGMMIGJMQswCQYDVQQGEwJOTDEVMBMGA1UECBMMWnVpZC1Ib2xsYW5kMRIwEAYDVQQHEwlQaWpuYWNrZXIxFDASBgNVBAoTC01PTy1BcmNoaXZlMSAwHgYJKoZIhvcNAQkBFhF0dmRpamVuQGdtYWlsLmNvbTEXMBUGA1UEAxMOTU9PLUFyY2hpdmUubmyCAQAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFCAICMAsGA1UdDwQEAwIFoDAlBgNVHREEHjAcghpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDANBgkqhkiG9w0BAQsFAAOCAgEACcl027bjDDJJfB3u/amNPRGNgy/Yir+kMoRyDCDHYN9+bqwtY+5N1I/SwfeWcCJepe96CsZPrHypHzPOKNHEKyUwM8KrKF9rFI1ySRjEdeB/9FUbKCkXpTZTXT7OCqh1hxEjWGxfHQWj0uXeqS56zvDXY3uZECqexuO6xNNzS+ArRFePB/6tbm1tshdioRjHFGSNR6gG4YqSdZCJOzHSNqA2uwdnPR2kwbu2n60jL20hw9F9FDSj1GhccRuq3SurXZ+M/AJJ7fnVQdGREKgvfhisIWWvIagAns7DZ/r3VUvPmuGxee2ZSLgYVN8mfx3A/WEAAfKb/SgRUvpOa8z7sFV6sUx/9hbfustdDb3jTGRzplhpz403HXXQmf/P7MNM5zOg0TEWJsLsv7lmMbBY796x6rafJ5WFxvhyGCr2mDqRP6H2y1kmoVNEIAeSHhJGIj9Kki+fqChSQFNWmtNzz11C88TNnr6Iol5g/pHiFhGcvnpFSiCQ4gXNoHzHAfPZ9gwZyARuwRjKR3u0D2PtRUAe8YYddpL51GzHmNF9yQyaPagqLcdWbPlMb2Gjs5faWjpAhiVyCR8zlzvN9+5ZbQK8hpp4S/aV1XsXINJMHf7QA0KZfgnIg91lda4siaQbuNYWg4jCkUBe9ugqhOL8RKkJPGevlEvFMh74VHrQjjA=
+
+
+
+
+ urn:oasis:names:tc:SAML:2.0:nameid-format:transient
+
+
+
+
diff --git a/tests/resources/xml/metadata/valid-metadata-ca-signed.xml b/tests/resources/xml/metadata/valid-metadata-ca-signed.xml
new file mode 100644
index 000000000..ec01ca822
--- /dev/null
+++ b/tests/resources/xml/metadata/valid-metadata-ca-signed.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ dM5kF0HTkW9fnJOS77yNgTAwBj4=FGI5oDDpF9J/asZ6h8YV++0T5gl/zN1WuQCUCO3yJd1v01StVrGS8CXtRL80wR93VtFPwMVYTcpSxU6W/HhBndpPgbkJATA2YDvWQbe7X8Px4UOIpyr7AsZymkWwwE0WwWEt2qlzx3bi2KOSowDp4g/n9VGuTejpUBEdQdK8iOU=
+MIIEMjCCAhoCAQIwDQYJKoZIhvcNAQELBQAwgZkxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZIYXdhaWkxETAPBgNVBAcMCEhvbm9sdWx1MRYwFAYDVQQKDA1TaW1wbGVTQU1McGhwMRQwEgYDVQQLDAtEZXZlbG9wbWVudDEUMBIGA1UEAwwLZXhhbXBsZS5vcmcxIjAgBgkqhkiG9w0BCQEWE25vcmVwbHlAZXhhbXBsZS5vcmcwHhcNMTkwNzE4MTYxOTQ4WhcNMzkwNzEzMTYxOTQ4WjCBpzELMAkGA1UEBhMCVVMxDzANBgNVBAgMBkhhd2FpaTERMA8GA1UEBwwISG9ub2x1bHUxFjAUBgNVBAoMDVNpbXBsZVNBTUxwaHAxFDASBgNVBAsMC0RldmVsb3BtZW50MSIwIAYDVQQDDBlzaW1wbGVzYW1scGhwLmV4YW1wbGUub3JnMSIwIAYJKoZIhvcNAQkBFhNub3JlcGx5QGV4YW1wbGUub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDENbOkVckPBwcuYoUBdpWz4Vqv4JtCc5ff2RUas4WBZ5DGqCG8K6aN5RcYZpMIn1pQraAR1YWtFobKpC1FLOYm9s0/LqvnfCBd+g1J9hrQt+6k6IZO/zZu9ae5Hh+X8lvM1k4D+OMhCKLqNL2aHbDNj5mSLWbttfsu1dzCDUTwJwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQAcatz4MJNSZJxwGqzIUkModlffzN+xw1x7+OQtHPUZHzH+NBRQ48I58DCod/elyB1Vkb/2qAnIhRhH9yamjPnIgraTNG8YGRGBlrx31/Ow0ZJWs7OBJIJiNx0SXDw1cpmSuqWnr/Y39DdKBfpLNfkZSUP2RR74YKUCbcGaa0VOdSJjmpIscotkIkH45OncFgtbXADXEMQL45tB8dyRM4aXNk87dZHeJCaYMJ8NdgfgJl98XnvCXnSemVR4E/J4bM77J3xY3lT4hiDElyTKArUQ3Wfx3mFEWGBOMx36eB78/czhkJ4BKPoeEuCCheH3iovPOf3P5sI4fzMGTa/th8I44LJKfxK5mMNmDwLbolCL5tutPgXdu1aYdLHkSmO2l8growQ9yO/J/jrBFgp5BORdLyH/LNLVjnFz66RmN3gD2reBRkSd9JZShpwPr+HholKoT7oJDFlDKRY7cWQymTubHXdo8k7GVUZl0M4chhhi38IBk3t4OOXlesWao4UqCUICAIdkdQAJpfo67VF2G+lRoj2tTDFBDxNpazTHIk28dqHIjnf8DlJBI1qdrDFs92aZqsk1XkELAKhHDIY5BrFaqodC+v+rh0SawUt4TwlyRZu7bSllG2R7Op1uWxpmogce84TAoqj02lzdrGd72Vtu5XovITLS+ikwcNggyc1WcQ==
+
+
+
+
+ MIIGHzCCBAegAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBiTELMAkGA1UEBhMCTkwxFTATBgNVBAgTDFp1aWQtSG9sbGFuZDESMBAGA1UEBxMJUGlqbmFja2VyMRQwEgYDVQQKEwtNT08tQXJjaGl2ZTEgMB4GCSqGSIb3DQEJARYRdHZkaWplbkBnbWFpbC5jb20xFzAVBgNVBAMTDk1PTy1BcmNoaXZlLm5sMB4XDTE3MDYyOTEzNTcxMFoXDTI3MDYyNzEzNTcxMFowgZUxCzAJBgNVBAYTAk5MMRUwEwYDVQQIEwxadWlkLUhvbGxhbmQxEjAQBgNVBAcTCVBpam5hY2tlcjEUMBIGA1UEChMLTU9PLUFyY2hpdmUxIDAeBgkqhkiG9w0BCQEWEXR2ZGlqZW5AZ21haWwuY29tMSMwIQYDVQQDExpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKw8a1UbecDb9297f4RD3gDB1CG+Lzlz771u6wv+gGH3slSzV3VsCoARtAXjJExl8RJWRzD1J39UwLnalEyOklD/5tBT9oWMLppCFX4d1O0oszj5DUs9KIEYJ6pPB7ddqGTk/1q8nwlwKsrMIXFJ3yZOAybVPE33najzpMSKqXq23OuyXs6F/AQ1WxQdpCGeI408guhXYycsOcARtIAS4b9W4qw0FXP5sipJafB453McQMjuJ/nX19Uu4vjqAbndZxl7DDpnuPBE0BIFlGSOl2RDgJ0mWuYSZyBiaGio4SqUqMLy4evsNX3An9mplAQYgxH3QQoamismbChw3bBqqZMCAwEAAaOCAYIwggF+MAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgZAMDMGCWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBTZXJ2ZXIgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFKmdvXHiKRfPK7Ril7HHtWjgC4y+MIG2BgNVHSMEga4wgauAFLv3Qlv+TKAu5aYX4JPeHDPHYsasoYGPpIGMMIGJMQswCQYDVQQGEwJOTDEVMBMGA1UECBMMWnVpZC1Ib2xsYW5kMRIwEAYDVQQHEwlQaWpuYWNrZXIxFDASBgNVBAoTC01PTy1BcmNoaXZlMSAwHgYJKoZIhvcNAQkBFhF0dmRpamVuQGdtYWlsLmNvbTEXMBUGA1UEAxMOTU9PLUFyY2hpdmUubmyCAQAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFCAICMAsGA1UdDwQEAwIFoDAlBgNVHREEHjAcghpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDANBgkqhkiG9w0BAQsFAAOCAgEACcl027bjDDJJfB3u/amNPRGNgy/Yir+kMoRyDCDHYN9+bqwtY+5N1I/SwfeWcCJepe96CsZPrHypHzPOKNHEKyUwM8KrKF9rFI1ySRjEdeB/9FUbKCkXpTZTXT7OCqh1hxEjWGxfHQWj0uXeqS56zvDXY3uZECqexuO6xNNzS+ArRFePB/6tbm1tshdioRjHFGSNR6gG4YqSdZCJOzHSNqA2uwdnPR2kwbu2n60jL20hw9F9FDSj1GhccRuq3SurXZ+M/AJJ7fnVQdGREKgvfhisIWWvIagAns7DZ/r3VUvPmuGxee2ZSLgYVN8mfx3A/WEAAfKb/SgRUvpOa8z7sFV6sUx/9hbfustdDb3jTGRzplhpz403HXXQmf/P7MNM5zOg0TEWJsLsv7lmMbBY796x6rafJ5WFxvhyGCr2mDqRP6H2y1kmoVNEIAeSHhJGIj9Kki+fqChSQFNWmtNzz11C88TNnr6Iol5g/pHiFhGcvnpFSiCQ4gXNoHzHAfPZ9gwZyARuwRjKR3u0D2PtRUAe8YYddpL51GzHmNF9yQyaPagqLcdWbPlMb2Gjs5faWjpAhiVyCR8zlzvN9+5ZbQK8hpp4S/aV1XsXINJMHf7QA0KZfgnIg91lda4siaQbuNYWg4jCkUBe9ugqhOL8RKkJPGevlEvFMh74VHrQjjA=
+
+
+
+
+
+
+ MIIGHzCCBAegAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBiTELMAkGA1UEBhMCTkwxFTATBgNVBAgTDFp1aWQtSG9sbGFuZDESMBAGA1UEBxMJUGlqbmFja2VyMRQwEgYDVQQKEwtNT08tQXJjaGl2ZTEgMB4GCSqGSIb3DQEJARYRdHZkaWplbkBnbWFpbC5jb20xFzAVBgNVBAMTDk1PTy1BcmNoaXZlLm5sMB4XDTE3MDYyOTEzNTcxMFoXDTI3MDYyNzEzNTcxMFowgZUxCzAJBgNVBAYTAk5MMRUwEwYDVQQIEwxadWlkLUhvbGxhbmQxEjAQBgNVBAcTCVBpam5hY2tlcjEUMBIGA1UEChMLTU9PLUFyY2hpdmUxIDAeBgkqhkiG9w0BCQEWEXR2ZGlqZW5AZ21haWwuY29tMSMwIQYDVQQDExpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKw8a1UbecDb9297f4RD3gDB1CG+Lzlz771u6wv+gGH3slSzV3VsCoARtAXjJExl8RJWRzD1J39UwLnalEyOklD/5tBT9oWMLppCFX4d1O0oszj5DUs9KIEYJ6pPB7ddqGTk/1q8nwlwKsrMIXFJ3yZOAybVPE33najzpMSKqXq23OuyXs6F/AQ1WxQdpCGeI408guhXYycsOcARtIAS4b9W4qw0FXP5sipJafB453McQMjuJ/nX19Uu4vjqAbndZxl7DDpnuPBE0BIFlGSOl2RDgJ0mWuYSZyBiaGio4SqUqMLy4evsNX3An9mplAQYgxH3QQoamismbChw3bBqqZMCAwEAAaOCAYIwggF+MAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgZAMDMGCWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBTZXJ2ZXIgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFKmdvXHiKRfPK7Ril7HHtWjgC4y+MIG2BgNVHSMEga4wgauAFLv3Qlv+TKAu5aYX4JPeHDPHYsasoYGPpIGMMIGJMQswCQYDVQQGEwJOTDEVMBMGA1UECBMMWnVpZC1Ib2xsYW5kMRIwEAYDVQQHEwlQaWpuYWNrZXIxFDASBgNVBAoTC01PTy1BcmNoaXZlMSAwHgYJKoZIhvcNAQkBFhF0dmRpamVuQGdtYWlsLmNvbTEXMBUGA1UEAxMOTU9PLUFyY2hpdmUubmyCAQAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFCAICMAsGA1UdDwQEAwIFoDAlBgNVHREEHjAcghpzaWduaW5nLmlkcC5tb28tYXJjaGl2ZS5ubDANBgkqhkiG9w0BAQsFAAOCAgEACcl027bjDDJJfB3u/amNPRGNgy/Yir+kMoRyDCDHYN9+bqwtY+5N1I/SwfeWcCJepe96CsZPrHypHzPOKNHEKyUwM8KrKF9rFI1ySRjEdeB/9FUbKCkXpTZTXT7OCqh1hxEjWGxfHQWj0uXeqS56zvDXY3uZECqexuO6xNNzS+ArRFePB/6tbm1tshdioRjHFGSNR6gG4YqSdZCJOzHSNqA2uwdnPR2kwbu2n60jL20hw9F9FDSj1GhccRuq3SurXZ+M/AJJ7fnVQdGREKgvfhisIWWvIagAns7DZ/r3VUvPmuGxee2ZSLgYVN8mfx3A/WEAAfKb/SgRUvpOa8z7sFV6sUx/9hbfustdDb3jTGRzplhpz403HXXQmf/P7MNM5zOg0TEWJsLsv7lmMbBY796x6rafJ5WFxvhyGCr2mDqRP6H2y1kmoVNEIAeSHhJGIj9Kki+fqChSQFNWmtNzz11C88TNnr6Iol5g/pHiFhGcvnpFSiCQ4gXNoHzHAfPZ9gwZyARuwRjKR3u0D2PtRUAe8YYddpL51GzHmNF9yQyaPagqLcdWbPlMb2Gjs5faWjpAhiVyCR8zlzvN9+5ZbQK8hpp4S/aV1XsXINJMHf7QA0KZfgnIg91lda4siaQbuNYWg4jCkUBe9ugqhOL8RKkJPGevlEvFMh74VHrQjjA=
+
+
+
+
+ urn:oasis:names:tc:SAML:2.0:nameid-format:transient
+
+
+
+