Skip to content

Commit

Permalink
Add wst classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 23, 2024
1 parent 7f864a3 commit 54090ca
Show file tree
Hide file tree
Showing 24 changed files with 696 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/XML/wst/CanonicalizationAlgorithm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\URIElementTrait;

/**
* A CanonicalizationAlgorithm element
*
* @package tvdijen/ws-security
*/
final class CanonicalizationAlgorithm extends AbstractWstElement
{
use URIElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/ComputedKeyAlgorithm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\URIElementTrait;

/**
* A ComputedKeyAlgorithm element
*
* @package tvdijen/ws-security
*/
final class ComputedKeyAlgorithm extends AbstractWstElement
{
use URIElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/Delegatable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\BooleanElementTrait;

/**
* A Delegatable element
*
* @package tvdijen/ws-security
*/
final class Delegatable extends AbstractWstElement
{
use BooleanElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/EncryptWith.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\URIElementTrait;

/**
* An EncryptWith element
*
* @package tvdijen/ws-security
*/
final class EncryptWith extends AbstractWstElement
{
use URIElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/EncryptionAlgorithm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\URIElementTrait;

/**
* A EncryptionAlgorithm element
*
* @package tvdijen/ws-security
*/
final class EncryptionAlgorithm extends AbstractWstElement
{
use URIElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/Forwardable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\BooleanElementTrait;

/**
* A Forwardable element
*
* @package tvdijen/ws-security
*/
final class Forwardable extends AbstractWstElement
{
use BooleanElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/SignWith.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\URIElementTrait;

/**
* A SignWith element
*
* @package tvdijen/ws-security
*/
final class SignWith extends AbstractWstElement
{
use URIElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/wst/SignatureAlgorithm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\wst;

use SimpleSAML\XML\URIElementTrait;

/**
* A SignatureAlgorithm element
*
* @package tvdijen/ws-security
*/
final class SignatureAlgorithm extends AbstractWstElement
{
use URIElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
60 changes: 60 additions & 0 deletions tests/WSSecurity/XML/wst/CanonicalizationAlgorithmTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\WSSecurity\XML\wst;

use DOMDocument;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Test\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\wst\CanonicalizationAlgorithm;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;

use function dirname;

/**
* Class \SimpleSAML\WSSecurity\XML\wst\CanonicalizationAlgorithmTest
*
* @covers \SimpleSAML\WSSecurity\XML\wst\CanonicalizationAlgorithm
* @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement
*
* @package tvdijen/ws-security
*/
final class CanonicalizationAlgorithmTest extends TestCase
{
use SchemaValidationTestTrait;
use SerializableElementTestTrait;


/**
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust.xsd';

self::$testedClass = CanonicalizationAlgorithm::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 4) . '/resources/xml/wst_CanonicalizationAlgorithm.xml',
);
}


// test marshalling


/**
* Test creating a CanonicalizationAlgorithm object from scratch.
*/
public function testMarshalling(): void
{
$canonicalizationAlgorithm = new CanonicalizationAlgorithm(C::NAMESPACE);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($canonicalizationAlgorithm),
);
}
}
60 changes: 60 additions & 0 deletions tests/WSSecurity/XML/wst/ComputedKeyAlgorithmTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\WSSecurity\XML\wst;

use DOMDocument;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Test\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\wst\ComputedKeyAlgorithm;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;

use function dirname;

/**
* Class \SimpleSAML\WSSecurity\XML\wst\ComputedKeyAlgorithmTest
*
* @covers \SimpleSAML\WSSecurity\XML\wst\ComputedKeyAlgorithm
* @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement
*
* @package tvdijen/ws-security
*/
final class ComputedKeyAlgorithmTest extends TestCase
{
use SchemaValidationTestTrait;
use SerializableElementTestTrait;


/**
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust.xsd';

self::$testedClass = ComputedKeyAlgorithm::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 4) . '/resources/xml/wst_ComputedKeyAlgorithm.xml',
);
}


// test marshalling


/**
* Test creating a ComputedKeyAlgorithm object from scratch.
*/
public function testMarshalling(): void
{
$computedKeyAlgorithm = new ComputedKeyAlgorithm(C::NAMESPACE);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($computedKeyAlgorithm),
);
}
}
60 changes: 60 additions & 0 deletions tests/WSSecurity/XML/wst/DelegatableTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\WSSecurity\XML\wst;

use DOMDocument;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Test\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\wst\Delegatable;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;

use function dirname;

/**
* Class \SimpleSAML\WSSecurity\XML\wst\DelegatableTest
*
* @covers \SimpleSAML\WSSecurity\XML\wst\Delegatable
* @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement
*
* @package tvdijen/ws-security
*/
final class DelegatableTest extends TestCase
{
use SchemaValidationTestTrait;
use SerializableElementTestTrait;


/**
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust.xsd';

self::$testedClass = Delegatable::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 4) . '/resources/xml/wst_Delegatable.xml',
);
}


// test marshalling


/**
* Test creating a Delegatable object from scratch.
*/
public function testMarshalling(): void
{
$delegatable = new Delegatable('true');

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($delegatable),
);
}
}
Loading

0 comments on commit 54090ca

Please sign in to comment.