From 4de4593cd9a4d973a1f18312a423281fe3d6eefa Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sat, 13 Dec 2025 21:23:08 +0100 Subject: [PATCH 1/2] Initial import --- .github/dependabot.yml | 29 ++ .github/workflows/autolock-conversations.yml | 25 ++ .github/workflows/documentation.yml | 35 ++ .github/workflows/php.yml | 281 ++++++++++++++++ .gitignore | 13 +- codecov.yml | 20 ++ composer.json | 56 +++ phpcs.xml | 29 ++ phpstan-dev.neon | 4 + phpstan.neon | 4 + phpunit.xml | 19 ++ resources/schemas/ws-addr-200408.xsd | 149 ++++++++ resources/schemas/ws-addr-200508.xsd | 137 ++++++++ resources/schemas/ws-addr-wsdl.xsd | 66 ++++ resources/schemas/xml.xsd | 286 ++++++++++++++++ resources/schemas/xmldsig-core-schema.xsd | 318 ++++++++++++++++++ src/Assert/Assert.php | 14 + src/Constants.php | 65 ++++ .../AbstractAttributedQNameType.php | 85 +++++ .../wsa_200408/AbstractAttributedURIType.php | 84 +++++ .../AbstractEndpointReferenceType.php | 203 +++++++++++ .../wsa_200408/AbstractRelationshipType.php | 106 ++++++ src/XML/wsa_200408/AbstractRetryAfterType.php | 87 +++++ .../wsa_200408/AbstractServiceNameType.php | 107 ++++++ src/XML/wsa_200408/AbstractWsaElement.php | 25 ++ src/XML/wsa_200408/Action.php | 18 + src/XML/wsa_200408/Address.php | 14 + src/XML/wsa_200408/EndpointReference.php | 18 + src/XML/wsa_200408/FaultTo.php | 18 + src/XML/wsa_200408/From.php | 18 + src/XML/wsa_200408/MessageID.php | 18 + src/XML/wsa_200408/PortType.php | 14 + src/XML/wsa_200408/ReferenceParameters.php | 87 +++++ src/XML/wsa_200408/ReferenceProperties.php | 87 +++++ src/XML/wsa_200408/RelatesTo.php | 16 + src/XML/wsa_200408/ReplyTo.php | 18 + src/XML/wsa_200408/RetryAfter.php | 16 + src/XML/wsa_200408/ServiceName.php | 14 + src/XML/wsa_200408/To.php | 18 + .../AbstractAttributedQNameType.php | 85 +++++ .../wsa_200508/AbstractAttributedURIType.php | 84 +++++ .../AbstractAttributedUnsignedLongType.php | 84 +++++ .../AbstractEndpointReferenceType.php | 166 +++++++++ .../wsa_200508/AbstractProblemActionType.php | 75 +++++ src/XML/wsa_200508/AbstractWsaElement.php | 25 ++ src/XML/wsa_200508/Action.php | 18 + src/XML/wsa_200508/Address.php | 14 + src/XML/wsa_200508/EndpointReference.php | 18 + src/XML/wsa_200508/FaultTo.php | 18 + src/XML/wsa_200508/From.php | 18 + src/XML/wsa_200508/MessageID.php | 18 + src/XML/wsa_200508/Metadata.php | 102 ++++++ src/XML/wsa_200508/ProblemAction.php | 58 ++++ src/XML/wsa_200508/ProblemHeaderQName.php | 18 + src/XML/wsa_200508/ProblemIRI.php | 18 + src/XML/wsa_200508/ReferenceParameters.php | 102 ++++++ src/XML/wsa_200508/RelatesTo.php | 107 ++++++ src/XML/wsa_200508/ReplyTo.php | 18 + src/XML/wsa_200508/RetryAfter.php | 18 + src/XML/wsa_200508/SoapAction.php | 20 ++ src/XML/wsa_200508/To.php | 18 + tests/WS_ADDR/XML/wsa_200408/ActionTest.php | 66 ++++ tests/WS_ADDR/XML/wsa_200408/AddressTest.php | 64 ++++ .../XML/wsa_200408/EndpointReferenceTest.php | 175 ++++++++++ tests/WS_ADDR/XML/wsa_200408/FaultToTest.php | 171 ++++++++++ tests/WS_ADDR/XML/wsa_200408/FromTest.php | 171 ++++++++++ .../WS_ADDR/XML/wsa_200408/MessageIDTest.php | 66 ++++ tests/WS_ADDR/XML/wsa_200408/PortTypeTest.php | 64 ++++ .../wsa_200408/ReferenceParametersTest.php | 78 +++++ .../wsa_200408/ReferencePropertiesTest.php | 78 +++++ .../WS_ADDR/XML/wsa_200408/RelatesToTest.php | 71 ++++ tests/WS_ADDR/XML/wsa_200408/ReplyToTest.php | 171 ++++++++++ .../WS_ADDR/XML/wsa_200408/RetryAfterTest.php | 63 ++++ .../XML/wsa_200408/ServiceNameTest.php | 69 ++++ tests/WS_ADDR/XML/wsa_200408/ToTest.php | 66 ++++ tests/WS_ADDR/XML/wsa_200508/ActionTest.php | 66 ++++ tests/WS_ADDR/XML/wsa_200508/AddressTest.php | 64 ++++ .../XML/wsa_200508/EndpointReferenceTest.php | 107 ++++++ tests/WS_ADDR/XML/wsa_200508/FaultToTest.php | 109 ++++++ tests/WS_ADDR/XML/wsa_200508/FromTest.php | 109 ++++++ .../WS_ADDR/XML/wsa_200508/MessageIDTest.php | 68 ++++ tests/WS_ADDR/XML/wsa_200508/MetadataTest.php | 84 +++++ .../XML/wsa_200508/ProblemActionTest.php | 89 +++++ .../XML/wsa_200508/ProblemHeaderQNameTest.php | 76 +++++ .../WS_ADDR/XML/wsa_200508/ProblemIRITest.php | 67 ++++ .../wsa_200508/ReferenceParametersTest.php | 84 +++++ .../WS_ADDR/XML/wsa_200508/RelatesToTest.php | 65 ++++ tests/WS_ADDR/XML/wsa_200508/ReplyToTest.php | 109 ++++++ .../WS_ADDR/XML/wsa_200508/RetryAfterTest.php | 66 ++++ .../WS_ADDR/XML/wsa_200508/SoapActionTest.php | 59 ++++ tests/WS_ADDR/XML/wsa_200508/ToTest.php | 67 ++++ tests/bootstrap.php | 6 + tests/resources/xml/wsa/200408/Action.xml | 1 + tests/resources/xml/wsa/200408/Address.xml | 1 + .../xml/wsa/200408/EndpointReference.xml | 16 + tests/resources/xml/wsa/200408/FaultTo.xml | 16 + tests/resources/xml/wsa/200408/From.xml | 16 + tests/resources/xml/wsa/200408/MessageID.xml | 1 + tests/resources/xml/wsa/200408/PortType.xml | 1 + .../xml/wsa/200408/ReferenceParameters.xml | 5 + .../xml/wsa/200408/ReferenceProperties.xml | 5 + tests/resources/xml/wsa/200408/RelatesTo.xml | 1 + tests/resources/xml/wsa/200408/ReplyTo.xml | 16 + tests/resources/xml/wsa/200408/RetryAfter.xml | 1 + .../resources/xml/wsa/200408/ServiceName.xml | 1 + tests/resources/xml/wsa/200408/To.xml | 1 + tests/resources/xml/wsa/200508/Action.xml | 1 + tests/resources/xml/wsa/200508/Address.xml | 1 + .../xml/wsa/200508/EndpointReference.xml | 14 + tests/resources/xml/wsa/200508/FaultTo.xml | 14 + tests/resources/xml/wsa/200508/From.xml | 14 + tests/resources/xml/wsa/200508/MessageID.xml | 1 + tests/resources/xml/wsa/200508/Metadata.xml | 5 + .../xml/wsa/200508/ProblemAction.xml | 4 + .../xml/wsa/200508/ProblemHeaderQName.xml | 1 + tests/resources/xml/wsa/200508/ProblemIRI.xml | 1 + .../xml/wsa/200508/ReferenceParameters.xml | 5 + tests/resources/xml/wsa/200508/RelatesTo.xml | 1 + tests/resources/xml/wsa/200508/ReplyTo.xml | 14 + tests/resources/xml/wsa/200508/RetryAfter.xml | 1 + tests/resources/xml/wsa/200508/SoapAction.xml | 1 + tests/resources/xml/wsa/200508/To.xml | 1 + tools/linters/.yaml-lint.yml | 7 + 123 files changed, 6554 insertions(+), 5 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/autolock-conversations.yml create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/php.yml create mode 100644 codecov.yml create mode 100644 composer.json create mode 100644 phpcs.xml create mode 100644 phpstan-dev.neon create mode 100644 phpstan.neon create mode 100644 phpunit.xml create mode 100644 resources/schemas/ws-addr-200408.xsd create mode 100644 resources/schemas/ws-addr-200508.xsd create mode 100644 resources/schemas/ws-addr-wsdl.xsd create mode 100644 resources/schemas/xml.xsd create mode 100644 resources/schemas/xmldsig-core-schema.xsd create mode 100644 src/Assert/Assert.php create mode 100644 src/Constants.php create mode 100644 src/XML/wsa_200408/AbstractAttributedQNameType.php create mode 100644 src/XML/wsa_200408/AbstractAttributedURIType.php create mode 100644 src/XML/wsa_200408/AbstractEndpointReferenceType.php create mode 100644 src/XML/wsa_200408/AbstractRelationshipType.php create mode 100644 src/XML/wsa_200408/AbstractRetryAfterType.php create mode 100644 src/XML/wsa_200408/AbstractServiceNameType.php create mode 100644 src/XML/wsa_200408/AbstractWsaElement.php create mode 100644 src/XML/wsa_200408/Action.php create mode 100644 src/XML/wsa_200408/Address.php create mode 100644 src/XML/wsa_200408/EndpointReference.php create mode 100644 src/XML/wsa_200408/FaultTo.php create mode 100644 src/XML/wsa_200408/From.php create mode 100644 src/XML/wsa_200408/MessageID.php create mode 100644 src/XML/wsa_200408/PortType.php create mode 100644 src/XML/wsa_200408/ReferenceParameters.php create mode 100644 src/XML/wsa_200408/ReferenceProperties.php create mode 100644 src/XML/wsa_200408/RelatesTo.php create mode 100644 src/XML/wsa_200408/ReplyTo.php create mode 100644 src/XML/wsa_200408/RetryAfter.php create mode 100644 src/XML/wsa_200408/ServiceName.php create mode 100644 src/XML/wsa_200408/To.php create mode 100644 src/XML/wsa_200508/AbstractAttributedQNameType.php create mode 100644 src/XML/wsa_200508/AbstractAttributedURIType.php create mode 100644 src/XML/wsa_200508/AbstractAttributedUnsignedLongType.php create mode 100644 src/XML/wsa_200508/AbstractEndpointReferenceType.php create mode 100644 src/XML/wsa_200508/AbstractProblemActionType.php create mode 100644 src/XML/wsa_200508/AbstractWsaElement.php create mode 100644 src/XML/wsa_200508/Action.php create mode 100644 src/XML/wsa_200508/Address.php create mode 100644 src/XML/wsa_200508/EndpointReference.php create mode 100644 src/XML/wsa_200508/FaultTo.php create mode 100644 src/XML/wsa_200508/From.php create mode 100644 src/XML/wsa_200508/MessageID.php create mode 100644 src/XML/wsa_200508/Metadata.php create mode 100644 src/XML/wsa_200508/ProblemAction.php create mode 100644 src/XML/wsa_200508/ProblemHeaderQName.php create mode 100644 src/XML/wsa_200508/ProblemIRI.php create mode 100644 src/XML/wsa_200508/ReferenceParameters.php create mode 100644 src/XML/wsa_200508/RelatesTo.php create mode 100644 src/XML/wsa_200508/ReplyTo.php create mode 100644 src/XML/wsa_200508/RetryAfter.php create mode 100644 src/XML/wsa_200508/SoapAction.php create mode 100644 src/XML/wsa_200508/To.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/ActionTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/AddressTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/EndpointReferenceTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/FaultToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/FromTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/MessageIDTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/PortTypeTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/ReferenceParametersTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/ReferencePropertiesTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/RelatesToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/ReplyToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/RetryAfterTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/ServiceNameTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200408/ToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ActionTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/AddressTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/EndpointReferenceTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/FaultToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/FromTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/MessageIDTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/MetadataTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ProblemActionTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ProblemHeaderQNameTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ProblemIRITest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ReferenceParametersTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/RelatesToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ReplyToTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/RetryAfterTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/SoapActionTest.php create mode 100644 tests/WS_ADDR/XML/wsa_200508/ToTest.php create mode 100644 tests/bootstrap.php create mode 100644 tests/resources/xml/wsa/200408/Action.xml create mode 100644 tests/resources/xml/wsa/200408/Address.xml create mode 100644 tests/resources/xml/wsa/200408/EndpointReference.xml create mode 100644 tests/resources/xml/wsa/200408/FaultTo.xml create mode 100644 tests/resources/xml/wsa/200408/From.xml create mode 100644 tests/resources/xml/wsa/200408/MessageID.xml create mode 100644 tests/resources/xml/wsa/200408/PortType.xml create mode 100644 tests/resources/xml/wsa/200408/ReferenceParameters.xml create mode 100644 tests/resources/xml/wsa/200408/ReferenceProperties.xml create mode 100644 tests/resources/xml/wsa/200408/RelatesTo.xml create mode 100644 tests/resources/xml/wsa/200408/ReplyTo.xml create mode 100644 tests/resources/xml/wsa/200408/RetryAfter.xml create mode 100644 tests/resources/xml/wsa/200408/ServiceName.xml create mode 100644 tests/resources/xml/wsa/200408/To.xml create mode 100644 tests/resources/xml/wsa/200508/Action.xml create mode 100644 tests/resources/xml/wsa/200508/Address.xml create mode 100644 tests/resources/xml/wsa/200508/EndpointReference.xml create mode 100644 tests/resources/xml/wsa/200508/FaultTo.xml create mode 100644 tests/resources/xml/wsa/200508/From.xml create mode 100644 tests/resources/xml/wsa/200508/MessageID.xml create mode 100644 tests/resources/xml/wsa/200508/Metadata.xml create mode 100644 tests/resources/xml/wsa/200508/ProblemAction.xml create mode 100644 tests/resources/xml/wsa/200508/ProblemHeaderQName.xml create mode 100644 tests/resources/xml/wsa/200508/ProblemIRI.xml create mode 100644 tests/resources/xml/wsa/200508/ReferenceParameters.xml create mode 100644 tests/resources/xml/wsa/200508/RelatesTo.xml create mode 100644 tests/resources/xml/wsa/200508/ReplyTo.xml create mode 100644 tests/resources/xml/wsa/200508/RetryAfter.xml create mode 100644 tests/resources/xml/wsa/200508/SoapAction.xml create mode 100644 tests/resources/xml/wsa/200508/To.xml create mode 100644 tools/linters/.yaml-lint.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7fcaf10 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +--- + +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + groups: + all-actions: + patterns: ["*"] + + - package-ecosystem: "composer" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major"] + groups: + production-dependencies: + dependency-type: "production" + dev-dependencies: + dependency-type: "development" diff --git a/.github/workflows/autolock-conversations.yml b/.github/workflows/autolock-conversations.yml new file mode 100644 index 0000000..3c7be52 --- /dev/null +++ b/.github/workflows/autolock-conversations.yml @@ -0,0 +1,25 @@ +--- + +name: 'Lock Threads' + +on: # yamllint disable-line rule:truthy + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + +permissions: + issues: write + pull-requests: write + +concurrency: + group: lock + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v5 + with: + issue-inactive-days: '90' + pr-inactive-days: '90' + log-output: true diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..3ac7fbe --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,35 @@ +--- + +name: Documentation + +on: # yamllint disable-line rule:truthy + push: + branches: [master, release-*] + paths: + - '**.md' + pull_request: + branches: [master, release-*] + paths: + - '**.md' + workflow_dispatch: + +jobs: + quality: + name: Quality checks + runs-on: [ubuntu-latest] + + steps: + - uses: actions/checkout@v6 + + - name: Lint markdown files + uses: nosborn/github-action-markdown-cli@v3 + with: + files: . + ignore_path: .markdownlintignore + + - name: Perform spell check + uses: codespell-project/actions-codespell@v2 + with: + path: '**/*.md' + check_filenames: true + ignore_words_list: tekst diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..a93c8b1 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,281 @@ +--- + +name: CI + +on: # yamllint disable-line rule:truthy + push: + branches: ['**'] + paths-ignore: + - '**.md' + pull_request: + branches: [master, release-*] + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + phplinter: + name: 'PHP-Linter' + strategy: + fail-fast: false + matrix: + php-version: ['8.2', '8.3', '8.4', '8.5'] + + uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.6 + with: + php-version: ${{ matrix.php-version }} + + linter: + name: 'Linter' + strategy: + fail-fast: false + + uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.10.6 + with: + enable_eslinter: false + enable_jsonlinter: true + enable_stylelinter: false + enable_yamllinter: true + + unit-tests-linux: + name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}" + runs-on: ${{ matrix.operating-system }} + needs: [phplinter, linter] + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest] + php-versions: ['8.2', '8.3', '8.4', '8.5'] + + 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, pcre, spl, xml + tools: composer + ini-values: error_reporting=E_ALL + coverage: pcov + + - 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@v6 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Run unit tests with coverage + if: ${{ matrix.php-versions == '8.5' }} + run: vendor/bin/phpunit + + - name: Run unit tests (no coverage) + if: ${{ matrix.php-versions != '8.5' }} + run: vendor/bin/phpunit --no-coverage + + - name: Save coverage data + if: ${{ matrix.php-versions == '8.5' }} + uses: actions/upload-artifact@v5 + with: + name: coverage-data + path: ${{ github.workspace }}/build + + unit-tests-windows: + name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}" + runs-on: ${{ matrix.operating-system }} + needs: [phplinter, linter] + strategy: + fail-fast: true + matrix: + operating-system: [windows-latest] + php-versions: ['8.2', '8.3', '8.4', '8.5'] + + 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, pcre, spl, xml + tools: composer + ini-values: error_reporting=E_ALL + 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@v6 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Run unit tests + run: vendor/bin/phpunit --no-coverage + + security: + name: Security checks + needs: [unit-tests-linux] + runs-on: [ubuntu-latest] + + steps: + - name: Setup PHP, with composer and extensions + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + # Should be the lowest supported version + php-version: '8.2' + extensions: ctype, date, dom, pcre, spl, xml + tools: composer + coverage: none + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - uses: actions/checkout@v6 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Security check for locked dependencies + run: composer audit + + - name: Update Composer dependencies + run: composer update --no-progress --prefer-dist --optimize-autoloader + + - name: Security check for updated dependencies + run: composer audit + + quality: + name: Quality control + needs: [unit-tests-linux] + runs-on: [ubuntu-latest] + + steps: + - name: Setup PHP, with composer and extensions + id: setup-php + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + # Should be the higest supported version, so we can use the newest tools + php-version: '8.5' + tools: composer, composer-require-checker, composer-unused, phpcs + extensions: ctype, date, dom, pcre, spl, xml + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - uses: actions/checkout@v6 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + 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: Check code for hard dependencies missing in composer.json + run: composer-require-checker check composer.json + + - name: Check code for unused dependencies in composer.json + run: composer-unused + + - name: PHP Code Sniffer + run: vendor/bin/phpcs + + - name: PHPStan + run: | + vendor/bin/phpstan analyze -c phpstan.neon + + - name: PHPStan (testsuite) + run: | + vendor/bin/phpstan analyze -c phpstan-dev.neon + + coverage: + name: Code coverage + runs-on: [ubuntu-latest] + needs: [unit-tests-linux] + + steps: + - uses: actions/checkout@v6 + + - uses: actions/download-artifact@v6 + with: + name: coverage-data + path: ${{ github.workspace }}/build + + - name: Codecov + uses: codecov/codecov-action@v5 + 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.result == 'success' && needs.coverage.result == 'skipped') + + steps: + - uses: geekyeggo/delete-artifact@v5 + with: + name: coverage-data diff --git a/.gitignore b/.gitignore index a67d42b..bcc198c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ -composer.phar +/build/ +/.phpunit.cache/ +/.phpunit.result.cache +/cache.properties +/composer.lock +/composer.phar +phpunit.xml.bak +/super-linter-output/ /vendor/ - -# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..4affc05 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,20 @@ +--- + +coverage: + status: + project: + default: + target: 0% + threshold: 2% + patch: false +comment: + layout: "diff" + behavior: once + require_changes: true + require_base: false + require_head: true + branches: null +github_checks: + annotations: false +ignore: + - 'classes/element.registry.php' diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a4205bc --- /dev/null +++ b/composer.json @@ -0,0 +1,56 @@ +{ + "name": "simplesamlphp/xml-ws-addressing", + "description": "Web Services Addressing library from SimpleSAMLphp", + "type": "simplesamlphp-xmlprovider", + "license": "LGPL-2.1-or-later", + "authors": [ + { + "name": "Tim van Dijen", + "email": "tvdijen@gmail.com" + } + ], + "require": { + "php": "^8.2", + "ext-dom": "*", + + "simplesamlphp/assert": "~1.9", + "simplesamlphp/xml-common": "~2.4", + "simplesamlphp/xml-soap": "~2.0" + }, + "require-dev": { + "simplesamlphp/simplesamlphp-test-framework": "~1.10" + }, + "autoload": { + "psr-4": { + "SimpleSAML\\WS_ADDR\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "SimpleSAML\\Test\\WS_ADDR\\": "tests/WS_ADDR/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "v1.0.x-dev" + } + }, + "config": { + "allow-plugins": { + "composer/package-versions-deprecated": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true, + "simplesamlphp/composer-xmlprovider-installer": true + } + }, + "scripts": { + "pre-commit": [ + "vendor/bin/phpcs -p", + "vendor/bin/composer-require-checker check composer.json", + "vendor/bin/phpstan analyze -c phpstan.neon", + "vendor/bin/phpstan analyze -c phpstan-dev.neon", + "vendor/bin/composer-unused", + "vendor/bin/phpunit --no-coverage --testdox" + ] + } +} diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..0a56bb7 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,29 @@ + + + + By default it is less stringent about long lines than other coding standards + + + + + + + src + tests + + + + + + + src/_autoload.php + + + + + + + + + + diff --git a/phpstan-dev.neon b/phpstan-dev.neon new file mode 100644 index 0000000..fe30128 --- /dev/null +++ b/phpstan-dev.neon @@ -0,0 +1,4 @@ +parameters: + level: 7 + paths: + - tests diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..ffdbd91 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 9 + paths: + - src diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..c24bbe8 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + + + + + + + ./tests + + + + + + ./src + + + diff --git a/resources/schemas/ws-addr-200408.xsd b/resources/schemas/ws-addr-200408.xsd new file mode 100644 index 0000000..8a668e2 --- /dev/null +++ b/resources/schemas/ws-addr-200408.xsd @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + If "Policy" elements from namespace "http://schemas.xmlsoap.org/ws/2002/12/policy#policy" are used, they must appear first (before any extensibility elements). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/schemas/ws-addr-200508.xsd b/resources/schemas/ws-addr-200508.xsd new file mode 100644 index 0000000..47362ed --- /dev/null +++ b/resources/schemas/ws-addr-200508.xsd @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/schemas/ws-addr-wsdl.xsd b/resources/schemas/ws-addr-wsdl.xsd new file mode 100644 index 0000000..57310d7 --- /dev/null +++ b/resources/schemas/ws-addr-wsdl.xsd @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/schemas/xml.xsd b/resources/schemas/xml.xsd new file mode 100644 index 0000000..bd291f3 --- /dev/null +++ b/resources/schemas/xml.xsd @@ -0,0 +1,286 @@ + + + + + + +
+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ Note that local names in this namespace are intended to be + defined only by the World Wide Web Consortium or its subgroups. + The names currently defined in this namespace are listed below. + They should not be used with conflicting semantics by any Working + Group, specification, or document instance. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+
+
+ + + + +
+ +

lang (as an attribute name)

+

+ denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification.

+ +
+
+

Notes

+

+ Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: +

+
+

+ In appreciation for his vision, leadership and + dedication the W3C XML Plenary on this 10th day of + February, 2000, reserves for Jon Bosak in perpetuity + the XML name "xml:Father". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML + Schema itself, or with the XML namespace itself. In other words, + if the XML Schema or XML namespaces change, the version of this + document at + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ +
diff --git a/resources/schemas/xmldsig-core-schema.xsd b/resources/schemas/xmldsig-core-schema.xsd new file mode 100644 index 0000000..df126b3 --- /dev/null +++ b/resources/schemas/xmldsig-core-schema.xsd @@ -0,0 +1,318 @@ + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Assert/Assert.php b/src/Assert/Assert.php new file mode 100644 index 0000000..5e655c7 --- /dev/null +++ b/src/Assert/Assert.php @@ -0,0 +1,14 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static(QNameValue::fromDocument($xml->textContent, $xml), self::getAttributesNSFromXML($xml)); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/AbstractAttributedURIType.php b/src/XML/wsa_200408/AbstractAttributedURIType.php new file mode 100644 index 0000000..0fd7e3c --- /dev/null +++ b/src/XML/wsa_200408/AbstractAttributedURIType.php @@ -0,0 +1,84 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static(AnyURIValue::fromString($xml->textContent), self::getAttributesNSFromXML($xml)); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/AbstractEndpointReferenceType.php b/src/XML/wsa_200408/AbstractEndpointReferenceType.php new file mode 100644 index 0000000..681e1a3 --- /dev/null +++ b/src/XML/wsa_200408/AbstractEndpointReferenceType.php @@ -0,0 +1,203 @@ +setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Collect the value of the address property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200408\Address + */ + public function getAddress(): Address + { + return $this->address; + } + + + /** + * Collect the value of the referenceProperties property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200408\ReferenceProperties|null + */ + public function getReferenceProperties(): ?ReferenceProperties + { + return $this->referenceProperties; + } + + + /** + * Collect the value of the referenceParameters property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200408\ReferenceParameters|null + */ + public function getReferenceParameters(): ?ReferenceParameters + { + return $this->referenceParameters; + } + + + /** + * Collect the value of the portType property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200408\PortType|null + */ + public function getPortType(): ?PortType + { + return $this->portType; + } + + + /** + * Collect the value of the serviceName property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200408\ServiceName|null + */ + public function getServiceName(): ?ServiceName + { + return $this->serviceName; + } + + + /** + * Initialize an EndpointReferenceType. + * + * Note: this method cannot be used when extending this class, if the constructor has a different signature. + * + * @param \DOMElement $xml The XML element we should load. + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException + * if the supplied element is missing any of the mandatory attributes + */ + public static function fromXML(DOMElement $xml): static + { + $qualifiedName = static::getClassName(static::class); + Assert::eq( + $xml->localName, + $qualifiedName, + sprintf('Unexpected name for endpoint reference: %s. Expected: %s.', $xml->localName, $qualifiedName), + InvalidDOMElementException::class, + ); + + $address = Address::getChildrenOfClass($xml); + Assert::minCount($address, 1, MissingElementException::class); + Assert::maxCount($address, 1, TooManyElementsException::class); + + $referenceProperties = ReferenceProperties::getChildrenOfClass($xml); + Assert::maxCount($referenceProperties, 1, TooManyElementsException::class); + + $referenceParameters = ReferenceParameters::getChildrenOfClass($xml); + Assert::maxCount($referenceParameters, 1, TooManyElementsException::class); + + $portType = PortType::getChildrenOfClass($xml); + Assert::maxCount($portType, 1, TooManyElementsException::class); + + $serviceName = ServiceName::getChildrenOfClass($xml); + Assert::maxCount($serviceName, 1, TooManyElementsException::class); + + return new static( + $address[0], + array_pop($referenceProperties), + array_pop($referenceParameters), + array_pop($portType), + array_pop($serviceName), + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this endpoint reference to an XML element. + * + * @param \DOMElement|null $parent The element we should append this endpoint to. + * @return \DOMElement + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + $this->getAddress()->toXML($e); + + $this->getReferenceProperties()?->toXML($e); + $this->getReferenceParameters()?->toXML($e); + $this->getPortType()?->toXML($e); + $this->getServiceName()?->toXML($e); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/AbstractRelationshipType.php b/src/XML/wsa_200408/AbstractRelationshipType.php new file mode 100644 index 0000000..544584d --- /dev/null +++ b/src/XML/wsa_200408/AbstractRelationshipType.php @@ -0,0 +1,106 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Retrieve the value of the relationshipType property + */ + public function getRelationshipType(): ?QNameValue + { + return $this->relationshipType; + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static( + AnyURIValue::fromString($xml->textContent), + self::getOptionalAttribute($xml, 'RelationshipType', QNameValue::class, null), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + if ($this->getRelationshipType() !== null) { + $e->setAttribute('RelationshipType', $this->getRelationshipType()->getValue()); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/AbstractRetryAfterType.php b/src/XML/wsa_200408/AbstractRetryAfterType.php new file mode 100644 index 0000000..c87a89b --- /dev/null +++ b/src/XML/wsa_200408/AbstractRetryAfterType.php @@ -0,0 +1,87 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static(NonNegativeIntegerValue::fromString($xml->textContent), self::getAttributesNSFromXML($xml)); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/AbstractServiceNameType.php b/src/XML/wsa_200408/AbstractServiceNameType.php new file mode 100644 index 0000000..c243e0f --- /dev/null +++ b/src/XML/wsa_200408/AbstractServiceNameType.php @@ -0,0 +1,107 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Get the value of the portName property + */ + public function getPortName(): ?NCNameValue + { + return $this->portName; + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static( + QNameValue::fromDocument($xml->textContent, $xml), + self::getOptionalAttribute($xml, 'PortName', NCNameValue::class, null), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + if ($this->getPortName() !== null) { + $e->setAttribute('PortName', $this->getPortName()->getValue()); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/AbstractWsaElement.php b/src/XML/wsa_200408/AbstractWsaElement.php new file mode 100644 index 0000000..2b8c075 --- /dev/null +++ b/src/XML/wsa_200408/AbstractWsaElement.php @@ -0,0 +1,25 @@ +setElements($children); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->elements); + } + + + /* + * Convert XML into an ReferenceParameters element + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, 'ReferenceParameters', InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, ReferenceParameters::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + ); + } + + + /** + * Convert this ReferenceParameters to XML. + * + * @param \DOMElement|null $parent The element we should add this ReferenceParameters to. + * @return \DOMElement This Header-element. + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/ReferenceProperties.php b/src/XML/wsa_200408/ReferenceProperties.php new file mode 100644 index 0000000..0901128 --- /dev/null +++ b/src/XML/wsa_200408/ReferenceProperties.php @@ -0,0 +1,87 @@ +setElements($children); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->elements); + } + + + /* + * Convert XML into an ReferenceProperties element + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, 'ReferenceProperties', InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, ReferenceProperties::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + ); + } + + + /** + * Convert this ReferenceProperties to XML. + * + * @param \DOMElement|null $parent The element we should add this ReferenceProperties to. + * @return \DOMElement This Header-element. + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wsa_200408/RelatesTo.php b/src/XML/wsa_200408/RelatesTo.php new file mode 100644 index 0000000..3623816 --- /dev/null +++ b/src/XML/wsa_200408/RelatesTo.php @@ -0,0 +1,16 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static(QNameValue::fromDocument($xml->textContent, $xml), self::getAttributesNSFromXML($xml)); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/AbstractAttributedURIType.php b/src/XML/wsa_200508/AbstractAttributedURIType.php new file mode 100644 index 0000000..c996b6b --- /dev/null +++ b/src/XML/wsa_200508/AbstractAttributedURIType.php @@ -0,0 +1,84 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static(AnyURIValue::fromString($xml->textContent), self::getAttributesNSFromXML($xml)); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/AbstractAttributedUnsignedLongType.php b/src/XML/wsa_200508/AbstractAttributedUnsignedLongType.php new file mode 100644 index 0000000..c9b8394 --- /dev/null +++ b/src/XML/wsa_200508/AbstractAttributedUnsignedLongType.php @@ -0,0 +1,84 @@ +setContent($value); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\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); + + return new static(UnsignedLongValue::fromString($xml->textContent), self::getAttributesNSFromXML($xml)); + } + + + /** + * Convert this element 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->textContent = $this->getContent()->getValue(); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/AbstractEndpointReferenceType.php b/src/XML/wsa_200508/AbstractEndpointReferenceType.php new file mode 100644 index 0000000..bfdf82c --- /dev/null +++ b/src/XML/wsa_200508/AbstractEndpointReferenceType.php @@ -0,0 +1,166 @@ +setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Collect the value of the address property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200508\Address + */ + public function getAddress(): Address + { + return $this->address; + } + + + /** + * Collect the value of the referenceParameters property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200508\ReferenceParameters|null + */ + public function getReferenceParameters(): ?ReferenceParameters + { + return $this->referenceParameters; + } + + + /** + * Collect the value of the metadata property. + * + * @return \SimpleSAML\WS_ADDR\XML\wsa_200508\Metadata|null + */ + public function getMetadata(): ?Metadata + { + return $this->metadata; + } + + + /** + * Initialize an EndpointReferenceType. + * + * Note: this method cannot be used when extending this class, if the constructor has a different signature. + * + * @param \DOMElement $xml The XML element we should load. + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException + * if the supplied element is missing any of the mandatory attributes + */ + public static function fromXML(DOMElement $xml): static + { + $qualifiedName = static::getClassName(static::class); + Assert::eq( + $xml->localName, + $qualifiedName, + sprintf('Unexpected name for endpoint reference: %s. Expected: %s.', $xml->localName, $qualifiedName), + InvalidDOMElementException::class, + ); + + $address = Address::getChildrenOfClass($xml); + Assert::minCount($address, 1, MissingElementException::class); + Assert::maxCount($address, 1, TooManyElementsException::class); + + $referenceParameters = ReferenceParameters::getChildrenOfClass($xml); + Assert::maxCount($referenceParameters, 1, TooManyElementsException::class); + + $metadata = Metadata::getChildrenOfClass($xml); + Assert::maxCount($metadata, 1, TooManyElementsException::class); + + return new static( + $address[0], + array_pop($referenceParameters), + array_pop($metadata), + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this endpoint reference to an XML element. + * + * @param \DOMElement $parent The element we should append this endpoint to. + * @return \DOMElement + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + $this->getAddress()->toXML($e); + $this->getReferenceParameters()?->toXML($e); + $this->getMetadata()?->toXML($e); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/AbstractProblemActionType.php b/src/XML/wsa_200508/AbstractProblemActionType.php new file mode 100644 index 0000000..9a6c925 --- /dev/null +++ b/src/XML/wsa_200508/AbstractProblemActionType.php @@ -0,0 +1,75 @@ +setAttributesNS($namespacedAttributes); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->action) && empty($this->soapAction) && empty($this->namespacedAttributes); + } + + + /** + * Convert this element 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); + + $this->action?->toXML($e); + $this->soapAction?->toXML($e); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/AbstractWsaElement.php b/src/XML/wsa_200508/AbstractWsaElement.php new file mode 100644 index 0000000..7dfe20e --- /dev/null +++ b/src/XML/wsa_200508/AbstractWsaElement.php @@ -0,0 +1,25 @@ +setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getElements()) && empty($this->getAttributesNS()); + } + + + /* + * Convert XML into an Metadata element + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, 'Metadata', InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, Metadata::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this Metadata to XML. + * + * @param \DOMElement|null $parent The element we should add this Metadata to. + * @return \DOMElement This Metadata-element. + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/ProblemAction.php b/src/XML/wsa_200508/ProblemAction.php new file mode 100644 index 0000000..b74225a --- /dev/null +++ b/src/XML/wsa_200508/ProblemAction.php @@ -0,0 +1,58 @@ +localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $action = Action::getChildrenOfClass($xml); + Assert::maxCount( + $action, + 1, + 'No more than one Action element allowed in .', + TooManyElementsException::class, + ); + + $soapAction = SoapAction::getChildrenOfClass($xml); + Assert::maxCount( + $soapAction, + 1, + 'No more than one SoapAction element allowed in .', + TooManyElementsException::class, + ); + + return new static(array_pop($action), array_pop($soapAction), self::getAttributesNSFromXML($xml)); + } +} diff --git a/src/XML/wsa_200508/ProblemHeaderQName.php b/src/XML/wsa_200508/ProblemHeaderQName.php new file mode 100644 index 0000000..948cb5b --- /dev/null +++ b/src/XML/wsa_200508/ProblemHeaderQName.php @@ -0,0 +1,18 @@ +setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getElements()) && empty($this->getAttributesNS()); + } + + + /* + * Convert XML into an ReferenceParameters element + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, 'ReferenceParameters', InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, ReferenceParameters::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this ReferenceParameters to XML. + * + * @param \DOMElement|null $parent The element we should add this ReferenceParameters to. + * @return \DOMElement This Header-element. + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/RelatesTo.php b/src/XML/wsa_200508/RelatesTo.php new file mode 100644 index 0000000..aafcf9e --- /dev/null +++ b/src/XML/wsa_200508/RelatesTo.php @@ -0,0 +1,107 @@ +setContent($content); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Collect the value of the RelationshipType property. + * + * @return \SimpleSAML\XMLSchema\Type\AnyURIValue|null + */ + public function getRelationshipType(): ?AnyURIValue + { + return $this->RelationshipType; + } + + + /* + * Convert XML into an RelatesTo element + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, 'RelatesTo', InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, RelatesTo::NS, InvalidDOMElementException::class); + + return new static( + AnyURIValue::fromString($xml->textContent), + self::getOptionalAttribute($xml, 'RelationshipType', AnyURIValue::class, null), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this RelatesTo to XML. + * + * @param \DOMElement|null $parent The element we should add this RelatesTo to. + * @return \DOMElement This Header-element. + */ + public function toXML(?DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + $e->textContent = $this->getContent()->getValue(); + + if ($this->getRelationshipType() !== null) { + $e->setAttribute('RelationshipType', $this->getRelationshipType()->getValue()); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsa_200508/ReplyTo.php b/src/XML/wsa_200508/ReplyTo.php new file mode 100644 index 0000000..aa1e515 --- /dev/null +++ b/src/XML/wsa_200508/ReplyTo.php @@ -0,0 +1,18 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($action), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/AddressTest.php b/tests/WS_ADDR/XML/wsa_200408/AddressTest.php new file mode 100644 index 0000000..0a739cb --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/AddressTest.php @@ -0,0 +1,64 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($Address), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/EndpointReferenceTest.php b/tests/WS_ADDR/XML/wsa_200408/EndpointReferenceTest.php new file mode 100644 index 0000000..0ff96cc --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/EndpointReferenceTest.php @@ -0,0 +1,175 @@ +Apples', + )->documentElement; + + self::$referenceParametersContent = DOMDocumentFactory::fromString( + 'Pears', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'Some', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an EndpointReference object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $endpointReference = new EndpointReference( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($endpointReference), + ); + } + + + /** + * Test element order. + */ + public function testMarshallingElementOrdering(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $endpointReference = new EndpointReference( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + // Test for an Address + $endpointReferenceElement = $endpointReference->toXML(); + $xpCache = XPath::getXPath($endpointReferenceElement); + $endpointReferenceElements = XPath::xpQuery($endpointReferenceElement, './wsa:Address', $xpCache); + $this->assertCount(1, $endpointReferenceElements); + + // Test ordering of EndpointReference contents + /** @var \DOMElement[] $endpointReferenceElements */ + $endpointReferenceElements = XPath::xpQuery( + $endpointReferenceElement, + './wsa:Address/following-sibling::*', + $xpCache, + ); + + $this->assertCount(5, $endpointReferenceElements); + $this->assertEquals('wsa:ReferenceProperties', $endpointReferenceElements[0]->tagName); + $this->assertEquals('wsa:ReferenceParameters', $endpointReferenceElements[1]->tagName); + $this->assertEquals('wsa:PortType', $endpointReferenceElements[2]->tagName); + $this->assertEquals('wsa:ServiceName', $endpointReferenceElements[3]->tagName); + $this->assertEquals('ssp:Chunk', $endpointReferenceElements[4]->tagName); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/FaultToTest.php b/tests/WS_ADDR/XML/wsa_200408/FaultToTest.php new file mode 100644 index 0000000..4dd792f --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/FaultToTest.php @@ -0,0 +1,171 @@ +Apples', + )->documentElement; + + self::$referenceParametersContent = DOMDocumentFactory::fromString( + 'Pears', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'Some', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an FaultTo object FaultTo scratch. + */ + public function testMarshalling(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $faultTo = new FaultTo( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($faultTo), + ); + } + + + /** + * Test element order. + */ + public function testMarshallingElementOrdering(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $faultTo = new FaultTo( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + // Test for an Address + $faultToElement = $faultTo->toXML(); + $xpCache = XPath::getXPath($faultToElement); + $faultToElements = XPath::xpQuery($faultToElement, './wsa:Address', $xpCache); + $this->assertCount(1, $faultToElements); + + // Test ordering of FaultTo contents + /** @var \DOMElement[] $faultToElements */ + $faultToElements = XPath::xpQuery($faultToElement, './wsa:Address/following-sibling::*', $xpCache); + + $this->assertCount(5, $faultToElements); + $this->assertEquals('wsa:ReferenceProperties', $faultToElements[0]->tagName); + $this->assertEquals('wsa:ReferenceParameters', $faultToElements[1]->tagName); + $this->assertEquals('wsa:PortType', $faultToElements[2]->tagName); + $this->assertEquals('wsa:ServiceName', $faultToElements[3]->tagName); + $this->assertEquals('ssp:Chunk', $faultToElements[4]->tagName); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/FromTest.php b/tests/WS_ADDR/XML/wsa_200408/FromTest.php new file mode 100644 index 0000000..2277856 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/FromTest.php @@ -0,0 +1,171 @@ +Apples', + )->documentElement; + + self::$referenceParametersContent = DOMDocumentFactory::fromString( + 'Pears', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'Some', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an From object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $from = new From( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($from), + ); + } + + + /** + * Test element order. + */ + public function testMarshallingElementOrdering(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $from = new From( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + // Test for an Address + $fromElement = $from->toXML(); + $xpCache = XPath::getXPath($fromElement); + $fromElements = XPath::xpQuery($fromElement, './wsa:Address', $xpCache); + $this->assertCount(1, $fromElements); + + // Test ordering of From contents + /** @var \DOMElement[] $fromElements */ + $fromElements = XPath::xpQuery($fromElement, './wsa:Address/following-sibling::*', $xpCache); + + $this->assertCount(5, $fromElements); + $this->assertEquals('wsa:ReferenceProperties', $fromElements[0]->tagName); + $this->assertEquals('wsa:ReferenceParameters', $fromElements[1]->tagName); + $this->assertEquals('wsa:PortType', $fromElements[2]->tagName); + $this->assertEquals('wsa:ServiceName', $fromElements[3]->tagName); + $this->assertEquals('ssp:Chunk', $fromElements[4]->tagName); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/MessageIDTest.php b/tests/WS_ADDR/XML/wsa_200408/MessageIDTest.php new file mode 100644 index 0000000..ccfd3eb --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/MessageIDTest.php @@ -0,0 +1,66 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($MessageID), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/PortTypeTest.php b/tests/WS_ADDR/XML/wsa_200408/PortTypeTest.php new file mode 100644 index 0000000..d07e950 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/PortTypeTest.php @@ -0,0 +1,64 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($portType), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/ReferenceParametersTest.php b/tests/WS_ADDR/XML/wsa_200408/ReferenceParametersTest.php new file mode 100644 index 0000000..e4fb158 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/ReferenceParametersTest.php @@ -0,0 +1,78 @@ +Apples', + )->documentElement; + } + + + /** + */ + public function testMarshalling(): void + { + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $this->assertFalse($referenceParameters->isEmptyElement()); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($referenceParameters), + ); + } + + + /** + */ + public function testMarshallingWithNoContent(): void + { + $referenceParameters = new ReferenceParameters([]); + $this->assertEquals( + '', + strval($referenceParameters), + ); + $this->assertTrue($referenceParameters->isEmptyElement()); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/ReferencePropertiesTest.php b/tests/WS_ADDR/XML/wsa_200408/ReferencePropertiesTest.php new file mode 100644 index 0000000..6d363bf --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/ReferencePropertiesTest.php @@ -0,0 +1,78 @@ +Apples', + )->documentElement; + } + + + /** + */ + public function testMarshalling(): void + { + $ReferenceProperties = new ReferenceProperties([new Chunk(self::$ReferencePropertiesContent)]); + $this->assertFalse($ReferenceProperties->isEmptyElement()); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($ReferenceProperties), + ); + } + + + /** + */ + public function testMarshallingWithNoContent(): void + { + $ReferenceProperties = new ReferenceProperties([]); + $this->assertEquals( + '', + strval($ReferenceProperties), + ); + $this->assertTrue($ReferenceProperties->isEmptyElement()); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/RelatesToTest.php b/tests/WS_ADDR/XML/wsa_200408/RelatesToTest.php new file mode 100644 index 0000000..b6efdd3 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/RelatesToTest.php @@ -0,0 +1,71 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($relatesTo), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/ReplyToTest.php b/tests/WS_ADDR/XML/wsa_200408/ReplyToTest.php new file mode 100644 index 0000000..60ca10a --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/ReplyToTest.php @@ -0,0 +1,171 @@ +Apples', + )->documentElement; + + self::$referenceParametersContent = DOMDocumentFactory::fromString( + 'Pears', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'Some', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an ReplyTo object ReplyTo scratch. + */ + public function testMarshalling(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $replyTo = new ReplyTo( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($replyTo), + ); + } + + + /** + * Test element order. + */ + public function testMarshallingElementOrdering(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)]); + $referenceProperties = new ReferenceProperties([new Chunk(self::$referencePropertiesContent)]); + + $portType = new PortType(QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), [$attr3]); + $serviceName = new ServiceName( + QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), + NCNameValue::fromString('PHPUnit'), + [$attr4], + ); + $chunk = new Chunk(self::$customContent); + + $replyTo = new ReplyTo( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceProperties, + $referenceParameters, + $portType, + $serviceName, + [$chunk], + [$attr1], + ); + + // Test for an Address + $replyToElement = $replyTo->toXML(); + $xpCache = XPath::getXPath($replyToElement); + $replyToElements = XPath::xpQuery($replyToElement, './wsa:Address', $xpCache); + $this->assertCount(1, $replyToElements); + + // Test ordering of ReplyTo contents + /** @var \DOMElement[] $replyToElements */ + $replyToElements = XPath::xpQuery($replyToElement, './wsa:Address/following-sibling::*', $xpCache); + + $this->assertCount(5, $replyToElements); + $this->assertEquals('wsa:ReferenceProperties', $replyToElements[0]->tagName); + $this->assertEquals('wsa:ReferenceParameters', $replyToElements[1]->tagName); + $this->assertEquals('wsa:PortType', $replyToElements[2]->tagName); + $this->assertEquals('wsa:ServiceName', $replyToElements[3]->tagName); + $this->assertEquals('ssp:Chunk', $replyToElements[4]->tagName); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/RetryAfterTest.php b/tests/WS_ADDR/XML/wsa_200408/RetryAfterTest.php new file mode 100644 index 0000000..e9419a2 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/RetryAfterTest.php @@ -0,0 +1,63 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($retryAfter), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/ServiceNameTest.php b/tests/WS_ADDR/XML/wsa_200408/ServiceNameTest.php new file mode 100644 index 0000000..ad90a34 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/ServiceNameTest.php @@ -0,0 +1,69 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($serviceName), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200408/ToTest.php b/tests/WS_ADDR/XML/wsa_200408/ToTest.php new file mode 100644 index 0000000..21eb732 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200408/ToTest.php @@ -0,0 +1,66 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($To), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ActionTest.php b/tests/WS_ADDR/XML/wsa_200508/ActionTest.php new file mode 100644 index 0000000..f087a34 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ActionTest.php @@ -0,0 +1,66 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($action), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/AddressTest.php b/tests/WS_ADDR/XML/wsa_200508/AddressTest.php new file mode 100644 index 0000000..19c0648 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/AddressTest.php @@ -0,0 +1,64 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($address), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/EndpointReferenceTest.php b/tests/WS_ADDR/XML/wsa_200508/EndpointReferenceTest.php new file mode 100644 index 0000000..ece25ac --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/EndpointReferenceTest.php @@ -0,0 +1,107 @@ +Pears', + )->documentElement; + + self::$metadataContent = DOMDocumentFactory::fromString( + 'Apples', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'SomeChunk', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an EndpointReference object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]); + $metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]); + $chunk = new Chunk(self::$customContent); + + $endpointReference = new EndpointReference( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceParameters, + $metadata, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($endpointReference), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/FaultToTest.php b/tests/WS_ADDR/XML/wsa_200508/FaultToTest.php new file mode 100644 index 0000000..dd7950f --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/FaultToTest.php @@ -0,0 +1,109 @@ +Pears', + )->documentElement; + + self::$metadataContent = DOMDocumentFactory::fromString( + 'Apples', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'SomeChunk', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an FaultTo object from scratch. + */ + public function testMarshalling(): void + { + $doc = DOMDocumentFactory::fromString(''); + + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]); + $metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]); + $chunk = new Chunk(self::$customContent); + + $faultTo = new FaultTo( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceParameters, + $metadata, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($faultTo), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/FromTest.php b/tests/WS_ADDR/XML/wsa_200508/FromTest.php new file mode 100644 index 0000000..88f8be5 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/FromTest.php @@ -0,0 +1,109 @@ +Pears', + )->documentElement; + + self::$metadataContent = DOMDocumentFactory::fromString( + 'Apples', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'SomeChunk', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an From object from scratch. + */ + public function testMarshalling(): void + { + $doc = DOMDocumentFactory::fromString(''); + + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]); + $metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]); + $chunk = new Chunk(self::$customContent); + + $from = new From( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceParameters, + $metadata, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($from), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/MessageIDTest.php b/tests/WS_ADDR/XML/wsa_200508/MessageIDTest.php new file mode 100644 index 0000000..ef8a710 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/MessageIDTest.php @@ -0,0 +1,68 @@ +toAttribute()], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($msgId), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/MetadataTest.php b/tests/WS_ADDR/XML/wsa_200508/MetadataTest.php new file mode 100644 index 0000000..5e58409 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/MetadataTest.php @@ -0,0 +1,84 @@ +Apples', + )->documentElement; + } + + + /** + */ + public function testMarshalling(): void + { + $domAttr = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('value1')); + + $metadata = new Metadata([new Chunk(self::$metadataContent)], [$domAttr]); + $this->assertFalse($metadata->isEmptyElement()); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($metadata), + ); + } + + + /** + */ + public function testMarshallingWithNoContent(): void + { + $metadata = new Metadata([], []); + $this->assertEquals( + '', + strval($metadata), + ); + $this->assertTrue($metadata->isEmptyElement()); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ProblemActionTest.php b/tests/WS_ADDR/XML/wsa_200508/ProblemActionTest.php new file mode 100644 index 0000000..89ca791 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ProblemActionTest.php @@ -0,0 +1,89 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($problemAction), + ); + } + + + /** + * Adding an empty ProblemAction element should yield an empty element. + */ + public function testMarshallingEmptyElement(): void + { + $wsans = C::NS_ADDR_200508; + $problemAction = new ProblemAction(); + $this->assertEquals( + "", + strval($problemAction), + ); + $this->assertTrue($problemAction->isEmptyElement()); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ProblemHeaderQNameTest.php b/tests/WS_ADDR/XML/wsa_200508/ProblemHeaderQNameTest.php new file mode 100644 index 0000000..419b43a --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ProblemHeaderQNameTest.php @@ -0,0 +1,76 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($problemHeaderQName), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ProblemIRITest.php b/tests/WS_ADDR/XML/wsa_200508/ProblemIRITest.php new file mode 100644 index 0000000..b767734 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ProblemIRITest.php @@ -0,0 +1,67 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($problemIri), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ReferenceParametersTest.php b/tests/WS_ADDR/XML/wsa_200508/ReferenceParametersTest.php new file mode 100644 index 0000000..12aae1d --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ReferenceParametersTest.php @@ -0,0 +1,84 @@ +Apples', + )->documentElement; + } + + + /** + */ + public function testMarshalling(): void + { + $domAttr = new Attribute('urn:test:something', 'test', 'attr1', StringValue::fromString('testval1')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$domAttr]); + $this->assertFalse($referenceParameters->isEmptyElement()); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($referenceParameters), + ); + } + + + /** + */ + public function testMarshallingWithNoContent(): void + { + $referenceParameters = new ReferenceParameters([], []); + $this->assertEquals( + '', + strval($referenceParameters), + ); + $this->assertTrue($referenceParameters->isEmptyElement()); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/RelatesToTest.php b/tests/WS_ADDR/XML/wsa_200508/RelatesToTest.php new file mode 100644 index 0000000..ae847aa --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/RelatesToTest.php @@ -0,0 +1,65 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($relatesTo), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ReplyToTest.php b/tests/WS_ADDR/XML/wsa_200508/ReplyToTest.php new file mode 100644 index 0000000..e31509f --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ReplyToTest.php @@ -0,0 +1,109 @@ +Pears', + )->documentElement; + + self::$metadataContent = DOMDocumentFactory::fromString( + 'Apples', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + 'SomeChunk', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an ReplyTo object from scratch. + */ + public function testMarshalling(): void + { + $doc = DOMDocumentFactory::fromString(''); + + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1')); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2')); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3')); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4')); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]); + $metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]); + $chunk = new Chunk(self::$customContent); + + $replyTo = new ReplyTo( + new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]), + $referenceParameters, + $metadata, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($replyTo), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/RetryAfterTest.php b/tests/WS_ADDR/XML/wsa_200508/RetryAfterTest.php new file mode 100644 index 0000000..4d3aa5c --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/RetryAfterTest.php @@ -0,0 +1,66 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($retryAfter), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/SoapActionTest.php b/tests/WS_ADDR/XML/wsa_200508/SoapActionTest.php new file mode 100644 index 0000000..537cb1e --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/SoapActionTest.php @@ -0,0 +1,59 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($soapAction), + ); + } +} diff --git a/tests/WS_ADDR/XML/wsa_200508/ToTest.php b/tests/WS_ADDR/XML/wsa_200508/ToTest.php new file mode 100644 index 0000000..2a97570 --- /dev/null +++ b/tests/WS_ADDR/XML/wsa_200508/ToTest.php @@ -0,0 +1,67 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($to), + ); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..3792ea7 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,6 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200408/Address.xml b/tests/resources/xml/wsa/200408/Address.xml new file mode 100644 index 0000000..faec767 --- /dev/null +++ b/tests/resources/xml/wsa/200408/Address.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200408/EndpointReference.xml b/tests/resources/xml/wsa/200408/EndpointReference.xml new file mode 100644 index 0000000..e8c8b4a --- /dev/null +++ b/tests/resources/xml/wsa/200408/EndpointReference.xml @@ -0,0 +1,16 @@ + + https://login.microsoftonline.com/login.srf + + + Apples + + + + + Pears + + + ssp:Chunk + ssp:Chunk + Some + diff --git a/tests/resources/xml/wsa/200408/FaultTo.xml b/tests/resources/xml/wsa/200408/FaultTo.xml new file mode 100644 index 0000000..f4c0746 --- /dev/null +++ b/tests/resources/xml/wsa/200408/FaultTo.xml @@ -0,0 +1,16 @@ + + https://login.microsoftonline.com/login.srf + + + Apples + + + + + Pears + + + ssp:Chunk + ssp:Chunk + Some + diff --git a/tests/resources/xml/wsa/200408/From.xml b/tests/resources/xml/wsa/200408/From.xml new file mode 100644 index 0000000..c7be563 --- /dev/null +++ b/tests/resources/xml/wsa/200408/From.xml @@ -0,0 +1,16 @@ + + https://login.microsoftonline.com/login.srf + + + Apples + + + + + Pears + + + ssp:Chunk + ssp:Chunk + Some + diff --git a/tests/resources/xml/wsa/200408/MessageID.xml b/tests/resources/xml/wsa/200408/MessageID.xml new file mode 100644 index 0000000..4277333 --- /dev/null +++ b/tests/resources/xml/wsa/200408/MessageID.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200408/PortType.xml b/tests/resources/xml/wsa/200408/PortType.xml new file mode 100644 index 0000000..fd79d16 --- /dev/null +++ b/tests/resources/xml/wsa/200408/PortType.xml @@ -0,0 +1 @@ +ssp:Chunk diff --git a/tests/resources/xml/wsa/200408/ReferenceParameters.xml b/tests/resources/xml/wsa/200408/ReferenceParameters.xml new file mode 100644 index 0000000..ca50575 --- /dev/null +++ b/tests/resources/xml/wsa/200408/ReferenceParameters.xml @@ -0,0 +1,5 @@ + + + Apples + + diff --git a/tests/resources/xml/wsa/200408/ReferenceProperties.xml b/tests/resources/xml/wsa/200408/ReferenceProperties.xml new file mode 100644 index 0000000..b7a8dd3 --- /dev/null +++ b/tests/resources/xml/wsa/200408/ReferenceProperties.xml @@ -0,0 +1,5 @@ + + + Apples + + diff --git a/tests/resources/xml/wsa/200408/RelatesTo.xml b/tests/resources/xml/wsa/200408/RelatesTo.xml new file mode 100644 index 0000000..9a5f1ae --- /dev/null +++ b/tests/resources/xml/wsa/200408/RelatesTo.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200408/ReplyTo.xml b/tests/resources/xml/wsa/200408/ReplyTo.xml new file mode 100644 index 0000000..c700af1 --- /dev/null +++ b/tests/resources/xml/wsa/200408/ReplyTo.xml @@ -0,0 +1,16 @@ + + https://login.microsoftonline.com/login.srf + + + Apples + + + + + Pears + + + ssp:Chunk + ssp:Chunk + Some + diff --git a/tests/resources/xml/wsa/200408/RetryAfter.xml b/tests/resources/xml/wsa/200408/RetryAfter.xml new file mode 100644 index 0000000..2e57747 --- /dev/null +++ b/tests/resources/xml/wsa/200408/RetryAfter.xml @@ -0,0 +1 @@ +30 diff --git a/tests/resources/xml/wsa/200408/ServiceName.xml b/tests/resources/xml/wsa/200408/ServiceName.xml new file mode 100644 index 0000000..aad2325 --- /dev/null +++ b/tests/resources/xml/wsa/200408/ServiceName.xml @@ -0,0 +1 @@ +ssp:Chunk diff --git a/tests/resources/xml/wsa/200408/To.xml b/tests/resources/xml/wsa/200408/To.xml new file mode 100644 index 0000000..bd8a144 --- /dev/null +++ b/tests/resources/xml/wsa/200408/To.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200508/Action.xml b/tests/resources/xml/wsa/200508/Action.xml new file mode 100644 index 0000000..82118cf --- /dev/null +++ b/tests/resources/xml/wsa/200508/Action.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200508/Address.xml b/tests/resources/xml/wsa/200508/Address.xml new file mode 100644 index 0000000..c155957 --- /dev/null +++ b/tests/resources/xml/wsa/200508/Address.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200508/EndpointReference.xml b/tests/resources/xml/wsa/200508/EndpointReference.xml new file mode 100644 index 0000000..a008b39 --- /dev/null +++ b/tests/resources/xml/wsa/200508/EndpointReference.xml @@ -0,0 +1,14 @@ + + https://login.microsoftonline.com/login.srf + + + Pears + + + + + Apples + + + SomeChunk + diff --git a/tests/resources/xml/wsa/200508/FaultTo.xml b/tests/resources/xml/wsa/200508/FaultTo.xml new file mode 100644 index 0000000..b6c2539 --- /dev/null +++ b/tests/resources/xml/wsa/200508/FaultTo.xml @@ -0,0 +1,14 @@ + + https://login.microsoftonline.com/login.srf + + + Pears + + + + + Apples + + + SomeChunk + diff --git a/tests/resources/xml/wsa/200508/From.xml b/tests/resources/xml/wsa/200508/From.xml new file mode 100644 index 0000000..b9f6c19 --- /dev/null +++ b/tests/resources/xml/wsa/200508/From.xml @@ -0,0 +1,14 @@ + + https://login.microsoftonline.com/login.srf + + + Pears + + + + + Apples + + + SomeChunk + diff --git a/tests/resources/xml/wsa/200508/MessageID.xml b/tests/resources/xml/wsa/200508/MessageID.xml new file mode 100644 index 0000000..f8aab78 --- /dev/null +++ b/tests/resources/xml/wsa/200508/MessageID.xml @@ -0,0 +1 @@ +uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de diff --git a/tests/resources/xml/wsa/200508/Metadata.xml b/tests/resources/xml/wsa/200508/Metadata.xml new file mode 100644 index 0000000..6f075a8 --- /dev/null +++ b/tests/resources/xml/wsa/200508/Metadata.xml @@ -0,0 +1,5 @@ + + + Apples + + diff --git a/tests/resources/xml/wsa/200508/ProblemAction.xml b/tests/resources/xml/wsa/200508/ProblemAction.xml new file mode 100644 index 0000000..d9ed3a9 --- /dev/null +++ b/tests/resources/xml/wsa/200508/ProblemAction.xml @@ -0,0 +1,4 @@ + + https://login.microsoftonline.com/login.srf + http://www.example.com/ + diff --git a/tests/resources/xml/wsa/200508/ProblemHeaderQName.xml b/tests/resources/xml/wsa/200508/ProblemHeaderQName.xml new file mode 100644 index 0000000..451af81 --- /dev/null +++ b/tests/resources/xml/wsa/200508/ProblemHeaderQName.xml @@ -0,0 +1 @@ +wsa10:Action diff --git a/tests/resources/xml/wsa/200508/ProblemIRI.xml b/tests/resources/xml/wsa/200508/ProblemIRI.xml new file mode 100644 index 0000000..327723d --- /dev/null +++ b/tests/resources/xml/wsa/200508/ProblemIRI.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tests/resources/xml/wsa/200508/ReferenceParameters.xml b/tests/resources/xml/wsa/200508/ReferenceParameters.xml new file mode 100644 index 0000000..137b4b9 --- /dev/null +++ b/tests/resources/xml/wsa/200508/ReferenceParameters.xml @@ -0,0 +1,5 @@ + + + Apples + + diff --git a/tests/resources/xml/wsa/200508/RelatesTo.xml b/tests/resources/xml/wsa/200508/RelatesTo.xml new file mode 100644 index 0000000..b25c54d --- /dev/null +++ b/tests/resources/xml/wsa/200508/RelatesTo.xml @@ -0,0 +1 @@ +urn:x-simplesamlphp:namespace diff --git a/tests/resources/xml/wsa/200508/ReplyTo.xml b/tests/resources/xml/wsa/200508/ReplyTo.xml new file mode 100644 index 0000000..6eaf12e --- /dev/null +++ b/tests/resources/xml/wsa/200508/ReplyTo.xml @@ -0,0 +1,14 @@ + + https://login.microsoftonline.com/login.srf + + + Pears + + + + + Apples + + + SomeChunk + diff --git a/tests/resources/xml/wsa/200508/RetryAfter.xml b/tests/resources/xml/wsa/200508/RetryAfter.xml new file mode 100644 index 0000000..6d6650f --- /dev/null +++ b/tests/resources/xml/wsa/200508/RetryAfter.xml @@ -0,0 +1 @@ +1234567890 diff --git a/tests/resources/xml/wsa/200508/SoapAction.xml b/tests/resources/xml/wsa/200508/SoapAction.xml new file mode 100644 index 0000000..25eb43a --- /dev/null +++ b/tests/resources/xml/wsa/200508/SoapAction.xml @@ -0,0 +1 @@ +http://www.example.com/ diff --git a/tests/resources/xml/wsa/200508/To.xml b/tests/resources/xml/wsa/200508/To.xml new file mode 100644 index 0000000..7c134c7 --- /dev/null +++ b/tests/resources/xml/wsa/200508/To.xml @@ -0,0 +1 @@ +https://login.microsoftonline.com/login.srf diff --git a/tools/linters/.yaml-lint.yml b/tools/linters/.yaml-lint.yml new file mode 100644 index 0000000..630095a --- /dev/null +++ b/tools/linters/.yaml-lint.yml @@ -0,0 +1,7 @@ +--- + +extends: default + +rules: + line-length: + max: 120 From ee322f682328362a9580a7edbef4f6cfb0703dd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Dec 2025 20:24:13 +0000 Subject: [PATCH 2/2] Bump the all-actions group with 4 updates Bumps the all-actions group with 4 updates: [dessant/lock-threads](https://github.com/dessant/lock-threads), [actions/cache](https://github.com/actions/cache), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `dessant/lock-threads` from 5 to 6 - [Release notes](https://github.com/dessant/lock-threads/releases) - [Changelog](https://github.com/dessant/lock-threads/blob/main/CHANGELOG.md) - [Commits](https://github.com/dessant/lock-threads/compare/v5...v6) Updates `actions/cache` from 4 to 5 - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v4...v5) Updates `actions/upload-artifact` from 5 to 6 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v5...v6) Updates `actions/download-artifact` from 6 to 7 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v6...v7) --- updated-dependencies: - dependency-name: dessant/lock-threads dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: all-actions - dependency-name: actions/cache dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major dependency-group: all-actions - dependency-name: actions/upload-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: all-actions - dependency-name: actions/download-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: all-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/autolock-conversations.yml | 2 +- .github/workflows/php.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/autolock-conversations.yml b/.github/workflows/autolock-conversations.yml index 3c7be52..66797ba 100644 --- a/.github/workflows/autolock-conversations.yml +++ b/.github/workflows/autolock-conversations.yml @@ -18,7 +18,7 @@ jobs: action: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v5 + - uses: dessant/lock-threads@v6 with: issue-inactive-days: '90' pr-inactive-days: '90' diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a93c8b1..c81c5b0 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -75,7 +75,7 @@ jobs: run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" - name: Cache composer dependencies - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ${{ env.COMPOSER_CACHE }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -94,7 +94,7 @@ jobs: - name: Save coverage data if: ${{ matrix.php-versions == '8.5' }} - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: coverage-data path: ${{ github.workspace }}/build @@ -137,7 +137,7 @@ jobs: run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV" - name: Cache composer dependencies - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ${{ env.COMPOSER_CACHE }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -174,7 +174,7 @@ jobs: run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" - name: Cache composer dependencies - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ${{ env.COMPOSER_CACHE }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -217,7 +217,7 @@ jobs: run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" - name: Cache composer dependencies - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ${{ env.COMPOSER_CACHE }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -254,7 +254,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: actions/download-artifact@v6 + - uses: actions/download-artifact@v7 with: name: coverage-data path: ${{ github.workspace }}/build