You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ur...@apache.org on 2022/08/18 06:08:46 UTC
[airflow] branch main updated: Support `/` in variable get endpoint (#25774)
This is an automated email from the ASF dual-hosted git repository.
uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new a1beede41f Support `/` in variable get endpoint (#25774)
a1beede41f is described below
commit a1beede41fb299b215f73f987a572c34f628de36
Author: Jed Cunningham <66...@users.noreply.github.com>
AuthorDate: Wed Aug 17 23:08:27 2022 -0700
Support `/` in variable get endpoint (#25774)
---
airflow/api_connexion/openapi/v1.yaml | 1 +
tests/api_connexion/endpoints/test_variable_endpoint.py | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/airflow/api_connexion/openapi/v1.yaml b/airflow/api_connexion/openapi/v1.yaml
index e5bb89a4fe..4d2650fee6 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -4335,6 +4335,7 @@ components:
name: variable_key
schema:
type: string
+ format: path
required: true
description: The variable Key.
diff --git a/tests/api_connexion/endpoints/test_variable_endpoint.py b/tests/api_connexion/endpoints/test_variable_endpoint.py
index 4967a4f236..4070a00fde 100644
--- a/tests/api_connexion/endpoints/test_variable_endpoint.py
+++ b/tests/api_connexion/endpoints/test_variable_endpoint.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+import urllib
+
import pytest
from parameterized import parameterized
@@ -124,6 +126,16 @@ class TestGetVariable(TestVariableEndpoint):
assert_401(response)
+ def test_should_handle_slashes_in_keys(self):
+ expected_value = 'hello'
+ Variable.set("foo/bar", expected_value)
+ response = self.client.get(
+ f"/api/v1/variables/{urllib.parse.quote('foo/bar', safe='')}",
+ environ_overrides={'REMOTE_USER': "test"},
+ )
+ assert response.status_code == 200
+ assert response.json == {"key": "foo/bar", "value": expected_value, "description": None}
+
class TestGetVariables(TestVariableEndpoint):
@parameterized.expand(