class NotContainsOwsException(NotContainsStrings): """ Checks if HTTP response NOT contains given OWS Exceptions. """ NAME = 'Response NOT contains OWS Exception' DESCRIPTION = 'HTTP response does not contain an OWS Exception' PARAM_DEFS = Plugin.merge( ContainsStrings.PARAM_DEFS, {'strings': { 'value': ['ExceptionReport>', 'ServiceException>'] }}) """Param defs"""
class SosGetCaps(OwsGetCaps): """SOS GetCapabilities Probe""" NAME = 'SOS GetCapabilities' RESOURCE_TYPE = 'OGC:SOS' PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, { 'service': { 'value': 'SOS' }, 'version': { 'default': '1.0.0', 'range': ['1.0.0', '2.0.0'] } }) """Param defs"""
class CswGetCaps(OwsGetCaps): """CSW GetCapabilities Probe""" NAME = 'CSW GetCapabilities' RESOURCE_TYPE = 'OGC:CSW' PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, { 'service': { 'value': 'CSW' }, 'version': { 'default': '2.0.2', 'range': ['2.0.2'] } }) """Param defs"""
class WmsGetCaps(OwsGetCaps): """Fetch WMS capabilities doc""" NAME = 'WMS GetCapabilities' RESOURCE_TYPE = 'OGC:WMS' PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, { 'service': { 'value': 'WMS' }, 'version': { 'default': '1.3.0', 'range': ['1.1.1', '1.3.0'] } }) """Param defs"""
class HttpHasContentType(HttpHasHeaderValue): """ Checks if HTTP response has content type. """ NAME = 'Has specific Content-Type' DESCRIPTION = 'HTTP response has specific Content-Type' PARAM_DEFS = Plugin.merge(HttpHasHeaderValue.PARAM_DEFS, {'header_name': { 'value': 'content-type' }}) """Params defs for header content type.""" def __init__(self): HttpHasHeaderValue.__init__(self) def perform(self): HttpHasHeaderValue.perform(self)
class WfsGetCaps(OwsGetCaps): """WFS GetCapabilities Probe""" NAME = 'WFS GetCapabilities' RESOURCE_TYPE = 'OGC:WFS' def __init__(self): OwsGetCaps.__init__(self) PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, { 'service': { 'value': 'WFS' }, 'version': { 'default': '1.1.0', 'range': ['1.0.0', '1.1.0', '2.0.2'] } }) """Param defs"""
class TmsGetTileAll(TmsGetTile): """ Get TMS map image for each Layer using the TMS GetTile operation. """ NAME = 'TMS GetTile All - get Tile Image for ALL Layers' DESCRIPTION = """ Do TMS GetTile request for each Layer. """ PARAM_DEFS = Plugin.merge(TmsGetTile.PARAM_DEFS, {}) def __init__(self): TmsGetTile.__init__(self) self.tms = None self.layers = None # Overridden: expand param-ranges from TMS metadata # from single-layer GetTile parent Probe and set layers # fixed to * def expand_params(self, resource): TmsGetTile.expand_params(self, resource) layer_val = 'all %d layers' % self.layer_count extension_val = 'all extensions' self.PARAM_DEFS['layer']['range'] = [layer_val] self.PARAM_DEFS['layer']['value'] = layer_val self.PARAM_DEFS['layer']['default'] = layer_val self.PARAM_DEFS['extension']['range'] = [extension_val] self.PARAM_DEFS['extension']['value'] = extension_val self.PARAM_DEFS['extension']['default'] = extension_val def before_request(self): """ Before request to service, overridden from base class""" # Get capabilities doc to get all layers try: self.tms = self.get_metadata_cached(self._resource, version='1.0.0') self.layers = self.tms.contents except Exception as err: self.result.set(False, str(err)) def perform_request(self): """ Perform actual request to service, overridden from base class""" if not self.layers: self.result.set(False, 'Found no TMS Layers') return self.result.start() results_failed_total = [] for layer_name in self.layers.keys(): # Layer name is last part of full URL self._parameters['layer'] = layer_name.split('1.0.0/')[-1] self._parameters['extension'] = self.layers[layer_name].extension # Let the templated parent perform Probe.perform_request(self) self.run_checks() # Only keep failed Layer results # otherwise with 100s of Layers the report grows out of hand... results_failed = self.result.results_failed if len(results_failed) > 0: # We have a failed layer: add to result message for result in results_failed: result.message = 'layer %s: %s' % \ (layer_name, result.message) results_failed_total += results_failed self.result.results_failed = [] self.result.results = [] self.result.results_failed = results_failed_total self.result.results = results_failed_total
class WfsGetFeatureBboxAll(WfsGetFeatureBbox): """ Do WFS GetFeature for each FeatureType in WFS. """ NAME = "WFS GetFeature in BBOX for ALL FeatureTypes" DESCRIPTION = """ WFS GetFeature in BBOX for ALL FeatureTypes. """ # Copy all PARAM_DEFS from parent to have own instance PARAM_DEFS = Plugin.merge(WfsGetFeatureBbox.PARAM_DEFS, {}) def __init__(self): WfsGetFeatureBbox.__init__(self) self.wfs = None self.feature_types = None # Overridden: expand param-ranges from WFS metadata # from single-layer GetFeature parent Probe and set layers # fixed to * def expand_params(self, resource): WfsGetFeatureBbox.expand_params(self, resource) val = 'all %d feature types' % self.layer_count self.PARAM_DEFS['type_name']['range'] = [val] self.PARAM_DEFS['type_name']['value'] = val self.PARAM_DEFS['type_name']['default'] = val def before_request(self): """ Before request to service, overridden from base class""" # Get capabilities doc to get all layers try: self.wfs = self.get_metadata_cached(self._resource, version='1.1.0') self.feature_types = self.wfs.contents.keys() except Exception as err: self.result.set(False, str(err)) def perform_request(self): """ Perform actual request to service, overridden from base class""" if not self.feature_types: self.result.set(False, 'Found no WFS Feature Types') return self.result.start() results_failed_total = [] for feature_type in self.feature_types: self._parameters['type_name'] = feature_type # Let the templated parent perform Probe.perform_request(self) self.run_checks() # Only keep failed feature_type results # otherwise with 100s of FTs the report grows out of hand... results_failed = self.result.results_failed if len(results_failed) > 0: # We have a failed feature_type: add to result message for result in results_failed: result.message = 'feature_type %s: %s' % \ (feature_type, result.message) results_failed_total += results_failed self.result.results_failed = [] self.result.results = [] self.result.results_failed = results_failed_total
class WmsGetMapV1All(WmsGetMapV1): """ Get WMS map image for each Layer using the WMS GetMap operation. """ NAME = 'WMS GetMap WMS v1.1.1. operation on ALL Layers' DESCRIPTION = """ Do WMS GetMap v1.1.1 request for all Layers with user-specified parameters. """ # Copy all PARAM_DEFS from parent to have own instance PARAM_DEFS = Plugin.merge(WmsGetMapV1.PARAM_DEFS, {}) def __init__(self): WmsGetMapV1.__init__(self) self.wms = None self.layers = None # Overridden: expand param-ranges from WMS metadata # from single-layer GetMap parent Probe and set layers # fixed to * def expand_params(self, resource): WmsGetMapV1.expand_params(self, resource) val = 'all %d layers' % self.layer_count self.PARAM_DEFS['layers']['range'] = [val] self.PARAM_DEFS['layers']['value'] = val self.PARAM_DEFS['layers']['default'] = val def before_request(self): """ Before request to service, overridden from base class""" # Get capabilities doc to get all layers try: self.wms = WebMapService(self._resource.url) self.layers = self.wms.contents.keys() except Exception as err: self.result.set(False, str(err)) def perform_request(self): """ Perform actual request to service, overridden from base class""" if not self.layers: self.result.set(False, 'Found no WMS Layers') return self.result.start() results_failed_total = [] for layer in self.layers: self._parameters['layers'] = [layer] # Let the templated parent perform Probe.perform_request(self) self.run_checks() # Only keep failed Layer results # otherwise with 100s of Layers the report grows out of hand... results_failed = self.result.results_failed if len(results_failed) > 0: # We have a failed layer: add to result message for result in results_failed: result.message = 'layer %s: %s' % (layer, result.message) results_failed_total += results_failed self.result.results_failed = [] self.result.results = [] self.result.results_failed = results_failed_total