mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-02 15:57:31 +00:00
client side keygen: add tests
This commit is contained in:
parent
3b00b7cf83
commit
981db6618f
@ -184,6 +184,8 @@ class ApiTestBase(unittest.TestCase):
|
||||
self.admin_delete(user_url)
|
||||
|
||||
def create_file(self, repo, fname=None):
|
||||
if isinstance(repo, basestring):
|
||||
repo = _Repo(repo)
|
||||
fname = fname or ('文件 %s.txt' % randstring())
|
||||
furl = repo.get_filepath_url('/' + fname)
|
||||
data = {'operation': 'create'}
|
||||
|
@ -6,6 +6,7 @@ import pytest
|
||||
import uuid
|
||||
import unittest
|
||||
|
||||
from seaserv import seafile_api
|
||||
from tests.api.apitestbase import ApiTestBase
|
||||
from tests.api.urls import (
|
||||
REPOS_URL, DEFAULT_REPO_URL, VIRTUAL_REPOS_URL, GET_REPO_TOKENS_URL
|
||||
@ -186,3 +187,32 @@ class ReposApiTest(ApiTestBase):
|
||||
url = urljoin(SEAFILE_BASE_URL,
|
||||
'repo/%s/permission-check/?op=upload' % repo_id)
|
||||
self.get(url, use_token=False, headers=headers, **kwargs)
|
||||
|
||||
@pytest.mark.xfail
|
||||
def 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)
|
||||
magic, random_key = seafile_api.generate_magic_and_random_key(repo_id, password).split('\t')
|
||||
data = {
|
||||
'name': 'enc-test',
|
||||
'encrypted': '1',
|
||||
'repo_id': repo_id,
|
||||
'magic': magic,
|
||||
'random_key': random_key,
|
||||
}
|
||||
res = self.post(REPOS_URL, data=data)
|
||||
repo = res.json()
|
||||
assert repo['repo_id'] == repo_id
|
||||
assert repo['encrypted']
|
||||
assert repo['magic'] == magic
|
||||
assert repo['random_key'] == 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)
|
||||
|
Loading…
Reference in New Issue
Block a user