-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from timohaas/bugfix
Prevent users from creating databases with owner `postgres`
- Loading branch information
Showing
3 changed files
with
56 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 |
---|---|---|
|
@@ -2,6 +2,11 @@ | |
Changelog | ||
========= | ||
|
||
v2.1.2 | ||
====== | ||
|
||
- Blacklist postgres as username | ||
|
||
v2.1.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
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 |
---|---|---|
|
@@ -176,6 +176,51 @@ def test_create_postgres_instance_api_with_fully_qualified_user(self): | |
assert created_db["db_name"] == 'test_create_postgres_instance' | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
|
||
def test_create_postgres_instance_api_with_postgres_as_user(self): | ||
db_credentials = { | ||
"postgraas_instance_name": "tests_postgraas_test_create_postgres_instance_api", | ||
"db_name": "test_create_postgres_instance", | ||
"db_username": "postgres", | ||
"db_pwd": "secret" | ||
} | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
headers = {'Content-Type': 'application/json'} | ||
result = self.app_client.post( | ||
'/api/v2/postgraas_instances', headers=headers, data=json.dumps(db_credentials) | ||
) | ||
assert result.status_code == 422 | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
|
||
def test_create_postgres_instance_api_with_postgres_at_example_com_as_user(self): | ||
db_credentials = { | ||
"postgraas_instance_name": "tests_postgraas_test_create_postgres_instance_api", | ||
"db_name": "test_create_postgres_instance", | ||
"db_username": "[email protected]", | ||
"db_pwd": "secret" | ||
} | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
headers = {'Content-Type': 'application/json'} | ||
result = self.app_client.post( | ||
'/api/v2/postgraas_instances', headers=headers, data=json.dumps(db_credentials) | ||
) | ||
assert result.status_code == 422 | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
|
||
def test_create_postgres_instance_api_with_postgres_at_localhost_as_user(self): | ||
db_credentials = { | ||
"postgraas_instance_name": "tests_postgraas_test_create_postgres_instance_api", | ||
"db_name": "test_create_postgres_instance", | ||
"db_username": "postgres@localhost", | ||
"db_pwd": "secret" | ||
} | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
headers = {'Content-Type': 'application/json'} | ||
result = self.app_client.post( | ||
'/api/v2/postgraas_instances', headers=headers, data=json.dumps(db_credentials) | ||
) | ||
assert result.status_code == 422 | ||
self.delete_instance_by_name(db_credentials, self.app_client) | ||
|
||
def test_create_docker_fails(self): | ||
db_credentials = { | ||
"postgraas_instance_name": "tests_postgraas_test_create_postgres_instance_api", | ||
|