-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also use Hatch rather than setuptools. This means that if the source distribution has a directory added to it (as is needed for packaging for OS distributions) the package can still be built.
- Loading branch information
Showing
15 changed files
with
82 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import ssl | ||
|
||
from ssl import CERT_NONE, create_default_context | ||
import pytest | ||
|
||
from pg8000.dbapi import DatabaseError, connect | ||
|
||
# This requires a line in pg_hba.conf that requires scram-sha-256 for the | ||
# database scram-sha-256 | ||
# database pg8000_scram-sha-256 | ||
|
||
DB = "pg8000_scram_sha_256" | ||
|
||
|
||
@pytest.fixture | ||
def setup(con, cursor): | ||
try: | ||
cursor.execute(f"CREATE DATABASE {DB}") | ||
except DatabaseError: | ||
con.rollback() | ||
|
||
|
||
def test_scram_sha_256(db_kwargs): | ||
context = ssl.create_default_context() | ||
context.check_hostname = False | ||
context.verify_mode = ssl.CERT_NONE | ||
db_kwargs["database"] = "pg8000_scram_sha_256" | ||
|
||
con = connect(**db_kwargs) | ||
con.close() | ||
|
||
|
||
def test_scram_sha_256_ssl_context(db_kwargs): | ||
ssl_context = create_default_context() | ||
ssl_context.check_hostname = False | ||
ssl_context.verify_mode = CERT_NONE | ||
|
||
db_kwargs["ssl_context"] = context | ||
db_kwargs["database"] = "pg8000_scram_sha_256" | ||
db_kwargs["ssl_context"] = ssl_context | ||
|
||
# Should only raise an exception saying db doesn't exist | ||
with pytest.raises(DatabaseError, match="3D000"): | ||
with connect(**db_kwargs) as con: | ||
con.close() | ||
con = connect(**db_kwargs) | ||
con.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters