Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,11 @@ def set_client_id(monkeypatch):
monkeypatch.setattr(workos, "client_id", "client_b27needthisforssotemxo")


@pytest.fixture
def set_project_id(monkeypatch):
monkeypatch.setattr(workos, "project_id", "project_b27needthisforssotemxo")


@pytest.fixture
def set_api_key_and_client_id(set_api_key, set_client_id):
pass


@pytest.fixture
def set_api_key_and_project_id(set_api_key, set_project_id):
pass


@pytest.fixture
def mock_request_method(monkeypatch):
def inner(method, response_dict, status_code, headers=None):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setup(self):
client._portal = None
client._sso = None

def test_initialize_sso(self, set_api_key_and_project_id):
def test_initialize_sso(self, set_api_key_and_client_id):
assert bool(client.sso)

def test_initialize_audit_log(self, set_api_key):
Expand All @@ -28,14 +28,14 @@ def test_initialize_passwordless(self, set_api_key):
def test_initialize_portal(self, set_api_key):
assert bool(client.portal)

def test_initialize_sso_missing_api_key(self, set_project_id):
def test_initialize_sso_missing_api_key(self, set_client_id):
with pytest.raises(ConfigurationException) as ex:
client.sso

message = str(ex)

assert "api_key" in message
assert "project_id" not in message
assert "client_id" not in message

def test_initialize_sso_missing_client_id(self, set_api_key):
with pytest.raises(ConfigurationException) as ex:
Expand All @@ -46,7 +46,7 @@ def test_initialize_sso_missing_client_id(self, set_api_key):
assert "client_id" in message
assert "api_key" not in message

def test_initialize_sso_missing_api_key_and_project_id(self):
def test_initialize_sso_missing_api_key_and_client_id(self):
with pytest.raises(ConfigurationException) as ex:
client.sso

Expand Down
3 changes: 1 addition & 2 deletions tests/test_directory_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ def mock_directories(self):
"state": "linked",
"type": "gsuite directory",
"name": "Ri Jeong Hyeok",
"bearer_token": None,
"project_id": "project_id",
"environment_id": "environment_id",
"domain": "crashlandingonyou.com",
}
],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_passwordless.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class TestPasswordless(object):
@pytest.fixture(autouse=True)
def setup(self, set_api_key_and_project_id):
def setup(self, set_api_key_and_client_id):
self.passwordless = Passwordless()

@pytest.fixture
Expand Down
31 changes: 0 additions & 31 deletions tests/test_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ def setup_with_client_id(self, set_api_key_and_client_id):

self.sso = SSO()

@pytest.fixture
def setup_with_project_id(self, set_api_key_and_project_id):
self.provider = ConnectionType.GoogleOAuth
self.customer_domain = "workos.com"
self.redirect_uri = "https://localhost/auth/callback"
self.state = json.dumps({"things": "with_stuff"})

self.sso = SSO()

@pytest.fixture
def mock_profile(self):
return {
Expand Down Expand Up @@ -194,28 +185,6 @@ def test_authorization_url_has_expected_query_params_with_domain_and_provider(
"state": self.state,
}

def test_authorization_url_supports_project_id_with_deprecation_warning(
self, setup_with_project_id
):
with pytest.deprecated_call():
authorization_url = self.sso.get_authorization_url(
domain=self.customer_domain,
provider=self.provider,
redirect_uri=self.redirect_uri,
state=self.state,
)

parsed_url = urlparse(authorization_url)

assert dict(parse_qsl(parsed_url.query)) == {
"domain": self.customer_domain,
"provider": str(self.provider.value),
"client_id": workos.project_id,
"redirect_uri": self.redirect_uri,
"response_type": RESPONSE_TYPE_CODE,
"state": self.state,
}

def test_get_profile_returns_expected_workosprofile_object(
self, setup_with_client_id, mock_profile, mock_request_method
):
Expand Down
1 change: 0 additions & 1 deletion workos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
from workos.client import client

api_key = os.getenv("WORKOS_API_KEY")
project_id = os.getenv("WORKOS_PROJECT_ID")
client_id = os.getenv("WORKOS_CLIENT_ID")
base_api_url = "https://api.workos.com/"
14 changes: 0 additions & 14 deletions workos/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ def get_authorization_url(
if state is not None:
params["state"] = state

if workos.project_id is not None:
params["client_id"] = workos.project_id
warn(
"'project_id' is deprecated. Use 'client_id' instead.",
DeprecationWarning,
)

prepared_request = Request(
"GET",
self.request_helper.generate_api_url(AUTHORIZATION_PATH),
Expand Down Expand Up @@ -114,13 +107,6 @@ def get_profile(self, code):
"grant_type": OAUTH_GRANT_TYPE,
}

if workos.project_id is not None:
params["client_id"] = workos.project_id
warn(
"'project_id' is deprecated. Use 'client_id' instead.",
DeprecationWarning,
)

response = self.request_helper.request(
TOKEN_PATH, method=REQUEST_METHOD_POST, params=params
)
Expand Down
16 changes: 3 additions & 13 deletions workos/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,9 @@ def decorator(fn):
def wrapper(*args, **kwargs):
missing_settings = []

# Adding this to accept both client_id and project_id
# can remove once project_id is deprecated
if module_name == SSO_MODULE:
if not getattr(workos, "api_key", None):
missing_settings.append("api_key")
if not getattr(workos, "client_id", None) and not getattr(
workos, "project_id", None
):
missing_settings.append("client_id")
else:
for setting in REQUIRED_SETTINGS_FOR_MODULE[module_name]:
if not getattr(workos, setting, None):
missing_settings.append(setting)
for setting in REQUIRED_SETTINGS_FOR_MODULE[module_name]:
if not getattr(workos, setting, None):
missing_settings.append(setting)

if missing_settings:
raise ConfigurationException(
Expand Down