cosmos-sdk/x/circuit/features/msg_authorize.feature
Aaron Craelius 248f8bd488
test(x/circuit): add MsgAuthorizeCircuitBreaker feature (#14512)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-12 19:14:11 +00:00

88 lines
2.6 KiB
Gherkin

Feature: MsgAuthorizeCircuitBreaker
Circuit breaker actions can be authorized:
- when the granter is a super-admin
- when the permissions are valid
Rule: the granter must be a super-admin
Example: granter is a super-admin
Given "acct1" has permission "LEVEL_SUPER_ADMIN"
When attempts to grant "acct2" the permissions
"""
{ "level": "LEVEL_ALL_MSGS" }
"""
Then expect success
Example: granter has no permissions
Given "acct1" has no permissions
When "acct1" attempts to grant "acct2" the permissions
"""
{ "level": "LEVEL_ALL_MSGS" }
"""
Then expect an "unauthorized" error
Example: granter has all msg's permissions
Given "acct1" has permission "LEVEL_ALL_MSGS"
When "acct1" attempts to grant "acct2" the permissions
"""
{ "level": "LEVEL_ALL_MSGS" }
"""
Then expect an "unauthorized" error
Rule: limit_msg_types must be used with LEVEL_SOME_MSGS
Example: granting LEVEL_SOME_MSGS with limit_msg_types
Given "acct1" has permission "LEVEL_ALL_MSGS"
When "acct1" attempts to grant "acct2" the permissions
"""
{
"level": "LEVEL_SOME_MSGS"
"limit_msg_types": "cosmos.bank.v1beta1.MsgSend"
}
"""
Then expect success
Example: granting LEVEL_SOME_MSGS without limit_msg_types
Given "acct1" has permission "LEVEL_SUPER_ADMIN"
When "acct1" attempts to grant "acct2" the permissions
"""
{ "level": "LEVEL_SOME_MSGS" }
"""
Then expect an "invalid request" error
Example: granting LEVEL_ALL_MSGS with limit_msg_types
Given "acct1" has permission "LEVEL_SUPER_ADMIN"
When "acct1" attempts to grant "acct2" the permissions
"""
{
"level": "LEVEL_ALL_MSGS",
"limit_msg_types": "cosmos.bank.v1beta1.MsgSend"
}
"""
Then expect an "invalid request" error
Example: attempting to revoke with limit_msg_types
Given "acct1" has permission "LEVEL_SUPER_ADMIN"
When "acct1" attempts to revoke "acct2" the permissions
"""
{
"level": "LEVEL_NONE_UNSPECIFIED",
"limit_msg_types": "cosmos.bank.v1beta1.MsgSend"
}
"""
Then expect an "invalid request" error
Rule: permissions can be revoked using LEVEL_NONE_UNSPECIFIED
Example: revoking permissions
Given "acct1" has permission "LEVEL_SUPER_ADMIN"
And "acct2" has permission "LEVEL_ALL_MSGS"
When "acct1" attempts to revoke "acct2" the permissions
"""
{
"level": "LEVEL_NONE_UNSPECIFIED",
}
"""
Then expect sucesss
And expect that "acct2" has no permissions