|
1 | 1 | <?php |
2 | 2 | namespace Pdsinterop\PhpSolid; |
3 | 3 |
|
4 | | - use Pdsinterop\PhpSolid\Server; |
5 | | - |
6 | | - const PUBSUB_SERVER = "https://localhost:1234"; |
7 | | - const KEYDIR = "php://memory/"; |
8 | | - const BASEURL = "https://example.com"; |
9 | | - const DBPATH = ":memory:"; |
| 4 | + require_once(__DIR__ . "/test-config.php"); |
10 | 5 |
|
11 | | - function header($header) { |
12 | | - ServerTest::$headers[] = $header; |
13 | | - } |
14 | | - |
15 | | - function file_get_contents($file) { |
16 | | - if(!isset(ServerTest::$keys)) { |
17 | | - ServerTest::$keys = Server::generateKeySet(); |
18 | | - } |
19 | | - if (preg_match("/encryption/", $file)) { |
20 | | - return ServerTest::$keys['encryptionKey']; |
21 | | - } |
22 | | - if (preg_match("/public/", $file)) { |
23 | | - return ServerTest::$keys['publicKey']; |
24 | | - } |
25 | | - if (preg_match("/private/", $file)) { |
26 | | - return ServerTest::$keys['privateKey']; |
27 | | - } |
28 | | - } |
| 6 | + use Pdsinterop\PhpSolid\Server; |
29 | 7 |
|
30 | | - class MockBody { |
31 | | - public function rewind() { |
32 | | - return true; |
33 | | - } |
34 | | - public function getContents() { |
35 | | - return json_encode(["Hello" => "world"]); |
36 | | - } |
37 | | - } |
38 | | - |
39 | | - class MockResponse { |
40 | | - public function getStatusCode() { |
41 | | - return 200; |
42 | | - } |
43 | | - public function getBody() { |
44 | | - return new MockBody(); |
45 | | - } |
46 | | - public function getHeaders() { |
47 | | - return [ |
48 | | - "Foo" => ["Bar", "Blah"] |
49 | | - ]; |
50 | | - } |
51 | | - } |
52 | | - |
53 | 8 | class ServerTest extends \PHPUnit\Framework\TestCase |
54 | 9 | { |
55 | 10 | public static $headers = []; |
@@ -130,14 +85,14 @@ public function testGetBearer() { |
130 | 85 | } |
131 | 86 | public function testGetEndpoints() { |
132 | 87 | $endpoints = Server::getEndpoints(); |
133 | | - $this->assertEquals($endpoints["issuer"], "https://example.com"); |
134 | | - $this->assertEquals($endpoints["jwks_uri"], "https://example.com/jwks/"); |
135 | | - $this->assertEquals($endpoints["check_session_iframe"], "https://example.com/session/"); |
136 | | - $this->assertEquals($endpoints["end_session_endpoint"], "https://example.com/logout/"); |
137 | | - $this->assertEquals($endpoints["authorization_endpoint"], "https://example.com/authorize/"); |
138 | | - $this->assertEquals($endpoints["token_endpoint"], "https://example.com/token/"); |
139 | | - $this->assertEquals($endpoints["userinfo_endpoint"], "https://example.com/userinfo/"); |
140 | | - $this->assertEquals($endpoints["registration_endpoint"], "https://example.com/register/"); |
| 88 | + $this->assertEquals($endpoints["issuer"], "https://solid.example.com"); |
| 89 | + $this->assertEquals($endpoints["jwks_uri"], "https://solid.example.com/jwks/"); |
| 90 | + $this->assertEquals($endpoints["check_session_iframe"], "https://solid.example.com/session/"); |
| 91 | + $this->assertEquals($endpoints["end_session_endpoint"], "https://solid.example.com/logout/"); |
| 92 | + $this->assertEquals($endpoints["authorization_endpoint"], "https://solid.example.com/authorize/"); |
| 93 | + $this->assertEquals($endpoints["token_endpoint"], "https://solid.example.com/token/"); |
| 94 | + $this->assertEquals($endpoints["userinfo_endpoint"], "https://solid.example.com/userinfo/"); |
| 95 | + $this->assertEquals($endpoints["registration_endpoint"], "https://solid.example.com/register/"); |
141 | 96 | } |
142 | 97 |
|
143 | 98 | public function testGetKeys() { |
|
0 commit comments