Skip to content

Commit f3a6b94

Browse files
[async] Adjust binding security test
1 parent c9f415b commit f3a6b94

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

test/integ/aio_it/test_cursor_binding_async.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
from __future__ import annotations
77

8-
from test.csp_helpers import is_running_against_gcp
9-
108
import pytest
119

1210
from snowflake.connector.errors import ProgrammingError
@@ -48,23 +46,29 @@ async def test_binding_security(conn_cnx, db_parameters):
4846

4947
# SQL injection safe test
5048
# Good Example
51-
if not is_running_against_gcp():
52-
with pytest.raises(ProgrammingError):
53-
r = await cnx.cursor().execute(
54-
"SELECT * FROM {name} WHERE aa=%s".format(
55-
name=db_parameters["name"]
56-
),
57-
("1 or aa>0",),
58-
)
59-
await r.fetchall()
60-
61-
with pytest.raises(ProgrammingError):
62-
await cnx.cursor().execute(
63-
"SELECT * FROM {name} WHERE aa=%(aa)s".format(
64-
name=db_parameters["name"]
65-
),
66-
{"aa": "1 or aa>0"},
67-
)
49+
# server behavior change: this no longer raises an error, but returns an empty result set
50+
try:
51+
results = await cnx.cursor().execute(
52+
"SELECT * FROM {name} WHERE aa=%s".format(
53+
name=db_parameters["name"]
54+
),
55+
("1 or aa>0",),
56+
)
57+
assert await results.fetchall() == []
58+
except ProgrammingError:
59+
# old server behavior: OK
60+
pass
61+
try:
62+
results = await cnx.cursor().execute(
63+
"SELECT * FROM {name} WHERE aa=%(aa)s".format(
64+
name=db_parameters["name"]
65+
),
66+
{"aa": "1 or aa>0"},
67+
)
68+
assert await results.fetchall() == []
69+
except ProgrammingError:
70+
# old server behavior: OK
71+
pass
6872

6973
# Bad Example in application. DON'T DO THIS
7074
c = cnx.cursor()

0 commit comments

Comments
 (0)