Skip to content

Commit 208d0dc

Browse files
committed
Add ByPKCE::SUPPORTED
1 parent cbc6cfd commit 208d0dc

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/php/web/auth/oauth/ByPKCE.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
/** @test web.auth.unittest.ByPKCETest */
66
class ByPKCE extends Credentials {
7+
const SUPPORTED= ['S256', 'plain'];
8+
79
private $challenge, $method;
810

911
/**
@@ -19,13 +21,12 @@ public function __construct($clientId, $method) {
1921

2022
if ('S256' === $method) {
2123
$this->challenge= fn($verifier) => JWT::encode(hash('sha256', $verifier, true));
22-
$this->method= 'S256';
2324
} else if ('plain' === $method) {
2425
$this->challenge= fn($verifier) => $verifier;
25-
$this->method= 'plain';
2626
} else {
27-
throw new IllegalArgumentException('Unsupported method '.$method);
27+
throw new IllegalArgumentException('Unsupported method '.$method.', expected one of ['.implode(', ', self::SUPPORTED).']');
2828
}
29+
$this->method= $method;
2930
}
3031

3132
/** @return string */

src/test/php/web/auth/unittest/ByPKCETest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private function challenges() {
1414
yield ['plain', 'test-challenge'];
1515
}
1616

17-
#[Test, Values(['S256', 'plain'])]
17+
#[Test, Values(ByPKCE::SUPPORTED)]
1818
public function can_create_with($method) {
1919
new ByPKCE(self::CLIENT_ID, $method);
2020
}

0 commit comments

Comments
 (0)