Ejemplo n.º 1
0
 def determineAuthentication(self):
     authFailures = 0
     while authFailures < 2:
         try:
             self.resource.getCollectionContents()
         except AuthorizationError as e:
             if e.authType == "Basic":
                 #self.password = QInputDialog.getText(None, "WebDav Inventory Password", "WebDav Inventory is asking for Basic authentication\n\nPlease give your password:"******"")
                 #self.password = "" # CableBeach server does not check passwords yet
                 self.resource.connection.addBasicAuthorization(
                     self.user, str(self.password))
             elif e.authType == "Digest":
                 #self.password = QInputDialog.getText(None, "WebDav Inventory Password", "WebDav Inventory is asking for Digest authentication\n\nPlease give your password:"******"")
                 #self.password = "" # CableBeach server does not check passwords yet
                 info = WebdavClient.parseDigestAuthInfo(e.authInfo)
                 self.resource.connection.addDigestAuthorization(
                     self.user,
                     self.password,
                     realm=info["realm"],
                     qop=info["qop"],
                     nonce=info["nonce"])
             else:
                 raise WebdavError
         except HTTPException:
             raise HTTPException
         authFailures += 1
Ejemplo n.º 2
0
 def resendAuthorization(self, AuthError):
     print ''
     print '---------------------------------------------------------'
     print 'AuthorizationError was raised, trying to resend auth data'
     print '---------------------------------------------------------'
     if AuthError.authType == "Basic":
         self.resource.connection.addBasicAuthorization(
             self.user, str(self.password))
     elif AuthError.authType == "Digest":
         info = WebdavClient.parseDigestAuthInfo(AuthError.authInfo)
         self.resource.connection.addDigestAuthorization(
             self.user,
             self.password,
             realm=info["realm"],
             qop=info["qop"],
             nonce=info["nonce"])
     else:
         raise WebdavError
     try:
         self.resource.getCollectionContents()
         print "----------- RE-AUTHENTICATION SUCCESFULL ------------\n"
     except AuthorizationError as e:
         print "-------- TRIED TO RE-AUTHENTICATE BUT FAILED --------\n"
         print "Please restart your viewer and reconnect to fix,"
         print "webdav inventory is in early dev state and "
         print "reauthentication is not fully working."
Ejemplo n.º 3
0
 def __init__(self, *args, **kw):
     unittest.TestCase.__init__(self, *args, **kw)
     self.url = BASE_URL
     if len(sys.argv) > 1:
         self.url = sys.argv[1]
     print "init ", self.url
     self.resource = WebdavClient.CollectionStorer(self.url)
Ejemplo n.º 4
0
 def setCollectionStorerToPath(self, path):
     try:
         self.resource = WebdavClient.CollectionStorer(self.url + path, self.resource.connection)
         return True
     except AuthorizationError as AuthError:
         self.resendAuthorization(AuthError)
     except WebdavError:
         return False
Ejemplo n.º 5
0
 def setupConnection(self):
     if (self.connection != None):
         self.connection = None
     try:
         self.resource = WebdavClient.CollectionStorer(self.url, self.connection)
         self.determineAuthentication()
         return True
     except WebdavError:
         raise HTTPException
Ejemplo n.º 6
0
 def __init__(self, *args, **kw):
     unittest.TestCase.__init__(self, *args, **kw)
     self.url = url
     print "init ", self.url
     self.resource = WebdavClient.CollectionStorer(
         self.url, ClientTestCase.connection)
     if not ClientTestCase.connection:
         ClientTestCase.connection = self.resource.connection
     if len(user) > 0:
         self.resource.connection.addBasicAuthorization(user, password)
Ejemplo n.º 7
0
 def __init__(self, *args, **kw):
     unittest.TestCase.__init__(self, *args, **kw)
     print "init URL=", url
     self.resource = WebdavClient.CollectionStorer(
         url, ExtensionTestCase.connection)
     if not ExtensionTestCase.connection:
         ExtensionTestCase.connection = self.resource.connection
     if user:
         print "User", user, "Password:", password
         self.resource.connection.addBasicAuthorization(user, password)
Ejemplo n.º 8
0
 def __init__(self, *args, **kw):
     unittest.TestCase.__init__(self, *args, **kw)
     print "init URL=", url
     self.resource = WebdavClient.CollectionStorer(
         url, UnicodeTestCase.connection)
     if not UnicodeTestCase.connection:
         UnicodeTestCase.connection = self.resource.connection
     if user:
         print "User", user, "Password:"******"slide") < 0:  # is this a Tamino server ?
         self.resource.connection.TAMINO_URL_ENCODE_BUG = 0
Ejemplo n.º 9
0
 def updateVersion(self):
     print "Creating second versions with"
     storer = WebdavClient.ResourceStorer(url + '/new',
                                          ExtensionTestCase.connection)
     # checkout resource
     storer.checkout()
     # PUT request/ update data
     storer.uploadContent("New binary content")
     # unlock
     storer.checkin()
     # view versions
     result = storer.listAllVersions()
     printresult(result)
Ejemplo n.º 10
0
 def determineAuthentication(self):       
     authFailures = 0
     while authFailures < 2:
         try:
             self.resource.getCollectionContents()
         except AuthorizationError as e:                           
             if e.authType == "Basic":
                 #self.password = QInputDialog.getText(None, "WebDav Inventory Password", "WebDav Inventory is asking for Basic authentication\n\nPlease give your password:"******"")
                 self.password = "" # CableBeach server does not check passwords yet
                 self.resource.connection.addBasicAuthorization(self.user, str(self.password))
             elif e.authType == "Digest":
                 #self.password = QInputDialog.getText(None, "WebDav Inventory Password", "WebDav Inventory is asking for Digest authentication\n\nPlease give your password:"******"")
                 self.password = "" # CableBeach server does not check passwords yet
                 info = WebdavClient.parseDigestAuthInfo(e.authInfo)
                 self.resource.connection.addDigestAuthorization(self.user, self.password, realm=info["realm"], qop=info["qop"], nonce=info["nonce"])
             else:
                 raise WebdavError
         except HTTPException:
             raise HTTPException
         authFailures += 1
Ejemplo n.º 11
0
 def resendAuthorization(self, AuthError):
     print ''
     print '---------------------------------------------------------'
     print 'AuthorizationError was raised, trying to resend auth data'
     print '---------------------------------------------------------'
     if AuthError.authType == "Basic":
         self.resource.connection.addBasicAuthorization(self.user, str(self.password))
     elif AuthError.authType == "Digest":
         info = WebdavClient.parseDigestAuthInfo(AuthError.authInfo)
         self.resource.connection.addDigestAuthorization(self.user, self.password, realm=info["realm"], qop=info["qop"], nonce=info["nonce"])
     else:
         raise WebdavError
     try:
         self.resource.getCollectionContents()
         print "----------- RE-AUTHENTICATION SUCCESFULL ------------\n"
     except AuthorizationError as e:
         print "-------- TRIED TO RE-AUTHENTICATE BUT FAILED --------\n"
         print "Please restart your viewer and reconnect to fix,"
         print "webdav inventory is in early dev state and "
         print "reauthentication is not fully working."
Ejemplo n.º 12
0
 def updateAutoVersion(self):
     print "Test adding a new version"
     storer = WebdavClient.ResourceStorer(url + '/new',
                                          ExtensionTestCase.connection)
     # lock resource
     lockToken = storer.lock(user)
     try:
         # PUT request/ update data
         storer.uploadContent("New binary content", lockToken)
         storer.writeProperties({('TENT:', 'features'): "X4711"}, lockToken)
     finally:  # unlock
         storer.unlock(lockToken)
     # view versions
     result = storer.listAllVersions()
     print "Existing versions of 'new':"
     for item in result:
         print "\t", item
     self.failUnless(
         len(result) == 2,
         "Two versions expected insted of %d." % len(result))
Ejemplo n.º 13
0
def valid_resource(resource, user, password):
    resource = WebdavClient.ResourceStorer(resource)
    resource.connection.addBasicAuthorization(user, password)
    return resource
Ejemplo n.º 14
0
def valid_collection(directory, user, password):
    resource = WebdavClient.CollectionStorer(directory)
    resource.connection.addBasicAuthorization(user, password)
    return resource
Ejemplo n.º 15
0
 def setUp(self):
     self.resource = WebdavClient.CollectionStorer(self.url)
     self.resource.connection.addBasicAuthorization(self.username,
                                                    self.password)