-
Notifications
You must be signed in to change notification settings - Fork 5
feat: organization session policy SDK methods #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5024f80
feat: add organization session policy SDK methods and generate local …
srinivaskarre-sk 21bcaf1
chore: bump proto ref to v0.1.120.2
srinivaskarre-sk 24a80a1
feat: regenerate protos for v0.1.120.2 and add session policy tests
srinivaskarre-sk 2d8760c
fix: add --include-imports to generate-local and restore buf/validate…
srinivaskarre-sk 81a89fc
chore: revert unrelated proto changes, remove generate-local, bump PR…
srinivaskarre-sk dbf259b
chore: ignore proto/ directory (local generate-local output)
srinivaskarre-sk 57c8e16
chore: regenerate all proto stubs for v0.1.120.2
srinivaskarre-sk 62a10b9
chore: regenerate proto stubs from local scalekit proto and add gener…
srinivaskarre-sk bdcae9c
chore: merge main and regenerate proto stubs from local scalekit proto
srinivaskarre-sk b4290a9
build
srinivaskarre-sk 8c84f5b
fix: remove blocking input() call from test_actions setUp
srinivaskarre-sk cd194f0
Revert "fix: remove blocking input() call from test_actions setUp"
srinivaskarre-sk 9b77c05
build
srinivaskarre-sk 6452edf
chore: merge main into b_org_session_policy_v1
srinivaskarre-sk 2db5d33
chore: regenerate proto stubs from local scalekit proto
srinivaskarre-sk ae03820
chore: regenerate proto stubs from published v0.1.121.2
srinivaskarre-sk 0d33670
fix: address coderabbitai review comments
srinivaskarre-sk 0ef8307
build
srinivaskarre-sk eda1a26
Merge branch 'main' into b_org_session_policy_v1
srinivaskarre-sk 400ccc8
fix: return raw grpc response from session policy methods and bump ve…
srinivaskarre-sk e080b3f
fix: update session policy tests to unpack raw grpc response tuple
srinivaskarre-sk 0cd7ce3
fix: correct return types for session policy methods to use response …
srinivaskarre-sk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,7 +170,8 @@ proto | |
|
|
||
| # Claude Code documentation | ||
| CLAUDE.md | ||
| proto/ | ||
| .claude/* | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # Single source of truth for the SDK version. | ||
| # Import this in setup.py and scalekit/core.py — never hardcode the version elsewhere. | ||
| __version__ = "2.9.0" | ||
| __version__ = "2.10.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| from faker import Faker | ||
|
|
||
| from basetest import BaseTest | ||
| from scalekit.v1.organizations.organizations_pb2 import ( | ||
| CreateOrganization, | ||
| SessionPolicyType, | ||
| ) | ||
| from scalekit.v1.commons.commons_pb2 import TimeUnit | ||
|
|
||
|
|
||
| class TestOrganizationSessionPolicy(BaseTest): | ||
| """Test cases for organization session policy management.""" | ||
|
|
||
| def setUp(self): | ||
| self.org_id = None | ||
|
|
||
| def _create_org(self): | ||
| organization = CreateOrganization(display_name=Faker().company(), external_id=Faker().uuid4()) | ||
| response = self.scalekit_client.organization.create_organization(organization=organization) | ||
| self.org_id = response[0].organization.id | ||
| return self.org_id | ||
|
|
||
| def test_get_default_policy(self): | ||
| """New org should inherit APPLICATION policy by default.""" | ||
| org_id = self._create_org() | ||
|
|
||
| policy = self.scalekit_client.organization.get_organization_session_policy( | ||
| organization_id=org_id | ||
| )[0].policy | ||
|
|
||
| self.assertIsNotNone(policy) | ||
| self.assertEqual(policy.policy_source, SessionPolicyType.APPLICATION) | ||
|
|
||
| def test_set_custom_policy(self): | ||
| """Setting a custom policy should persist and be retrievable.""" | ||
| org_id = self._create_org() | ||
|
|
||
| policy = self.scalekit_client.organization.update_organization_session_policy( | ||
| organization_id=org_id, | ||
| policy_source=SessionPolicyType.CUSTOM, | ||
| absolute_session_timeout=360, | ||
| absolute_session_timeout_unit=TimeUnit.MINUTES, | ||
| idle_session_timeout_enabled=True, | ||
| idle_session_timeout=60, | ||
| idle_session_timeout_unit=TimeUnit.MINUTES, | ||
| )[0].policy | ||
|
|
||
| self.assertIsNotNone(policy) | ||
| self.assertEqual(policy.policy_source, SessionPolicyType.CUSTOM) | ||
|
|
||
| fetched = self.scalekit_client.organization.get_organization_session_policy( | ||
| organization_id=org_id | ||
| )[0].policy | ||
| self.assertEqual(fetched.policy_source, SessionPolicyType.CUSTOM) | ||
| self.assertTrue(fetched.HasField("absolute_session_timeout")) | ||
| self.assertEqual(fetched.absolute_session_timeout.value, 360) | ||
| self.assertTrue(fetched.HasField("idle_session_timeout_enabled")) | ||
| self.assertTrue(fetched.idle_session_timeout_enabled.value) | ||
|
|
||
| def test_revert_to_application_policy(self): | ||
| """Setting policy source to APPLICATION should revert to application defaults.""" | ||
| org_id = self._create_org() | ||
|
|
||
| self.scalekit_client.organization.update_organization_session_policy( | ||
| organization_id=org_id, | ||
| policy_source=SessionPolicyType.CUSTOM, | ||
| absolute_session_timeout=120, | ||
| absolute_session_timeout_unit=TimeUnit.MINUTES, | ||
| ) | ||
|
|
||
| reverted = self.scalekit_client.organization.update_organization_session_policy( | ||
| organization_id=org_id, | ||
| policy_source=SessionPolicyType.APPLICATION, | ||
| )[0].policy | ||
|
|
||
| self.assertIsNotNone(reverted) | ||
| self.assertEqual(reverted.policy_source, SessionPolicyType.APPLICATION) | ||
|
|
||
| fetched = self.scalekit_client.organization.get_organization_session_policy( | ||
| organization_id=org_id | ||
| )[0].policy | ||
| self.assertEqual(fetched.policy_source, SessionPolicyType.APPLICATION) | ||
|
|
||
| def test_set_idle_timeout_disabled(self): | ||
| """Setting idle_session_timeout_enabled=False should persist as false.""" | ||
| org_id = self._create_org() | ||
|
|
||
| policy = self.scalekit_client.organization.update_organization_session_policy( | ||
| organization_id=org_id, | ||
| policy_source=SessionPolicyType.CUSTOM, | ||
| absolute_session_timeout=480, | ||
| absolute_session_timeout_unit=TimeUnit.MINUTES, | ||
| idle_session_timeout_enabled=False, | ||
| )[0].policy | ||
|
|
||
| self.assertIsNotNone(policy) | ||
| self.assertEqual(policy.policy_source, SessionPolicyType.CUSTOM) | ||
|
|
||
| fetched = self.scalekit_client.organization.get_organization_session_policy( | ||
| organization_id=org_id | ||
| )[0].policy | ||
| self.assertTrue(fetched.HasField("idle_session_timeout_enabled")) | ||
| self.assertFalse(fetched.idle_session_timeout_enabled.value) | ||
|
|
||
| def tearDown(self): | ||
| if self.org_id: | ||
| self.scalekit_client.organization.delete_organization(organization_id=self.org_id) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.