Skip to content

Commit

Permalink
Add wsdl to the library
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Aug 31, 2024
1 parent 715d665 commit 43c5d39
Show file tree
Hide file tree
Showing 70 changed files with 4,204 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/interoperability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---

name: Interoperability

on: # yamllint disable-line rule:truthy
push:
branches: ['**']
paths-ignore:
- '**.md'
- '**.yml'
pull_request:
branches: [master, release-*]
paths-ignore:
- '**.md'
- '**.yml'
workflow_dispatch:

jobs:
edugain:
name: "Interoperability tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.2']

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, hash, mbstring, openssl, pcre, spl, xml
tools: composer:v2
ini-values: error_reporting=E_ALL, memory_limit=-1
coverage: none

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: $(composer config cache-files-dir)
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Get current date
id: date
run: |
echo "{date}={$(date +'%Y-%m-%d')}" >> "$GITHUB_STATE"
- name: Cache metadata
id: cache-metadata
uses: actions/cache@v4
with:
path: /tmp/metadata
key: ${{ runner.os }}-metadata-${{ env.date }}
restore-keys: ${{ runner.os }}-metadata-

- name: Run unit tests
run: |
./vendor/bin/phpunit -c phpunit-interoperability.xml
8 changes: 8 additions & 0 deletions phpunit-interoperability.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite - Interoperability">
<directory>./tests/InterOperability</directory>
</testsuite>
</testsuites>
</phpunit>
104 changes: 104 additions & 0 deletions src/XML/wsdl/AbstractBinding.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wsdl;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;

/**
* Abstract class representing the tBinding type.
*
* @package simplesamlphp/ws-security
*/
abstract class AbstractBinding extends AbstractExtensibleDocumented
{
/**
* Initialize a wsdl:tBinding
*
* @param string $name
* @param string $type
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperation[] $operation
* @param \SimpleSAML\XML\Chunk[] $elements
*/
public function __construct(
protected string $name,
protected string $type,
protected array $operation = [],
array $elements = [],
) {
Assert::validNCName($name, SchemaViolationException::class);
Assert::validQName($type, SchemaViolationException::class);
Assert::allIsInstanceOf($operation, BindingOperation::class, SchemaViolationException::class);

parent::__construct($elements);
}


/**
* Collect the value of the name-property.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}


/**
* Collect the value of the type-property.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}


/**
* Collect the value of the operation-property.
*
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperation[]
*/
public function getOperation(): array
{
return $this->operation;
}


/**
* Test if an object, at the state it's in, would produce an empty XML-element
*
* @return bool
*/
public function isEmptyElement(): bool
{
// Upstream abstract elements can be empty, but this one cannot
return false;
}


/**
* Convert this tBinding to XML.
*
* @param \DOMElement|null $parent The element we are converting to XML.
* @return \DOMElement The XML element after adding the data corresponding to this tBinding.
*/
public function toXML(DOMElement $parent = null): DOMElement
{
$e = parent::toXML($parent);

$e->setAttribute('name', $this->getName());
$e->setAttribute('type', $this->getType());

foreach ($this->getOperation() as $operation) {
$operation->toXML($e);
}

return $e;
}
}
118 changes: 118 additions & 0 deletions src/XML/wsdl/AbstractBindingOperation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wsdl;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;

/**
* Abstract class representing the tBindingOperation type.
*
* @package simplesamlphp/ws-security
*/
abstract class AbstractBindingOperation extends AbstractExtensibleDocumented
{
/**
* Initialize a wsdl:tBindingOperation
*
* @param string $name
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationInput|null $input
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationOutput|null $output
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationFault[] $fault
* @param \SimpleSAML\XML\Chunk[] $elements
*/
public function __construct(
protected string $name,
protected ?BindingOperationInput $input = null,
protected ?BindingOperationOutput $output = null,
protected array $fault = [],
array $elements = [],
) {
Assert::validNCName($name, SchemaViolationException::class);
Assert::allIsInstanceOf($fault, BindingOperationFault::class, SchemaViolationException::class);

parent::__construct($elements);
}


/**
* Collect the value of the name-property.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}


/**
* Collect the value of the input-property.
*
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationInput|null
*/
public function getInput(): ?BindingOperationInput
{
return $this->input;
}


/**
* Collect the value of the output-property.
*
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationOutput|null
*/
public function getOutput(): ?BindingOperationOutput
{
return $this->output;
}


/**
* Collect the value of the fault-property.
*
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationFault[]
*/
public function getFault(): array
{
return $this->fault;
}


/**
* Test if an object, at the state it's in, would produce an empty XML-element
*
* @return bool
*/
public function isEmptyElement(): bool
{
// Upstream abstract elements can be empty, but this one cannot
return false;
}


/**
* Convert this tBindingOperation to XML.
*
* @param \DOMElement|null $parent The element we are converting to XML.
* @return \DOMElement The XML element after adding the data corresponding to this tBindingOperation.
*/
public function toXML(DOMElement $parent = null): DOMElement
{
$e = parent::toXML($parent);

$e->setAttribute('name', $this->getName());

$this->getInput()?->toXML($e);
$this->getOutput()?->toXML($e);

foreach ($this->getFault() as $fault) {
$fault->toXML($e);
}

return $e;
}
}
69 changes: 69 additions & 0 deletions src/XML/wsdl/AbstractBindingOperationFault.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wsdl;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;

/**
* Abstract class representing the tBindingOperationFault type.
*
* @package simplesamlphp/ws-security
*/
abstract class AbstractBindingOperationFault extends AbstractExtensibleDocumented
{
/**
* Initialize a wsdl:tBindingOperationFault
*
* @param string $name
* @param \SimpleSAML\XML\Chunk[] $elements
*/
public function __construct(
protected string $name,
array $elements = [],
) {
Assert::validNCName($name, SchemaViolationException::class);
parent::__construct($elements);
}


/**
* Collect the value of the name-property.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}


/**
* Test if an object, at the state it's in, would produce an empty XML-element
*
* @return bool
*/
public function isEmptyElement(): bool
{
// Upstream abstract elements can be empty, but this one cannot
return false;
}


/**
* Convert this tBindingOperationFault to XML.
*
* @param \DOMElement|null $parent The element we are converting to XML.
* @return \DOMElement The XML element after adding the data corresponding to this tBindingOperationFault.
*/
public function toXML(DOMElement $parent = null): DOMElement
{
$e = parent::toXML($parent);
$e->setAttribute('name', $this->getName());

return $e;
}
}
Loading

0 comments on commit 43c5d39

Please sign in to comment.