mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
fix: url shortener invalid input (#13461)
* fix: url shortner invalid input * fix lint
This commit is contained in:
committed by
GitHub
parent
0318b6d4ae
commit
c3c73763d0
@@ -634,6 +634,28 @@ class TestCore(SupersetTestCase):
|
||||
resp = self.client.post("/r/shortner/", data=dict(data=data))
|
||||
assert re.search(r"\/r\/[0-9]+", resp.data.decode("utf-8"))
|
||||
|
||||
def test_shortner_invalid(self):
|
||||
self.login(username="admin")
|
||||
invalid_urls = [
|
||||
"hhttp://invalid.com",
|
||||
"hhttps://invalid.com",
|
||||
"www.invalid.com",
|
||||
]
|
||||
for invalid_url in invalid_urls:
|
||||
resp = self.client.post("/r/shortner/", data=dict(data=invalid_url))
|
||||
assert resp.status_code == 400
|
||||
|
||||
def test_redirect_invalid(self):
|
||||
model_url = models.Url(url="hhttp://invalid.com")
|
||||
db.session.add(model_url)
|
||||
db.session.commit()
|
||||
|
||||
self.login(username="admin")
|
||||
response = self.client.get(f"/r/{model_url.id}")
|
||||
assert response.headers["Location"] == "http://localhost/"
|
||||
db.session.delete(model_url)
|
||||
db.session.commit()
|
||||
|
||||
@skipUnless(
|
||||
(is_feature_enabled("KV_STORE")), "skipping as /kv/ endpoints are not enabled"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user