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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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")
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)
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)