Skip to content

Commit 950afa6

Browse files
fixup! fixup! fixup! fixup! Run only test_external_browser_successful
1 parent 2e9355f commit 950afa6

File tree

2 files changed

+45
-43
lines changed

2 files changed

+45
-43
lines changed

test/auth/aio/authorization_test_helper.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -76,54 +76,54 @@ async def connect_and_provide_credentials(
7676
):
7777
import asyncio
7878

79-
# try:
80-
# Start connection as an async task in the main event loop
81-
# This allows the browser to be opened from the main thread context
82-
connect_task = asyncio.create_task(self.connect_and_execute_simple_query())
83-
84-
if self.auth_test_env == "docker":
85-
# Give connection time to start and open the browser
86-
await asyncio.sleep(5)
87-
88-
# Run browser automation in a thread WITHOUT blocking the event loop
89-
# This allows the connection task to continue making progress
90-
loop = asyncio.get_running_loop()
91-
credentials_task = loop.run_in_executor(
92-
None,
93-
self._provide_credentials,
94-
scenario,
95-
login,
96-
password,
97-
)
79+
try:
80+
# Start connection as an async task in the main event loop
81+
# This allows the browser to be opened from the main thread context
82+
connect_task = asyncio.create_task(self.connect_and_execute_simple_query())
83+
84+
if self.auth_test_env == "docker":
85+
# Give connection time to start and open the browser
86+
await asyncio.sleep(5)
87+
88+
# Run browser automation in a thread WITHOUT blocking the event loop
89+
# This allows the connection task to continue making progress
90+
loop = asyncio.get_running_loop()
91+
credentials_task = loop.run_in_executor(
92+
None,
93+
self._provide_credentials,
94+
scenario,
95+
login,
96+
password,
97+
)
9898

99-
# Wait for both tasks to complete concurrently
100-
await asyncio.gather(connect_task, credentials_task)
101-
else:
102-
# Wait for connection to complete
103-
await connect_task
99+
# Wait for both tasks to complete concurrently
100+
await asyncio.gather(connect_task, credentials_task)
101+
else:
102+
# Wait for connection to complete
103+
await connect_task
104104

105-
# except Exception as e:
106-
# self.error_msg = e
107-
# logger.error(e)
105+
except Exception as e:
106+
self.error_msg = e
107+
logger.error(e)
108108

109109
def get_error_msg(self) -> str:
110110
return str(self.error_msg)
111111

112112
async def connect_and_execute_simple_query(self):
113-
# try:
114-
logger.info("Trying to connect to Snowflake")
115-
async with snowflake.connector.aio.SnowflakeConnection(
116-
**self.configuration
117-
) as con:
118-
logger.info("Connected to Snowflake, executing query")
119-
result = await con.cursor().execute("select 1;")
120-
logger.debug(await result.fetchall())
121-
logger.info("Successfully connected to Snowflake")
122-
return True
123-
# except Exception as e:
124-
# self.error_msg = e
125-
# logger.error(e)
126-
# return False
113+
try:
114+
logger.info("Trying to connect to Snowflake")
115+
async with snowflake.connector.aio.SnowflakeConnection(
116+
**self.configuration
117+
) as con:
118+
logger.info("Connected to Snowflake, executing query")
119+
result = await con.cursor().execute("select 1;")
120+
logger.debug(await result.fetchall())
121+
logger.info("Successfully connected to Snowflake")
122+
return True
123+
except Exception as e:
124+
self.error_msg = e
125+
logger.error(e)
126+
return False
127127

128128
async def connect_and_execute_set_session_state(self, key: str, value: str):
129129
try:
@@ -172,7 +172,7 @@ def _provide_credentials(self, scenario: Scenario, login: str, password: str):
172172
],
173173
timeout=30,
174174
)
175-
# logger.debug(f"OUTPUT: {process.stdout}, ERRORS: {process.stderr}")
175+
logger.debug(f"OUTPUT: {process.stdout}, ERRORS: {process.stderr}")
176176
except Exception as e:
177177
self.error_msg = e
178178
raise RuntimeError(e)

test/auth/aio/test_external_browser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ def setup_and_teardown():
2525

2626
@pytest.mark.auth
2727
@pytest.mark.asyncio
28+
# @pytest.mark.skip(reason="SNOW-2895170: Script providing credentials cannot connect to browser")
2829
async def test_external_browser_successful():
2930
logging.getLogger("snowflake.connector").setLevel(logging.DEBUG)
3031
connection_parameters = (
3132
AuthConnectionParameters().get_external_browser_connection_parameters()
3233
)
33-
test_helper = AuthorizationTestHelper(connection_parameters)
3434
browser_login, browser_password = get_okta_login_credentials().values()
35+
36+
test_helper = AuthorizationTestHelper(connection_parameters)
3537
await test_helper.connect_and_provide_credentials(
3638
Scenario.SUCCESS, browser_login, browser_password
3739
)

0 commit comments

Comments
 (0)