Revision 96738a78 pithos/tools/pithos-test

b/pithos/tools/pithos-test
41 41
from StringIO import StringIO
42 42
from hashlib import new as newhasher
43 43
from binascii import hexlify
44
from httplib import HTTPConnection
45
from urlparse import urlparse
44 46

  
45 47
import json
46 48
import unittest
......
1833 1835
        self.client.share_object('φάκελος', 'ο1', ['%s:σεφς' % get_user()])
1834 1836
        chef = Pithos_Client(get_url(),
1835 1837
                            '0009',
1836
                            'διογένης',
1837
                            get_api())
1838
                            'διογένης')
1838 1839
        self.assert_not_raises_fault(403, chef.retrieve_object_metadata,
1839 1840
                                     'φάκελος', 'ο1', account=get_user())
1840 1841
        
......
1892 1893
    
1893 1894
    def assert_read(self, authorized=[], any=False):
1894 1895
        for token, account in OTHER_ACCOUNTS.items():
1895
            cl = Pithos_Client(get_url(), token, account, get_api()) 
1896
            cl = Pithos_Client(get_url(), token, account)
1896 1897
            if account in authorized or any:
1897 1898
                self.assert_not_raises_fault(403, cl.retrieve_object_metadata,
1898 1899
                                             'c', 'o', account=get_user())
......
1903 1904
        #check inheritance
1904 1905
        o = self.upload_random_data('c', 'o/also-shared')
1905 1906
        for token, account in OTHER_ACCOUNTS.items():
1906
            cl = Pithos_Client(get_url(), token, account, get_api()) 
1907
            cl = Pithos_Client(get_url(), token, account)
1907 1908
            if account in authorized or any:
1908 1909
                self.assert_not_raises_fault(403, cl.retrieve_object_metadata,
1909 1910
                                             'c', 'o/also-shared', account=get_user())
......
1913 1914
    
1914 1915
    def assert_write(self, o_data, authorized=[], any=False):
1915 1916
        for token, account in OTHER_ACCOUNTS.items():
1916
            cl = Pithos_Client(get_url(), token, account, get_api()) 
1917
            cl = Pithos_Client(get_url(), token, account)
1917 1918
            new_data = get_random_data()
1918 1919
            if account in authorized or any:
1919 1920
                # test write access
......
1937 1938
        o = self.upload_random_data('c', 'o/also-shared')
1938 1939
        o_data = o['data']
1939 1940
        for token, account in OTHER_ACCOUNTS.items():
1940
            cl = Pithos_Client(get_url(), token, account, get_api()) 
1941
            cl = Pithos_Client(get_url(), token, account)
1941 1942
            new_data = get_random_data()
1942 1943
            if account in authorized or any:
1943 1944
                # test write access
......
2004 2005
        meta = self.client.retrieve_object_metadata('c', 'o')
2005 2006
        self.assertTrue('x-object-public' in meta)
2006 2007
        url = meta['x-object-public']
2007
        public_client = Pithos_Client(get_url(), get_auth(), get_user(), api='')
2008
        data = public_client.get(url)[2]
2008
        
2009
        p = urlparse(get_url())
2010
        if p.scheme == 'http':
2011
            conn = HTTPConnection(p.netloc)
2012
        elif p.scheme == 'https':
2013
            conn = HTTPSConnection(p.netloc)
2014
        else:
2015
            raise Exception('Unknown URL scheme')
2016
        
2017
        conn.request('GET', url)
2018
        resp = conn.getresponse()
2019
        length = resp.getheader('content-length', None)
2020
        data = resp.read(length)
2009 2021
        self.assertEqual(o_data, data)
2010 2022

  
2011 2023
class AssertUUidInvariant(object):

Also available in: Unified diff