diff --git a/README.md b/README.md index 9778c37..e0b69e3 100644 --- a/README.md +++ b/README.md @@ -104,3 +104,5 @@ composer test ``` The test script runs PHPUnit, PHPStan, PHP_CodeSniffer and PHPMD. To run the unit tests alone, use `composer phpunit`. + +For a local test provider, HTTP is supported for hosts ending in `.test`, such as `http://login.realtest.authwave.test:9090`. Configure local DNS or a hosts-file entry for the provider. This exception applies only to HTTP and the complete `.test` hostname suffix; `.authwave-test` and names such as `example.test.com` do not qualify. Other remote providers require HTTPS. Use test accounts on a trusted development network; the suffix does not encrypt traffic or guarantee that it stays on your machine. diff --git a/src/ProviderUri/BaseProviderUri.php b/src/ProviderUri/BaseProviderUri.php index 0153555..86d04ff 100644 --- a/src/ProviderUri/BaseProviderUri.php +++ b/src/ProviderUri/BaseProviderUri.php @@ -25,8 +25,11 @@ protected function normaliseBaseUri(string $baseUri):Uri { ->withHost($host) ->withPort($port); + $isTestHttp = $uri->getScheme() === "http" + && str_ends_with(strtolower(rtrim($uri->getHost(), ".")), ".test"); if($uri->getHost() !== "localhost" && $uri->getHost() !== "127.0.0.127" + && !$isTestHttp && $uri->getScheme() !== "https") { throw new InsecureProtocolException($uri->getScheme()); } diff --git a/test/phpunit/ProviderUri/TestDomainTest.php b/test/phpunit/ProviderUri/TestDomainTest.php new file mode 100644 index 0000000..88d5128 --- /dev/null +++ b/test/phpunit/ProviderUri/TestDomainTest.php @@ -0,0 +1,42 @@ +getPath()); + if($allowed && str_starts_with($host, "http://")) { + self::assertSame("http", $uri->getScheme()); + } + if(str_contains($host, ":9090")) { + self::assertSame(9090, $uri->getPort()); + } + } +}