fix(embedded): CSV download for chart (#20261)

* move postForm to superset client

* lint

* fix lint

* fix type

* update tests

* add tests

* add test for form submit

* add test for request form

* lint

* fix test

* fix tests

* more tests

* more tests

* test

* lint

* more test for postForm

* lint

* Update superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts

Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com>

* update tests

* remove useless test

* make test cover happy

* make test cover happy

* make test cover happy

* make codecov happy

* make codecov happy

Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com>
(cherry picked from commit ab9f72f1a1)
This commit is contained in:
Lily Kuang
2022-06-17 20:01:08 -07:00
committed by Michael S. Molina
parent bd721cd86c
commit a08499d88d
12 changed files with 190 additions and 40 deletions

View File

@@ -1064,6 +1064,7 @@ class TestDatasources(SupersetTestCase):
class FakeRequest:
headers: Any = {}
form: Any = {}
class TestGuestTokens(SupersetTestCase):
@@ -1111,6 +1112,17 @@ class TestGuestTokens(SupersetTestCase):
self.assertIsNotNone(guest_user)
self.assertEqual("test_guest", guest_user.username)
def test_get_guest_user_with_request_form(self):
token = self.create_guest_token()
fake_request = FakeRequest()
fake_request.headers[current_app.config["GUEST_TOKEN_HEADER_NAME"]] = None
fake_request.form["guest_token"] = token
guest_user = security_manager.get_guest_user_from_request(fake_request)
self.assertIsNotNone(guest_user)
self.assertEqual("test_guest", guest_user.username)
@patch("superset.security.SupersetSecurityManager._get_current_epoch_time")
def test_get_guest_user_expired_token(self, get_time_mock):
# make a just-expired token