Skip to content

Commit faf8ac3

Browse files
committed
Update code to use library-constants for errors
1 parent cb666fd commit faf8ac3

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

public/proxy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@
9898

9999
\SimpleSAML\Logger::debug('casserver:' . $message);
100100

101-
echo $protocol->getProxyFailureResponse('INVALID_REQUEST', $message);
101+
echo $protocol->getProxyFailureResponse(C::ERR_INVALID_REQUEST, $message);
102102
} elseif (!checkServiceURL(sanitize($_GET['targetService']), $legal_target_service_urls)) {
103103
$message = 'Target service parameter not listed as a legal service: [targetService] = ' .
104104
var_export($_GET['targetService'], true);
105105

106106
\SimpleSAML\Logger::debug('casserver:' . $message);
107107

108-
echo $protocol->getProxyFailureResponse('INVALID_REQUEST', $message);
108+
echo $protocol->getProxyFailureResponse(C::ERR_INVALID_REQUEST, $message);
109109
} else {
110110
$message = 'Missing proxy granting ticket parameter: [pgt]';
111111

112112
\SimpleSAML\Logger::debug('casserver:' . $message);
113113

114-
echo $protocol->getProxyFailureResponse('INVALID_REQUEST', $message);
114+
echo $protocol->getProxyFailureResponse(C::ERR_INVALID_REQUEST, $message);
115115
}

tests/src/TicketValidatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testNonExistantTicket(): void
5454
$this->ticketValidator->validateAndDeleteTicket($id, 'efg');
5555
$this->fail('exception expected');
5656
} catch (CasException $e) {
57-
$this->assertEquals('INVALID_TICKET', $e->getCasCode());
57+
$this->assertEquals(C::ERR_INVALID_TICKET, $e->getCasCode());
5858
$this->assertEquals('Ticket \'' . $id . '\' not recognized', $e->getMessage());
5959
}
6060
}
@@ -77,7 +77,7 @@ public function testValidTicket(): void
7777
$this->ticketValidator->validateAndDeleteTicket($id, $serviceUrl);
7878
$this->fail('exception expected');
7979
} catch (CasException $e) {
80-
$this->assertEquals('INVALID_TICKET', $e->getCasCode());
80+
$this->assertEquals(C::ERR_INVALID_TICKET, $e->getCasCode());
8181
$this->assertEquals('Ticket \'' . $id . '\' not recognized', $e->getMessage());
8282
}
8383
}
@@ -95,7 +95,7 @@ public function testWrongServiceUrlTicket(): void
9595
$this->ticketValidator->validateAndDeleteTicket($id, $serviceUrl);
9696
$this->fail('exception expected');
9797
} catch (CasException $e) {
98-
$this->assertEquals('INVALID_SERVICE', $e->getCasCode());
98+
$this->assertEquals(C::ERR_INVALID_SERVICE, $e->getCasCode());
9999
$this->assertEquals(
100100
"Mismatching service parameters: expected 'http://otherurl.com' but was: 'http://efh.com?a=b&'",
101101
$e->getMessage()
@@ -118,7 +118,7 @@ public function testExpiredTicket(): void
118118
$this->ticketValidator->validateAndDeleteTicket($id, $serviceUrl);
119119
$this->fail('exception expected');
120120
} catch (CasException $e) {
121-
$this->assertEquals('INVALID_TICKET', $e->getCasCode());
121+
$this->assertEquals(C::ERR_INVALID_TICKET, $e->getCasCode());
122122
$this->assertEquals('Ticket \'' . $id . '\' has expired', $e->getMessage());
123123
}
124124
// ensure ticket deleted after validation

0 commit comments

Comments
 (0)