From 05f9417f53cafb3e72d949f015da4b42b7c3520c Mon Sep 17 00:00:00 2001 From: byhsu Date: Mon, 15 May 2023 22:35:34 -0700 Subject: [PATCH] add tests Signed-off-by: byhsu --- tests/flytekit/unit/clients/auth/test_authenticator.py | 4 +++- tests/flytekit/unit/clients/auth/test_token_client.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/flytekit/unit/clients/auth/test_authenticator.py b/tests/flytekit/unit/clients/auth/test_authenticator.py index 495f4648ac..36bf1707a0 100644 --- a/tests/flytekit/unit/clients/auth/test_authenticator.py +++ b/tests/flytekit/unit/clients/auth/test_authenticator.py @@ -96,6 +96,7 @@ def test_device_flow_authenticator(poll_mock: MagicMock, device_mock: MagicMock, ENDPOINT, static_cfg_store, audience="x", + verify=True ) cfg_store = StaticClientConfigStore( @@ -107,7 +108,7 @@ def test_device_flow_authenticator(poll_mock: MagicMock, device_mock: MagicMock, device_authorization_endpoint="dev", ) ) - authn = DeviceCodeAuthenticator(ENDPOINT, cfg_store, audience="x", http_proxy_url="http://my-proxy:9000") + authn = DeviceCodeAuthenticator(ENDPOINT, cfg_store, audience="x", http_proxy_url="http://my-proxy:9000", verfiy=False) device_mock.return_value = DeviceCodeResponse("x", "y", "s", 1000, 0) poll_mock.return_value = ("access", 100) @@ -124,6 +125,7 @@ def test_client_creds_authenticator_with_custom_scopes(mock_requests): client_secret="secret", cfg_store=static_cfg_store, scopes=expected_scopes, + verify=True, ) response = MagicMock() response.status_code = 200 diff --git a/tests/flytekit/unit/clients/auth/test_token_client.py b/tests/flytekit/unit/clients/auth/test_token_client.py index f0c10b16d1..d0e75ec88a 100644 --- a/tests/flytekit/unit/clients/auth/test_token_client.py +++ b/tests/flytekit/unit/clients/auth/test_token_client.py @@ -29,7 +29,7 @@ def test_get_token(mock_requests): response.json.return_value = json.loads("""{"access_token": "abc", "expires_in": 60}""") mock_requests.post.return_value = response access, expiration = get_token( - "https://corp.idp.net", client_id="abc123", scopes=["my_scope"], http_proxy_url="http://proxy:3000" + "https://corp.idp.net", client_id="abc123", scopes=["my_scope"], http_proxy_url="http://proxy:3000", verify=True ) assert access == "abc" assert expiration == 60 @@ -66,13 +66,13 @@ def test_poll_token_endpoint(mock_requests): r = DeviceCodeResponse(device_code="x", user_code="y", verification_uri="v", expires_in=1, interval=1) with pytest.raises(AuthenticationError): - poll_token_endpoint(r, "test.com", "test", http_proxy_url="http://proxy:3000") + poll_token_endpoint(r, "test.com", "test", http_proxy_url="http://proxy:3000", verify=True) response = MagicMock() response.ok = True response.json.return_value = {"access_token": "abc", "expires_in": 60} mock_requests.post.return_value = response r = DeviceCodeResponse(device_code="x", user_code="y", verification_uri="v", expires_in=1, interval=0) - t, e = poll_token_endpoint(r, "test.com", "test", http_proxy_url="http://proxy:3000") + t, e = poll_token_endpoint(r, "test.com", "test", http_proxy_url="http://proxy:3000", verify=True) assert t assert e