diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml index 708e0ff..f67c9dc 100644 --- a/.github/workflows/php83.yml +++ b/.github/workflows/php83.yml @@ -42,18 +42,10 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - release_staging: - needs: - - "test" - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/dev' - steps: - - uses: actions/checkout@v4 - - uses: google-github-actions/release-please-action@v3 - with: - release-type: php - token: ${{ secrets.GITHUB_TOKEN }} + + release_prod: + name: Publish Release needs: - "test" runs-on: ubuntu-latest @@ -63,4 +55,5 @@ jobs: - uses: google-github-actions/release-please-action@v3 with: release-type: php + config-file: release-please-config.json token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/composer.json b/composer.json index c87eba2..ee40350 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "PSR-7", "JSONx" ], + "version":"3.3.15", "license": "MIT", "require": { "php": ">=7.0", diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..3fe3029 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,26 @@ +{ + "include-v-in-tag":true, + "tag-separator": "-", + "packages":{ + ".":{ + "changelog-path": "CHANGELOG.md", + "changelog-sections": [ + { "type": "feat", "section": "Features" }, + { "type": "feature", "section": "Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "perf", "section": "Performance Improvements" }, + { "type": "revert", "section": "Reverts" }, + { "type": "docs", "section": "Documentation" }, + { "type": "style", "section": "Styles" }, + { "type": "chore", "section": "Miscellaneous Chores" }, + { "type": "refactor", "section": "Code Refactoring" }, + { "type": "test", "section": "Testing" }, + { "type": "build", "section": "Build System" }, + { "type": "ci", "section": "Continuous Integration" }, + { "type": "ui", "section": "User Interface" }, + { "type": "database", "section": "Database Changes" }, + { "type": "email", "section": "Email Notifications Changes" } + ] + } + } +} \ No newline at end of file diff --git a/webfiori/http/APITestCase.php b/webfiori/http/APITestCase.php index 2dcb63f..3a3c8fe 100644 --- a/webfiori/http/APITestCase.php +++ b/webfiori/http/APITestCase.php @@ -69,10 +69,14 @@ public function addFile(string $fileIdx, string $filePath, bool $reset = false) * @param array $parameters A dictionary thar represents the parameters that * will be sent to the endpoint. The name is parameter name as it appears in * service implementation and its value is the value of the parameter. + * + * @param array $httpHeaders An optional associative array that can be used + * to mimic HTTP request headers. The keys of the array are names of headers + * and the value of each key represents the value of the header. * * @return string The method will return the output of the endpoint. */ - public function callEndpoint(WebServicesManager $manager, string $requestMethod, string $apiEndpointName, array $parameters = []) : string { + public function callEndpoint(WebServicesManager $manager, string $requestMethod, string $apiEndpointName, array $parameters = [], array $httpHeaders = []) : string { $manager->setOutputStream(fopen(self::OUTPUT_STREAM,'w')); $method = strtoupper($requestMethod); putenv('REQUEST_METHOD='.$method); @@ -90,13 +94,13 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod, } $_POST['service'] = $apiEndpointName; $_SERVER['CONTENT_TYPE'] = 'multipart/form-data'; - $this->unset($_POST, $parameters, $manager); + $this->unset($_POST, $parameters, $manager, $httpHeaders); } else { foreach ($parameters as $key => $val) { $_GET[$key] = $this->parseVal($val); } $_GET['service'] = $apiEndpointName; - $this->unset($_GET, $parameters, $manager); + $this->unset($_GET, $parameters, $manager, $httpHeaders); } $retVal = $manager->readOutputStream(); @@ -141,11 +145,15 @@ private function parseVal($val) { * @param array $parameters An optional array of request parameters that can be * passed to the endpoint. * + * @param array $httpHeaders An optional associative array that can be used + * to mimic HTTP request headers. The keys of the array are names of headers + * and the value of each key represents the value of the header. + * * @return string The method will return the output that was produced by * the endpoint as string. */ - public function deletRequest(WebServicesManager $manager, string $endpoint, array $parameters = []) : string { - return $this->callEndpoint($manager, RequestMethod::DELETE, $endpoint, $parameters); + public function deletRequest(WebServicesManager $manager, string $endpoint, array $parameters = [], array $httpHeaders = []) : string { + return $this->callEndpoint($manager, RequestMethod::DELETE, $endpoint, $parameters, $httpHeaders); } /** * Sends a GET request to specific endpoint. @@ -160,8 +168,8 @@ public function deletRequest(WebServicesManager $manager, string $endpoint, arra * @return string The method will return the output that was produced by * the endpoint as string. */ - public function getRequest(WebServicesManager $manager, string $endpoint, array $parameters = []) : string { - return $this->callEndpoint($manager, RequestMethod::GET, $endpoint, $parameters); + public function getRequest(WebServicesManager $manager, string $endpoint, array $parameters = [], array $httpHeaders = []) : string { + return $this->callEndpoint($manager, RequestMethod::GET, $endpoint, $parameters, $httpHeaders); } /** * Sends a POST request to specific endpoint. @@ -173,11 +181,15 @@ public function getRequest(WebServicesManager $manager, string $endpoint, array * @param array $parameters An optional array of request parameters that can be * passed to the endpoint. * + * @param array $httpHeaders An optional associative array that can be used + * to mimic HTTP request headers. The keys of the array are names of headers + * and the value of each key represents the value of the header. + * * @return string The method will return the output that was produced by * the endpoint as string. */ - public function postRequest(WebServicesManager $manager, string $endpoint, array $parameters = []) : string { - return $this->callEndpoint($manager, RequestMethod::POST, $endpoint, $parameters); + public function postRequest(WebServicesManager $manager, string $endpoint, array $parameters = [], array $httpHeaders = []) : string { + return $this->callEndpoint($manager, RequestMethod::POST, $endpoint, $parameters, $httpHeaders); } /** * Sends a PUT request to specific endpoint. @@ -189,11 +201,15 @@ public function postRequest(WebServicesManager $manager, string $endpoint, array * @param array $parameters An optional array of request parameters that can be * passed to the endpoint. * + * @param array $httpHeaders An optional associative array that can be used + * to mimic HTTP request headers. The keys of the array are names of headers + * and the value of each key represents the value of the header. + * * @return string The method will return the output that was produced by * the endpoint as string. */ - public function putRequest(WebServicesManager $manager, string $endpoint, array $parameters = []) : string { - return $this->callEndpoint($manager, RequestMethod::PUT, $endpoint, $parameters); + public function putRequest(WebServicesManager $manager, string $endpoint, array $parameters = [], array $httpHeaders = []) : string { + return $this->callEndpoint($manager, RequestMethod::PUT, $endpoint, $parameters, $httpHeaders); } private function extractPathAndName($absPath): array { $DS = DIRECTORY_SEPARATOR; @@ -219,11 +235,23 @@ private function extractPathAndName($absPath): array { 'path' => '' ]; } - private function unset(array &$arr, array $params, WebServicesManager $m) { + private function unset(array &$arr, array $params, WebServicesManager $m, array $httpHeaders) { + foreach ($httpHeaders as $header => $value) { + $trHeader = trim($header.''); + $trVal = trim($value.''); + if (strlen($trHeader) != 0) { + $_SERVER['HTTP_'.strtoupper($trHeader)] = $trVal; + } + } $m->process(); foreach ($params as $key => $val) { unset($arr[$key]); } + + foreach ($httpHeaders as $header => $value) { + $trHeader = trim($header.''); + unset($_SERVER['HTTP_'.strtoupper($trHeader)]); + } } }