Skip to content

981 add unauthorized caller tests - #1311

Merged
aji70 merged 3 commits into
MyFanss:mainfrom
ndii-dev:981-add-unauthorized-caller-tests
Jun 27, 2026
Merged

981 add unauthorized caller tests#1311
aji70 merged 3 commits into
MyFanss:mainfrom
ndii-dev:981-add-unauthorized-caller-tests

Conversation

@ndii-dev

Copy link
Copy Markdown
Contributor

Summary

Changes

Test Plan

Automated tests added or updated

  • Unit tests (backend/src/**/*.spec.ts) — service/guard/decorator logic in isolation
  • Integration / e2e tests (backend/test/**/*.e2e-spec.ts) — HTTP round-trips with mocked infrastructure
  • Frontend component tests (frontend/src/**/*.test.{ts,tsx}) — React component behaviour
  • Frontend e2e tests (frontend/e2e/**/*.spec.ts) — Playwright browser flows
  • Contract tests (contract/) — Soroban/Rust unit tests via cargo test
  • No new tests required — explain why: ___

How to run the tests locally

# Backend unit tests
cd backend && npm test

# Backend e2e tests (requires no live DB — uses in-memory mocks)
cd backend && npm run test:e2e

# Frontend component tests
cd frontend && npx vitest run

# Frontend e2e tests (requires dev server on :3000 and API on :3001)
cd frontend && npx playwright test

# Contract tests
cd contract && cargo test

Manual verification checklist

  • Happy path works end-to-end in a local environment
  • Error / edge cases handled gracefully (stale state, invalid input, disconnected wallet)
  • No regressions in closely related API or UI flows
  • Rate-limiting, auth guards, and feature flags behave as expected where touched
  • Linting passes: cd backend && npm run lint / cd frontend && npm run lint

Related issues

Notes for reviewers

ndii-dev and others added 3 commits June 26, 2026 12:07
… tests

- Add set_paused(paused: bool) admin-protected function
  - Requires caller to be the admin
  - Returns NotAuthorized error for unauthorized callers
  - Can only be called after initialize
- Add is_paused() function to retrieve paused status
- Add Paused data key to DataKey enum
- Initialize paused status to false during initialization
- Add comprehensive unauthorized caller revert tests:
  - test_set_paused_admin_authorization: verifies admin can set paused
  - test_set_paused_unauthorized_caller_revert: verifies unauthorized caller gets NotAuthorized
  - test_set_paused_multiple_unauthorized_callers: verifies consistent rejection
  - test_set_paused_admin_can_toggle: verifies admin can toggle state multiple times

Fixes MyFanss#981
## Description

Improve documentation for the `myfans-lib` Soroban contract by documenting all public functions and modules in the contract README.

## Changes

- **Document SubscriptionStatus enum**: All variants with their properties and use cases
- **Document ContentType enum**: Classification of content access types
- **Document MyfansError enum**: All error variants with descriptions
- **Document error_codes module**: All sub-modules and comprehensive usage examples
- **Document test_fixtures module**: Details on the testutils feature
- **Add Getting Started guide**: Installation and basic usage examples
- **Add error handling example**: Shows how to work with error codes
- **Update features list**: Comprehensive list of all capabilities

## How to test

The documentation is comprehensive and includes code examples that can be copy-pasted and compiled.

## Acceptance Criteria

- ✅ All public types documented
- ✅ All public modules documented
- ✅ Usage examples provided
- ✅ Error handling patterns explained
- ✅ Code examples are accurate and compile

## Fixes

Closes MyFanss#973
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@ndii-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@aji70
aji70 merged commit 957ffa3 into MyFanss:main Jun 27, 2026
2 of 7 checks passed
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