def setUp(self): # print "setUp" if EXTERNAL_SERVER_ADDRESS: self.server_thread = None self.client = davclient.DAVClient(EXTERNAL_SERVER_ADDRESS) else: self.server_thread = WsgiDAVServerThread() self.server_thread.start() # let server start the loop, otherwise shutdown might lock time.sleep(.1) self.client = davclient.DAVClient("http://127.0.0.1:8080/") self.client.set_basic_auth("tester", "tester")
MyLog.info('building transfer records') # transfer records FileList = glob.glob('data/wims/*.fw9') FileName = 'data/wims/transfer/fl-wx-data.fw9' Output = [] for fw9File in FileList: fw9data = open(fw9File, 'r').readlines() for d in fw9data: Output.append(d) TransferFile = open(FileName, 'w') for d in Output: TransferFile.write(d) TransferFile.close() MyLog.info('transferring data') client = davclient.DAVClient(url) client.set_basic_auth(user, passwd) myFile = open(FileName, 'r') name = FileName.split('/')[-1] client.put(dest + name, f=myFile) #log = open('nfdrs.log','a') #log.write('wims processing completed on '+time.asctime()+'\n' ) #log.close() MyLog.info('wims processing completed on ' + time.asctime() + '\n') except Exception, err: MyLog.error('wims processing failed %s' % err) emailIt.emailMsg('%s - Error: wims processing failed %s' % (MyApp, err)) sys.exit(1)
def testLocking(self): """Locking.""" client1 = self.client client2 = davclient.DAVClient("http://127.0.0.1:8080/") client2.set_basic_auth("tester2", "tester2") self._prepareTree0() # --- Check with deoth-infinity lock ----------------------------------- # LOCK-infinity parent collection and try to access members locks = client1.set_lock("/test/a", owner="test-bench", locktype="write", lockscope="exclusive", depth="infinity") client1.checkResponse(200) assert len(locks) == 1, "LOCK failed" token = locks[0] # Unlock with correct token, but other principal: expect '403 Forbidden' client2.unlock("/test/a", token) client2.checkResponse(403) # Check that commonly protected operations fail self._checkCommonLock(client2) # Check operations that are only protected when /test/a is locked # with depth-infinity locks = client2.set_lock("/test/a/b/c", owner="test-bench", locktype="write", lockscope="exclusive", depth="0") client2.checkResponse(423) locks = client2.set_lock("/test/a/b/d", owner="test-bench", locktype="write", lockscope="exclusive", depth="infinity") client2.checkResponse(423) locks = client2.set_lock("/test/a/b/c", owner="test-bench", locktype="write", lockscope="exclusive", depth="0") client2.checkResponse(423) # client1 can LOCK /a and /a/b/d at the same time, but must # provide both tokens in order to access a/b/d # TODO: correct? # locks = client1.set_lock("/test/a/b/d", # owner="test-bench", # locktype="write", # lockscope="exclusive", # depth="0") # client1.checkResponse(200) # assert len(locks) == 1, "Locking inside below locked collection failed" # tokenABD = locks[0] # --- Check with depth-0 lock ------------------------------------------ # LOCK-0 parent collection and try to access members client1.unlock("/test/a", token) client1.checkResponse(204) locks = client1.set_lock("/test/a", owner="test-bench", locktype="write", lockscope="exclusive", depth="0") client1.checkResponse(200) assert len(locks) == 1, "LOCK failed" token = locks[0] # Check that commonly protected operations fail self._checkCommonLock(client2) # These operations are allowed with depth-0 # Modifying member properties is allowed client2.proppatch("/test/a/c", set_props=[("{testns:}testname", "testval")]) client2.checkMultiStatusResponse(200) # Modifying a member without creating a new resource is allowed client2.put("/test/a/c", "data") client2.checkResponse(204) # Modifying non-internal member resources is allowed client2.put("/test/a/b/f", "data") client2.checkResponse(201) client2.mkcol("/test/a/b/g") client2.checkResponse(201) client2.move("/test/a/b/g", "/test/a/b/g2") client2.checkResponse(201) client2.delete("/test/a/b/g2") client2.checkResponse(204) # --- Check root access, when a child is locked ------------------------ client1.unlock("/test/a", token) client1.checkResponse(204) locks = client1.set_lock("/test/a/b/d", owner="test-bench", locktype="write", lockscope="exclusive", depth="0") client1.checkResponse(200) assert len(locks) == 1, "LOCK failed" token = locks[0] # LOCK /a/b/d, then DELETE /a/b/ # --> Must delete all but a/b/d (expect 423 Locked inside Multistatus) client2.delete("/test/a/b") # print client2.response.body client2.checkMultiStatusResponse(423)