Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: byhsu <[email protected]>
  • Loading branch information
ByronHsu committed May 16, 2023
1 parent 25b78b7 commit 05f9417
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tests/flytekit/unit/clients/auth/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/flytekit/unit/clients/auth/test_token_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 05f9417

Please sign in to comment.