Skip to content

Integration tests for user auto-provision #400

@ngjunsiang

Description

@ngjunsiang

Summary

Implement remaining integration tests for user auto-provisioning behavior during OAuth login flows. Test file scaffold exists but several tests are placeholders.

File

campus/tests/integration/auth/resources/test_user.py

Placeholder Tests to Implement

TestUsersResourceGetOrCreate class:

  1. test_get_or_create_idempotent_multiple_calls (line 82-85)

    • Verify that multiple calls with same email return the same user record
    • Check that created_at timestamps remain consistent across calls
  2. test_new_creates_user_with_activated_at (line 87-90)

    • Create user with explicit activated_at timestamp
    • Verify the timestamp is stored correctly
  3. test_new_creates_user_without_activated_at (line 92-95)

    • Create user without activated_at
    • Verify the field is null/None

TestUserResource class:

  1. test_activate_sets_activated_at (line 145-148)

    • Create a user without activated_at
    • Call activate() on the user resource
    • Verify activated_at is now set
  2. test_delete_removes_user (line 150-153)

    • Create a user
    • Call delete() on the user resource
    • Verify user is removed (should raise NotFoundError on subsequent get)

Already Implemented

  • test_get_or_create_creates_new_user_when_not_exists
  • test_get_or_create_returns_existing_user_when_exists
  • test_list_returns_all_users

Technical Notes

  • Uses lazy imports to avoid storage initialization before test mode is configured (see AGENTS.md)
  • Leverages campus.storage.testing for test storage configuration
  • Tests cover the auto-provisioning flow used during OAuth login

Metadata

Metadata

Assignees

No one assigned

    Labels

    for-contributorsTask is suitable for NYSD Contributors

    Type

    Projects

    Status

    Open

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions