Skip to content

Commit f751a87

Browse files
author
maxim-lixakov
committed
[DOP-21482] - removed keycloak settings from TestSettings
1 parent c7ff5a6 commit f751a87

File tree

5 files changed

+8
-39
lines changed

5 files changed

+8
-39
lines changed

.env.docker

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SYNCMASTER__DATABASE__URL=postgresql+asyncpg://syncmaster:changeme@db:5432/syncm
2020

2121
# TODO: add to KeycloakAuthProvider documentation about creating new realms, add users, etc.
2222
# KEYCLOAK Auth
23-
SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080/
23+
SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080
2424
SYNCMASTER__AUTH__REALM_NAME=manually_created
2525
SYNCMASTER__AUTH__CLIENT_ID=manually_created
2626
SYNCMASTER__AUTH__CLIENT_SECRET=generated_by_keycloak
@@ -80,15 +80,6 @@ TEST_HDFS_HOST=test-hive
8080
TEST_HDFS_WEBHDFS_PORT=9870
8181
TEST_HDFS_IPC_PORT=9820
8282

83-
# Keycloack Auth
84-
TEST_AUTH_SERVER_URL=http://localhost:8080
85-
TEST_AUTH_REALM_NAME=manually_created
86-
TEST_AUTH_CLIENT_ID=manually_created
87-
TEST_AUTH_CLIENT_SECRET=generated_by_keycloak
88-
TEST_AUTH_REDIRECT_URI=http://localhost:8000/auth/callback
89-
TEST_AUTH_SCOPE=email
90-
TEST_AUTH_PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider
91-
9283
SPARK_CONF_DIR=/app/tests/spark/hive/conf/
9384
HADOOP_CONF_DIR=/app/tests/spark/hadoop/
9485
HIVE_CONF_DIR=/app/tests/spark/hive/conf/

.env.local

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export SYNCMASTER__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
1919
export SYNCMASTER__DATABASE__URL=postgresql+asyncpg://syncmaster:changeme@localhost:5432/syncmaster
2020

2121
# Keycloack Auth
22-
export SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080/
22+
export SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080
2323
export SYNCMASTER__AUTH__REALM_NAME=manually_created
2424
export SYNCMASTER__AUTH__CLIENT_ID=manually_created
2525
export SYNCMASTER__AUTH__CLIENT_SECRET=generated_by_keycloak
@@ -69,13 +69,3 @@ export TEST_HDFS_IPC_PORT=9820
6969
export SPARK_CONF_DIR=./tests/spark/hive/conf/
7070
export HADOOP_CONF_DIR=./tests/spark/hadoop/
7171
export HIVE_CONF_DIR=./tests/spark/hive/conf/
72-
73-
74-
# Keycloack Auth
75-
export TEST_AUTH_SERVER_URL=http://localhost:8080
76-
export TEST_AUTH_REALM_NAME=manually_created
77-
export TEST_AUTH_CLIENT_ID=manually_created
78-
export TEST_AUTH_CLIENT_SECRET=generated_by_keycloak
79-
export TEST_AUTH_REDIRECT_URI=http://localhost:8000/auth/callback
80-
export TEST_AUTH_SCOPE=email
81-
export TEST_AUTH_PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider

tests/settings.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ class TestSettings(BaseSettings):
4040
TEST_S3_PROTOCOL: str = "http"
4141
TEST_S3_ADDITIONAL_PARAMS: dict = {}
4242

43-
TEST_AUTH_SERVER_URL: str
44-
TEST_AUTH_REALM_NAME: str
45-
TEST_AUTH_CLIENT_ID: str
46-
TEST_AUTH_CLIENT_SECRET: str
47-
TEST_AUTH_REDIRECT_URI: str
48-
TEST_AUTH_SCOPE: str
49-
TEST_AUTH_PROVIDER: str
50-
5143
@model_validator(mode="before")
5244
def check_sid_and_service_name(cls, values):
5345
sid = values.get("TEST_ORACLE_SID")

tests/test_unit/test_auth/auth_fixtures/keycloak_fixture.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def _create_session_cookie(user, expire_in_msec=1000) -> str:
8080

8181

8282
@pytest.fixture
83-
def mock_keycloak_well_known(test_settings):
84-
server_url = test_settings.TEST_AUTH_SERVER_URL
85-
realm_name = test_settings.TEST_AUTH_REALM_NAME
83+
def mock_keycloak_well_known(settings):
84+
server_url = settings.auth.server_url
85+
realm_name = settings.auth.client_id
8686
well_known_url = f"{server_url}/realms/{realm_name}/.well-known/openid-configuration"
8787

8888
responses.add(
@@ -102,9 +102,9 @@ def mock_keycloak_well_known(test_settings):
102102

103103

104104
@pytest.fixture
105-
def mock_keycloak_realm(test_settings, rsa_keys):
106-
server_url = test_settings.TEST_AUTH_SERVER_URL
107-
realm_name = test_settings.TEST_AUTH_REALM_NAME
105+
def mock_keycloak_realm(settings, rsa_keys):
106+
server_url = settings.auth.server_url
107+
realm_name = settings.auth.client_id
108108
realm_url = f"{server_url}/realms/{realm_name}"
109109
public_pem_str = get_public_key_pem(rsa_keys["public_key"])
110110

tests/test_unit/test_auth/test_auth_keycloak.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
{
1717
"auth": {
1818
"provider": KEYCLOAK_PROVIDER,
19-
"server_url": "http://localhost:8080/",
2019
},
2120
},
2221
],
@@ -39,7 +38,6 @@ async def test_get_keycloak_user_unauthorized(client: AsyncClient, mock_keycloak
3938
{
4039
"auth": {
4140
"provider": KEYCLOAK_PROVIDER,
42-
"server_url": "http://localhost:8080/",
4341
},
4442
},
4543
],
@@ -77,7 +75,6 @@ async def test_get_keycloak_user_authorized(
7775
{
7876
"auth": {
7977
"provider": KEYCLOAK_PROVIDER,
80-
"server_url": "http://localhost:8080/",
8178
},
8279
},
8380
],
@@ -117,7 +114,6 @@ async def test_get_keycloak_deleted_user(
117114
{
118115
"auth": {
119116
"provider": KEYCLOAK_PROVIDER,
120-
"server_url": "http://localhost:8080/",
121117
},
122118
},
123119
],

0 commit comments

Comments
 (0)