github.com/status-im/status-go@v1.1.0/protocol/communities_events_owner_without_community_key_test.go (about) 1 package protocol 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/suite" 7 8 "github.com/status-im/status-go/protocol/common" 9 "github.com/status-im/status-go/protocol/communities/token" 10 "github.com/status-im/status-go/protocol/protobuf" 11 ) 12 13 func TestOwnerWithoutCommunityKeyCommunityEventsSuite(t *testing.T) { 14 suite.Run(t, new(OwnerWithoutCommunityKeyCommunityEventsSuite)) 15 } 16 17 type OwnerWithoutCommunityKeyCommunityEventsSuite struct { 18 EventSenderCommunityEventsSuiteBase 19 } 20 21 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerEditCommunityDescription() { 22 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 23 editCommunityDescription(s, community) 24 } 25 26 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerCreateEditDeleteChannels() { 27 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 28 29 testCreateEditDeleteChannels(s, community) 30 } 31 32 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerCreateEditDeleteBecomeMemberPermission() { 33 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 34 testCreateEditDeleteBecomeMemberPermission(s, community, protobuf.CommunityTokenPermission_BECOME_MEMBER) 35 } 36 37 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerCreateEditDeleteBecomeAdminPermission() { 38 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 39 testCreateEditDeleteBecomeMemberPermission(s, community, protobuf.CommunityTokenPermission_BECOME_ADMIN) 40 } 41 42 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerCreateEditDeleteBecomeTokenMasterPermission() { 43 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 44 testCreateEditDeleteBecomeMemberPermission(s, community, protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER) 45 } 46 47 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders() { 48 additionalOwner := s.newMessenger(accountPassword, []string{eventsSenderAccountAddress}) 49 community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER, []*Messenger{additionalOwner}) 50 51 // set up additional user that will send request to join 52 user := s.newMessenger("somePassword", []string{"0x0123400000000000000000000000000000000000"}) 53 s.SetupAdditionalMessengers([]*Messenger{user}) 54 55 testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders(s, community, user, additionalOwner) 56 } 57 58 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAcceptMemberRequestToJoin() { 59 community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER, []*Messenger{}) 60 61 // set up additional user that will send request to join 62 user := s.newMessenger("somePassword", []string{"0x0123400000000000000000000000000000000000"}) 63 s.SetupAdditionalMessengers([]*Messenger{user}) 64 65 testAcceptMemberRequestToJoin(s, community, user) 66 } 67 68 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerRejectMemberRequestToJoinResponseSharedWithOtherEventSenders() { 69 additionalOwner := s.newMessenger(accountPassword, []string{eventsSenderAccountAddress}) 70 community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER, []*Messenger{additionalOwner}) 71 72 // set up additional user that will send request to join 73 user := s.newMessenger("somePassword", []string{"0x0123400000000000000000000000000000000000"}) 74 s.SetupAdditionalMessengers([]*Messenger{user}) 75 76 testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders(s, community, user, additionalOwner) 77 } 78 79 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerRejectMemberRequestToJoin() { 80 community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER, []*Messenger{}) 81 82 // set up additional user that will send request to join 83 user := s.newMessenger("somePassword", []string{"0x0123400000000000000000000000000000000000"}) 84 s.SetupAdditionalMessengers([]*Messenger{user}) 85 86 testRejectMemberRequestToJoin(s, community, user) 87 } 88 89 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerControlNodeHandlesMultipleEventSenderRequestToJoinDecisions() { 90 // TODO: test fixed, need to fix the code as it contains error 91 s.T().Skip("flaky test") 92 93 additionalOwner := s.newMessenger(accountPassword, []string{eventsSenderAccountAddress}) 94 community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER, []*Messenger{additionalOwner}) 95 96 // set up additional user that will send request to join 97 user := s.newMessenger("somePassword", []string{"0x0123400000000000000000000000000000000000"}) 98 testControlNodeHandlesMultipleEventSenderRequestToJoinDecisions(s, community, user, additionalOwner) 99 } 100 101 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerCreateEditDeleteCategories() { 102 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 103 testCreateEditDeleteCategories(s, community) 104 } 105 106 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerReorderChannelsAndCategories() { 107 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 108 testReorderChannelsAndCategories(s, community) 109 } 110 111 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerKickOwnerWithoutCommunityKey() { 112 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 113 testEventSenderKickTheSameRole(s, community) 114 } 115 116 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerKickControlNode() { 117 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 118 testEventSenderKickControlNode(s, community) 119 } 120 121 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerKickMember() { 122 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 123 kickMember(s, community.ID(), common.PubkeyToHex(&s.alice.identity.PublicKey)) 124 } 125 126 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerBanOwnerWithoutCommunityKey() { 127 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 128 testOwnerBanTheSameRole(s, community) 129 } 130 131 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerBanControlNode() { 132 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 133 testOwnerBanControlNode(s, community) 134 } 135 136 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerBanUnbanMember() { 137 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 138 testBanUnbanMember(s, community) 139 } 140 141 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerDeleteAnyMessageInTheCommunity() { 142 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 143 testDeleteAnyMessageInTheCommunity(s, community) 144 } 145 146 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerPinMessage() { 147 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 148 testEventSenderPinMessage(s, community) 149 } 150 151 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAddCommunityToken() { 152 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 153 testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.CommunityLevel) 154 } 155 156 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAddOwnerToken() { 157 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 158 testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.OwnerLevel) 159 } 160 161 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerAddTokenMasterToken() { 162 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 163 testAddAndSyncTokenFromEventSenderByControlNode(s, community, token.MasterLevel) 164 } 165 166 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerReceiveOwnerTokenFromControlNode() { 167 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 168 testAddAndSyncOwnerTokenFromControlNode(s, community, token.OwnerLevel) 169 } 170 171 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerReceiveTokenMasterTokenFromControlNode() { 172 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 173 testAddAndSyncTokenFromControlNode(s, community, token.MasterLevel) 174 } 175 176 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerReceiveCommunityTokenFromControlNode() { 177 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 178 testAddAndSyncTokenFromControlNode(s, community, token.CommunityLevel) 179 } 180 181 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestMemberReceiveOwnerEventsWhenControlNodeOffline() { 182 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 183 testMemberReceiveEventsWhenControlNodeOffline(s, community) 184 } 185 186 func (s *OwnerWithoutCommunityKeyCommunityEventsSuite) TestOwnerBanMemberWithDeletingAllMessages() { 187 community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_OWNER) 188 testBanMemberWithDeletingAllMessages(s, community) 189 }