예제 #1
0
파일: linktest.py 프로젝트: x2wing/h5serv
    def testPutExternalLink(self):
        logging.info("LinkTest.testPutExternalLink")
        domain = 'tall_updated.' + config.get('domain')
        target_domain = 'external_target.' + config.get('domain')
        target_path = '/dset1'
        grpId = helper.createGroup(domain)
        rootId = helper.getRootUUID(domain)
        name = 'extlink'
        req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
        payload = {"h5path": target_path, "h5domain": target_domain}
        headers = {'host': domain}
        # verify extlink does not exist
        rsp = requests.get(req, data=json.dumps(payload), headers=headers)
        self.assertEqual(rsp.status_code, 404)
        # make request
        rsp = requests.put(req, data=json.dumps(payload), headers=headers)
        self.assertEqual(rsp.status_code, 201)
        # verify link is created
        rsp = requests.get(req, data=json.dumps(payload), headers=headers)
        self.assertEqual(rsp.status_code, 200)
        # verify that it is an external link
        rspJson = json.loads(rsp.text)
        target = rspJson['link']

        self.assertEqual(target['class'], 'H5L_TYPE_EXTERNAL')
        self.assertEqual(target['h5domain'], target_domain)
        self.assertEqual(target['h5path'], target_path)
예제 #2
0
파일: linktest.py 프로젝트: DrKenHo/h5serv
 def testPutExternalLink(self):
     logging.info("LinkTest.testPutExternalLink")
     domain = 'tall_updated.' + config.get('domain') 
     target_domain = 'external_target.' + config.get('domain')  
     target_path = '/dset1'
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'extlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"h5path": target_path, "h5domain": target_domain}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201) 
     # verify link is created
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     # verify that it is an external link
     rspJson = json.loads(rsp.text)   
     target = rspJson['link']
           
     self.failUnlessEqual(target['class'], 'H5L_TYPE_EXTERNAL')
     self.failUnlessEqual(target['h5domain'], target_domain)
     self.failUnlessEqual(target['h5path'], target_path)
예제 #3
0
 def testPutNoName(self):
     logging.info("LinkTest.testPutNoName")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/"
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
예제 #4
0
파일: linktest.py 프로젝트: Dorianux/h5serv
 def testPutNoName(self):
     logging.info("LinkTest.testPutNoName")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/"  
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
예제 #5
0
파일: linktest.py 프로젝트: HDFGroup/h5serv
 def testPutBadName(self):
     logging.info("LinkTest.testPutBadName")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'bad/name'  # forward slash not allowed
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 400)
예제 #6
0
 def testPutBadReqId(self):
     logging.info("LinkTest.testPutBadReqId")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     badReqId = 'b2771194-347f-11e4-bb67-3c15c2da029e'  # doesn't exist in tall.h5
     name = 'g3'
     req = helper.getEndpoint() + "/groups/" + badReqId + "/links/" + name
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
예제 #7
0
파일: linktest.py 프로젝트: Dorianux/h5serv
 def testPutBadReqId(self):
     logging.info("LinkTest.testPutBadReqId")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     badReqId  = 'b2771194-347f-11e4-bb67-3c15c2da029e' # doesn't exist in tall.h5
     name = 'g3'
     req = helper.getEndpoint() + "/groups/" + badReqId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
예제 #8
0
파일: linktest.py 프로젝트: x2wing/h5serv
 def testPutBadName(self):
     logging.info("LinkTest.testPutBadName")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'bad/name'  # forward slash not allowed
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 400)
예제 #9
0
파일: linktest.py 프로젝트: Dorianux/h5serv
 def testPut(self):
     logging.info("LinkTest.testPut")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'g3'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)  # link doesn't exist
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)  # it's there now!
     # make a request second time (verify idempotent)
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     # now try with a different payload
     grpId2 = helper.createGroup(domain)
     payload["id"] = grpId2
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
예제 #10
0
 def testPut(self):
     logging.info("LinkTest.testPut")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'g3'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)  # link doesn't exist
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)  # it's there now!
     # make a request second time (verify idempotent)
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     # now try with a different payload
     grpId2 = helper.createGroup(domain)
     payload["id"] = grpId2
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
예제 #11
0
 def testPutExternalLink(self):
     logging.info("LinkTest.testPutExternalLink")
     domain = 'tall_updated.' + config.get('domain') 
     href = 'http://external_target.' + config.get('domain') + '/#h5path(/dset1)'
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'extlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"href": href}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201) 
예제 #12
0
파일: linktest.py 프로젝트: Dorianux/h5serv
 def testPutExternalMissingPath(self):
     logging.info("LinkTest.testPutExternalMissingPath")
     fakeId = "14bfeeb8-68b1-11e4-a69a-3c15c2da029e"
     domain = 'tall_updated.' + config.get('domain') 
     external_domain = 'external_target.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'extlinkid'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"h5domain": external_domain}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)     
예제 #13
0
 def testPutExternalLink(self):
     logging.info("LinkTest.testPutExternalLink")
     domain = 'tall_updated.' + config.get('domain')
     href = 'http://external_target.' + config.get(
         'domain') + '/#h5path(/dset1)'
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'extlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"href": href}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
예제 #14
0
파일: linktest.py 프로젝트: x2wing/h5serv
 def testPutExternalMissingPath(self):
     logging.info("LinkTest.testPutExternalMissingPath")
     fakeId = "14bfeeb8-68b1-11e4-a69a-3c15c2da029e"
     domain = 'tall_updated.' + config.get('domain')
     external_domain = 'external_target.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'extlinkid'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"h5domain": external_domain}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 400)
예제 #15
0
 def testPutExternalLinkBadHref(self):
     logging.info("LinkTest.testPutExternalLinkId")
     fakeId = "14bfeeb8-68b1-11e4-a69a-3c15c2da029e"
     domain = 'tall_updated.' + config.get('domain')
     href = 'http://external_target.' + config.get(
         'domain') + '/foobar/' + fakeId
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'extlinkid'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"href": href}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
예제 #16
0
파일: linktest.py 프로젝트: HDFGroup/h5serv
 def testPutNameWithSpaces(self):
     logging.info("LinkTest.testPutNameWithSpaces")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'name with spaces'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 201)
     # verify we can read the link back
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue("link" in rspJson)
     link = rspJson["link"]
     self.assertTrue("title" in link)
     self.assertEqual(link["title"], name)
     self.assertTrue("class" in link)
     self.assertEqual(link["class"], "H5L_TYPE_HARD")
예제 #17
0
 def testPutSoftLink(self):
     logging.info("LinkTest.testPutSoftLink")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'softlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"h5path": "/somewhere"}
     headers = {'host': domain}
     # verify softlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     # verify link is created
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     # verify idempotent
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
예제 #18
0
파일: linktest.py 프로젝트: Dorianux/h5serv
 def testPutSoftLink(self):
     logging.info("LinkTest.testPutSoftLink")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'softlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"h5path": "/somewhere"}
     headers = {'host': domain}
     # verify softlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     # verify link is created
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     # verify idempotent
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
예제 #19
0
파일: linktest.py 프로젝트: x2wing/h5serv
 def testPutNameWithSpaces(self):
     logging.info("LinkTest.testPutNameWithSpaces")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'name with spaces'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 201)
     # verify we can read the link back
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue("link" in rspJson)
     link = rspJson["link"]
     self.assertTrue("title" in link)
     self.assertEqual(link["title"], name)
     self.assertTrue("class" in link)
     self.assertEqual(link["class"], "H5L_TYPE_HARD")
예제 #20
0
    def testDelete(self):
        logging.info("LinkTest.testDelete")
        domain = 'tall_updated.' + config.get('domain')
        grpId = helper.createGroup(domain)
        rootId = helper.getRootUUID(domain)
        name = 'deleteme'
        req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
        payload = {"id": grpId}
        headers = {'host': domain}
        rsp = requests.put(req, data=json.dumps(payload), headers=headers)
        self.failUnlessEqual(rsp.status_code, 201)

        # now remove the link
        rsp = requests.delete(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)

        # get should fail
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 410)

        # Group should still be accessible via uuid
        req = self.endpoint + "/groups/" + grpId
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)
예제 #21
0
파일: linktest.py 프로젝트: Dorianux/h5serv
 def testDelete(self):
     logging.info("LinkTest.testDelete")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'deleteme'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     
     # now remove the link
     rsp = requests.delete(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     
     # get should fail
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 410)   
     
     # Group should still be accessible via uuid
     req = self.endpoint + "/groups/" + grpId
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)