Skip to content

SCL: replace assert statements with exceptions, add tests#184

Merged
tronikos merged 3 commits into
tronikos:mainfrom
JamieMagee:fix-scl-asserts-and-tests
May 1, 2026
Merged

SCL: replace assert statements with exceptions, add tests#184
tronikos merged 3 commits into
tronikos:mainfrom
JamieMagee:fix-scl-asserts-and-tests

Conversation

@JamieMagee
Copy link
Copy Markdown
Contributor

SCL's async_login used 10 bare assert statements for runtime validation. These are silently skipped when Python runs with -O, which means the entire auth flow loses its guardrails in optimized environments.

This replaces each assert with an explicit InvalidAuth raise and a message that says what went wrong:

  • Unexpected form fields from SSO endpoints
  • Missing session storage values
  • Missing tokens at each step of the Oracle IDCS / SAML flow

Also adds 14 unit tests (SCL previously had zero). The tests cover:

  • name(), subdomain(), timezone()
  • _get_session_storage_values() parsing (normal, empty, multiple items)
  • _get_user_token_from_url() extraction (valid, invalid, empty, UUID-style)
  • HTML form parsing for each SSO step (SSO login, IDCS session, SAML response)
  • A gated live login test (skipped unless SCL_USERNAME/SCL_PASSWORD are in .env.secret)

No behavioral changes to the happy path. All 54 existing tests still pass.

JamieMagee and others added 2 commits April 5, 2026 14:31
SCL's async_login used 10 bare assert statements for runtime
validation. These break silently under python -O. Replaced with
InvalidAuth exceptions with descriptive messages.

Added test coverage: helper function unit tests, HTML fixture
parsing for each SSO step, and a gated live login test.
@tronikos
Copy link
Copy Markdown
Owner

tronikos commented Apr 8, 2026

Can you make pre-commit happy?

@JamieMagee
Copy link
Copy Markdown
Contributor Author

@tronikos Done!

@tronikos tronikos merged commit e3caf93 into tronikos:main May 1, 2026
3 checks passed
@JamieMagee JamieMagee deleted the fix-scl-asserts-and-tests branch May 1, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants