Ejemplo n.º 1
0
    def create_group_repo(self, group_id, expected=None, *args, **kwargs):
        path = apiurl(reverse("api2-grouprepos", args=[group_id]))
        data = {"name": 'grepo-test'}
        data.update(kwargs)
        resp = self.post(path, data=data, expected=expected)

        return resp
Ejemplo n.º 2
0
    def test_create_encrypted_repo(self):
        """Test create an encrypted repo with the secure keys generated on client
        side.
        """
        repo_id = str(uuid.uuid4())
        password = randstring(16)
        enc_version = 2
        enc_info = seafile_api.generate_magic_and_random_key(
            enc_version, repo_id, password)
        data = {
            'name': 'enc-test',
            'repo_id': repo_id,
            'enc_version': enc_version,
            'magic': enc_info.magic,
            'random_key': enc_info.random_key,
        }
        repo = self.client.post(REPOS_URL, data=data)
        repo = json.loads(repo.content)
        assert repo['repo_id'] == repo_id
        assert repo['encrypted']
        assert repo['magic'] == enc_info.magic
        assert repo['random_key'] == enc_info.random_key

        # validate the password on server
        set_password_url = apiurl('/api2/repos/{}/'.format(repo['repo_id']))
        self.client.post(set_password_url, data={'password': password})

        # do some file operation
        self.create_file(repo_id=repo['repo_id'],
                         parent_dir='/',
                         filename='repo-test',
                         username=self.admin.username)
Ejemplo n.º 3
0
    def test_can_get(self):
        with self.get_tmp_repo() as repo:
            url = apiurl(reverse('api2-repo-tokens')) + '?repos=' + repo.repo_id
            resp = self.get(url)
            json_resp = json.loads(resp.content)

            assert repo.repo_id in json_resp
Ejemplo n.º 4
0
    def test_create_encrypted_repo(self):
        """Test create an encrypted repo with the secure keys generated on client
        side.
        """
        repo_id = str(uuid.uuid4())
        password = randstring(16)
        enc_version = 2
        enc_info = seafile_api.generate_magic_and_random_key(enc_version, repo_id, password)
        data = {
            'name': 'enc-test',
            'repo_id': repo_id,
            'enc_version': enc_version,
            'magic': enc_info.magic,
            'random_key': enc_info.random_key,
        }
        res = self.post(REPOS_URL, data=data)
        repo = res.json()
        assert repo['repo_id'] == repo_id
        assert repo['encrypted']
        assert repo['magic'] == enc_info.magic
        assert repo['random_key'] == enc_info.random_key

        # validate the password on server
        set_password_url = apiurl('/api2/repos/{}/'.format(repo['repo_id']))
        self.post(set_password_url, data={'password': password})

        # do some file operation
        self.create_file(repo['repo_id'])
Ejemplo n.º 5
0
    def test_can_get(self):
        with self.get_tmp_repo() as repo:
            url = apiurl(reverse('api2-repo-tokens')) + '?repos=' + repo.repo_id
            resp = self.get(url)
            json_resp = json.loads(resp.content)

            assert repo.repo_id in json_resp
Ejemplo n.º 6
0
    def create_group_repo(self, group_id, expected=None, *args, **kwargs):
        path = apiurl(reverse("api2-grouprepos", args=[group_id]))
        data = {"name": 'grepo-test'}
        data.update(kwargs)
        resp = self.post(path, data=data, expected=expected)

        return resp
Ejemplo n.º 7
0
    def create_group_repo(self, group_id, expected=None, *args, **kwargs):
        path = apiurl('/api2/groups/%s/repos/' % group_id)

        data = {"name": 'grepo-test'}
        data.update(kwargs)
        resp = self.post(path, data=data, expected=expected)

        return resp
Ejemplo n.º 8
0
    def test_can_delete(self):
        with self.get_tmp_group() as group:
            resp = self.create_group_repo(group.group_id)

            repo_id = resp.json()['id']
            path = apiurl(reverse("api2-grouprepo", args=[group.group_id, repo_id]))
            resp = self.delete(path)
            assert resp.status_code == 200
Ejemplo n.º 9
0
    def test_can_delete(self):
        with self.get_tmp_group() as group:
            resp = self.create_group_repo(group.group_id)

            repo_id = resp.json()['id']
            path = apiurl('/api2/groups/%s/repos/%s/' % (group.group_id, repo_id))
            resp = self.delete(path)
            assert resp.status_code == 200
Ejemplo n.º 10
0
    def create_group_repo(self, group_id, expected=None, *args, **kwargs):
        path = apiurl('/api2/groups/%s/repos/' % group_id)

        data = {"name": 'grepo-test'}
        data.update(kwargs)
        resp = self.post(path, data=data, expected=expected)

        return resp
Ejemplo n.º 11
0
    def test_can_delete(self):
        with self.get_tmp_group() as group:
            resp = self.create_group_repo(group.group_id)

            repo_id = resp.json()['id']
            path = apiurl('/api2/groups/%s/repos/%s/' %
                          (group.group_id, repo_id))
            resp = self.delete(path)
            assert resp.status_code == 200
Ejemplo n.º 12
0
    def test_can_delete(self):
        with self.get_tmp_group() as group:
            resp = self.create_group_repo(group.group_id)

            repo_id = resp.json()['id']
            path = apiurl(
                reverse("api2-grouprepo", args=[group.group_id, repo_id]))
            resp = self.delete(path)
            assert resp.status_code == 200
Ejemplo n.º 13
0
    def test_can_list(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)

            path = apiurl(reverse("api2-grouprepos", args=[group.group_id]))
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 1
Ejemplo n.º 14
0
    def test_order_by_mtime(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)

            path = apiurl('/api2/groups/%s/repos/' % group.group_id)
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 3

            assert (resp.json()[0]['mtime'] > resp.json()[1]['mtime'] and
                    resp.json()[1]['mtime'] > resp.json()[2]['mtime'] )
Ejemplo n.º 15
0
    def test_order_by_mtime(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)

            path = apiurl(reverse("api2-grouprepos", args=[group.group_id]))
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 3

            assert (resp.json()[0]['mtime'] > resp.json()[1]['mtime'] and
                    resp.json()[1]['mtime'] > resp.json()[2]['mtime'] )
Ejemplo n.º 16
0
    def test_order_by_mtime(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)

            path = apiurl('/api2/groups/%s/repos/' % group.group_id)
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 3

            assert (resp.json()[0]['mtime'] > resp.json()[1]['mtime']
                    and resp.json()[1]['mtime'] > resp.json()[2]['mtime'])
Ejemplo n.º 17
0
    def test_order_by_mtime(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)
            time.sleep(1)
            self.create_group_repo(group.group_id)

            path = apiurl(reverse("api2-grouprepos", args=[group.group_id]))
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 3

            assert (resp.json()[0]['mtime'] > resp.json()[1]['mtime']
                    and resp.json()[1]['mtime'] > resp.json()[2]['mtime'])
Ejemplo n.º 18
0
    def test_can_list(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)

            path = apiurl('/api2/groups/%s/repos/' % group.group_id)
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 1

            resp_repo = resp.json()[0]
            assert len(resp_repo['id']) == 36
            assert resp_repo['name'] == 'grepo-test'
            assert resp_repo['size'] >= 0
            assert resp_repo['mtime'] > 0
            assert resp_repo['permission'] in ('r', 'rw')
            assert '</time>' in resp_repo['mtime_relative']
Ejemplo n.º 19
0
    def test_can_list(self):
        with self.get_tmp_group() as group:
            self.create_group_repo(group.group_id)

            path = apiurl('/api2/groups/%s/repos/' % group.group_id)
            resp = self.get(path)

            assert resp.status_code == 200
            assert len(resp.json()) == 1

            resp_repo = resp.json()[0]
            assert len(resp_repo['id']) == 36
            assert resp_repo['name'] == 'grepo-test'
            assert resp_repo['size'] >= 0
            assert resp_repo['mtime'] > 0
            assert resp_repo['permission'] in ('r', 'rw')
            assert '</time>' in resp_repo['mtime_relative']
Ejemplo n.º 20
0
from tests.common.utils import apiurl

PING_URL = apiurl('/api2/ping/')
TOKEN_URL = apiurl('/api2/auth-token/')
AUTH_PING_URL = apiurl('/api2/auth/ping/')

ACCOUNTS_URL = apiurl('/api2/accounts/')
ACCOUNT_INFO_URL = apiurl('/api2/account/info/')
AVATAR_BASE_URL = apiurl(u'/api2/avatars/')

REPOS_URL = apiurl('/api2/repos/')
DEFAULT_REPO_URL = apiurl('/api2/default-repo/')
VIRTUAL_REPOS_URL = apiurl('/api2/virtual-repos/')
GET_REPO_TOKENS_URL = apiurl('/api2/repo-tokens/')

GROUPS_URL = apiurl(u'/api2/groups/')

USERMSGS_COUNT_URL = apiurl('/api2/unseen_messages/')

STARREDFILES_URL = apiurl('/api2/starredfiles/')
SHARED_LINKS_URL = apiurl('/api2/shared-links/')
SHARED_LIBRARIES_URL = apiurl('/api2/shared-repos/')
BESHARED_LIBRARIES_URL = apiurl('/api2/beshared-repos/')
F_URL = apiurl('/api2/f/')

DOWNLOAD_REPO_URL = apiurl('api2/repos/%s/download-info/')
LOGOUT_DEVICE_URL = apiurl('api2/logout-device/')

SERVER_INFO_URL = apiurl('/api2/server-info/')

CLIENT_LOGIN_TOKEN_URL = apiurl('/api2/client-login/')
Ejemplo n.º 21
0
Archivo: urls.py Proyecto: 3c7/seahub
from tests.common.common import USERNAME
from tests.common.utils import apiurl

PING_URL = apiurl('/api2/ping/')
TOKEN_URL = apiurl('/api2/auth-token/')
AUTH_PING_URL = apiurl('/api2/auth/ping/')

ACCOUNTS_URL = apiurl('/api2/accounts/')
ACCOUNT_INFO_URL = apiurl('/api2/account/info/')
AVATAR_BASE_URL = apiurl(u'/api2/avatars/')

REPOS_URL = apiurl('/api2/repos/')
DEFAULT_REPO_URL = apiurl('/api2/default-repo/')
VIRTUAL_REPOS_URL = apiurl('/api2/virtual-repos/')

GROUPS_URL = apiurl(u'/api2/groups/')

USERMSGS_URL = apiurl('/api2/user/msgs/', USERNAME)
USERMSGS_COUNT_URL = apiurl('/api2/unseen_messages/')
GROUPMSGS_URL = apiurl('/api2/group/msgs/')
GROUPMSGS_NREPLY_URL = apiurl('/api2/new_replies/')

STARREDFILES_URL = apiurl('/api2/starredfiles/')
SHARED_LINKS_URL = apiurl('/api2/shared-links/')
SHARED_LIBRARIES_URL = apiurl('/api2/shared-repos/')
BESHARED_LIBRARIES_URL = apiurl('/api2/beshared-repos/')
SHARED_FILES_URL = apiurl('/api2/shared-files/')
F_URL = apiurl('/api2/f/')
S_F_URL = apiurl('/api2/s/f/')

LIST_GROUP_AND_CONTACTS_URL = apiurl('/api2/groupandcontacts/')
Ejemplo n.º 22
0
from tests.common.common import USERNAME
from tests.common.utils import apiurl

PING_URL = apiurl("/api2/ping/")
TOKEN_URL = apiurl("/api2/auth-token/")
AUTH_PING_URL = apiurl("/api2/auth/ping/")

ACCOUNTS_URL = apiurl("/api2/accounts/")
ACCOUNT_INFO_URL = apiurl("/api2/account/info/")
AVATAR_BASE_URL = apiurl(u"/api2/avatars/")

REPOS_URL = apiurl("/api2/repos/")
DEFAULT_REPO_URL = apiurl("/api2/default-repo/")
VIRTUAL_REPOS_URL = apiurl("/api2/virtual-repos/")
GET_REPO_TOKENS_URL = apiurl("/api2/repo-tokens/")

GROUPS_URL = apiurl(u"/api2/groups/")

USERMSGS_URL = apiurl("/api2/user/msgs/", USERNAME)
USERMSGS_COUNT_URL = apiurl("/api2/unseen_messages/")
GROUPMSGS_URL = apiurl("/api2/group/msgs/")
GROUPMSGS_NREPLY_URL = apiurl("/api2/new_replies/")

STARREDFILES_URL = apiurl("/api2/starredfiles/")
SHARED_LINKS_URL = apiurl("/api2/shared-links/")
SHARED_LIBRARIES_URL = apiurl("/api2/shared-repos/")
BESHARED_LIBRARIES_URL = apiurl("/api2/beshared-repos/")
SHARED_FILES_URL = apiurl("/api2/shared-files/")
F_URL = apiurl("/api2/f/")
S_F_URL = apiurl("/api2/s/f/")
Ejemplo n.º 23
0
from tests.common.common import USERNAME
from tests.common.utils import apiurl

PING_URL = apiurl('/api2/ping/')
TOKEN_URL = apiurl('/api2/auth-token/')
AUTH_PING_URL = apiurl('/api2/auth/ping/')

ACCOUNTS_URL = apiurl('/api2/accounts/')
ACCOUNT_INFO_URL = apiurl('/api2/account/info/')
AVATAR_BASE_URL = apiurl(u'/api2/avatars/')

REPOS_URL = apiurl('/api2/repos/')
DEFAULT_REPO_URL = apiurl('/api2/default-repo/')
VIRTUAL_REPOS_URL = apiurl('/api2/virtual-repos/')

GROUPS_URL = apiurl(u'/api2/groups/')

USERMSGS_URL = apiurl('/api2/user/msgs/', USERNAME)
USERMSGS_COUNT_URL = apiurl('/api2/unseen_messages/')
GROUPMSGS_URL = apiurl('/api2/group/msgs/')
GROUPMSGS_NREPLY_URL = apiurl('/api2/new_replies/')

STARREDFILES_URL = apiurl('/api2/starredfiles/')
SHARED_LINKS_URL = apiurl('/api2/shared-links/')
SHARED_LIBRARIES_URL = apiurl('/api2/shared-repos/')
BESHARED_LIBRARIES_URL = apiurl('/api2/beshared-repos/')
SHARED_FILES_URL = apiurl('/api2/shared-files/')
F_URL = apiurl('/api2/f/')
S_F_URL = apiurl('/api2/s/f/')

LIST_GROUP_AND_CONTACTS_URL = apiurl('/api2/groupandcontacts/')