fixes

pull/10/head
Andrew Wang 1 year ago
parent d6dbfd5d3f
commit 562c6aca96
  1. 7
      ceod/api/database.py
  2. 10
      tests/ceod/api/test_db_mysql.py
  3. 10
      tests/ceod/api/test_db_psql.py

@ -1,10 +1,9 @@
from flask import Blueprint, request
from flask import Blueprint
from zope import component
from functools import wraps
from ceod.api.utils import authz_restrict_to_staff, authz_restrict_to_syscom, \
user_is_in_group, requires_authentication_no_realm, \
create_streaming_response, development_only
from ceod.api.utils import authz_restrict_to_syscom, user_is_in_group, requires_authentication_no_realm, \
development_only
from ceo_common.errors import UserNotFoundError, DatabaseConnectionError, DatabasePermissionError, \
InvalidUsernameError, UserAlreadyExistsError
from ceo_common.interfaces import ILDAPService, IDatabaseService

@ -22,7 +22,7 @@ def test_api_create_mysql_db(cfg, client, g_admin_ctx, create_user_result):
assert status == 409
# normal user cannot create db for others
status, data = client.post(f"/api/mysql/someone_else", json={}, principal=uid)
status, data = client.post("/api/mysql/someone_else", json={}, principal=uid)
assert status == 403
# cannot create db for user not in ldap
@ -85,9 +85,9 @@ def test_api_passwd_reset_mysql(cfg, client, g_admin_ctx, create_user_result):
old_passwd = data['password']
con = connect(
host=cfg.get('ceod_database_host'),
user=uid,
password=old_passwd,
host=cfg.get('ceod_database_host'),
user=uid,
password=old_passwd,
)
con.close()
@ -104,7 +104,7 @@ def test_api_passwd_reset_mysql(cfg, client, g_admin_ctx, create_user_result):
assert status == 403
# cannot password reset a user that does not have a database
status, data = client.post(f"/api/mysql/someone_else/pwreset", json={})
status, data = client.post("/api/mysql/someone_else/pwreset", json={})
assert status == 404
con = connect(

@ -21,7 +21,7 @@ def test_api_create_psql_db(cfg, client, g_admin_ctx, create_user_result):
assert status == 409
# normal user cannot create db for others
status, data = client.post(f"/api/postgresql/someone_else", json={}, principal=uid)
status, data = client.post("/api/postgresql/someone_else", json={}, principal=uid)
assert status == 403
# cannot create db for user not in ldap
@ -84,9 +84,9 @@ def test_api_passwd_reset_psql(cfg, client, g_admin_ctx, create_user_result):
old_passwd = data['password']
con = connect(
host=cfg.get('ceod_database_host'),
user=uid,
password=old_passwd,
host=cfg.get('ceod_database_host'),
user=uid,
password=old_passwd,
)
con.close()
@ -103,7 +103,7 @@ def test_api_passwd_reset_psql(cfg, client, g_admin_ctx, create_user_result):
assert status == 403
# cannot password reset a user that does not have a database
status, data = client.post(f"/api/postgresql/someone_else/pwreset", json={})
status, data = client.post("/api/postgresql/someone_else/pwreset", json={})
assert status == 404
con = connect(

Loading…
Cancel
Save