def test_http(self):
     anchor = smimeX509validation.LoadDirChainOfTrust(self.trustAnchordirectory)
     foo = vmcatcher.vmcatcher_subscribe.retrieveFacard.retrieveFacard()
     foo.trustanchor = anchor
     #uri = "http://http.fritz.box/repos/public/imagelist/yokel.imagelist.smime"'
     uri = "http://www.yokel.org/pub/software/yokel.org/imagelist/yokel.imagelist.smime"
     foo.uri = uri
     #print ("trustanchor=%s" % (foo.trustanchor))
     responce = foo.requestAsString()
     self.log.error("output=%s" % (foo.requestAsString()))
     # self.assertIn is not available in SL5
     self.assertTrue("code" in responce.keys())
     self.assertTrue("responce" in responce.keys())
Exemple #2
0
    def download_imagelist(self, imagelistUUID, flags):
        Session = self.SessionFactory()
        query_imagelist_uri = Session.query(model.ImagelistMetadata).\
                filter(model.Imagelist.identifier == imagelistUUID).\
                filter(model.Imagelist.id == model.ImagelistMetadata.fkImageList).\
                filter(model.ImagelistMetadata.key == 'hv:uri')

        if query_imagelist_uri.count() == 0:
            self.log.warning('image list uri not found')
            return True
        uri = None
        for item in query_imagelist_uri:
            uri = item.value
        if uri is None:
            self.log.error('image list uri not found')
            return True
        content = downloader.downloader(uri)
        if content is None:
            self.log.error("Content is None.")
            sys.exit(22)
        anchor = smimeX509validation.LoadDirChainOfTrust("/etc/grid-security/certificates/")
        smimeProcessor = smimeX509validation.smimeX509validation(anchor)
        try:
            dwonloader_responce = content["responce"]
        except KeyError:
            self.log.error("Retrive uri failed:'%s'" % (uri))
            return False
        try:
            smimeProcessor.Process(dwonloader_responce)
        except smimeX509validation.truststore.TrustStoreError as exp:
            self.log.error("Validate text '%s' produced error '%s'" % (uri, exp))
            self.log.debug("Downloaded=%s" % (content['responce']))
            return False
        except smimeX509validation.smimeX509ValidationError as exp:
            self.log.error("Validate text '%s' produced error '%s'" % (uri, exp))
            self.log.debug("Downloaded=%s" % (uri))
            return False
        if not smimeProcessor.verified:
            self.log.error("Failed to  verify text '%s'" % (content))
            return False
        try:
            candidate = json.loads(smimeProcessor.InputDaraStringIO.getvalue())
        except ValueError:
            self.log.error("Failed to parse JSON.")
            sys.exit(20)
        if candidate is None:
            self.log.error("No JSON content.")
            sys.exit(21)
        self.importer(candidate)
Exemple #3
0
 def setup_trust_anchor(self, directory):
     self.anchor = smimeX509validation.LoadDirChainOfTrust(directory)
 def test_one(self):
     anchor = smimeX509validation.LoadDirChainOfTrust(self.x509anchor)