Skip to content

Commit

Permalink
update postgres config for CI tests to handle scram-sha-256 auth alon…
Browse files Browse the repository at this point in the history
…g with md5
  • Loading branch information
zwirek committed Aug 21, 2023
1 parent 7889cef commit 574faa9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
image: postgres:${{ matrix.postgres }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: --auth-host=md5
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand All @@ -34,7 +35,7 @@ jobs:
fail-fast: false
matrix:
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
postgres: [12, 13]
postgres: [12, 13, 14, 15]
composer: [lowest, locked, highest]
needs:
- supported-versions-matrix
Expand All @@ -46,6 +47,8 @@ jobs:
PGPASSWORD=postgres psql -h localhost -U postgres -c "ALTER ROLE pgasync PASSWORD 'pgasync'"
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER pgasyncpw"
PGPASSWORD=postgres psql -h localhost -U postgres -c "ALTER ROLE pgasyncpw PASSWORD 'example_password'"
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER scram_user"
PGPASSWORD=postgres psql -h localhost -U postgres -c "SET password_encryption='scram-sha-256';ALTER ROLE scram_user PASSWORD 'scram_password'"
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE pgasync_test OWNER pgasync"
PGPASSWORD=pgasync psql -h localhost -U pgasync -f tests/test_db.sql pgasync_test
# PGPASSWORD=postgres cat tests/test_db.sql | xargs -I % psql -h localhost -U postgres -c "%"
Expand Down
17 changes: 5 additions & 12 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
environment:
- PGDATA=/database
- POSTGRES_PASSWORD=some_password
- POSTGRES_INITDB_ARGS=--auth-host=md5
- TZ=America/New_York
volumes:
- .:/app
Expand All @@ -16,15 +17,7 @@ services:
ports:
- "5432:5432"

pgasync-postgres-15:
container_name: pgasync-postgres-15
image: postgres:15
environment:
- PGDATA=/database
- POSTGRES_USER=sampleuser
- POSTGRES_PASSWORD=some_password
- TZ=America/New_York
volumes:
- .:/app
ports:
- "5415:5432"
configs:
pg_hba:
file: pg_hba_new.conf

2 changes: 2 additions & 0 deletions docker/docker-entrypoint-initdb.d/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ echo "Running as $USER in $PWD"

createuser -U postgres --createdb pgasync
createuser -U postgres --createdb pgasyncpw
createuser -U postgres --createdb scram_user
psql -U postgres -c "ALTER ROLE pgasyncpw PASSWORD 'example_password'"
psql -U postgres -c "SET password_encryption='scram-sha-256'; ALTER ROLE scram_user PASSWORD 'scram_password'"

cd /app
cp pg_hba_new.conf database/pg_hba.conf
Expand Down
2 changes: 1 addition & 1 deletion src/PgAsync/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function prependLengthInt32(string $s): string
return Message::int32($len + 4) . $s;
}

public static function createMessageFromIdentifier(string $identifier, array $dependencies): ParserInterface
public static function createMessageFromIdentifier(string $identifier, array $dependencies = []): ParserInterface
{
switch ($identifier) {
case 'R':
Expand Down
9 changes: 4 additions & 5 deletions tests/Integration/ScramSha256PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

class ScramSha256PasswordTest extends TestCase
{
public function testScamSha256Login()
public function testScramSha256Login()
{
$client = new Client([
"user" => 'sampleuser',
"database" => 'postgres',
"port" => 5415,
"user" => 'scram_user',
"database" => $this->getDbName(),
"auto_disconnect" => true,
"password" => "some_password"
"password" => "scram_password"
], $this->getLoop());

$hello = null;
Expand Down

0 comments on commit 574faa9

Please sign in to comment.