Beispiel #1
0
    def __call__(self, target, creds, enforcer):
        """Check http: rules by calling to a remote server.

        This example implementation simply verifies that the response
        is exactly 'True'.
        """

        url = ('http:' + self.match) % target
        data = {'target': jsonutils.dumps(target),
                'credentials': jsonutils.dumps(creds)}
        post_data = urlutils.urlencode(data)
        f = urlutils.urlopen(url, post_data)
        return f.read() == "True"
 def test_urlopen(self):
     tmp = tempfile.NamedTemporaryFile()
     url = 'file://' + tmp.name
     result = urlutils.urlopen(url)
     self.assertEqual(result.url, url)
     tmp.close()
Beispiel #3
0
 def test_urlopen(self):
     tmp = tempfile.NamedTemporaryFile()
     url = 'file://' + tmp.name
     result = urlutils.urlopen(url)
     self.assertEqual(result.url, url)
     tmp.close()