Skip to content

Commit c28564c

Browse files
committed
Fix unit tests
1 parent 3a286ea commit c28564c

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

src/Cas/Protocol/Cas20.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public function getProxyGrantingTicketIOU(): ?string
117117

118118
/**
119119
* @param string $username
120-
* @return \SimpleSAML\CAS\XML\cas\AuthenticationSuccess
120+
* @return \SimpleSAML\CAS\XML\cas\ServiceResponse
121121
*/
122-
public function getValidateSuccessResponse(string $username): AuthenticationSuccess
122+
public function getValidateSuccessResponse(string $username): ServiceResponse
123123
{
124124
$user = new User($username);
125125

@@ -157,9 +157,10 @@ public function getValidateSuccessResponse(string $username): AuthenticationSucc
157157
$attr,
158158
);
159159

160-
$authenticationSucces = new AuthenticationSuccess($user, $attributes, $proxyGrantingTicket);
160+
$authenticationSuccess = new AuthenticationSuccess($user, $attributes, $proxyGrantingTicket);
161+
$serviceResponse = new ServiceResponse($authenticationSuccess);
161162

162-
return $authenticationSucces;
163+
return $serviceResponse;
163164
}
164165

165166

@@ -217,8 +218,7 @@ private function generateCas20Attribute(
217218
$xmlDocument = DOMDocumentFactory::create();
218219

219220
$attributeValue = $this->base64EncodeAttributes ? base64_encode($attributeValue) : $attributeValue;
220-
$attributeElement = $xmlDocument->createElement('cas:' . $attributeName);
221-
$attributeElement->appendChild($attributeValueNode);
221+
$attributeElement = $xmlDocument->createElementNS(Attributes::NS, 'cas:' . $attributeName, $attributeValue);
222222

223223
return new Chunk($attributeElement);
224224
}
@@ -242,6 +242,6 @@ private function isValidXmlName(string $name): bool
242242
$name,
243243
FILTER_VALIDATE_REGEXP,
244244
['options' => ['regexp' => '/^[a-zA-Z_][\w.-]*$/']],
245-
) === true;
245+
) !== false;
246246
}
247247
}

tests/bootstrap.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
/** @psalm-suppress UnresolvableInclude */
1717
require_once($projectRootDirectory . '/vendor/autoload.php');
1818

19+
// Symlink module into ssp vendor lib so that templates and urls can resolve correctly
20+
$linkPath = $projectRootDirectory . '/vendor/simplesamlphp/simplesamlphp/modules/casserver';
21+
if (file_exists($linkPath) === false) {
22+
echo "Linking '$linkPath' to '$projectRootDirectory'\n";
23+
symlink($projectRootDirectory, $linkPath);
24+
}
25+
1926
/**
2027
* Sets a link in the simplesamlphp vendor directory
2128
* @param string $target

tests/resources/xml/testAttributeToXmlConversion.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<cas:authenticationSuccess>
33
<cas:user>myUser</cas:user>
44
<cas:attributes>
5+
<cas:authenticationDate>2024-07-16T22:31:00Z</cas:authenticationDate>
6+
<cas:longTermAuthenticationRequestTokenUsed>true</cas:longTermAuthenticationRequestTokenUsed>
7+
<cas:isFromNewLogin>true</cas:isFromNewLogin>
58
<cas:lastName>lasty</cas:lastName>
69
<cas:valuesAreEscaped>&gt;abc&lt;blah&gt;</cas:valuesAreEscaped>
710
<cas:urn_oid_0.9.2342.19200300.100.1.1>someValue</cas:urn_oid_0.9.2342.19200300.100.1.1>

tests/src/Cas/Protocol/Cas20Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function testAttributeToXmlConversion(): void
5454

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

57-
$this->assertEquals($this->document->saveXML(), $xml);
57+
$this->assertEquals($this->document->saveXML($this->document->documentElement), strval($xml));
5858
}
5959
}

tests/src/Ticket/DelegatingTicketStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DelegatingTicketStoreTest extends TestCase
3535

3636
/**
3737
*/
38-
public function setup(): void
38+
public function setUp(): void
3939
{
4040
parent::setUp();
4141

0 commit comments

Comments
 (0)