Skip to content

Commit 3b82efc

Browse files
authored
Remove support for deprecated project_id parameter (#66)
* Remove support for deprecated `project_id` parameter * Remove unneeded fixture
1 parent 8c2d7ee commit 3b82efc

File tree

8 files changed

+9
-76
lines changed

8 files changed

+9
-76
lines changed

tests/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,11 @@ def set_client_id(monkeypatch):
2424
monkeypatch.setattr(workos, "client_id", "client_b27needthisforssotemxo")
2525

2626

27-
@pytest.fixture
28-
def set_project_id(monkeypatch):
29-
monkeypatch.setattr(workos, "project_id", "project_b27needthisforssotemxo")
30-
31-
3227
@pytest.fixture
3328
def set_api_key_and_client_id(set_api_key, set_client_id):
3429
pass
3530

3631

37-
@pytest.fixture
38-
def set_api_key_and_project_id(set_api_key, set_project_id):
39-
pass
40-
41-
4232
@pytest.fixture
4333
def mock_request_method(monkeypatch):
4434
def inner(method, response_dict, status_code, headers=None):

tests/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def setup(self):
1313
client._portal = None
1414
client._sso = None
1515

16-
def test_initialize_sso(self, set_api_key_and_project_id):
16+
def test_initialize_sso(self, set_api_key_and_client_id):
1717
assert bool(client.sso)
1818

1919
def test_initialize_audit_log(self, set_api_key):
@@ -28,14 +28,14 @@ def test_initialize_passwordless(self, set_api_key):
2828
def test_initialize_portal(self, set_api_key):
2929
assert bool(client.portal)
3030

31-
def test_initialize_sso_missing_api_key(self, set_project_id):
31+
def test_initialize_sso_missing_api_key(self, set_client_id):
3232
with pytest.raises(ConfigurationException) as ex:
3333
client.sso
3434

3535
message = str(ex)
3636

3737
assert "api_key" in message
38-
assert "project_id" not in message
38+
assert "client_id" not in message
3939

4040
def test_initialize_sso_missing_client_id(self, set_api_key):
4141
with pytest.raises(ConfigurationException) as ex:
@@ -46,7 +46,7 @@ def test_initialize_sso_missing_client_id(self, set_api_key):
4646
assert "client_id" in message
4747
assert "api_key" not in message
4848

49-
def test_initialize_sso_missing_api_key_and_project_id(self):
49+
def test_initialize_sso_missing_api_key_and_client_id(self):
5050
with pytest.raises(ConfigurationException) as ex:
5151
client.sso
5252

tests/test_directory_sync.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ def mock_directories(self):
104104
"state": "linked",
105105
"type": "gsuite directory",
106106
"name": "Ri Jeong Hyeok",
107-
"bearer_token": None,
108-
"project_id": "project_id",
107+
"environment_id": "environment_id",
109108
"domain": "crashlandingonyou.com",
110109
}
111110
],

tests/test_passwordless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class TestPasswordless(object):
1111
@pytest.fixture(autouse=True)
12-
def setup(self, set_api_key_and_project_id):
12+
def setup(self, set_api_key_and_client_id):
1313
self.passwordless = Passwordless()
1414

1515
@pytest.fixture

tests/test_sso.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ def setup_with_client_id(self, set_api_key_and_client_id):
2121

2222
self.sso = SSO()
2323

24-
@pytest.fixture
25-
def setup_with_project_id(self, set_api_key_and_project_id):
26-
self.provider = ConnectionType.GoogleOAuth
27-
self.customer_domain = "workos.com"
28-
self.redirect_uri = "https://localhost/auth/callback"
29-
self.state = json.dumps({"things": "with_stuff"})
30-
31-
self.sso = SSO()
32-
3324
@pytest.fixture
3425
def mock_profile(self):
3526
return {
@@ -194,28 +185,6 @@ def test_authorization_url_has_expected_query_params_with_domain_and_provider(
194185
"state": self.state,
195186
}
196187

197-
def test_authorization_url_supports_project_id_with_deprecation_warning(
198-
self, setup_with_project_id
199-
):
200-
with pytest.deprecated_call():
201-
authorization_url = self.sso.get_authorization_url(
202-
domain=self.customer_domain,
203-
provider=self.provider,
204-
redirect_uri=self.redirect_uri,
205-
state=self.state,
206-
)
207-
208-
parsed_url = urlparse(authorization_url)
209-
210-
assert dict(parse_qsl(parsed_url.query)) == {
211-
"domain": self.customer_domain,
212-
"provider": str(self.provider.value),
213-
"client_id": workos.project_id,
214-
"redirect_uri": self.redirect_uri,
215-
"response_type": RESPONSE_TYPE_CODE,
216-
"state": self.state,
217-
}
218-
219188
def test_get_profile_returns_expected_workosprofile_object(
220189
self, setup_with_client_id, mock_profile, mock_request_method
221190
):

workos/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
from workos.client import client
55

66
api_key = os.getenv("WORKOS_API_KEY")
7-
project_id = os.getenv("WORKOS_PROJECT_ID")
87
client_id = os.getenv("WORKOS_CLIENT_ID")
98
base_api_url = "https://api.workos.com/"

workos/sso.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ def get_authorization_url(
8080
if state is not None:
8181
params["state"] = state
8282

83-
if workos.project_id is not None:
84-
params["client_id"] = workos.project_id
85-
warn(
86-
"'project_id' is deprecated. Use 'client_id' instead.",
87-
DeprecationWarning,
88-
)
89-
9083
prepared_request = Request(
9184
"GET",
9285
self.request_helper.generate_api_url(AUTHORIZATION_PATH),
@@ -114,13 +107,6 @@ def get_profile(self, code):
114107
"grant_type": OAUTH_GRANT_TYPE,
115108
}
116109

117-
if workos.project_id is not None:
118-
params["client_id"] = workos.project_id
119-
warn(
120-
"'project_id' is deprecated. Use 'client_id' instead.",
121-
DeprecationWarning,
122-
)
123-
124110
response = self.request_helper.request(
125111
TOKEN_PATH, method=REQUEST_METHOD_POST, params=params
126112
)

workos/utils/validation.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,9 @@ def decorator(fn):
2424
def wrapper(*args, **kwargs):
2525
missing_settings = []
2626

27-
# Adding this to accept both client_id and project_id
28-
# can remove once project_id is deprecated
29-
if module_name == SSO_MODULE:
30-
if not getattr(workos, "api_key", None):
31-
missing_settings.append("api_key")
32-
if not getattr(workos, "client_id", None) and not getattr(
33-
workos, "project_id", None
34-
):
35-
missing_settings.append("client_id")
36-
else:
37-
for setting in REQUIRED_SETTINGS_FOR_MODULE[module_name]:
38-
if not getattr(workos, setting, None):
39-
missing_settings.append(setting)
27+
for setting in REQUIRED_SETTINGS_FOR_MODULE[module_name]:
28+
if not getattr(workos, setting, None):
29+
missing_settings.append(setting)
4030

4131
if missing_settings:
4232
raise ConfigurationException(

0 commit comments

Comments
 (0)