Skip to content

Commit 574faa9

Browse files
committed
update postgres config for CI tests to handle scram-sha-256 auth along with md5
1 parent 7889cef commit 574faa9

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

.github/workflows/ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
image: postgres:${{ matrix.postgres }}
2222
env:
2323
POSTGRES_PASSWORD: postgres
24+
POSTGRES_INITDB_ARGS: --auth-host=md5
2425
# Set health checks to wait until postgres has started
2526
options: >-
2627
--health-cmd pg_isready
@@ -34,7 +35,7 @@ jobs:
3435
fail-fast: false
3536
matrix:
3637
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
37-
postgres: [12, 13]
38+
postgres: [12, 13, 14, 15]
3839
composer: [lowest, locked, highest]
3940
needs:
4041
- supported-versions-matrix
@@ -46,6 +47,8 @@ jobs:
4647
PGPASSWORD=postgres psql -h localhost -U postgres -c "ALTER ROLE pgasync PASSWORD 'pgasync'"
4748
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER pgasyncpw"
4849
PGPASSWORD=postgres psql -h localhost -U postgres -c "ALTER ROLE pgasyncpw PASSWORD 'example_password'"
50+
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER scram_user"
51+
PGPASSWORD=postgres psql -h localhost -U postgres -c "SET password_encryption='scram-sha-256';ALTER ROLE scram_user PASSWORD 'scram_password'"
4952
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE pgasync_test OWNER pgasync"
5053
PGPASSWORD=pgasync psql -h localhost -U pgasync -f tests/test_db.sql pgasync_test
5154
# PGPASSWORD=postgres cat tests/test_db.sql | xargs -I % psql -h localhost -U postgres -c "%"

docker/docker-compose.yml

+5-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
environment:
88
- PGDATA=/database
99
- POSTGRES_PASSWORD=some_password
10+
- POSTGRES_INITDB_ARGS=--auth-host=md5
1011
- TZ=America/New_York
1112
volumes:
1213
- .:/app
@@ -16,15 +17,7 @@ services:
1617
ports:
1718
- "5432:5432"
1819

19-
pgasync-postgres-15:
20-
container_name: pgasync-postgres-15
21-
image: postgres:15
22-
environment:
23-
- PGDATA=/database
24-
- POSTGRES_USER=sampleuser
25-
- POSTGRES_PASSWORD=some_password
26-
- TZ=America/New_York
27-
volumes:
28-
- .:/app
29-
ports:
30-
- "5415:5432"
20+
configs:
21+
pg_hba:
22+
file: pg_hba_new.conf
23+

docker/docker-entrypoint-initdb.d/init.sh

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ echo "Running as $USER in $PWD"
55

66
createuser -U postgres --createdb pgasync
77
createuser -U postgres --createdb pgasyncpw
8+
createuser -U postgres --createdb scram_user
89
psql -U postgres -c "ALTER ROLE pgasyncpw PASSWORD 'example_password'"
10+
psql -U postgres -c "SET password_encryption='scram-sha-256'; ALTER ROLE scram_user PASSWORD 'scram_password'"
911

1012
cd /app
1113
cp pg_hba_new.conf database/pg_hba.conf

src/PgAsync/Message/Message.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function prependLengthInt32(string $s): string
2323
return Message::int32($len + 4) . $s;
2424
}
2525

26-
public static function createMessageFromIdentifier(string $identifier, array $dependencies): ParserInterface
26+
public static function createMessageFromIdentifier(string $identifier, array $dependencies = []): ParserInterface
2727
{
2828
switch ($identifier) {
2929
case 'R':

tests/Integration/ScramSha256PasswordTest.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
class ScramSha256PasswordTest extends TestCase
1010
{
11-
public function testScamSha256Login()
11+
public function testScramSha256Login()
1212
{
1313
$client = new Client([
14-
"user" => 'sampleuser',
15-
"database" => 'postgres',
16-
"port" => 5415,
14+
"user" => 'scram_user',
15+
"database" => $this->getDbName(),
1716
"auto_disconnect" => true,
18-
"password" => "some_password"
17+
"password" => "scram_password"
1918
], $this->getLoop());
2019

2120
$hello = null;

0 commit comments

Comments
 (0)