Skip to content

Commit d9a2840

Browse files
committed
Use standard ports where not specified
1 parent 8e51531 commit d9a2840

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/ProviderUri/AbstractProviderUri.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected function normaliseBaseUri(string $baseUri):Uri {
1313
$host = parse_url($baseUri, PHP_URL_HOST)
1414
?? parse_url($baseUri, PHP_URL_PATH);
1515
$port = parse_url($baseUri, PHP_URL_PORT)
16-
?? 80;
16+
?? null;
1717

1818
$uri = (new Uri())
1919
->withScheme($scheme)

test/phpunit/ProviderUri/AbstractProviderUriTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ public function testAuthUriHttps() {
2424
"https",
2525
$sut->getScheme()
2626
);
27+
self::assertNull(
28+
$sut->getPort()
29+
);
30+
}
31+
32+
public function testAuthUriWithNonStandardPort() {
33+
$baseUri = self::createMock(UriInterface::class);
34+
$baseUri->method("__toString")
35+
->willReturn("http://localhost:8081");
36+
$token = self::createMock(Token::class);
37+
38+
$sut = new AuthUri(
39+
$token,
40+
"",
41+
$baseUri
42+
);
43+
self::assertEquals(
44+
"http",
45+
$sut->getScheme()
46+
);
47+
self::assertEquals(
48+
8081,
49+
$sut->getPort()
50+
);
2751
}
2852

2953
// All AuthUris MUST be served over HTTPS, with the one exception of localhost.

0 commit comments

Comments
 (0)