-
Notifications
You must be signed in to change notification settings - Fork 2
Access control tests #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mts1715
wants to merge
14
commits into
main
Choose a base branch
from
taras/177-access-control-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Access control tests #244
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c38635e
add security permission matrix doc
vishalchangrani 25fd067
docs: highlight EPosition over-grant risk in permission matrix
vishalchangrani 7a1ea97
docs: restructure matrix by actor to expose beta over-grant clearly
vishalchangrani 2780290
docs: clarify EPositionAdmin is user acting on own positions via storage
vishalchangrani 4265852
Merge branch 'main' into taras/177-access-control-test
mts1715 f9f728b
Add comprehensive entitlement/capability access-control test suite
mts1715 491193a
fix comments
mts1715 4a2ea5e
Merge remote-tracking branch 'origin/main' into taras/177-access-cont…
mts1715 9e0b53b
Merge remote-tracking branch 'origin/main' into taras/177-access-cont…
mts1715 bd0dc05
fix wrong path for capability EGovernance
mts1715 dee9360
move some scripts from the `helper` folder to appropriate paths
mts1715 1a0d372
Merge remote-tracking branch 'origin/main' into taras/177-access-cont…
mts1715 27dc3b5
typo fix
mts1715 ca275cf
fix pool_pause_test.cdc to change from direct pool storage borrow to …
mts1715 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule FlowActions
updated
11 files
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
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
18 changes: 0 additions & 18 deletions
18
cadence/tests/transactions/flow-alp/beta/publish_beta_cap.cdc
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
cadence/tests/transactions/flow-alp/egovernance/add_supported_token.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
| import "FlowALPInterestRates" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.addSupportedToken. | ||
| /// Adds a token with a zero-rate interest curve (0% APY). | ||
| transaction( | ||
| tokenTypeIdentifier: String, | ||
| collateralFactor: UFix64, | ||
| borrowFactor: UFix64, | ||
| depositRate: UFix64, | ||
| depositCapacityCap: UFix64 | ||
| ) { | ||
| let tokenType: Type | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.tokenType = CompositeType(tokenTypeIdentifier) | ||
| ?? panic("Invalid tokenTypeIdentifier \(tokenTypeIdentifier)") | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.addSupportedToken( | ||
| tokenType: self.tokenType, | ||
| collateralFactor: collateralFactor, | ||
| borrowFactor: borrowFactor, | ||
| interestCurve: FlowALPInterestRates.FixedCurve(yearlyRate: 0.0), | ||
| depositRate: depositRate, | ||
| depositCapacityCap: depositCapacityCap | ||
| ) | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
cadence/tests/transactions/flow-alp/egovernance/collect_insurance.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.collectInsurance. | ||
| transaction(tokenTypeIdentifier: String) { | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
| let tokenType: Type | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.tokenType = CompositeType(tokenTypeIdentifier) | ||
| ?? panic("Invalid tokenTypeIdentifier: \(tokenTypeIdentifier)") | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.collectInsurance(tokenType: self.tokenType) | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
cadence/tests/transactions/flow-alp/egovernance/collect_stability.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.collectStability. | ||
| transaction(tokenTypeIdentifier: String) { | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
| let tokenType: Type | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.tokenType = CompositeType(tokenTypeIdentifier) | ||
| ?? panic("Invalid tokenTypeIdentifier: \(tokenTypeIdentifier)") | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.collectStability(tokenType: self.tokenType) | ||
| } | ||
| } | ||
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
cadence/tests/transactions/flow-alp/egovernance/set_deposit_limit_fraction.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.setDepositLimitFraction. | ||
| transaction( | ||
| tokenTypeIdentifier: String, | ||
| fraction: UFix64 | ||
| ) { | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
| let tokenType: Type | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.tokenType = CompositeType(tokenTypeIdentifier) | ||
| ?? panic("Invalid tokenTypeIdentifier \(tokenTypeIdentifier)") | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.setDepositLimitFraction(tokenType: self.tokenType, fraction: fraction) | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
cadence/tests/transactions/flow-alp/egovernance/set_dex.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import "DeFiActions" | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
| import "MockDexSwapper" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.borrowConfig, | ||
| /// enabling the governance holder to set the DEX via the config. | ||
| /// Uses MockDexSwapper.SwapperProvider as the DEX implementation. | ||
| transaction { | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.borrowConfig().setDex(MockDexSwapper.SwapperProvider()) | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
cadence/tests/transactions/flow-alp/egovernance/set_insurance_rate.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.setInsuranceRate. | ||
| transaction( | ||
| tokenTypeIdentifier: String, | ||
| insuranceRate: UFix64 | ||
| ) { | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
| let tokenType: Type | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.tokenType = CompositeType(tokenTypeIdentifier) | ||
| ?? panic("Invalid tokenTypeIdentifier \(tokenTypeIdentifier)") | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.setInsuranceRate(tokenType: self.tokenType, insuranceRate: insuranceRate) | ||
| } | ||
| } |
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
cadence/tests/transactions/flow-alp/egovernance/set_interest_curve.cdc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import "FlowALPv0" | ||
| import "FlowALPModels" | ||
| import "FlowALPInterestRates" | ||
|
|
||
| /// TEST TRANSACTION - DO NOT USE IN PRODUCTION | ||
| /// | ||
| /// Verifies that auth(EGovernance) &Pool grants access to Pool.setInterestCurve. | ||
| /// Sets a FixedCurve with the given yearly rate. | ||
| transaction( | ||
| tokenTypeIdentifier: String, | ||
| yearlyRate: UFix128 | ||
| ) { | ||
| let tokenType: Type | ||
| let pool: auth(FlowALPModels.EGovernance) &FlowALPv0.Pool | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.tokenType = CompositeType(tokenTypeIdentifier) | ||
| ?? panic("Invalid tokenTypeIdentifier \(tokenTypeIdentifier)") | ||
| let cap = signer.storage.borrow<&Capability<auth(FlowALPModels.EGovernance) &FlowALPv0.Pool>>( | ||
| from: FlowALPv0.PoolCapStoragePath | ||
| ) ?? panic("No EGovernance cap found") | ||
| self.pool = cap.borrow() ?? panic("Could not borrow Pool from EGovernance cap") | ||
| } | ||
|
|
||
| execute { | ||
| self.pool.setInterestCurve( | ||
| tokenType: self.tokenType, | ||
| interestCurve: FlowALPInterestRates.FixedCurve(yearlyRate: yearlyRate) | ||
| ) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all really test transactions only? seems like they technically would still work in prod, no? assuming the account has the right entitlement?