diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index ffc568dd..43ca7262 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -28,9 +28,6 @@ jobs: - name: "caracal" openstack_version: "stable/2024.1" ubuntu_version: "22.04" - - name: "bobcat" - openstack_version: "stable/2023.2" - ubuntu_version: "22.04" - name: "antelope" openstack_version: "unmaintained/2023.1" ubuntu_version: "22.04" diff --git a/src/Common/Api/OperatorTrait.php b/src/Common/Api/OperatorTrait.php index 710bd8ad..56f4d42d 100644 --- a/src/Common/Api/OperatorTrait.php +++ b/src/Common/Api/OperatorTrait.php @@ -101,8 +101,13 @@ protected function sendRequest(Operation $operation, array $userValues = [], boo $uri = Utils::uri_template($operation->getPath(), $userValues); - if (array_key_exists('requestOptions', $userValues)) { + if (isset($userValues['requestOptions'])) { $options += $userValues['requestOptions']; + + // headers are always created in options, merge them + if (isset($userValues['requestOptions']['headers'])) { + $options['headers'] = array_merge($options['headers'], $userValues['requestOptions']['headers']); + } } $options['openstack.skip_auth'] = $operation->getSkipAuth(); diff --git a/tests/unit/Common/Api/OperatorTraitTest.php b/tests/unit/Common/Api/OperatorTraitTest.php index c269b5b1..66b4d61a 100644 --- a/tests/unit/Common/Api/OperatorTraitTest.php +++ b/tests/unit/Common/Api/OperatorTraitTest.php @@ -111,6 +111,30 @@ public function test_guzzle_options_are_forwarded() 'requestOptions' => ['stream' => true], ]); } + + public function test_it_sends_custom_headers_in_request_options() + { + $this->client + ->requestAsync('GET', 'test', + [ + 'headers' => [ + 'Access-Control-Allow-Origin' => '*', + 'Access-Control-Allow-Methods' => 'GET, POST, OPTIONS', + ], + 'openstack.skip_auth' => false, + ]) + ->shouldBeCalled() + ->willReturn(new Promise()); + + $this->operator->executeAsync($this->def, [ + 'requestOptions' => [ + 'headers' => [ + 'Access-Control-Allow-Origin' => '*', + 'Access-Control-Allow-Methods' => 'GET, POST, OPTIONS', + ], + ], + ]); + } }