Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jul 16, 2024
1 parent 3a286ea commit 530e200
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/Cas/Protocol/Cas20.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ public function getProxyGrantingTicketIOU(): ?string

/**
* @param string $username
* @return \SimpleSAML\CAS\XML\cas\AuthenticationSuccess
* @return \SimpleSAML\CAS\XML\cas\ServiceResponse
*/
public function getValidateSuccessResponse(string $username): AuthenticationSuccess
public function getValidateSuccessResponse(string $username): ServiceResponse
{
$user = new User($username);

Expand Down Expand Up @@ -157,9 +157,10 @@ public function getValidateSuccessResponse(string $username): AuthenticationSucc
$attr,
);

$authenticationSucces = new AuthenticationSuccess($user, $attributes, $proxyGrantingTicket);
$authenticationSuccess = new AuthenticationSuccess($user, $attributes, $proxyGrantingTicket);
$serviceResponse = new ServiceResponse($authenticationSuccess);

return $authenticationSucces;
return $serviceResponse;
}


Expand Down Expand Up @@ -218,7 +219,7 @@ private function generateCas20Attribute(

$attributeValue = $this->base64EncodeAttributes ? base64_encode($attributeValue) : $attributeValue;
$attributeElement = $xmlDocument->createElement('cas:' . $attributeName);
$attributeElement->appendChild($attributeValueNode);
$attributeElement->appendChild($xmlDocument->createTextNode($attributeValueNode));

return new Chunk($attributeElement);
}
Expand All @@ -242,6 +243,6 @@ private function isValidXmlName(string $name): bool
$name,
FILTER_VALIDATE_REGEXP,
['options' => ['regexp' => '/^[a-zA-Z_][\w.-]*$/']],
) === true;
) !== false;
}
}
7 changes: 7 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
/** @psalm-suppress UnresolvableInclude */
require_once($projectRootDirectory . '/vendor/autoload.php');

// Symlink module into ssp vendor lib so that templates and urls can resolve correctly
$linkPath = $projectRootDirectory . '/vendor/simplesamlphp/simplesamlphp/modules/casserver';
if (file_exists($linkPath) === false) {
echo "Linking '$linkPath' to '$projectRootDirectory'\n";
symlink($projectRootDirectory, $linkPath);
}

/**
* Sets a link in the simplesamlphp vendor directory
* @param string $target
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Cas/Protocol/Cas20Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function testAttributeToXmlConversion(): void

$xml = $casProtocol->getValidateSuccessResponse('myUser');

$this->assertEquals($this->document->saveXML(), $xml);
$this->assertEquals($this->document->saveXML($this->document), strval($xml));
}
}
2 changes: 1 addition & 1 deletion tests/src/Ticket/DelegatingTicketStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DelegatingTicketStoreTest extends TestCase

/**
*/
public function setup(): void
public function setUp(): void
{
parent::setUp();

Expand Down

0 comments on commit 530e200

Please sign in to comment.