def test_is_steward(nym_handler): identifier = "test_identifier" target_nym = "test_target_nym" txn = create_nym_txn(identifier, STEWARD, target_nym) nym_handler.update_state(txn, None, None) assert is_steward(nym_handler.state, target_nym) assert not is_steward(nym_handler.state, "other_identifier")
def dynamic_validation(self, request: Request, req_pp_time: Optional[int]): self._validate_request_type(request) identifier, req_id, operation = get_request_data(request) error = None if not is_steward(self.state, identifier, is_committed=False): error = "Only Steward is allowed to do these transactions" if operation.get(ROLE) == STEWARD: if self._steward_threshold_exceeded(self.config): error = "New stewards cannot be added by other stewards " \ "as there are already {} stewards in the system". \ format(self.config.stewardThreshold) if error: raise UnauthorizedClientRequest(identifier, req_id, error)
def _is_steward(self, nym, is_committed: bool = True): domain_state = self.database_manager.get_database(DOMAIN_LEDGER_ID).state return is_steward(domain_state, nym, is_committed)
def test_is_steward(nym_handler): identifier = "test_identifier" update_nym(nym_handler.state, identifier, STEWARD) assert is_steward(nym_handler.state, identifier) assert not is_steward(nym_handler.state, "other_identifier")