Skip to content

Commit 6a75a26

Browse files
Merge branch 'master' into improve-efs-2
2 parents f09d4b9 + 54f9bcd commit 6a75a26

File tree

10 files changed

+43
-15
lines changed

10 files changed

+43
-15
lines changed

.env-devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ POSTGRES_PORT=5432
154154
POSTGRES_USER=scu
155155

156156
POSTGRES_READONLY_PASSWORD=readonly
157-
POSTGRES_READONLY_USER=readonly
157+
POSTGRES_READONLY_USER=postgres_readonly
158158

159159

160160
RABBIT_HOST=rabbit

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,3 @@ tests/public-api/osparc_python_wheels/*
181181

182182
# osparc-config repo files
183183
repo.config
184-
185-
# scripts resolved with .env s
186-
services/postgres/scripts/create-readonly-user.sql

.vscode/settings.template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
"files.associations": {
1010
".*rc": "ini",
1111
".env*": "ini",
12+
"*.logs*": "log",
1213
"**/requirements/*.in": "pip-requirements",
1314
"**/requirements/*.txt": "pip-requirements",
1415
"*logs.txt": "log",
15-
"*.logs*": "log",
1616
"*Makefile": "makefile",
17+
"*sql.*": "sql",
1718
"docker-compose*.yml": "dockercompose",
1819
"Dockerfile*": "dockerfile"
1920
},

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
from .typing_extension import Handler, Middleware
3232

3333
DEFAULT_API_VERSION = "v0"
34-
FMSG_INTERNAL_ERROR_USER_FRIENDLY = "We apologize for the inconvenience. Our team has recorded the issue and is working to resolve it as quickly as possible. Thank you for your patience [{}]"
34+
_FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC = (
35+
"We apologize for the inconvenience."
36+
" Our team has recorded the issue [{error_code}] and is working to resolve it as quickly as possible."
37+
" Thank you for your patience"
38+
)
3539

3640

3741
_logger = logging.getLogger(__name__)
@@ -58,7 +62,9 @@ def _process_and_raise_unexpected_error(request: web.BaseRequest, err: Exception
5862
if isinstance(err, OsparcErrorMixin):
5963
error_context.update(err.error_context())
6064

61-
frontend_msg = FMSG_INTERNAL_ERROR_USER_FRIENDLY.format(error_code)
65+
frontend_msg = _FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC.format(
66+
error_code=error_code
67+
)
6268
log_msg = create_troubleshotting_log_message(
6369
message_to_user=frontend_msg,
6470
error=err,

packages/service-library/tests/aiohttp/test_rest_middlewares.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from models_library.utils.json_serialization import json_dumps
1717
from servicelib.aiohttp import status
1818
from servicelib.aiohttp.rest_middlewares import (
19-
FMSG_INTERNAL_ERROR_USER_FRIENDLY,
19+
_FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC,
2020
envelope_middleware_factory,
2121
error_middleware_factory,
2222
)
@@ -238,7 +238,10 @@ async def test_raised_unhandled_exception(
238238
# user friendly message with OEC reference
239239
assert "OEC" in error["message"]
240240
parsed_oec = parse_error_code(error["message"]).pop()
241-
assert FMSG_INTERNAL_ERROR_USER_FRIENDLY.format(parsed_oec) == error["message"]
241+
assert (
242+
_FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC.format(error_code=parsed_oec)
243+
== error["message"]
244+
)
242245

243246
# avoids details
244247
assert not error.get("errors")

services/postgres/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ifneq (,$(wildcard $(DOT_ENV_FILE)))
77
endif
88

99

10-
.PHONY: scripts/create-readonly-user.sql
11-
scripts/create-readonly-user.sql: scripts/create-readonly-user.sql.template
12-
@echo "Generating SQL script from $<..."
10+
11+
scripts/%.sql: scripts/%.sql.template
12+
@echo "Generating SQL script from '$<'..."
1313
@envsubst < $< > $@
14-
@echo "SQL script generated as $@"
14+
@echo "SQL script generated as '$@'"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+
!*.template.*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Revoke all privileges the user has on the public schema
2+
REVOKE ALL PRIVILEGES ON SCHEMA public FROM ${POSTGRES_READONLY_USER};
3+
4+
-- Revoke all privileges the user has on tables and sequences in the public schema
5+
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM ${POSTGRES_READONLY_USER};
6+
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM ${POSTGRES_READONLY_USER};
7+
8+
-- Revoke any future privileges set via ALTER DEFAULT PRIVILEGES
9+
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON TABLES FROM ${POSTGRES_READONLY_USER};
10+
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON SEQUENCES FROM ${POSTGRES_READONLY_USER};
11+
12+
-- Drop the user
13+
DROP USER ${POSTGRES_READONLY_USER};
14+
15+
-- Listing all users
16+
SELECT * FROM pg_roles;

services/web/server/src/simcore_service_webserver/users/_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
5454
raise web.HTTPNotFound(reason=f"{exc}") from exc
5555
except MissingGroupExtraPropertiesForProductError as exc:
5656
error_code = create_error_code(exc)
57-
frontend_msg = FMSG_MISSING_CONFIG_WITH_OEC.format(error_code)
57+
frontend_msg = FMSG_MISSING_CONFIG_WITH_OEC.format(error_code=error_code)
5858
log_msg = create_troubleshotting_log_message(
5959
message_to_user=frontend_msg,
6060
error=exc,

services/web/server/tests/unit/with_dbs/03/test_users.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ async def test_get_profile_with_failing_db_connection(
196196

197197
resp = await client.get(url.path)
198198

199-
await assert_status(resp, expected)
199+
data, error = await assert_status(resp, expected)
200+
assert not data
201+
assert error["message"] == "Authentication service is temporary unavailable"
200202

201203

202204
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)