コード例 #1
0
 def setUp(self):
     self.h = fake_authz_headers(FAKE_FILE.data)
     self.hglobal = fake_authz_headers(
         FAKE_FILE.data, roles={"Global Admin": {
             'group': ['global']
         }})
     webtest.WebCase.PORT = PORT
     self.engine = cherrypy.engine
     self.proc = load_server(self.engine)
コード例 #2
0
    def test_upload_tgz(self,
                        fmt='application/json',
                        page="/test/file",
                        inbody=None):
        h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
        # empty of input submit failing with 400
        self.getPage(page, headers=h, method="PUT", body=None)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
        # empty inputfile
        body1 = 'hashkey=' + self.checksum
        h1 = h + [('Content-Length', len(body1))]
        self.getPage(page, headers=h1, method="PUT", body=body1)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
        # real upload request
        # TODO this is not working because it gets 'File is not a .tgz file.'
        b2 = """--x
Content-Disposition: form-data; name="inputfile"; filename="%s"
Content-Type: application/x-tar

%s
--x
Content-Disposition: form-data; name="hashkey"

%s
--x--
""" % (self.tgz.name, open(self.tgz.name, 'rb').read(), self.checksum)
        h2 = [("Content-type", "multipart/form-data; boundary=x"),
              ("Content-Length", len(b2))]
        self.getPage(page, headers=h + h2, method="PUT", body=b2)
コード例 #3
0
ファイル: RESTBaseAPI_t.py プロジェクト: vlimant/CRABServer
 def test_workflow_non_null_submit(self,
                                   fmt='application/json',
                                   page="/test/workflow",
                                   inbody=SUBMIT_BODY):
     """Try submitting job with all the parameters """
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page, headers=h, method="PUT", body=inbody)
コード例 #4
0
ファイル: Daemon_t.py プロジェクト: tsarangi/WMCore
 def test(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     for _ in xrange(0, 10):
         self.getPage("/test/status", headers=h)
         print self.body
         time.sleep(.3)
コード例 #5
0
ファイル: RESTBaseAPI_t.py プロジェクト: cinquo/CRABServer
    def test_upload_tgz(self, fmt='application/json', page="/test/file", inbody = None):
        h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
        # empty of input submit failing with 400
        self.getPage(page, headers=h, method="PUT", body=None)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
        # empty inputfile
        body1 = 'hashkey='+self.checksum
        h1 = h + [('Content-Length', len(body1))]
        self.getPage(page, headers=h1, method="PUT", body=body1)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
        # real upload request
        # TODO this is not working because it gets 'File is not a .tgz file.'
        b2 = """--x
Content-Disposition: form-data; name="inputfile"; filename="%s"
Content-Type: application/x-tar

%s
--x
Content-Disposition: form-data; name="hashkey"

%s
--x--
""" % (self.tgz.name, open(self.tgz.name,'rb').read(), self.checksum)
        h2 = [("Content-type", "multipart/form-data; boundary=x"),
             ("Content-Length", len(b2))]
        self.getPage(page, headers=h+h2, method="PUT", body=b2)
コード例 #6
0
ファイル: Daemon_t.py プロジェクト: lucacopa/WMCore
 def test(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     for _ in xrange(0, 10):
         self.getPage("/test/status", headers=h)
         print self.body
         time.sleep(.3)
コード例 #7
0
ファイル: DataLdapSync.py プロジェクト: zdenekmaxa/sitedb
  def __init__(self, app, baseurl, mount, cacertdir = "/etc/grid-security/certificates", minreq = 1000, interval = 300, instance = "test"):
    Thread.__init__(self, name = "LdapSync")
    self.sectoken = "".join(random.sample(string.letters, 30))
    self._inturl = "http://localhost:%d%s/%s/ldapsync" % \
                   (app.srvconfig.port, mount, instance)
    self._headers = \
      fake_authz_headers(open(app.srvconfig.tools.cms_auth.key_file).read(),
                         method = "Internal", login = self.sectoken,
                         name = self.__class__.__name__, dn = None,
                         roles = {"Global Admin": {"group": ["global"]}}) \
      + [("Accept", "application/json")]

    self._cv = Condition()
    if isinstance(baseurl, str):
      self._baseurl = baseurl

    self._cacertdir = cacertdir
    self._minreq = minreq
    self._interval = interval
    self._stopme = False
    self._full = (0, [], [])
    self._warnings = {}

    self._intreq = RequestManager(num_connections = 2,
                                  user_agent = self._ident,
                                  handle_init = self._handle_init,
                                  request_respond = self._respond,
                                  request_init = self._int_init)
    cherrypy.engine.subscribe("stop", self.stop)
    cherrypy.engine.subscribe("start", self.start)
コード例 #8
0
 def test_exists_json(self,
                      fmt='application/json',
                      page="/test/file",
                      inbody=None):
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     username = [head[1] for head in h if head[0] == 'cms-authn-login'][-1]
     # empty request failing
     self.getPage(page, headers=h, method="GET", body=None)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
     # checking a not existing file
     body1 = '?hashkey=' + str(64 * 'a') + '&nodownload=1'
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("404 Not Found")
     self.assertHeader("X-Error-Http", "404")
     self.assertHeader("X-Error-Detail", "No such instance")
     self.assertHeader("X-Error-Info", "Not found")
     # checking a real file
     tgz, checksum = self._fake_upload_json(username)
     body1 = '?inputfilename=' + os.path.basename(
         tgz.name) + '&nodownload=1'
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Type", fmt)
     self.assertInBody(checksum)
コード例 #9
0
ファイル: DataLdapSync.py プロジェクト: amaltaro/sitedb
  def __init__(self, app, baseurl, mount, cacertdir = "/etc/grid-security/certificates", minreq = 1000, interval = 300, instance = "test"):
    Thread.__init__(self, name = "LdapSync")
    self.sectoken = "".join(random.sample(string.letters, 30))
    self._inturl = "http://localhost:%d%s/%s/ldapsync" % \
                   (app.srvconfig.port, mount, instance)
    self._headers = \
      fake_authz_headers(open(app.srvconfig.tools.cms_auth.key_file).read(),
                         method = "Internal", login = self.sectoken,
                         name = self.__class__.__name__, dn = None,
                         roles = {"Global Admin": {"group": ["global"]}}) \
      + [("Accept", "application/json")]

    self._cv = Condition()
    if isinstance(baseurl, str):
      self._baseurl = baseurl

    self._cacertdir = cacertdir
    self._minreq = minreq
    self._interval = interval
    self._stopme = False
    self._full = (0, [], [])
    self._warnings = {}

    self._intreq = RequestManager(num_connections = 2,
                                  user_agent = self._ident,
                                  handle_init = self._handle_init,
                                  request_respond = self._respond,
                                  request_init = self._int_init)
    cherrypy.engine.subscribe("stop", self.stop)
    cherrypy.engine.subscribe("start", self.start)
コード例 #10
0
ファイル: Simple_t.py プロジェクト: tsarangi/WMCore
 def test_auth_success(self):
     h = fake_authz_headers(T.test_authz_key.data,
                            roles={"Global Admin": {
                                'group': ['global']
                            }})
     self.getPage("/test/global_admin", headers=h)
     self.assertStatus("200 OK")
     self.assertBody("ok")
コード例 #11
0
        def test_worklow_invalid_param(self, fmt = 'application/json', page = "/test/workflow", inbody=None):
            """Try getting workflow with some extra invalid parameter provided"""

            h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
            self.getPage(page + '?workflow=pippo&invalid_param=xxx', headers=h, method="GET", body=inbody)
            self.assertStatus("400 Bad Request")
            self.assertHeader("X-Error-Http", "400")
            self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #12
0
 def test_workflow_get_wo_workflow(self, fmt = 'application/json', page = "/test/workflow", inbody=None):
     """Try getting workflow without workflow parameter provided"""
     
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page + '?subresource=data', headers=h, method="GET", body=inbody)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #13
0
        def test_workflow_invalid_param_only(self,fmt = 'application/json', page = "/test/workflow", inbody=SUBMIT_BODY):
            """Try submitting job with invalid parameter ONLY """

            h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
            self.getPage(page + '?invalid=x',headers=h, method="GET", body=inbody)
            self.assertStatus("400 Bad Request")
            self.assertHeader("X-Error-Http", "400")
            self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #14
0
    def test_worklow_invalid_param(self, fmt = 'application/json', page = "/test/workflow", inbody=None):
        """Try getting workflow with some extra invalid parameter provided"""

        h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
        self.getPage(page + '?workflow=pippo&invalid_param=xxx', headers=h, method="GET", body=inbody)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #15
0
    def test_workflow_empty_submit(self, fmt = 'application/json', page = "/test/workflow",inbody = None):
        """Try to submit workflow without any parameters"""

        h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
        self.getPage(page, headers=h, method="PUT", body=inbody)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #16
0
 def test_workflow_get_wo_workflow(self, fmt = 'application/json', page = "/test/workflow", inbody=None):
     """Try getting workflow without workflow parameter provided"""
     
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page + '?subresource=data', headers=h, method="GET", body=inbody)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #17
0
    def test_workflow_invalid_param_only(self,fmt = 'application/json', page = "/test/workflow", inbody=SUBMIT_BODY):
        """Try submitting job with invalid parameter ONLY """

        h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
        self.getPage(page + '?invalid=x',headers=h, method="GET", body=inbody)
        self.assertStatus("400 Bad Request")
        self.assertHeader("X-Error-Http", "400")
        self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #18
0
        def test_workflow_empty_submit(self, fmt = 'application/json', page = "/test/workflow",inbody = None):
            """Try to submit workflow without any parameters"""

            h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
            self.getPage(page, headers=h, method="PUT", body=inbody)
            self.assertStatus("400 Bad Request")
            self.assertHeader("X-Error-Http", "400")
            self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #19
0
 def test_workflow_too_long_param(self, fmt = 'application/json', page = "/test/workflow", inbody=None):
     """Try getting workflow with random and too long parameter provided """
     
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     randomlongname=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(200))
     self.getPage(page + '?workflow='+randomlongname, headers=h, method="GET", body=inbody)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #20
0
def getAuthHeader(hmacData, reqAuth):
    roles = {}
    for role in reqAuth['role']:
        roles[role] = {'group': reqAuth['group']}

    return fake_authz_headers(hmacData,
                              dn="/TEST/DN/CN",
                              roles=roles,
                              format="dict")
コード例 #21
0
 def test_workflow_too_long_param(self, fmt = 'application/json', page = "/test/workflow", inbody=None):
     """Try getting workflow with random and too long parameter provided """
     
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     randomlongname=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(200))
     self.getPage(page + '?workflow='+randomlongname, headers=h, method="GET", body=inbody)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
コード例 #22
0
ファイル: Api_t.py プロジェクト: AndrewLevin/WMCore
 def test_multi_throw5b(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     self.getPage("/test/multi?lim=5", headers = h)
     self.assertStatus(400)
     self.assertHeader("X-REST-Status", "200")
     self.assertHeader("X-Error-HTTP", "400")
     self.assertHeader("X-Error-Info", "cut at 5")
     self.assertHeader("X-Error-Detail", "Invalid object")
     self.assertHeader("X-Error-ID")
コード例 #23
0
ファイル: Api_t.py プロジェクト: lucacopa/WMCore
 def test_multi_throw5b(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     self.getPage("/test/multi?lim=5", headers=h)
     self.assertStatus(400)
     self.assertHeader("X-REST-Status", "200")
     self.assertHeader("X-Error-HTTP", "400")
     self.assertHeader("X-Error-Info", "cut at 5")
     self.assertHeader("X-Error-Detail", "Invalid object")
     self.assertHeader("X-Error-ID")
コード例 #24
0
ファイル: Api_t.py プロジェクト: AndrewLevin/WMCore
 def _test_accept_fail(self, fmt, page="/test/simple",
                       avail="application/json, application/xml"):
     h = fake_authz_headers(T.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page, headers = h)
     self.assertStatus("406 Not Acceptable")
     self.assertHeader("X-REST-Status", "201")
     self.assertHeader("X-REST-Time")
     self.assertHeader("X-Error-ID")
     self.assertHeader("X-Error-HTTP", "406")
     self.assertHeader("X-Error-Info", "Available types: %s" % avail)
     self.assertHeader("X-Error-Detail", "Not acceptable")
     self.assertInBody("Not acceptable")
コード例 #25
0
ファイル: Api_t.py プロジェクト: lucacopa/WMCore
 def test_simple_json(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     self.getPage("/test/simple", headers=h)
     self.assertStatus("200 OK")
     b = cjson.decode(self.body)
     assert isinstance(b, dict)
     assert "desc" not in b
     assert "result" in b
     assert isinstance(b["result"], list)
     assert len(b["result"]) == 1
     assert b["result"][0] == "foo"
コード例 #26
0
ファイル: Api_t.py プロジェクト: AndrewLevin/WMCore
 def test_simple_json(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     self.getPage("/test/simple", headers = h)
     self.assertStatus("200 OK")
     b = cjson.decode(self.body)
     assert isinstance(b, dict)
     assert "desc" not in b
     assert "result" in b
     assert isinstance(b["result"], list)
     assert len(b["result"]) == 1
     assert b["result"][0] == "foo"
コード例 #27
0
ファイル: Api_t.py プロジェクト: lucacopa/WMCore
 def _test_accept_fail(self,
                       fmt,
                       page="/test/simple",
                       avail="application/json, application/xml"):
     h = fake_authz_headers(T.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page, headers=h)
     self.assertStatus("406 Not Acceptable")
     self.assertHeader("X-REST-Status", "201")
     self.assertHeader("X-REST-Time")
     self.assertHeader("X-Error-ID")
     self.assertHeader("X-Error-HTTP", "406")
     self.assertHeader("X-Error-Info", "Available types: %s" % avail)
     self.assertHeader("X-Error-Detail", "Not acceptable")
     self.assertInBody("Not acceptable")
コード例 #28
0
ファイル: RESTBaseAPI_t.py プロジェクト: cinquo/CRABServer
 def test_download_tgz(self, fmt='application/octet-stream', page="/test/file", inbody = None):
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     # empty request failing
     self.getPage(page, headers=h, method="GET", body=None)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
     # real file upload
     tgz, checksum = self._fake_upload_isb()
     body1 = '?hashkey='+checksum
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Disposition", 'attachment; filename="%s"' % checksum)
     self.assertHeader("Content-Type", fmt)
コード例 #29
0
ファイル: Api_t.py プロジェクト: AndrewLevin/WMCore
 def test_simple_json_deflate(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     h.append(("Accept-Encoding", "deflate"))
     self.getPage("/test/simple", headers = h)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Length")
     self.assertHeader("Content-Encoding", "deflate")
     b = cjson.decode(zlib.decompress(self.body, -zlib.MAX_WBITS))
     assert isinstance(b, dict)
     assert "desc" not in b
     assert "result" in b
     assert isinstance(b["result"], list)
     assert len(b["result"]) == 1
     assert b["result"][0] == "foo"
コード例 #30
0
ファイル: Api_t.py プロジェクト: lucacopa/WMCore
 def test_simple_json_deflate(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     h.append(("Accept-Encoding", "deflate"))
     self.getPage("/test/simple", headers=h)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Length")
     self.assertHeader("Content-Encoding", "deflate")
     b = cjson.decode(zlib.decompress(self.body, -zlib.MAX_WBITS))
     assert isinstance(b, dict)
     assert "desc" not in b
     assert "result" in b
     assert isinstance(b["result"], list)
     assert len(b["result"]) == 1
     assert b["result"][0] == "foo"
コード例 #31
0
ファイル: RESTBaseAPI_t.py プロジェクト: cinquo/CRABServer
 def test_download_json(self, fmt='application/octet-stream', page="/test/file", inbody = None):
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     username = [head[1] for head in h if head[0] == 'cms-authn-login'][-1]
     # empty request failing
     self.getPage(page, headers=h, method="GET", body=None)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
     # real file download
     tgz, checksum = self._fake_upload_json(username)
     body1 = '?inputfilename='+os.path.basename(tgz.name)
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Disposition", 'attachment; filename="%s"' % os.path.basename(tgz.name))
     self.assertHeader("Content-Type", fmt)
コード例 #32
0
ファイル: Api_t.py プロジェクト: AndrewLevin/WMCore
 def _test_accept_ok(self, fmt, page = "/test/simple", inbody = None):
     h = fake_authz_headers(T.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page, headers = h)
     self.assertStatus("200 OK")
     if fmt.find("*") >= 0:
         self.assertHeader("Content-Type")
     else:
         self.assertHeader("Content-Type", fmt)
     self.assertHeader("X-REST-Status", "100")
     self.assertHeader("X-REST-Time")
     self.assertNoHeader("X-Error-ID")
     self.assertNoHeader("X-Error-HTTP")
     self.assertNoHeader("X-Error-Info")
     self.assertNoHeader("X-Error-Detail")
     if inbody:
         self.assertInBody(inbody)
コード例 #33
0
ファイル: Api_t.py プロジェクト: AndrewLevin/WMCore
 def test_multi_throw10(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     self.getPage("/test/multi?lim=10&etag=x", headers = h)
     self.assertStatus("200 OK")
     self.assertHeader("X-REST-Status", "100")
     b = cjson.decode(self.body)
     assert isinstance(b, dict)
     assert "desc" not in b
     assert "result" in b
     assert isinstance(b["result"], list)
     assert len(b["result"]) == 10
     for i in xrange(0, 10):
         assert isinstance(b["result"][i], list)
         assert b["result"][i][0] == "row"
         assert b["result"][i][1] == i
コード例 #34
0
ファイル: Api_t.py プロジェクト: lucacopa/WMCore
 def test_multi_throw10(self):
     h = fake_authz_headers(T.test_authz_key.data)
     h.append(("Accept", "application/json"))
     self.getPage("/test/multi?lim=10&etag=x", headers=h)
     self.assertStatus("200 OK")
     self.assertHeader("X-REST-Status", "100")
     b = cjson.decode(self.body)
     assert isinstance(b, dict)
     assert "desc" not in b
     assert "result" in b
     assert isinstance(b["result"], list)
     assert len(b["result"]) == 10
     for i in xrange(0, 10):
         assert isinstance(b["result"][i], list)
         assert b["result"][i][0] == "row"
         assert b["result"][i][1] == i
コード例 #35
0
ファイル: Api_t.py プロジェクト: lucacopa/WMCore
 def _test_accept_ok(self, fmt, page="/test/simple", inbody=None):
     h = fake_authz_headers(T.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page, headers=h)
     self.assertStatus("200 OK")
     if fmt.find("*") >= 0:
         self.assertHeader("Content-Type")
     else:
         self.assertHeader("Content-Type", fmt)
     self.assertHeader("X-REST-Status", "100")
     self.assertHeader("X-REST-Time")
     self.assertNoHeader("X-Error-ID")
     self.assertNoHeader("X-Error-HTTP")
     self.assertNoHeader("X-Error-Info")
     self.assertNoHeader("X-Error-Detail")
     if inbody:
         self.assertInBody(inbody)
コード例 #36
0
 def test_download_tgz(self,
                       fmt='application/octet-stream',
                       page="/test/file",
                       inbody=None):
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     # empty request failing
     self.getPage(page, headers=h, method="GET", body=None)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
     # real file upload
     tgz, checksum = self._fake_upload_isb()
     body1 = '?hashkey=' + checksum
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Disposition",
                       'attachment; filename="%s"' % checksum)
     self.assertHeader("Content-Type", fmt)
コード例 #37
0
 def test_download_json(self,
                        fmt='application/octet-stream',
                        page="/test/file",
                        inbody=None):
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     username = [head[1] for head in h if head[0] == 'cms-authn-login'][-1]
     # empty request failing
     self.getPage(page, headers=h, method="GET", body=None)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
     # real file download
     tgz, checksum = self._fake_upload_json(username)
     body1 = '?inputfilename=' + os.path.basename(tgz.name)
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("200 OK")
     self.assertHeader(
         "Content-Disposition",
         'attachment; filename="%s"' % os.path.basename(tgz.name))
     self.assertHeader("Content-Type", fmt)
コード例 #38
0
ファイル: RESTBaseAPI_t.py プロジェクト: cinquo/CRABServer
 def test_exists_tgz(self, fmt='application/json', page="/test/file", inbody = None):
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     # empty request failing
     self.getPage(page, headers=h, method="GET", body=None)
     self.assertStatus("400 Bad Request")
     self.assertHeader("X-Error-Http", "400")
     self.assertHeader("X-Error-Detail", "Invalid input parameter")
     # checking a not existing file
     body1 = '?hashkey='+str(64*'a')+'&nodownload=1'
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("404 Not Found")
     self.assertHeader("X-Error-Http", "404")
     self.assertHeader("X-Error-Detail", "No such instance")
     self.assertHeader("X-Error-Info", "Not found")
     # checking a real file
     tgz, checksum = self._fake_upload_isb()
     body1 = '?hashkey='+checksum+'&nodownload=1'
     self.getPage(page + body1, headers=h, method="GET", body=inbody)
     self.assertStatus("200 OK")
     self.assertHeader("Content-Type", fmt)
     self.assertInBody(checksum)
コード例 #39
0
ファイル: Simple_t.py プロジェクト: stuartw/WMCore
 def test_auth_success(self):
   h = fake_authz_headers(T.test_authz_key.data, roles = {"Global Admin": {'group': ['global']}})
   self.getPage("/test/global_admin", headers = h)
   self.assertStatus("200 OK")
   self.assertBody("ok")
コード例 #40
0
ファイル: ReqMgr_t.py プロジェクト: mmascher/WMCore
def getAuthHeader(hmacData, reqAuth):
    roles = {}
    for role in reqAuth['role']:
        roles[role] = {'group': reqAuth['group']}
        
    return fake_authz_headers(hmacData, roles = roles, format = "dict") 
コード例 #41
0
 def test_workflow_non_null_submit(self, fmt = 'application/json', page = "/test/workflow",inbody = SUBMIT_BODY):
     """Try submitting job with all the parameters """
     h = fake_authz_headers(RT.test_authz_key.data) + [("Accept", fmt)]
     self.getPage(page, headers=h, method="PUT", body=inbody)
コード例 #42
0
ファイル: Simple_t.py プロジェクト: stuartw/WMCore
 def test_basic_success(self):
   h = fake_authz_headers(T.test_authz_key.data)
   self.getPage("/test", headers = h)
   self.assertStatus("200 OK")
   self.assertBody("foo")
コード例 #43
0
ファイル: ReqMgr_t.py プロジェクト: pietverwilligen/WMCore
def getAuthHeader(hmacData, reqAuth):
    roles = {}
    for role in reqAuth["role"]:
        roles[role] = {"group": reqAuth["group"]}

    return fake_authz_headers(hmacData, dn="/TEST/DN/CN", roles=roles, format="dict")
コード例 #44
0
ファイル: Simple_t.py プロジェクト: stuartw/WMCore
 def test_auth_fail(self):
   h = fake_authz_headers(T.test_authz_key.data)
   self.getPage("/test/global_admin", headers = h)
   self.assertStatus("403 Forbidden")
コード例 #45
0
ファイル: Simple_t.py プロジェクト: tsarangi/WMCore
 def test_basic_success(self):
     h = fake_authz_headers(T.test_authz_key.data)
     self.getPage("/test", headers=h)
     self.assertStatus("200 OK")
     self.assertBody("foo")
コード例 #46
0
ファイル: Simple_t.py プロジェクト: BrunoCoimbra/WMCore
 def setUp(self):
     self.h = fake_authz_headers(FAKE_FILE.data)
     self.hglobal = fake_authz_headers(FAKE_FILE.data, roles = {"Global Admin": {'group': ['global']}})
     webtest.WebCase.PORT = PORT
     self.engine = cherrypy.engine
     self.proc = load_server(self.engine)
コード例 #47
0
ファイル: Simple_t.py プロジェクト: tsarangi/WMCore
 def test_auth_fail(self):
     h = fake_authz_headers(T.test_authz_key.data)
     self.getPage("/test/global_admin", headers=h)
     self.assertStatus("403 Forbidden")
コード例 #48
0
ファイル: Daemon_t.py プロジェクト: vytjan/WMCore
 def setUp(self):
     self.h = fake_authz_headers(FAKE_FILE.data)
     webtest.WebCase.PORT = PORT
     self.engine = cherrypy.engine
     self.proc = load_server(self.engine)
コード例 #49
0
ファイル: Daemon_t.py プロジェクト: huohuo21/WMCore
 def setUp(self):
     self.h = fake_authz_headers(FAKE_FILE.data)
     webtest.WebCase.PORT = PORT
     self.engine = cherrypy.engine
     self.proc = load_server(self.engine)