def _test_manager(self): """ Verify that transactions are allowed """ if self.config.get('manager', 'transactions') != 'true': raise RuntimeError('CSW-T interface is disabled') ipaddress = self.environ['REMOTE_ADDR'] if not self.config.has_option('manager', 'allowed_ips') or \ (self.config.has_option('manager', 'allowed_ips') and not util.ipaddress_in_whitelist(ipaddress, self.config.get('manager', 'allowed_ips').split(','))): raise RuntimeError( 'CSW-T operations not allowed for this IP address: %s' % ipaddress)
def _test_manager(self): """ Verify that transactions are allowed """ if self.config.get('manager', 'transactions') != 'true': raise RuntimeError('CSW-T interface is disabled') ipaddress = self.environ['REMOTE_ADDR'] if not self.config.has_option('manager', 'allowed_ips') or \ (self.config.has_option('manager', 'allowed_ips') and not util.ipaddress_in_whitelist(ipaddress, self.config.get('manager', 'allowed_ips').split(','))): raise RuntimeError( 'CSW-T operations not allowed for this IP address: %s' % ipaddress)
def _test_manager(self): """ Verify that transactions are allowed """ if self.config.get("manager", "transactions") != "true": raise RuntimeError("CSW-T interface is disabled") ipaddress = self.environ["REMOTE_ADDR"] if self.config.has_option("manager", "allowed_ips"): allowed_ips = self.config.get("manager", "allowed_ips").split(",") else: allowed_ips = [] ip_in_whitelist = util.ipaddress_in_whitelist(ipaddress, allowed_ips) if len(allowed_ips) > 0 and not ip_in_whitelist: raise RuntimeError("CSW-T operations not allowed for this " "IP address: %s" % ipaddress)
def test_ipaddress_in_whitelist(ip, whitelist, expected): result = util.ipaddress_in_whitelist(ip, whitelist) assert result == expected
def test_ipaddress_in_whitelist(ip, whitelist, expected): result = util.ipaddress_in_whitelist(ip, whitelist) assert result == expected