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
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)
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
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'])
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
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
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
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
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
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'] )
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'] )
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'])
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'])
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']
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/')
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/')
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/")