Skip to content

Commit

Permalink
Merge branch 'main' into snowservices_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-turbaszek authored Sep 29, 2023
2 parents 3566c08 + c850e5e commit a909798
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/snowcli/cli/registry/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
@app.command("token")
@with_output
@global_options_with_connection
def token(environment: str = ConnectionOption, **options):
def token(**options):
"""
Gets the token from environment to use for authenticating with the registry.
"""
return ObjectResult(get_token(environment))
return ObjectResult(get_token())
11 changes: 3 additions & 8 deletions src/snowcli/cli/registry/manager.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from snowcli.cli.common.flags import ConnectionOption
from snowcli.cli.common.snow_cli_global_context import snow_cli_global_context_manager
from snowcli.snow_connector import connect_to_snowflake


def get_token(
environment: str = ConnectionOption,
):
def get_token():
"""
Get token to authenticate with registry.
"""
conn = connect_to_snowflake(
connection_name=environment,
# to support registry login
session_parameters={"PYTHON_CONNECTOR_QUERY_RESULT_FORMAT": "json"},
)
conn = snow_cli_global_context_manager.get_connection()

# disable session deletion
conn._all_async_queries_finished = lambda: False
Expand Down
4 changes: 3 additions & 1 deletion tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from tests.testing_utils.fixtures import *


@mock.patch("snowcli.cli.registry.manager.connect_to_snowflake")
@mock.patch(
"snowcli.cli.registry.manager.snow_cli_global_context_manager.get_connection"
)
def test_registry_get_token(mock_conn, runner):
mock_conn.return_value._rest._token_request.return_value = {
"data": {
Expand Down

0 comments on commit a909798

Please sign in to comment.