-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SCRAM auth feature tests (#292)
* Added "I run commandon host" step * Added .feature file * Some fixes * Switch back to "regress" user * Frontend auth test * Added "Command output should match" step * Added psql output check * Added backend auth test * Moved psql installation to Dockerfile
- Loading branch information
Showing
5 changed files
with
158 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
FROM spqr-base-image | ||
|
||
RUN apt-get update && apt-get install -y postgresql-client | ||
|
||
ENTRYPOINT CONFIG_PATH=${ROUTER_CONFIG=/spqr/docker/router/cfg.yaml} && CUR_HOST=$(cat ${CONFIG_PATH} | grep "host:") && sed -i "s/${CUR_HOST}/${ROUTER_HOST=${CUR_HOST}}/g" ${CONFIG_PATH} && /spqr/spqr-router run -c ${CONFIG_PATH} --proto-debug |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
host: 'regress_router' | ||
router_port: '6432' | ||
admin_console_port: '7432' | ||
grpc_api_port: '7000' | ||
router_mode: PROXY | ||
log_level: fatal | ||
log_filename: router.log | ||
time_quantiles: | ||
- 0.75 | ||
world_shard_fallback: true | ||
show_notice_messages: true | ||
frontend_rules: | ||
- db: regress | ||
usr: regress | ||
pool_default: true | ||
pool_mode: TRANSACTION | ||
auth_rule: | ||
auth_method: ok | ||
shards: | ||
sh1: | ||
db: regress | ||
usr: regress | ||
pwd: 12345678 | ||
type: DATA | ||
hosts: | ||
- 'spqr_shard_1:6432' | ||
sh2: | ||
db: regress | ||
usr: regress | ||
pwd: 12345678 | ||
type: DATA | ||
hosts: | ||
- 'spqr_shard_2:6432' | ||
|
||
backend_rules: | ||
- db: regress | ||
usr: regress | ||
pool_discard: true | ||
pool_rollback: true | ||
auth_rules: | ||
sh1: | ||
auth_method: scram | ||
password: 12345678 | ||
sh2: | ||
auth_method: scram | ||
password: 12345678 |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
host: 'regress_router' | ||
router_port: '6432' | ||
admin_console_port: '7432' | ||
grpc_api_port: '7000' | ||
router_mode: PROXY | ||
log_level: fatal | ||
log_filename: router.log | ||
time_quantiles: | ||
- 0.75 | ||
world_shard_fallback: true | ||
show_notice_messages: true | ||
frontend_rules: | ||
- db: regress | ||
usr: regress | ||
pool_default: true | ||
pool_mode: TRANSACTION | ||
auth_rule: | ||
auth_method: scram | ||
password: 12345678 | ||
shards: | ||
sh1: | ||
db: regress | ||
usr: regress | ||
pwd: 12345678 | ||
type: DATA | ||
hosts: | ||
- 'spqr_shard_1:6432' | ||
sh2: | ||
db: regress | ||
usr: regress | ||
pwd: 12345678 | ||
type: DATA | ||
hosts: | ||
- 'spqr_shard_2:6432' | ||
|
||
backend_rules: | ||
- db: regress | ||
usr: regress | ||
pool_discard: true | ||
pool_rollback: true | ||
auth_rules: | ||
sh1: | ||
auth_method: password | ||
password: 12345678 | ||
sh2: | ||
auth_method: password | ||
password: 12345678 |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Feature: SCRAM auth test | ||
|
||
Scenario: Frontend auth works | ||
Given cluster environment is | ||
""" | ||
ROUTER_CONFIG=/spqr/test/feature/conf/router_with_scram_frontend.yaml | ||
""" | ||
Given cluster is up and running | ||
When I run command on host "router" | ||
""" | ||
PGPASSWORD=12345678 psql -c "SELECT 1" -d regress -U regress -p 6432 -h localhost | ||
""" | ||
Then command return code should be "0" | ||
And command output should match regexp | ||
""" | ||
1 | ||
""" | ||
|
||
Scenario: Backend auth works | ||
Given cluster environment is | ||
""" | ||
ROUTER_CONFIG=/spqr/test/feature/conf/router_with_scram_backend.yaml | ||
""" | ||
Given cluster is up and running | ||
When I run command on host "shard1" | ||
""" | ||
echo 'host all all all scram-sha-256' > /var/lib/postgresql/13/main/pg_hba.conf | ||
service postgresql reload | ||
""" | ||
Then command return code should be "0" | ||
When I run command on host "shard2" | ||
""" | ||
echo 'host all all all scram-sha-256' > /var/lib/postgresql/13/main/pg_hba.conf | ||
service postgresql reload | ||
""" | ||
Then command return code should be "0" | ||
When I run SQL on host "router" | ||
""" | ||
SELECT 1 | ||
""" | ||
Then command return code should be "0" | ||
And SQL result should match regexp | ||
""" | ||
1 | ||
""" |
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