Add admin access control integration tests 558#574
Open
Stanley-Owoh wants to merge 3 commits into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add integration tests for admin-only function unauthorized access
Summary
Added
creator-keys/tests/admin_unauthorized.rs— an integration test file that verifies all admin-gated functions revert withContractError::Unauthorizedwhen called by a non-admin address, and that no contract state is mutated on failed calls.Admin-gated functions covered
These are all functions that check admin identity via
assert_is_admin()(lib.rs:871):pauselib.rs:1885unpauselib.rs:1898update_protocol_fee_recipientlib.rs:2763withdraw_treasurylib.rs:2990Tests added (8 total)
test_pause_reverts_for_non_adminpausereturnsUnauthorizedfor non-admintest_pause_no_state_change_on_non_admin_callget_is_paused()unchanged after rejected calltest_unpause_reverts_for_non_adminunpausereturnsUnauthorizedfor non-admintest_unpause_no_state_change_on_non_admin_callget_is_paused()unchanged after rejected calltest_update_protocol_fee_recipient_reverts_for_non_adminupdate_protocol_fee_recipientreturnsUnauthorizedfor non-admintest_update_protocol_fee_recipient_no_state_change_on_non_admin_callget_protocol_fee_recipient()unchanged after rejected calltest_withdraw_treasury_reverts_for_non_adminwithdraw_treasuryreturnsUnauthorizedfor non-admintest_withdraw_treasury_no_state_change_on_non_admin_callget_treasury_balance()unchanged after rejected callScope note
Functions that only use
require_auth()withoutassert_is_admin()(set_fee_config,set_key_price,set_curve_slope,set_treasury_address,set_protocol_admin,set_protocol_fee_recipient) are not admin-gated in the identity-check sense — any address that authorizes the call can invoke them. These are excluded from this test scope.Acceptance criteria
Unauthorizederror code (18) when called by non-adminAddress::generate)Closes #558