Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixedCase now works in pgtle.clientauth_users_to_skip as intended #267

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ check_string_in_guc_list(const char *str, const char *guc_var, const char *guc_n
ListCell *lc;

guc_copy = pstrdup(guc_var);
if (!SplitIdentifierString(guc_copy, ',', &guc_list))
if (!SplitGUCList(guc_copy, ',', &guc_list))
elog(ERROR, "could not parse %s", guc_name);

foreach(lc, guc_list)
Expand Down
47 changes: 46 additions & 1 deletion test/t/004_pg_tle_clientauth.pl
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@
"clientauth function does not reject testuser2 when clientauth is enabled without restart");

### 9. Functions do not take effect when user is on pgtle.clientauth_users_to_skip
$node->psql('postgres', 'CREATE ROLE testUser3 LOGIN', stderr => \$psql_err);
$node->append_conf('postgresql.conf', qq(pgtle.enable_clientauth = 'on'));
$node->append_conf('postgresql.conf', qq(pgtle.clientauth_users_to_skip = 'testuser,testuser2'));
$node->append_conf('postgresql.conf', qq(pgtle.clientauth_users_to_skip = 'testuser,testuser2,testUser3'));
$node->restart;

$node->command_ok(
Expand All @@ -176,6 +177,9 @@
$node->command_ok(
['psql', '-U', 'testuser2', '-c', 'select;'],
"clientauth function does not reject testuser2 when testuser2 is in pgtle.clientauth_users_to_skip");
$node->command_ok(
['psql', '-U', 'testUser3', '-c', 'select;'],
"clientauth function does not reject testUser3 when testUser3 is in pgtle.clientauth_users_to_skip");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please a add a test for mixed case clientauth_databases_to_skip as well


### 10. Functions do not take effect when database is on pgtle.clientauth_databases_to_skip
$node->psql('postgres', 'CREATE DATABASE not_excluded');
Expand Down Expand Up @@ -254,6 +258,47 @@
END IF;
END
$$ LANGUAGE plpgsql], on_error_die => 1);
### 16. Allow mixedCase in pgtle.clientauth_users_to_skip
$node->psql('postgres', 'CREATE ROLE testUser3 LOGIN', stderr => \$psql_err);
$node->psql('postgres', q[
CREATE FUNCTION reject_testUser3(port pgtle.clientauth_port_subset, status integer) RETURNS text AS $$
BEGIN
IF port.user_name = 'testUser3' THEN
RETURN 'testUser3 is not allowed to connect';
ELSE
RETURN '';
END IF;
END
$$ LANGUAGE plpgsql;]);
$node->psql('postgres', qq[SELECT pgtle.register_feature('reject_testUser3', 'clientauth')]);
$node->psql('postgres', 'select', extra_params => ['-U', 'testUser3'], stderr => \$psql_err);
like($psql_err, qr/FATAL: testUser3 is not allowed to connect/,
"clientauth function rejects testUser3");

$node->append_conf('postgresql.conf', qq(pgtle.enable_clientauth = 'on'));
$node->append_conf('postgresql.conf', qq(pgtle.clientauth_users_to_skip = 'testUser3'));
$node->restart;

$node->command_ok(
['psql', '-U', 'testUser3', '-c', 'select;'],
"clientauth function does not reject testUser3 when testUser3 is in pgtle.clientauth_users_to_skip");
### 17. Allow mixedCase in pgtle.clientauth_databases_to_skip
$node->psql('postgres', 'CREATE DATABASE mixedCaseDb');
$node->append_conf('postgresql.conf', qq(pgtle.clientauth_users_to_skip = ''));
$node->append_conf('postgresql.conf', qq(pgtle.clientauth_databases_to_skip = ''));
$node->psql('postgres', 'SELECT pg_reload_conf();');

$node->psql('mixedCaseDb', 'select', extra_params => ['-U', 'testUser3'], stderr => \$psql_err);
like($psql_err, qr/FATAL: testUser3 is not allowed to connect/,
"clientauth function rejects testUser3");

$node->append_conf('postgresql.conf', qq(pgtle.clientauth_databases_to_skip = 'mixedCaseDb'));
$node->psql('postgres', 'SELECT pg_reload_conf();');

$node->command_ok(
['psql', '-U', 'testUser3', '-c', 'select;'],
"clientauth function does not reject testUser3 when database is in pgtle.clientauth_databases_to_skip");

$node->psql('postgres', qq[SELECT pgtle.register_feature('reject_testuser', 'clientauth')], on_error_die => 1);
# Create role with name "
$node->psql('postgres', qq[CREATE ROLE """" LOGIN], on_error_die => 1);
Expand Down
Loading