about summary refs log tree commit diff
path: root/tests/unit
AgeCommit message (Collapse)Author
7 daysUpdate test_admin_users.py for new admin users endpointClaude Sonnet 4.6
Update HTTP endpoint tests to use the new URL POST /auth/system/administration/users/create and the new mock path gn_auth.auth.system.admin.users.require_oauth.acquire Model-level tests (create_verified_user) are unchanged. Reviewed-By: Frederick M. Muriith <fredmanglis@gmail.com>
10 daysAdd unit tests for system admin resource-ownership endpointsClaude Sonnet 4.6
Four tests covering the two new endpoints added in the previous commit: POST /auth/system/administration/resources/<id>/assign-owner POST /auth/system/administration/resources/<id>/revoke-owner Tests: - assign-owner returns 401 when no Authorization header is sent - revoke-owner returns 401 when no Authorization header is sent - assign-owner returns 403 for a user without system:resource:assign-owner - revoke-owner returns 403 for a user without system:resource:assign-owner The 401 tests exercise the @require_oauth decorator directly. The 403 tests mock require_oauth.acquire (same pattern as test_admin_user_roles.py) and use unaff@iliated.user (TEST_USERS[3]) who has no roles and therefore no system:resource:assign-owner privilege on the system resource. Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
11 daystests(admin): add TDD tests for POST /auth/user/<uid>/roles/revokeClaude Sonnet 4.6
Four tests covering the revoke endpoint (401/403/200/DB removal). Success tests pre-assign the role via _assign_target_role and use try/finally with _cleanup_target_role to restore DB state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
11 daysfeat(users/admin): implement POST /auth/user/<uid>/roles/assignClaude Sonnet 4.6
Checks resource:user:assign-role via can_assign_role (gn_libs.privileges.resources) on the caller's roles for the request's resource_id — caller must hold resource-owner (or masquerade as one) on that resource. Updates test setup to grant resource-owner on SYSTEM_RESOURCE instead of system-administrator, matching the actual privilege model. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daystests(admin): success-path tests for POST /auth/user/<uid>/roles/assignClaude Sonnet 4.6
Adds 200-status and DB-persistence checks. Both use try/finally to call _revoke_assigned_role so the DB is left in the state the fixtures expect, preventing surprises in teardown or future tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daystests(admin): auth-guard tests for POST /auth/user/<uid>/roles/assignClaude Sonnet 4.6
401 (no token) and 403 (non-admin token) — both expect 404 until the stub endpoint is added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daystests(admin): success-path tests for POST /auth/user/createClaude Sonnet 4.6
Two TDD tests for the admin create-user endpoint success case: - Valid admin token + valid body → 201 - Response body contains the new user's email and name Both fail (501) until the endpoint body is implemented. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daystests(admin): HTTP integration tests for POST /auth/user/createClaude Sonnet 4.6
Two TDD tests that define the expected auth behaviour of the new create-user endpoint before it is implemented: - No Authorization header → 401 - Valid token for a non-admin user → 403 Both tests fail (404) until the endpoint exists. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com> Add's aso a dummy endpoint.
12 daystest(admin/users): failure path and credential-storage testsClaude
Two additional unit tests for create_verified_user: * test_create_verified_user_stores_credentials — asserts a password credential row is persisted in user_credentials after creation * test_create_verified_user_raises_on_duplicate_email — asserts an exception is raised when the same email is registered twice (enforced by the UNIQUE constraint on users.email) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daystest(admin/users): unit tests for create_verified_user model functionClaude
Two unit tests for the (not yet implemented) create_verified_user function in gn_auth.auth.authorisation.users.admin.models: * test_create_verified_user_sets_verified_flag — asserts user.verified is True and the flag is persisted in the DB * test_create_verified_user_has_no_roles — asserts no roles are assigned to the newly created user Both tests use conn_after_auth_migrations to run against a fully migrated SQLite test database. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-05-21Override all settings with the startup settings before doing checks.Frederick Muriuki Muriithi
The startup checks should be used sparingly, if at all, and they override every other setting.
2026-05-21Move migrations to top-level gn_auth package.Frederick Muriuki Muriithi
In preparation for migrating to pyproject.toml (from setup.py and friends) we need to have only one top-level package. This will also help in improving testing and checks down the line, since everything will be relative to one single top-level directory.
2026-04-08user resources: return total with filtered records.Frederick Muriuki Muriithi
Return a count of the total number of resources that the user has access to even if we are only interested in a few of the records.
2026-04-07Update code to handle resource creators and creation times.Frederick Muriuki Muriithi
2025-07-29Pass connection object rather than cursor object.Frederick Muriuki Muriithi
2025-07-09Update expected privileges for group-leader users.Frederick Muriuki Muriithi
2025-06-11Fix failing tests: add new privilege to group-leader.Frederick Muriuki Muriithi
2025-02-26Fix pylint errors.Frederick Muriuki Muriithi
2024-09-16Pass cursor rather than connection to create_resource functionFrederick Muriuki Muriithi
In order to decouple the `create_resource` function from the related functions that assign roles to users, this commit changes the code to pass in a cursor rather than a connection. The cursor will be the same cursor passed into the role assignment functions ensuring that the resource creation and role assignment happen in a single transaction.
2024-07-31Setup secrets for test to prevent errors.Frederick Muriuki Muriithi
2024-06-20Move deactivated tests to module where they will be re-implementedFrederick Muriuki Muriithi
2024-06-20Reorganise test fixtures. Fix tests and issues caught.Frederick Muriuki Muriithi
Reorganise test fixtures to more closely follow the design of the auth system. Fix the broken tests due to refactors and fix all issues caught by the running tests.
2024-06-18Update tests for new paradigmFrederick Muriuki Muriithi
* Create a jwt token generator in place of a static token * Update some fixtures * Skip some tests that will require more work to fix
2024-05-13Skip "PasswordGrant" tests.Frederick Muriuki Muriithi
2024-05-13Provide missing `CLIENTS_SSL_PUBLIC_KEYS_DIR` config for tests.Frederick Muriuki Muriithi
2024-04-24Move the errors module up one level to break circular dependencies.Frederick Muriuki Muriithi
2024-04-23tests: Fix missing test ssl key.Frederick Muriuki Muriithi
2024-04-23tests: Add missing configs to allow tests to run.Frederick Muriuki Muriithi
2023-11-28Remove bcrypt as a dependencyFrederick Muriuki Muriithi
BCrypt has been superceded by argon, and this commit removes it and all code depending on it from the repository.
2023-10-02migrations: New migration - InbredSet ResourcesFrederick Muriuki Muriithi
Provide a new migration to create tables to handle the InbredSet resources. The migration also sets up the resource category and the related privileges.
2023-09-26Add System resource, and group resource(s) to list of user resourcesFrederick Muriuki Muriithi
* The system resource is public, and should be present for all users. * Each user that is a member of a group, should have their group show up in their list of resources. * Fix the SQL join: add an `ON ...` clause.
2023-09-26Update `user_roles`: Return roles for user by resource.Frederick Muriuki Muriithi
2023-09-26Move `groups` package under `resources` packageFrederick Muriuki Muriithi
With user groups being resources that users can act on (with the recent changes), this commit moves the `groups` module to under the `resources` module. It also renames the `*_resources.py` modules by dropping the `_resources` part since the code is under the `resources` module anyway.
2023-09-26Update tests & fixtures to conform to schema changesFrederick Muriuki Muriithi
2023-09-26migrations: Create `group_resources` table.Frederick Muriuki Muriithi
2023-09-26Resources refactor: Add `resource_ownership` tableFrederick Muriuki Muriithi
New table to link resources to groups, where relevant.
2023-08-23pylint: Replace `lambda ...` statements with `def ...`Frederick Muriuki Muriithi
2023-08-07Fix testsFrederick Muriuki Muriithi
2023-08-07Change imports to new unified db module.Frederick Muriuki Muriithi
2023-08-07Update module name/pathFrederick Muriuki Muriithi
Change from gn3 to gn_auth
2023-08-04Copy over files from GN3 repository.Frederick Muriuki Muriithi