Show More
@@ -46,8 +46,8 b" source_suffix = '.rst'" | |||||
46 | master_doc = 'index' |
|
46 | master_doc = 'index' | |
47 |
|
47 | |||
48 | # General information about the project. |
|
48 | # General information about the project. | |
49 |
project = |
|
49 | project = 'Kallithea' | |
50 |
copyright = |
|
50 | copyright = '2010-2020 by various authors, licensed as GPLv3.' | |
51 |
|
51 | |||
52 | # The version info for the project you're documenting, acts as replacement for |
|
52 | # The version info for the project you're documenting, acts as replacement for | |
53 | # |version| and |release|, also used in various other places throughout the |
|
53 | # |version| and |release|, also used in various other places throughout the | |
@@ -187,8 +187,8 b" htmlhelp_basename = 'Kallithea-docs'" | |||||
187 | # Grouping the document tree into LaTeX files. List of tuples |
|
187 | # Grouping the document tree into LaTeX files. List of tuples | |
188 | # (source start file, target name, title, author, documentclass [howto/manual]). |
|
188 | # (source start file, target name, title, author, documentclass [howto/manual]). | |
189 | latex_documents = [ |
|
189 | latex_documents = [ | |
190 |
('index', 'Kallithea.tex', |
|
190 | ('index', 'Kallithea.tex', 'Kallithea Documentation', | |
191 |
|
|
191 | 'Kallithea Developers', 'manual'), | |
192 | ] |
|
192 | ] | |
193 |
|
193 | |||
194 | # The name of an image file (relative to this directory) to place at the top of |
|
194 | # The name of an image file (relative to this directory) to place at the top of | |
@@ -220,8 +220,8 b' latex_documents = [' | |||||
220 | # One entry per manual page. List of tuples |
|
220 | # One entry per manual page. List of tuples | |
221 | # (source start file, name, description, authors, manual section). |
|
221 | # (source start file, name, description, authors, manual section). | |
222 | man_pages = [ |
|
222 | man_pages = [ | |
223 |
('index', 'kallithea', |
|
223 | ('index', 'kallithea', 'Kallithea Documentation', | |
224 |
[ |
|
224 | ['Kallithea Developers'], 1) | |
225 | ] |
|
225 | ] | |
226 |
|
226 | |||
227 |
|
227 |
@@ -433,7 +433,7 b' class ApiController(JSONRPCController):' | |||||
433 |
|
433 | |||
434 | @HasPermissionAnyDecorator('hg.admin') |
|
434 | @HasPermissionAnyDecorator('hg.admin') | |
435 | def create_user(self, username, email, password=Optional(''), |
|
435 | def create_user(self, username, email, password=Optional(''), | |
436 |
firstname=Optional( |
|
436 | firstname=Optional(''), lastname=Optional(''), | |
437 | active=Optional(True), admin=Optional(False), |
|
437 | active=Optional(True), admin=Optional(False), | |
438 | extern_type=Optional(User.DEFAULT_AUTH_TYPE), |
|
438 | extern_type=Optional(User.DEFAULT_AUTH_TYPE), | |
439 | extern_name=Optional('')): |
|
439 | extern_name=Optional('')): | |
@@ -686,7 +686,7 b' class ApiController(JSONRPCController):' | |||||
686 | ] |
|
686 | ] | |
687 |
|
687 | |||
688 | @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true') |
|
688 | @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true') | |
689 |
def create_user_group(self, group_name, description=Optional( |
|
689 | def create_user_group(self, group_name, description=Optional(''), | |
690 | owner=Optional(OAttr('apiuser')), active=Optional(True)): |
|
690 | owner=Optional(OAttr('apiuser')), active=Optional(True)): | |
691 | """ |
|
691 | """ | |
692 | Creates new user group. This command can be executed only using api_key |
|
692 | Creates new user group. This command can be executed only using api_key | |
@@ -2373,7 +2373,7 b' class ApiController(JSONRPCController):' | |||||
2373 | return pull_request.get_api_data() |
|
2373 | return pull_request.get_api_data() | |
2374 |
|
2374 | |||
2375 | # permission check inside |
|
2375 | # permission check inside | |
2376 |
def comment_pullrequest(self, pull_request_id, comment_msg= |
|
2376 | def comment_pullrequest(self, pull_request_id, comment_msg='', status=None, close_pr=False): | |
2377 | """ |
|
2377 | """ | |
2378 | Add comment, close and change status of pull request. |
|
2378 | Add comment, close and change status of pull request. | |
2379 | """ |
|
2379 | """ |
@@ -94,7 +94,7 b' class SearchController(BaseRepoControlle' | |||||
94 | if c.repo_name: |
|
94 | if c.repo_name: | |
95 | # use "repository_rawname:" instead of "repository:" |
|
95 | # use "repository_rawname:" instead of "repository:" | |
96 | # for case-sensitive matching |
|
96 | # for case-sensitive matching | |
97 |
cur_query = |
|
97 | cur_query = 'repository_rawname:%s %s' % (c.repo_name, cur_query) | |
98 | try: |
|
98 | try: | |
99 | query = qp.parse(cur_query) |
|
99 | query = qp.parse(cur_query) | |
100 | # extract words for highlight |
|
100 | # extract words for highlight |
@@ -286,11 +286,11 b' def loadplugin(plugin):' | |||||
286 | ImportError -- if we couldn't import the plugin at all |
|
286 | ImportError -- if we couldn't import the plugin at all | |
287 | """ |
|
287 | """ | |
288 | log.debug("Importing %s", plugin) |
|
288 | log.debug("Importing %s", plugin) | |
289 |
if not plugin.startswith( |
|
289 | if not plugin.startswith('kallithea.lib.auth_modules.auth_'): | |
290 |
parts = plugin.split( |
|
290 | parts = plugin.split('.lib.auth_modules.auth_', 1) | |
291 | if len(parts) == 2: |
|
291 | if len(parts) == 2: | |
292 | _module, pn = parts |
|
292 | _module, pn = parts | |
293 |
plugin = |
|
293 | plugin = 'kallithea.lib.auth_modules.auth_' + pn | |
294 | PLUGIN_CLASS_NAME = "KallitheaAuthPlugin" |
|
294 | PLUGIN_CLASS_NAME = "KallitheaAuthPlugin" | |
295 | try: |
|
295 | try: | |
296 | module = importlib.import_module(plugin) |
|
296 | module = importlib.import_module(plugin) |
@@ -385,7 +385,7 b' class DbManage(object):' | |||||
385 | def create_user(self, username, password, email='', admin=False): |
|
385 | def create_user(self, username, password, email='', admin=False): | |
386 | log.info('creating user %s', username) |
|
386 | log.info('creating user %s', username) | |
387 | UserModel().create_or_update(username, password, email, |
|
387 | UserModel().create_or_update(username, password, email, | |
388 |
firstname= |
|
388 | firstname='Kallithea', lastname='Admin', | |
389 | active=True, admin=admin, |
|
389 | active=True, admin=admin, | |
390 | extern_type=User.DEFAULT_AUTH_TYPE) |
|
390 | extern_type=User.DEFAULT_AUTH_TYPE) | |
391 |
|
391 | |||
@@ -395,8 +395,8 b' class DbManage(object):' | |||||
395 | user = UserModel().create_or_update(username=User.DEFAULT_USER, |
|
395 | user = UserModel().create_or_update(username=User.DEFAULT_USER, | |
396 | password=str(uuid.uuid1())[:20], |
|
396 | password=str(uuid.uuid1())[:20], | |
397 | email='anonymous@kallithea-scm.org', |
|
397 | email='anonymous@kallithea-scm.org', | |
398 |
firstname= |
|
398 | firstname='Anonymous', | |
399 |
lastname= |
|
399 | lastname='User') | |
400 | # based on configuration options activate/deactivate this user which |
|
400 | # based on configuration options activate/deactivate this user which | |
401 | # controls anonymous access |
|
401 | # controls anonymous access | |
402 | if self.cli_args.get('public_access') is False: |
|
402 | if self.cli_args.get('public_access') is False: |
@@ -59,7 +59,7 b' def get_tag_uri(url, date):' | |||||
59 | if date is not None: |
|
59 | if date is not None: | |
60 | tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1) |
|
60 | tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1) | |
61 | tag = re.sub('#', '/', tag) |
|
61 | tag = re.sub('#', '/', tag) | |
62 |
return |
|
62 | return 'tag:' + tag | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | class Attributes(object): |
|
65 | class Attributes(object): |
@@ -203,7 +203,7 b' class WhooshResultWrapper(object):' | |||||
203 | return res |
|
203 | return res | |
204 |
|
204 | |||
205 | def get_short_content(self, res, chunks): |
|
205 | def get_short_content(self, res, chunks): | |
206 |
return |
|
206 | return ''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks]) | |
207 |
|
207 | |||
208 | def get_chunks(self): |
|
208 | def get_chunks(self): | |
209 | """ |
|
209 | """ |
@@ -181,7 +181,7 b' class WhooshIndexingDaemon(object):' | |||||
181 | bytes_content = node.content |
|
181 | bytes_content = node.content | |
182 | if b'\0' in bytes_content: |
|
182 | if b'\0' in bytes_content: | |
183 | log.warning(' >> %s - no text content', path) |
|
183 | log.warning(' >> %s - no text content', path) | |
184 |
u_content = |
|
184 | u_content = '' | |
185 | else: |
|
185 | else: | |
186 | log.debug(' >> %s', path) |
|
186 | log.debug(' >> %s', path) | |
187 | u_content = safe_str(bytes_content) |
|
187 | u_content = safe_str(bytes_content) | |
@@ -190,7 +190,7 b' class WhooshIndexingDaemon(object):' | |||||
190 | else: |
|
190 | else: | |
191 | log.debug(' >> %s - not indexable', path) |
|
191 | log.debug(' >> %s - not indexable', path) | |
192 | # just index file name without it's content |
|
192 | # just index file name without it's content | |
193 |
u_content = |
|
193 | u_content = '' | |
194 | indexed += 1 |
|
194 | indexed += 1 | |
195 |
|
195 | |||
196 | writer.add_document( |
|
196 | writer.add_document( | |
@@ -241,10 +241,10 b' class WhooshIndexingDaemon(object):' | |||||
241 | author=cs.author, |
|
241 | author=cs.author, | |
242 | message=cs.message, |
|
242 | message=cs.message, | |
243 | last=cs.last, |
|
243 | last=cs.last, | |
244 |
added= |
|
244 | added=' '.join(node.path for node in cs.added).lower(), | |
245 |
removed= |
|
245 | removed=' '.join(node.path for node in cs.removed).lower(), | |
246 |
changed= |
|
246 | changed=' '.join(node.path for node in cs.changed).lower(), | |
247 |
parents= |
|
247 | parents=' '.join(cs.raw_id for cs in cs.parents), | |
248 | ) |
|
248 | ) | |
249 |
|
249 | |||
250 | return indexed |
|
250 | return indexed | |
@@ -287,7 +287,7 b' class WhooshIndexingDaemon(object):' | |||||
287 | continue |
|
287 | continue | |
288 |
|
288 | |||
289 | qp = QueryParser('repository', schema=CHGSETS_SCHEMA) |
|
289 | qp = QueryParser('repository', schema=CHGSETS_SCHEMA) | |
290 |
q = qp.parse( |
|
290 | q = qp.parse("last:t AND %s" % repo_name) | |
291 |
|
291 | |||
292 | results = searcher.search(q) |
|
292 | results = searcher.search(q) | |
293 |
|
293 | |||
@@ -306,7 +306,7 b' class WhooshIndexingDaemon(object):' | |||||
306 | # delete the docs in the index for the previous |
|
306 | # delete the docs in the index for the previous | |
307 | # last changeset(s) |
|
307 | # last changeset(s) | |
308 | for hit in results: |
|
308 | for hit in results: | |
309 |
q = qp.parse( |
|
309 | q = qp.parse("last:t AND %s AND raw_id:%s" % | |
310 | (repo_name, hit['raw_id'])) |
|
310 | (repo_name, hit['raw_id'])) | |
311 | writer.delete_by_query(q) |
|
311 | writer.delete_by_query(q) | |
312 |
|
312 | |||
@@ -326,7 +326,7 b' class WhooshIndexingDaemon(object):' | |||||
326 | log.debug('>> NOTHING TO COMMIT TO CHANGESET INDEX<<') |
|
326 | log.debug('>> NOTHING TO COMMIT TO CHANGESET INDEX<<') | |
327 |
|
327 | |||
328 | def update_file_index(self): |
|
328 | def update_file_index(self): | |
329 |
log.debug( |
|
329 | log.debug('STARTING INCREMENTAL INDEXING UPDATE FOR EXTENSIONS %s ' | |
330 | 'AND REPOS %s', INDEX_EXTENSIONS, ' and '.join(self.repo_paths)) |
|
330 | 'AND REPOS %s', INDEX_EXTENSIONS, ' and '.join(self.repo_paths)) | |
331 |
|
331 | |||
332 | idx = open_dir(self.index_location, indexname=self.indexname) |
|
332 | idx = open_dir(self.index_location, indexname=self.indexname) |
@@ -24,7 +24,7 b' def current_locale_is_valid():' | |||||
24 | Note: UTF-8 is preferred, but for example ISO-8859-1 or mbcs should also |
|
24 | Note: UTF-8 is preferred, but for example ISO-8859-1 or mbcs should also | |
25 | work under the right circumstances.""" |
|
25 | work under the right circumstances.""" | |
26 | try: |
|
26 | try: | |
27 |
|
|
27 | '\xe9'.encode(sys.getfilesystemencoding()) # Test using Γ© (é) | |
28 | except UnicodeEncodeError: |
|
28 | except UnicodeEncodeError: | |
29 | log.error("Cannot encode Unicode paths to file system encoding %r", sys.getfilesystemencoding()) |
|
29 | log.error("Cannot encode Unicode paths to file system encoding %r", sys.getfilesystemencoding()) | |
30 | for var in ['LC_ALL', 'LC_CTYPE', 'LANG']: |
|
30 | for var in ['LC_ALL', 'LC_CTYPE', 'LANG']: |
@@ -165,7 +165,7 b' class GitRepository(object):' | |||||
165 | log.error(traceback.format_exc()) |
|
165 | log.error(traceback.format_exc()) | |
166 | raise exc.HTTPExpectationFailed() |
|
166 | raise exc.HTTPExpectationFailed() | |
167 |
|
167 | |||
168 |
if git_command in [ |
|
168 | if git_command in ['git-receive-pack']: | |
169 | # updating refs manually after each push. |
|
169 | # updating refs manually after each push. | |
170 | # Needed for pre-1.7.0.4 git clients using regular HTTP mode. |
|
170 | # Needed for pre-1.7.0.4 git clients using regular HTTP mode. | |
171 | from kallithea.lib.vcs import get_repo |
|
171 | from kallithea.lib.vcs import get_repo |
@@ -145,7 +145,7 b' def action_logger(user, action, repo, ip' | |||||
145 | repo_obj = Repository.get_by_repo_name(repo_name) |
|
145 | repo_obj = Repository.get_by_repo_name(repo_name) | |
146 | else: |
|
146 | else: | |
147 | repo_obj = None |
|
147 | repo_obj = None | |
148 |
repo_name = |
|
148 | repo_name = '' | |
149 |
|
149 | |||
150 | user_log = UserLog() |
|
150 | user_log = UserLog() | |
151 | user_log.user_id = user_obj.user_id |
|
151 | user_log.user_id = user_obj.user_id | |
@@ -428,7 +428,7 b' def map_groups(path):' | |||||
428 | rgm = RepoGroupModel() |
|
428 | rgm = RepoGroupModel() | |
429 | owner = User.get_first_admin() |
|
429 | owner = User.get_first_admin() | |
430 | for lvl, group_name in enumerate(groups): |
|
430 | for lvl, group_name in enumerate(groups): | |
431 |
group_name = |
|
431 | group_name = '/'.join(groups[:lvl] + [group_name]) | |
432 | group = RepoGroup.get_by_group_name(group_name) |
|
432 | group = RepoGroup.get_by_group_name(group_name) | |
433 | desc = '%s group' % group_name |
|
433 | desc = '%s group' % group_name | |
434 |
|
434 |
@@ -239,12 +239,12 b' def age(prevdate, show_short_version=Fal' | |||||
239 |
|
239 | |||
240 | # Format the result |
|
240 | # Format the result | |
241 | fmt_funcs = { |
|
241 | fmt_funcs = { | |
242 |
'year': lambda d: ungettext( |
|
242 | 'year': lambda d: ungettext('%d year', '%d years', d) % d, | |
243 |
'month': lambda d: ungettext( |
|
243 | 'month': lambda d: ungettext('%d month', '%d months', d) % d, | |
244 |
'day': lambda d: ungettext( |
|
244 | 'day': lambda d: ungettext('%d day', '%d days', d) % d, | |
245 |
'hour': lambda d: ungettext( |
|
245 | 'hour': lambda d: ungettext('%d hour', '%d hours', d) % d, | |
246 |
'minute': lambda d: ungettext( |
|
246 | 'minute': lambda d: ungettext('%d minute', '%d minutes', d) % d, | |
247 |
'second': lambda d: ungettext( |
|
247 | 'second': lambda d: ungettext('%d second', '%d seconds', d) % d, | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | for i, part in enumerate(order): |
|
250 | for i, part in enumerate(order): |
@@ -1026,7 +1026,7 b' class EmptyChangeset(BaseChangeset):' | |||||
1026 | return self |
|
1026 | return self | |
1027 |
|
1027 | |||
1028 | def get_file_content(self, path): |
|
1028 | def get_file_content(self, path): | |
1029 |
return |
|
1029 | return '' | |
1030 |
|
1030 | |||
1031 | def get_file_size(self, path): |
|
1031 | def get_file_size(self, path): | |
1032 | return 0 |
|
1032 | return 0 |
@@ -351,7 +351,7 b' class GitRepository(BaseRepository):' | |||||
351 |
|
351 | |||
352 | @LazyProperty |
|
352 | @LazyProperty | |
353 | def contact(self): |
|
353 | def contact(self): | |
354 |
undefined_contact = |
|
354 | undefined_contact = 'Unknown' | |
355 | return undefined_contact |
|
355 | return undefined_contact | |
356 |
|
356 | |||
357 | @property |
|
357 | @property |
@@ -27,10 +27,10 b' class NodeKind:' | |||||
27 |
|
27 | |||
28 |
|
28 | |||
29 | class NodeState: |
|
29 | class NodeState: | |
30 |
ADDED = |
|
30 | ADDED = 'added' | |
31 |
CHANGED = |
|
31 | CHANGED = 'changed' | |
32 |
NOT_CHANGED = |
|
32 | NOT_CHANGED = 'not changed' | |
33 |
REMOVED = |
|
33 | REMOVED = 'removed' | |
34 |
|
34 | |||
35 |
|
35 | |||
36 | class NodeGeneratorBase(object): |
|
36 | class NodeGeneratorBase(object): | |
@@ -606,4 +606,4 b' class SubModuleNode(Node):' | |||||
606 | then only last part is returned. |
|
606 | then only last part is returned. | |
607 | """ |
|
607 | """ | |
608 | org = self.path.rstrip('/').rsplit('/', 1)[-1] |
|
608 | org = self.path.rstrip('/').rsplit('/', 1)[-1] | |
609 |
return |
|
609 | return '%s @ %s' % (org, self.changeset.short_id) |
@@ -959,9 +959,9 b' class Repository(Base, BaseDbModel):' | |||||
959 | DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}' |
|
959 | DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}' | |
960 | DEFAULT_CLONE_SSH = 'ssh://{system_user}@{hostname}/{repo}' |
|
960 | DEFAULT_CLONE_SSH = 'ssh://{system_user}@{hostname}/{repo}' | |
961 |
|
961 | |||
962 |
STATE_CREATED = |
|
962 | STATE_CREATED = 'repo_state_created' | |
963 |
STATE_PENDING = |
|
963 | STATE_PENDING = 'repo_state_pending' | |
964 |
STATE_ERROR = |
|
964 | STATE_ERROR = 'repo_state_error' | |
965 |
|
965 | |||
966 | repo_id = Column(Integer(), primary_key=True) |
|
966 | repo_id = Column(Integer(), primary_key=True) | |
967 | repo_name = Column(Unicode(255), nullable=False, unique=True) |
|
967 | repo_name = Column(Unicode(255), nullable=False, unique=True) | |
@@ -1490,7 +1490,7 b' class RepoGroup(Base, BaseDbModel):' | |||||
1490 | """Return tuple with group_id and name as html literal""" |
|
1490 | """Return tuple with group_id and name as html literal""" | |
1491 | from webhelpers2.html import literal |
|
1491 | from webhelpers2.html import literal | |
1492 | if repo_group is None: |
|
1492 | if repo_group is None: | |
1493 |
return (-1, |
|
1493 | return (-1, '-- %s --' % _('top level')) | |
1494 | return repo_group.group_id, literal(cls.SEP.join(repo_group.full_path_splitted)) |
|
1494 | return repo_group.group_id, literal(cls.SEP.join(repo_group.full_path_splitted)) | |
1495 |
|
1495 | |||
1496 | @classmethod |
|
1496 | @classmethod | |
@@ -2258,8 +2258,8 b' class PullRequest(Base, BaseDbModel):' | |||||
2258 | ) |
|
2258 | ) | |
2259 |
|
2259 | |||
2260 | # values for .status |
|
2260 | # values for .status | |
2261 |
STATUS_NEW = |
|
2261 | STATUS_NEW = 'new' | |
2262 |
STATUS_CLOSED = |
|
2262 | STATUS_CLOSED = 'closed' | |
2263 |
|
2263 | |||
2264 | pull_request_id = Column(Integer(), primary_key=True) |
|
2264 | pull_request_id = Column(Integer(), primary_key=True) | |
2265 | title = Column(Unicode(255), nullable=False) |
|
2265 | title = Column(Unicode(255), nullable=False) | |
@@ -2428,9 +2428,9 b' class Gist(Base, BaseDbModel):' | |||||
2428 | _table_args_default_dict, |
|
2428 | _table_args_default_dict, | |
2429 | ) |
|
2429 | ) | |
2430 |
|
2430 | |||
2431 |
GIST_PUBLIC = |
|
2431 | GIST_PUBLIC = 'public' | |
2432 |
GIST_PRIVATE = |
|
2432 | GIST_PRIVATE = 'private' | |
2433 |
DEFAULT_FILENAME = |
|
2433 | DEFAULT_FILENAME = 'gistfile1.txt' | |
2434 |
|
2434 | |||
2435 | gist_id = Column(Integer(), primary_key=True) |
|
2435 | gist_id = Column(Integer(), primary_key=True) | |
2436 | gist_access_id = Column(Unicode(250), nullable=False) |
|
2436 | gist_access_id = Column(Unicode(250), nullable=False) |
@@ -558,11 +558,11 b' def GistForm(lifetime_options):' | |||||
558 |
|
558 | |||
559 | filename = All(v.BasePath()(), |
|
559 | filename = All(v.BasePath()(), | |
560 | v.UnicodeString(strip=True, required=False)) |
|
560 | v.UnicodeString(strip=True, required=False)) | |
561 |
description = v.UnicodeString(required=False, if_missing= |
|
561 | description = v.UnicodeString(required=False, if_missing='') | |
562 | lifetime = v.OneOf(lifetime_options) |
|
562 | lifetime = v.OneOf(lifetime_options) | |
563 | mimetype = v.UnicodeString(required=False, if_missing=None) |
|
563 | mimetype = v.UnicodeString(required=False, if_missing=None) | |
564 | content = v.UnicodeString(required=True, not_empty=True) |
|
564 | content = v.UnicodeString(required=True, not_empty=True) | |
565 |
public = v.UnicodeString(required=False, if_missing= |
|
565 | public = v.UnicodeString(required=False, if_missing='') | |
566 |
private = v.UnicodeString(required=False, if_missing= |
|
566 | private = v.UnicodeString(required=False, if_missing='') | |
567 |
|
567 | |||
568 | return _GistForm |
|
568 | return _GistForm |
@@ -50,7 +50,7 b' def make_gist_access_id():' | |||||
50 | rnd = random.SystemRandom() # use cryptographically secure system PRNG |
|
50 | rnd = random.SystemRandom() # use cryptographically secure system PRNG | |
51 | alphabet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz' |
|
51 | alphabet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz' | |
52 | length = 20 |
|
52 | length = 20 | |
53 |
return |
|
53 | return ''.join(rnd.choice(alphabet) for _ in range(length)) | |
54 |
|
54 | |||
55 |
|
55 | |||
56 | class GistModel(object): |
|
56 | class GistModel(object): |
@@ -43,12 +43,12 b' log = logging.getLogger(__name__)' | |||||
43 |
|
43 | |||
44 | class NotificationModel(object): |
|
44 | class NotificationModel(object): | |
45 |
|
45 | |||
46 |
TYPE_CHANGESET_COMMENT = |
|
46 | TYPE_CHANGESET_COMMENT = 'cs_comment' | |
47 |
TYPE_MESSAGE = |
|
47 | TYPE_MESSAGE = 'message' | |
48 |
TYPE_MENTION = |
|
48 | TYPE_MENTION = 'mention' # not used | |
49 |
TYPE_REGISTRATION = |
|
49 | TYPE_REGISTRATION = 'registration' | |
50 |
TYPE_PULL_REQUEST = |
|
50 | TYPE_PULL_REQUEST = 'pull_request' | |
51 |
TYPE_PULL_REQUEST_COMMENT = |
|
51 | TYPE_PULL_REQUEST_COMMENT = 'pull_request_comment' | |
52 |
|
52 | |||
53 | def create(self, created_by, subject, body, recipients=None, |
|
53 | def create(self, created_by, subject, body, recipients=None, | |
54 | type_=TYPE_MESSAGE, with_email=True, |
|
54 | type_=TYPE_MESSAGE, with_email=True, |
@@ -265,7 +265,7 b' class CreatePullRequestAction(object):' | |||||
265 | from kallithea.model.changeset_status import ChangesetStatusModel |
|
265 | from kallithea.model.changeset_status import ChangesetStatusModel | |
266 | from kallithea.model.comment import ChangesetCommentsModel |
|
266 | from kallithea.model.comment import ChangesetCommentsModel | |
267 | comment = ChangesetCommentsModel().create( |
|
267 | comment = ChangesetCommentsModel().create( | |
268 |
text= |
|
268 | text='', | |
269 | repo=self.org_repo, |
|
269 | repo=self.org_repo, | |
270 | author=created_by, |
|
270 | author=created_by, | |
271 | pull_request=pr, |
|
271 | pull_request=pr, |
@@ -272,7 +272,7 b' class RepoModel(object):' | |||||
272 | cur_repo.owner = User.get_by_username(kwargs['owner']) |
|
272 | cur_repo.owner = User.get_by_username(kwargs['owner']) | |
273 |
|
273 | |||
274 | if 'repo_group' in kwargs: |
|
274 | if 'repo_group' in kwargs: | |
275 |
assert kwargs['repo_group'] != |
|
275 | assert kwargs['repo_group'] != '-1', kwargs # RepoForm should have converted to None | |
276 | cur_repo.group = RepoGroup.get(kwargs['repo_group']) |
|
276 | cur_repo.group = RepoGroup.get(kwargs['repo_group']) | |
277 | cur_repo.repo_name = cur_repo.get_new_name(cur_repo.just_name) |
|
277 | cur_repo.repo_name = cur_repo.get_new_name(cur_repo.just_name) | |
278 | log.debug('Updating repo %s with params:%s', cur_repo, kwargs) |
|
278 | log.debug('Updating repo %s with params:%s', cur_repo, kwargs) |
@@ -288,7 +288,7 b' class RepoGroupModel(object):' | |||||
288 | repo_group.parent_group_id = repo_group_args['parent_group_id'] |
|
288 | repo_group.parent_group_id = repo_group_args['parent_group_id'] | |
289 |
|
289 | |||
290 | if 'parent_group_id' in repo_group_args: |
|
290 | if 'parent_group_id' in repo_group_args: | |
291 |
assert repo_group_args['parent_group_id'] != |
|
291 | assert repo_group_args['parent_group_id'] != '-1', repo_group_args # RepoGroupForm should have converted to None | |
292 | repo_group.parent_group = RepoGroup.get(repo_group_args['parent_group_id']) |
|
292 | repo_group.parent_group = RepoGroup.get(repo_group_args['parent_group_id']) | |
293 | if 'group_name' in repo_group_args: |
|
293 | if 'group_name' in repo_group_args: | |
294 | group_name = repo_group_args['group_name'] |
|
294 | group_name = repo_group_args['group_name'] |
@@ -659,18 +659,18 b' class ScmModel(object):' | |||||
659 |
|
659 | |||
660 | repo = repo.scm_instance |
|
660 | repo = repo.scm_instance | |
661 |
|
661 | |||
662 |
branches_group = ([( |
|
662 | branches_group = ([('branch:%s' % k, k) for k, v in | |
663 | repo.branches.items()], _("Branches")) |
|
663 | repo.branches.items()], _("Branches")) | |
664 | hist_l.append(branches_group) |
|
664 | hist_l.append(branches_group) | |
665 | choices.extend([x[0] for x in branches_group[0]]) |
|
665 | choices.extend([x[0] for x in branches_group[0]]) | |
666 |
|
666 | |||
667 | if repo.alias == 'hg': |
|
667 | if repo.alias == 'hg': | |
668 |
bookmarks_group = ([( |
|
668 | bookmarks_group = ([('book:%s' % k, k) for k, v in | |
669 | repo.bookmarks.items()], _("Bookmarks")) |
|
669 | repo.bookmarks.items()], _("Bookmarks")) | |
670 | hist_l.append(bookmarks_group) |
|
670 | hist_l.append(bookmarks_group) | |
671 | choices.extend([x[0] for x in bookmarks_group[0]]) |
|
671 | choices.extend([x[0] for x in bookmarks_group[0]]) | |
672 |
|
672 | |||
673 |
tags_group = ([( |
|
673 | tags_group = ([('tag:%s' % k, k) for k, v in | |
674 | repo.tags.items()], _("Tags")) |
|
674 | repo.tags.items()], _("Tags")) | |
675 | hist_l.append(tags_group) |
|
675 | hist_l.append(tags_group) | |
676 | choices.extend([x[0] for x in tags_group[0]]) |
|
676 | choices.extend([x[0] for x in tags_group[0]]) |
@@ -94,8 +94,8 b' class UserModel(object):' | |||||
94 | log_create_user(new_user.get_dict(), cur_user) |
|
94 | log_create_user(new_user.get_dict(), cur_user) | |
95 | return new_user |
|
95 | return new_user | |
96 |
|
96 | |||
97 |
def create_or_update(self, username, password, email, firstname= |
|
97 | def create_or_update(self, username, password, email, firstname='', | |
98 |
lastname= |
|
98 | lastname='', active=True, admin=False, | |
99 | extern_type=None, extern_name=None, cur_user=None): |
|
99 | extern_type=None, extern_name=None, cur_user=None): | |
100 | """ |
|
100 | """ | |
101 | Creates a new instance if not found, or updates current one |
|
101 | Creates a new instance if not found, or updates current one | |
@@ -183,7 +183,7 b' class UserModel(object):' | |||||
183 | # notification to admins |
|
183 | # notification to admins | |
184 | subject = _('New user registration') |
|
184 | subject = _('New user registration') | |
185 | body = ( |
|
185 | body = ( | |
186 |
|
|
186 | 'New user registration\n' | |
187 | '---------------------\n' |
|
187 | '---------------------\n' | |
188 | '- Username: {user.username}\n' |
|
188 | '- Username: {user.username}\n' | |
189 | '- Full Name: {user.full_name}\n' |
|
189 | '- Full Name: {user.full_name}\n' | |
@@ -308,8 +308,8 b' class UserModel(object):' | |||||
308 | """ |
|
308 | """ | |
309 | app_secret = config.get('app_instance_uuid') |
|
309 | app_secret = config.get('app_instance_uuid') | |
310 | return hmac.HMAC( |
|
310 | return hmac.HMAC( | |
311 |
key= |
|
311 | key='\0'.join([app_secret, user.password]).encode('utf-8'), | |
312 |
msg= |
|
312 | msg='\0'.join([session_id, str(user.user_id), user.email, str(timestamp)]).encode('utf-8'), | |
313 | digestmod=hashlib.sha1, |
|
313 | digestmod=hashlib.sha1, | |
314 | ).hexdigest() |
|
314 | ).hexdigest() | |
315 |
|
315 |
@@ -367,7 +367,7 b' class UserGroupModel(object):' | |||||
367 | for gr in set(groups): |
|
367 | for gr in set(groups): | |
368 | existing_group = UserGroup.get_by_group_name(gr) |
|
368 | existing_group = UserGroup.get_by_group_name(gr) | |
369 | if not existing_group: |
|
369 | if not existing_group: | |
370 |
desc = |
|
370 | desc = 'Automatically created from plugin:%s' % extern_type | |
371 | # we use first admin account to set the owner of the group |
|
371 | # we use first admin account to set the owner of the group | |
372 | existing_group = UserGroupModel().create(gr, desc, owner, |
|
372 | existing_group = UserGroupModel().create(gr, desc, owner, | |
373 | group_data={'extern_type': extern_type}) |
|
373 | group_data={'extern_type': extern_type}) |
@@ -276,7 +276,7 b' def ValidPasswordsMatch(password_field, ' | |||||
276 | def ValidAuth(): |
|
276 | def ValidAuth(): | |
277 | class _validator(formencode.validators.FancyValidator): |
|
277 | class _validator(formencode.validators.FancyValidator): | |
278 | messages = { |
|
278 | messages = { | |
279 |
'invalid_auth': _( |
|
279 | 'invalid_auth': _('Invalid username or password'), | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 | def _validate_python(self, value, state): |
|
282 | def _validate_python(self, value, state): |
@@ -40,8 +40,8 b' from kallithea.tests.fixture import Fixt' | |||||
40 |
|
40 | |||
41 |
|
41 | |||
42 | API_URL = '/_admin/api' |
|
42 | API_URL = '/_admin/api' | |
43 |
TEST_USER_GROUP = |
|
43 | TEST_USER_GROUP = 'test_user_group' | |
44 |
TEST_REPO_GROUP = |
|
44 | TEST_REPO_GROUP = 'test_repo_group' | |
45 |
|
45 | |||
46 | fixture = Fixture() |
|
46 | fixture = Fixture() | |
47 |
|
47 | |||
@@ -100,8 +100,8 b' class _BaseTestApi(object):' | |||||
100 | username='test-api', |
|
100 | username='test-api', | |
101 | password='test', |
|
101 | password='test', | |
102 | email='test@example.com', |
|
102 | email='test@example.com', | |
103 |
firstname= |
|
103 | firstname='first', | |
104 |
lastname= |
|
104 | lastname='last' | |
105 | ) |
|
105 | ) | |
106 | Session().commit() |
|
106 | Session().commit() | |
107 | cls.TEST_USER_LOGIN = cls.test_user.username |
|
107 | cls.TEST_USER_LOGIN = cls.test_user.username | |
@@ -281,7 +281,7 b' class _BaseTestApi(object):' | |||||
281 | def test_api_pull_remote(self): |
|
281 | def test_api_pull_remote(self): | |
282 | # Note: pulling from local repos is a mis-feature - it will bypass access control |
|
282 | # Note: pulling from local repos is a mis-feature - it will bypass access control | |
283 | # ... but ok, if the path already has been set in the database |
|
283 | # ... but ok, if the path already has been set in the database | |
284 |
repo_name = |
|
284 | repo_name = 'test_pull' | |
285 | r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
285 | r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
286 | # hack around that clone_uri can't be set to to a local path |
|
286 | # hack around that clone_uri can't be set to to a local path | |
287 | # (as shown by test_api_create_repo_clone_uri_local) |
|
287 | # (as shown by test_api_create_repo_clone_uri_local) | |
@@ -305,7 +305,7 b' class _BaseTestApi(object):' | |||||
305 | assert pre_cached_tip != post_cached_tip |
|
305 | assert pre_cached_tip != post_cached_tip | |
306 |
|
306 | |||
307 | def test_api_pull_fork(self): |
|
307 | def test_api_pull_fork(self): | |
308 |
fork_name = |
|
308 | fork_name = 'fork' | |
309 | fixture.create_fork(self.REPO, fork_name) |
|
309 | fixture.create_fork(self.REPO, fork_name) | |
310 | id_, params = _build_data(self.apikey, 'pull', |
|
310 | id_, params = _build_data(self.apikey, 'pull', | |
311 | repoid=fork_name,) |
|
311 | repoid=fork_name,) | |
@@ -327,7 +327,7 b' class _BaseTestApi(object):' | |||||
327 | self._compare_error(id_, expected, given=response.body) |
|
327 | self._compare_error(id_, expected, given=response.body) | |
328 |
|
328 | |||
329 | def test_api_pull_custom_remote(self): |
|
329 | def test_api_pull_custom_remote(self): | |
330 |
repo_name = |
|
330 | repo_name = 'test_pull_custom_remote' | |
331 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
331 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
332 |
|
332 | |||
333 | custom_remote_path = os.path.join(Ui.get_by_key('paths', '/').ui_value, self.REPO) |
|
333 | custom_remote_path = os.path.join(Ui.get_by_key('paths', '/').ui_value, self.REPO) | |
@@ -489,10 +489,10 b' class _BaseTestApi(object):' | |||||
489 | self._compare_error(id_, expected, given=response.body) |
|
489 | self._compare_error(id_, expected, given=response.body) | |
490 |
|
490 | |||
491 | def test_api_delete_user(self): |
|
491 | def test_api_delete_user(self): | |
492 |
usr = UserModel().create_or_update(username= |
|
492 | usr = UserModel().create_or_update(username='test_user', | |
493 |
password= |
|
493 | password='qweqwe', | |
494 |
email= |
|
494 | email='u232@example.com', | |
495 |
firstname= |
|
495 | firstname='u1', lastname='u1') | |
496 | Session().commit() |
|
496 | Session().commit() | |
497 | username = usr.username |
|
497 | username = usr.username | |
498 | email = usr.email |
|
498 | email = usr.email | |
@@ -510,10 +510,10 b' class _BaseTestApi(object):' | |||||
510 |
|
510 | |||
511 | @mock.patch.object(UserModel, 'delete', crash) |
|
511 | @mock.patch.object(UserModel, 'delete', crash) | |
512 | def test_api_delete_user_when_exception_happened(self): |
|
512 | def test_api_delete_user_when_exception_happened(self): | |
513 |
usr = UserModel().create_or_update(username= |
|
513 | usr = UserModel().create_or_update(username='test_user', | |
514 |
password= |
|
514 | password='qweqwe', | |
515 |
email= |
|
515 | email='u232@example.com', | |
516 |
firstname= |
|
516 | firstname='u1', lastname='u1') | |
517 | Session().commit() |
|
517 | Session().commit() | |
518 | username = usr.username |
|
518 | username = usr.username | |
519 |
|
519 | |||
@@ -610,7 +610,7 b' class _BaseTestApi(object):' | |||||
610 | self._compare_error(id_, expected, given=response.body) |
|
610 | self._compare_error(id_, expected, given=response.body) | |
611 |
|
611 | |||
612 | def test_api_get_repo(self): |
|
612 | def test_api_get_repo(self): | |
613 |
new_group = |
|
613 | new_group = 'some_new_group' | |
614 | make_user_group(new_group) |
|
614 | make_user_group(new_group) | |
615 | RepoModel().grant_user_group_permission(repo=self.REPO, |
|
615 | RepoModel().grant_user_group_permission(repo=self.REPO, | |
616 | group_name=new_group, |
|
616 | group_name=new_group, | |
@@ -619,8 +619,8 b' class _BaseTestApi(object):' | |||||
619 | id_, params = _build_data(self.apikey, 'get_repo', |
|
619 | id_, params = _build_data(self.apikey, 'get_repo', | |
620 | repoid=self.REPO) |
|
620 | repoid=self.REPO) | |
621 | response = api_call(self, params) |
|
621 | response = api_call(self, params) | |
622 |
assert |
|
622 | assert "tags" not in response.json['result'] | |
623 |
assert |
|
623 | assert 'pull_requests' not in response.json['result'] | |
624 |
|
624 | |||
625 | repo = RepoModel().get_by_repo_name(self.REPO) |
|
625 | repo = RepoModel().get_by_repo_name(self.REPO) | |
626 | ret = repo.get_api_data() |
|
626 | ret = repo.get_api_data() | |
@@ -655,8 +655,8 b' class _BaseTestApi(object):' | |||||
655 | with_revision_names=True, |
|
655 | with_revision_names=True, | |
656 | with_pullrequests=True) |
|
656 | with_pullrequests=True) | |
657 | response = api_call(self, params) |
|
657 | response = api_call(self, params) | |
658 |
assert |
|
658 | assert "v0.2.0" in response.json['result']['tags'] | |
659 |
assert |
|
659 | assert 'pull_requests' in response.json['result'] | |
660 |
|
660 | |||
661 | @base.parametrize('grant_perm', [ |
|
661 | @base.parametrize('grant_perm', [ | |
662 | ('repository.admin'), |
|
662 | ('repository.admin'), | |
@@ -838,7 +838,7 b' class _BaseTestApi(object):' | |||||
838 | RepoModel().revoke_user_permission(self.REPO, self.TEST_USER_LOGIN) |
|
838 | RepoModel().revoke_user_permission(self.REPO, self.TEST_USER_LOGIN) | |
839 |
|
839 | |||
840 | def test_api_create_repo(self): |
|
840 | def test_api_create_repo(self): | |
841 |
repo_name = |
|
841 | repo_name = 'api-repo' | |
842 | id_, params = _build_data(self.apikey, 'create_repo', |
|
842 | id_, params = _build_data(self.apikey, 'create_repo', | |
843 | repo_name=repo_name, |
|
843 | repo_name=repo_name, | |
844 | owner=base.TEST_USER_ADMIN_LOGIN, |
|
844 | owner=base.TEST_USER_ADMIN_LOGIN, | |
@@ -858,12 +858,12 b' class _BaseTestApi(object):' | |||||
858 | fixture.destroy_repo(repo_name) |
|
858 | fixture.destroy_repo(repo_name) | |
859 |
|
859 | |||
860 | @base.parametrize('repo_name', [ |
|
860 | @base.parametrize('repo_name', [ | |
861 |
|
|
861 | '', | |
862 |
|
|
862 | '.', | |
863 |
|
|
863 | '..', | |
864 |
|
|
864 | ':', | |
865 |
|
|
865 | '/', | |
866 |
|
|
866 | '<test>', | |
867 | ]) |
|
867 | ]) | |
868 | def test_api_create_repo_bad_names(self, repo_name): |
|
868 | def test_api_create_repo_bad_names(self, repo_name): | |
869 | id_, params = _build_data(self.apikey, 'create_repo', |
|
869 | id_, params = _build_data(self.apikey, 'create_repo', | |
@@ -884,7 +884,7 b' class _BaseTestApi(object):' | |||||
884 | # cloning from local repos was a mis-feature - it would bypass access control |
|
884 | # cloning from local repos was a mis-feature - it would bypass access control | |
885 | # TODO: introduce other test coverage of actual remote cloning |
|
885 | # TODO: introduce other test coverage of actual remote cloning | |
886 | clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO) |
|
886 | clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO) | |
887 |
repo_name = |
|
887 | repo_name = 'api-repo' | |
888 | id_, params = _build_data(self.apikey, 'create_repo', |
|
888 | id_, params = _build_data(self.apikey, 'create_repo', | |
889 | repo_name=repo_name, |
|
889 | repo_name=repo_name, | |
890 | owner=base.TEST_USER_ADMIN_LOGIN, |
|
890 | owner=base.TEST_USER_ADMIN_LOGIN, | |
@@ -897,8 +897,8 b' class _BaseTestApi(object):' | |||||
897 | fixture.destroy_repo(repo_name) |
|
897 | fixture.destroy_repo(repo_name) | |
898 |
|
898 | |||
899 | def test_api_create_repo_and_repo_group(self): |
|
899 | def test_api_create_repo_and_repo_group(self): | |
900 |
repo_group_name = |
|
900 | repo_group_name = 'my_gr' | |
901 |
repo_name = |
|
901 | repo_name = '%s/api-repo' % repo_group_name | |
902 |
|
902 | |||
903 | # repo creation can no longer also create repo group |
|
903 | # repo creation can no longer also create repo group | |
904 | id_, params = _build_data(self.apikey, 'create_repo', |
|
904 | id_, params = _build_data(self.apikey, 'create_repo', | |
@@ -906,7 +906,7 b' class _BaseTestApi(object):' | |||||
906 | owner=base.TEST_USER_ADMIN_LOGIN, |
|
906 | owner=base.TEST_USER_ADMIN_LOGIN, | |
907 | repo_type=self.REPO_TYPE,) |
|
907 | repo_type=self.REPO_TYPE,) | |
908 | response = api_call(self, params) |
|
908 | response = api_call(self, params) | |
909 |
expected = |
|
909 | expected = 'repo group `%s` not found' % repo_group_name | |
910 | self._compare_error(id_, expected, given=response.body) |
|
910 | self._compare_error(id_, expected, given=response.body) | |
911 | assert RepoModel().get_by_repo_name(repo_name) is None |
|
911 | assert RepoModel().get_by_repo_name(repo_name) is None | |
912 |
|
912 | |||
@@ -932,9 +932,9 b' class _BaseTestApi(object):' | |||||
932 | fixture.destroy_repo_group(repo_group_name) |
|
932 | fixture.destroy_repo_group(repo_group_name) | |
933 |
|
933 | |||
934 | def test_api_create_repo_in_repo_group_without_permission(self): |
|
934 | def test_api_create_repo_in_repo_group_without_permission(self): | |
935 |
repo_group_basename = |
|
935 | repo_group_basename = 'api-repo-repo' | |
936 |
repo_group_name = |
|
936 | repo_group_name = '%s/%s' % (TEST_REPO_GROUP, repo_group_basename) | |
937 |
repo_name = |
|
937 | repo_name = '%s/api-repo' % repo_group_name | |
938 |
|
938 | |||
939 | top_group = RepoGroup.get_by_group_name(TEST_REPO_GROUP) |
|
939 | top_group = RepoGroup.get_by_group_name(TEST_REPO_GROUP) | |
940 | assert top_group |
|
940 | assert top_group | |
@@ -968,7 +968,7 b' class _BaseTestApi(object):' | |||||
968 | fixture.destroy_repo_group(repo_group_name) |
|
968 | fixture.destroy_repo_group(repo_group_name) | |
969 |
|
969 | |||
970 | def test_api_create_repo_unknown_owner(self): |
|
970 | def test_api_create_repo_unknown_owner(self): | |
971 |
repo_name = |
|
971 | repo_name = 'api-repo' | |
972 | owner = 'i-dont-exist' |
|
972 | owner = 'i-dont-exist' | |
973 | id_, params = _build_data(self.apikey, 'create_repo', |
|
973 | id_, params = _build_data(self.apikey, 'create_repo', | |
974 | repo_name=repo_name, |
|
974 | repo_name=repo_name, | |
@@ -980,7 +980,7 b' class _BaseTestApi(object):' | |||||
980 | self._compare_error(id_, expected, given=response.body) |
|
980 | self._compare_error(id_, expected, given=response.body) | |
981 |
|
981 | |||
982 | def test_api_create_repo_dont_specify_owner(self): |
|
982 | def test_api_create_repo_dont_specify_owner(self): | |
983 |
repo_name = |
|
983 | repo_name = 'api-repo' | |
984 | owner = 'i-dont-exist' |
|
984 | owner = 'i-dont-exist' | |
985 | id_, params = _build_data(self.apikey, 'create_repo', |
|
985 | id_, params = _build_data(self.apikey, 'create_repo', | |
986 | repo_name=repo_name, |
|
986 | repo_name=repo_name, | |
@@ -1000,7 +1000,7 b' class _BaseTestApi(object):' | |||||
1000 | fixture.destroy_repo(repo_name) |
|
1000 | fixture.destroy_repo(repo_name) | |
1001 |
|
1001 | |||
1002 | def test_api_create_repo_by_non_admin(self): |
|
1002 | def test_api_create_repo_by_non_admin(self): | |
1003 |
repo_name = |
|
1003 | repo_name = 'api-repo' | |
1004 | owner = 'i-dont-exist' |
|
1004 | owner = 'i-dont-exist' | |
1005 | id_, params = _build_data(self.apikey_regular, 'create_repo', |
|
1005 | id_, params = _build_data(self.apikey_regular, 'create_repo', | |
1006 | repo_name=repo_name, |
|
1006 | repo_name=repo_name, | |
@@ -1020,7 +1020,7 b' class _BaseTestApi(object):' | |||||
1020 | fixture.destroy_repo(repo_name) |
|
1020 | fixture.destroy_repo(repo_name) | |
1021 |
|
1021 | |||
1022 | def test_api_create_repo_by_non_admin_specify_owner(self): |
|
1022 | def test_api_create_repo_by_non_admin_specify_owner(self): | |
1023 |
repo_name = |
|
1023 | repo_name = 'api-repo' | |
1024 | owner = 'i-dont-exist' |
|
1024 | owner = 'i-dont-exist' | |
1025 | id_, params = _build_data(self.apikey_regular, 'create_repo', |
|
1025 | id_, params = _build_data(self.apikey_regular, 'create_repo', | |
1026 | repo_name=repo_name, |
|
1026 | repo_name=repo_name, | |
@@ -1051,13 +1051,13 b' class _BaseTestApi(object):' | |||||
1051 | owner=base.TEST_USER_ADMIN_LOGIN, |
|
1051 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1052 | repo_type=self.REPO_TYPE,) |
|
1052 | repo_type=self.REPO_TYPE,) | |
1053 | response = api_call(self, params) |
|
1053 | response = api_call(self, params) | |
1054 |
expected = |
|
1054 | expected = 'repo group `%s` not found' % group_name | |
1055 | self._compare_error(id_, expected, given=response.body) |
|
1055 | self._compare_error(id_, expected, given=response.body) | |
1056 | fixture.destroy_repo(repo_name) |
|
1056 | fixture.destroy_repo(repo_name) | |
1057 |
|
1057 | |||
1058 | @mock.patch.object(RepoModel, 'create', crash) |
|
1058 | @mock.patch.object(RepoModel, 'create', crash) | |
1059 | def test_api_create_repo_exception_occurred(self): |
|
1059 | def test_api_create_repo_exception_occurred(self): | |
1060 |
repo_name = |
|
1060 | repo_name = 'api-repo' | |
1061 | id_, params = _build_data(self.apikey, 'create_repo', |
|
1061 | id_, params = _build_data(self.apikey, 'create_repo', | |
1062 | repo_name=repo_name, |
|
1062 | repo_name=repo_name, | |
1063 | owner=base.TEST_USER_ADMIN_LOGIN, |
|
1063 | owner=base.TEST_USER_ADMIN_LOGIN, | |
@@ -1068,18 +1068,18 b' class _BaseTestApi(object):' | |||||
1068 |
|
1068 | |||
1069 | @base.parametrize('changing_attr,updates', [ |
|
1069 | @base.parametrize('changing_attr,updates', [ | |
1070 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), |
|
1070 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1071 |
('description', {'description': |
|
1071 | ('description', {'description': 'new description'}), | |
1072 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail |
|
1072 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail | |
1073 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control |
|
1073 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control | |
1074 | ('clone_uri', {'clone_uri': None}), |
|
1074 | ('clone_uri', {'clone_uri': None}), | |
1075 | ('landing_rev', {'landing_rev': 'branch:master'}), |
|
1075 | ('landing_rev', {'landing_rev': 'branch:master'}), | |
1076 | ('enable_statistics', {'enable_statistics': True}), |
|
1076 | ('enable_statistics', {'enable_statistics': True}), | |
1077 | ('enable_downloads', {'enable_downloads': True}), |
|
1077 | ('enable_downloads', {'enable_downloads': True}), | |
1078 |
('name', {'name': |
|
1078 | ('name', {'name': 'new_repo_name'}), | |
1079 |
('repo_group', {'group': |
|
1079 | ('repo_group', {'group': 'test_group_for_update'}), | |
1080 | ]) |
|
1080 | ]) | |
1081 | def test_api_update_repo(self, changing_attr, updates): |
|
1081 | def test_api_update_repo(self, changing_attr, updates): | |
1082 |
repo_name = |
|
1082 | repo_name = 'api_update_me' | |
1083 | repo = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1083 | repo = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1084 | if changing_attr == 'repo_group': |
|
1084 | if changing_attr == 'repo_group': | |
1085 | fixture.create_repo_group(updates['group']) |
|
1085 | fixture.create_repo_group(updates['group']) | |
@@ -1090,10 +1090,10 b' class _BaseTestApi(object):' | |||||
1090 | if changing_attr == 'name': |
|
1090 | if changing_attr == 'name': | |
1091 | repo_name = updates['name'] |
|
1091 | repo_name = updates['name'] | |
1092 | if changing_attr == 'repo_group': |
|
1092 | if changing_attr == 'repo_group': | |
1093 |
repo_name = |
|
1093 | repo_name = '/'.join([updates['group'], repo_name]) | |
1094 | try: |
|
1094 | try: | |
1095 | if changing_attr == 'clone_uri' and updates['clone_uri']: |
|
1095 | if changing_attr == 'clone_uri' and updates['clone_uri']: | |
1096 |
expected = |
|
1096 | expected = 'failed to update repo `%s`' % repo_name | |
1097 | self._compare_error(id_, expected, given=response.body) |
|
1097 | self._compare_error(id_, expected, given=response.body) | |
1098 | else: |
|
1098 | else: | |
1099 | expected = { |
|
1099 | expected = { | |
@@ -1108,20 +1108,20 b' class _BaseTestApi(object):' | |||||
1108 |
|
1108 | |||
1109 | @base.parametrize('changing_attr,updates', [ |
|
1109 | @base.parametrize('changing_attr,updates', [ | |
1110 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), |
|
1110 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1111 |
('description', {'description': |
|
1111 | ('description', {'description': 'new description'}), | |
1112 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail |
|
1112 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail | |
1113 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control |
|
1113 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control | |
1114 | ('clone_uri', {'clone_uri': None}), |
|
1114 | ('clone_uri', {'clone_uri': None}), | |
1115 | ('landing_rev', {'landing_rev': 'branch:master'}), |
|
1115 | ('landing_rev', {'landing_rev': 'branch:master'}), | |
1116 | ('enable_statistics', {'enable_statistics': True}), |
|
1116 | ('enable_statistics', {'enable_statistics': True}), | |
1117 | ('enable_downloads', {'enable_downloads': True}), |
|
1117 | ('enable_downloads', {'enable_downloads': True}), | |
1118 |
('name', {'name': |
|
1118 | ('name', {'name': 'new_repo_name'}), | |
1119 |
('repo_group', {'group': |
|
1119 | ('repo_group', {'group': 'test_group_for_update'}), | |
1120 | ]) |
|
1120 | ]) | |
1121 | def test_api_update_group_repo(self, changing_attr, updates): |
|
1121 | def test_api_update_group_repo(self, changing_attr, updates): | |
1122 |
group_name = |
|
1122 | group_name = 'lololo' | |
1123 | fixture.create_repo_group(group_name) |
|
1123 | fixture.create_repo_group(group_name) | |
1124 |
repo_name = |
|
1124 | repo_name = '%s/api_update_me' % group_name | |
1125 | repo = fixture.create_repo(repo_name, repo_group=group_name, repo_type=self.REPO_TYPE) |
|
1125 | repo = fixture.create_repo(repo_name, repo_group=group_name, repo_type=self.REPO_TYPE) | |
1126 | if changing_attr == 'repo_group': |
|
1126 | if changing_attr == 'repo_group': | |
1127 | fixture.create_repo_group(updates['group']) |
|
1127 | fixture.create_repo_group(updates['group']) | |
@@ -1130,12 +1130,12 b' class _BaseTestApi(object):' | |||||
1130 | repoid=repo_name, **updates) |
|
1130 | repoid=repo_name, **updates) | |
1131 | response = api_call(self, params) |
|
1131 | response = api_call(self, params) | |
1132 | if changing_attr == 'name': |
|
1132 | if changing_attr == 'name': | |
1133 |
repo_name = |
|
1133 | repo_name = '%s/%s' % (group_name, updates['name']) | |
1134 | if changing_attr == 'repo_group': |
|
1134 | if changing_attr == 'repo_group': | |
1135 |
repo_name = |
|
1135 | repo_name = '/'.join([updates['group'], repo_name.rsplit('/', 1)[-1]]) | |
1136 | try: |
|
1136 | try: | |
1137 | if changing_attr == 'clone_uri' and updates['clone_uri']: |
|
1137 | if changing_attr == 'clone_uri' and updates['clone_uri']: | |
1138 |
expected = |
|
1138 | expected = 'failed to update repo `%s`' % repo_name | |
1139 | self._compare_error(id_, expected, given=response.body) |
|
1139 | self._compare_error(id_, expected, given=response.body) | |
1140 | else: |
|
1140 | else: | |
1141 | expected = { |
|
1141 | expected = { | |
@@ -1150,7 +1150,7 b' class _BaseTestApi(object):' | |||||
1150 | fixture.destroy_repo_group(group_name) |
|
1150 | fixture.destroy_repo_group(group_name) | |
1151 |
|
1151 | |||
1152 | def test_api_update_repo_repo_group_does_not_exist(self): |
|
1152 | def test_api_update_repo_repo_group_does_not_exist(self): | |
1153 |
repo_name = |
|
1153 | repo_name = 'admin_owned' | |
1154 | fixture.create_repo(repo_name) |
|
1154 | fixture.create_repo(repo_name) | |
1155 | updates = {'group': 'test_group_for_update'} |
|
1155 | updates = {'group': 'test_group_for_update'} | |
1156 | id_, params = _build_data(self.apikey, 'update_repo', |
|
1156 | id_, params = _build_data(self.apikey, 'update_repo', | |
@@ -1163,7 +1163,7 b' class _BaseTestApi(object):' | |||||
1163 | fixture.destroy_repo(repo_name) |
|
1163 | fixture.destroy_repo(repo_name) | |
1164 |
|
1164 | |||
1165 | def test_api_update_repo_regular_user_not_allowed(self): |
|
1165 | def test_api_update_repo_regular_user_not_allowed(self): | |
1166 |
repo_name = |
|
1166 | repo_name = 'admin_owned' | |
1167 | fixture.create_repo(repo_name) |
|
1167 | fixture.create_repo(repo_name) | |
1168 | updates = {'description': 'something else'} |
|
1168 | updates = {'description': 'something else'} | |
1169 | id_, params = _build_data(self.apikey_regular, 'update_repo', |
|
1169 | id_, params = _build_data(self.apikey_regular, 'update_repo', | |
@@ -1177,7 +1177,7 b' class _BaseTestApi(object):' | |||||
1177 |
|
1177 | |||
1178 | @mock.patch.object(RepoModel, 'update', crash) |
|
1178 | @mock.patch.object(RepoModel, 'update', crash) | |
1179 | def test_api_update_repo_exception_occurred(self): |
|
1179 | def test_api_update_repo_exception_occurred(self): | |
1180 |
repo_name = |
|
1180 | repo_name = 'api_update_me' | |
1181 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1181 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1182 | id_, params = _build_data(self.apikey, 'update_repo', |
|
1182 | id_, params = _build_data(self.apikey, 'update_repo', | |
1183 | repoid=repo_name, owner=base.TEST_USER_ADMIN_LOGIN,) |
|
1183 | repoid=repo_name, owner=base.TEST_USER_ADMIN_LOGIN,) | |
@@ -1189,8 +1189,8 b' class _BaseTestApi(object):' | |||||
1189 | fixture.destroy_repo(repo_name) |
|
1189 | fixture.destroy_repo(repo_name) | |
1190 |
|
1190 | |||
1191 | def test_api_update_repo_regular_user_change_repo_name(self): |
|
1191 | def test_api_update_repo_regular_user_change_repo_name(self): | |
1192 |
repo_name = |
|
1192 | repo_name = 'admin_owned' | |
1193 |
new_repo_name = |
|
1193 | new_repo_name = 'new_repo_name' | |
1194 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1194 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1195 | RepoModel().grant_user_permission(repo=repo_name, |
|
1195 | RepoModel().grant_user_permission(repo=repo_name, | |
1196 | user=self.TEST_USER_LOGIN, |
|
1196 | user=self.TEST_USER_LOGIN, | |
@@ -1209,8 +1209,8 b' class _BaseTestApi(object):' | |||||
1209 | fixture.destroy_repo(new_repo_name) |
|
1209 | fixture.destroy_repo(new_repo_name) | |
1210 |
|
1210 | |||
1211 | def test_api_update_repo_regular_user_change_repo_name_allowed(self): |
|
1211 | def test_api_update_repo_regular_user_change_repo_name_allowed(self): | |
1212 |
repo_name = |
|
1212 | repo_name = 'admin_owned' | |
1213 |
new_repo_name = |
|
1213 | new_repo_name = 'new_repo_name' | |
1214 | repo = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1214 | repo = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1215 | RepoModel().grant_user_permission(repo=repo_name, |
|
1215 | RepoModel().grant_user_permission(repo=repo_name, | |
1216 | user=self.TEST_USER_LOGIN, |
|
1216 | user=self.TEST_USER_LOGIN, | |
@@ -1232,7 +1232,7 b' class _BaseTestApi(object):' | |||||
1232 | fixture.destroy_repo(new_repo_name) |
|
1232 | fixture.destroy_repo(new_repo_name) | |
1233 |
|
1233 | |||
1234 | def test_api_update_repo_regular_user_change_owner(self): |
|
1234 | def test_api_update_repo_regular_user_change_owner(self): | |
1235 |
repo_name = |
|
1235 | repo_name = 'admin_owned' | |
1236 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1236 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1237 | RepoModel().grant_user_permission(repo=repo_name, |
|
1237 | RepoModel().grant_user_permission(repo=repo_name, | |
1238 | user=self.TEST_USER_LOGIN, |
|
1238 | user=self.TEST_USER_LOGIN, | |
@@ -1248,7 +1248,7 b' class _BaseTestApi(object):' | |||||
1248 | fixture.destroy_repo(repo_name) |
|
1248 | fixture.destroy_repo(repo_name) | |
1249 |
|
1249 | |||
1250 | def test_api_delete_repo(self): |
|
1250 | def test_api_delete_repo(self): | |
1251 |
repo_name = |
|
1251 | repo_name = 'api_delete_me' | |
1252 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1252 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1253 |
|
1253 | |||
1254 | id_, params = _build_data(self.apikey, 'delete_repo', |
|
1254 | id_, params = _build_data(self.apikey, 'delete_repo', | |
@@ -1266,7 +1266,7 b' class _BaseTestApi(object):' | |||||
1266 | fixture.destroy_repo(repo_name) |
|
1266 | fixture.destroy_repo(repo_name) | |
1267 |
|
1267 | |||
1268 | def test_api_delete_repo_by_non_admin(self): |
|
1268 | def test_api_delete_repo_by_non_admin(self): | |
1269 |
repo_name = |
|
1269 | repo_name = 'api_delete_me' | |
1270 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE, |
|
1270 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE, | |
1271 | cur_user=self.TEST_USER_LOGIN) |
|
1271 | cur_user=self.TEST_USER_LOGIN) | |
1272 | id_, params = _build_data(self.apikey_regular, 'delete_repo', |
|
1272 | id_, params = _build_data(self.apikey_regular, 'delete_repo', | |
@@ -1284,7 +1284,7 b' class _BaseTestApi(object):' | |||||
1284 | fixture.destroy_repo(repo_name) |
|
1284 | fixture.destroy_repo(repo_name) | |
1285 |
|
1285 | |||
1286 | def test_api_delete_repo_by_non_admin_no_permission(self): |
|
1286 | def test_api_delete_repo_by_non_admin_no_permission(self): | |
1287 |
repo_name = |
|
1287 | repo_name = 'api_delete_me' | |
1288 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1288 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1289 | try: |
|
1289 | try: | |
1290 | id_, params = _build_data(self.apikey_regular, 'delete_repo', |
|
1290 | id_, params = _build_data(self.apikey_regular, 'delete_repo', | |
@@ -1296,7 +1296,7 b' class _BaseTestApi(object):' | |||||
1296 | fixture.destroy_repo(repo_name) |
|
1296 | fixture.destroy_repo(repo_name) | |
1297 |
|
1297 | |||
1298 | def test_api_delete_repo_exception_occurred(self): |
|
1298 | def test_api_delete_repo_exception_occurred(self): | |
1299 |
repo_name = |
|
1299 | repo_name = 'api_delete_me' | |
1300 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1300 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1301 | try: |
|
1301 | try: | |
1302 | with mock.patch.object(RepoModel, 'delete', crash): |
|
1302 | with mock.patch.object(RepoModel, 'delete', crash): | |
@@ -1310,7 +1310,7 b' class _BaseTestApi(object):' | |||||
1310 | fixture.destroy_repo(repo_name) |
|
1310 | fixture.destroy_repo(repo_name) | |
1311 |
|
1311 | |||
1312 | def test_api_fork_repo(self): |
|
1312 | def test_api_fork_repo(self): | |
1313 |
fork_name = |
|
1313 | fork_name = 'api-repo-fork' | |
1314 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1314 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1315 | repoid=self.REPO, |
|
1315 | repoid=self.REPO, | |
1316 | fork_name=fork_name, |
|
1316 | fork_name=fork_name, | |
@@ -1329,8 +1329,8 b' class _BaseTestApi(object):' | |||||
1329 | fixture.destroy_repo(fork_name) |
|
1329 | fixture.destroy_repo(fork_name) | |
1330 |
|
1330 | |||
1331 | @base.parametrize('fork_name', [ |
|
1331 | @base.parametrize('fork_name', [ | |
1332 |
|
|
1332 | 'api-repo-fork', | |
1333 |
|
|
1333 | '%s/api-repo-fork' % TEST_REPO_GROUP, | |
1334 | ]) |
|
1334 | ]) | |
1335 | def test_api_fork_repo_non_admin(self, fork_name): |
|
1335 | def test_api_fork_repo_non_admin(self, fork_name): | |
1336 | id_, params = _build_data(self.apikey_regular, 'fork_repo', |
|
1336 | id_, params = _build_data(self.apikey_regular, 'fork_repo', | |
@@ -1350,7 +1350,7 b' class _BaseTestApi(object):' | |||||
1350 | fixture.destroy_repo(fork_name) |
|
1350 | fixture.destroy_repo(fork_name) | |
1351 |
|
1351 | |||
1352 | def test_api_fork_repo_non_admin_specify_owner(self): |
|
1352 | def test_api_fork_repo_non_admin_specify_owner(self): | |
1353 |
fork_name = |
|
1353 | fork_name = 'api-repo-fork' | |
1354 | id_, params = _build_data(self.apikey_regular, 'fork_repo', |
|
1354 | id_, params = _build_data(self.apikey_regular, 'fork_repo', | |
1355 | repoid=self.REPO, |
|
1355 | repoid=self.REPO, | |
1356 | fork_name=fork_name, |
|
1356 | fork_name=fork_name, | |
@@ -1366,7 +1366,7 b' class _BaseTestApi(object):' | |||||
1366 | user=self.default_user_username, |
|
1366 | user=self.default_user_username, | |
1367 | perm='repository.none') |
|
1367 | perm='repository.none') | |
1368 | try: |
|
1368 | try: | |
1369 |
fork_name = |
|
1369 | fork_name = 'api-repo-fork' | |
1370 | id_, params = _build_data(self.apikey_regular, 'fork_repo', |
|
1370 | id_, params = _build_data(self.apikey_regular, 'fork_repo', | |
1371 | repoid=self.REPO, |
|
1371 | repoid=self.REPO, | |
1372 | fork_name=fork_name, |
|
1372 | fork_name=fork_name, | |
@@ -1386,7 +1386,7 b' class _BaseTestApi(object):' | |||||
1386 | ('admin', 'repository.admin'), |
|
1386 | ('admin', 'repository.admin'), | |
1387 | ]) |
|
1387 | ]) | |
1388 | def test_api_fork_repo_non_admin_no_create_repo_permission(self, name, perm): |
|
1388 | def test_api_fork_repo_non_admin_no_create_repo_permission(self, name, perm): | |
1389 |
fork_name = |
|
1389 | fork_name = 'api-repo-fork' | |
1390 | # regardless of base repository permission, forking is disallowed |
|
1390 | # regardless of base repository permission, forking is disallowed | |
1391 | # when repository creation is disabled |
|
1391 | # when repository creation is disabled | |
1392 | RepoModel().grant_user_permission(repo=self.REPO, |
|
1392 | RepoModel().grant_user_permission(repo=self.REPO, | |
@@ -1404,7 +1404,7 b' class _BaseTestApi(object):' | |||||
1404 | fixture.destroy_repo(fork_name) |
|
1404 | fixture.destroy_repo(fork_name) | |
1405 |
|
1405 | |||
1406 | def test_api_fork_repo_unknown_owner(self): |
|
1406 | def test_api_fork_repo_unknown_owner(self): | |
1407 |
fork_name = |
|
1407 | fork_name = 'api-repo-fork' | |
1408 | owner = 'i-dont-exist' |
|
1408 | owner = 'i-dont-exist' | |
1409 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1409 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1410 | repoid=self.REPO, |
|
1410 | repoid=self.REPO, | |
@@ -1416,11 +1416,11 b' class _BaseTestApi(object):' | |||||
1416 | self._compare_error(id_, expected, given=response.body) |
|
1416 | self._compare_error(id_, expected, given=response.body) | |
1417 |
|
1417 | |||
1418 | def test_api_fork_repo_fork_exists(self): |
|
1418 | def test_api_fork_repo_fork_exists(self): | |
1419 |
fork_name = |
|
1419 | fork_name = 'api-repo-fork' | |
1420 | fixture.create_fork(self.REPO, fork_name) |
|
1420 | fixture.create_fork(self.REPO, fork_name) | |
1421 |
|
1421 | |||
1422 | try: |
|
1422 | try: | |
1423 |
fork_name = |
|
1423 | fork_name = 'api-repo-fork' | |
1424 |
|
1424 | |||
1425 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1425 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1426 | repoid=self.REPO, |
|
1426 | repoid=self.REPO, | |
@@ -1449,7 +1449,7 b' class _BaseTestApi(object):' | |||||
1449 |
|
1449 | |||
1450 | @mock.patch.object(RepoModel, 'create_fork', crash) |
|
1450 | @mock.patch.object(RepoModel, 'create_fork', crash) | |
1451 | def test_api_fork_repo_exception_occurred(self): |
|
1451 | def test_api_fork_repo_exception_occurred(self): | |
1452 |
fork_name = |
|
1452 | fork_name = 'api-repo-fork' | |
1453 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1453 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1454 | repoid=self.REPO, |
|
1454 | repoid=self.REPO, | |
1455 | fork_name=fork_name, |
|
1455 | fork_name=fork_name, | |
@@ -1478,7 +1478,7 b' class _BaseTestApi(object):' | |||||
1478 | self._compare_ok(id_, expected, given=response.body) |
|
1478 | self._compare_ok(id_, expected, given=response.body) | |
1479 |
|
1479 | |||
1480 | def test_api_get_user_groups(self): |
|
1480 | def test_api_get_user_groups(self): | |
1481 |
gr_name = |
|
1481 | gr_name = 'test_user_group2' | |
1482 | make_user_group(gr_name) |
|
1482 | make_user_group(gr_name) | |
1483 |
|
1483 | |||
1484 | try: |
|
1484 | try: | |
@@ -1486,7 +1486,7 b' class _BaseTestApi(object):' | |||||
1486 | response = api_call(self, params) |
|
1486 | response = api_call(self, params) | |
1487 |
|
1487 | |||
1488 | expected = [] |
|
1488 | expected = [] | |
1489 |
for gr_name in [TEST_USER_GROUP, |
|
1489 | for gr_name in [TEST_USER_GROUP, 'test_user_group2']: | |
1490 | user_group = UserGroupModel().get_group(gr_name) |
|
1490 | user_group = UserGroupModel().get_group(gr_name) | |
1491 | ret = user_group.get_api_data() |
|
1491 | ret = user_group.get_api_data() | |
1492 | expected.append(ret) |
|
1492 | expected.append(ret) | |
@@ -1495,7 +1495,7 b' class _BaseTestApi(object):' | |||||
1495 | fixture.destroy_user_group(gr_name) |
|
1495 | fixture.destroy_user_group(gr_name) | |
1496 |
|
1496 | |||
1497 | def test_api_create_user_group(self): |
|
1497 | def test_api_create_user_group(self): | |
1498 |
group_name = |
|
1498 | group_name = 'some_new_group' | |
1499 | id_, params = _build_data(self.apikey, 'create_user_group', |
|
1499 | id_, params = _build_data(self.apikey, 'create_user_group', | |
1500 | group_name=group_name) |
|
1500 | group_name=group_name) | |
1501 | response = api_call(self, params) |
|
1501 | response = api_call(self, params) | |
@@ -1521,7 +1521,7 b' class _BaseTestApi(object):' | |||||
1521 |
|
1521 | |||
1522 | @mock.patch.object(UserGroupModel, 'create', crash) |
|
1522 | @mock.patch.object(UserGroupModel, 'create', crash) | |
1523 | def test_api_get_user_group_exception_occurred(self): |
|
1523 | def test_api_get_user_group_exception_occurred(self): | |
1524 |
group_name = |
|
1524 | group_name = 'exception_happens' | |
1525 | id_, params = _build_data(self.apikey, 'create_user_group', |
|
1525 | id_, params = _build_data(self.apikey, 'create_user_group', | |
1526 | group_name=group_name) |
|
1526 | group_name=group_name) | |
1527 | response = api_call(self, params) |
|
1527 | response = api_call(self, params) | |
@@ -1530,14 +1530,14 b' class _BaseTestApi(object):' | |||||
1530 | self._compare_error(id_, expected, given=response.body) |
|
1530 | self._compare_error(id_, expected, given=response.body) | |
1531 |
|
1531 | |||
1532 | @base.parametrize('changing_attr,updates', [ |
|
1532 | @base.parametrize('changing_attr,updates', [ | |
1533 |
('group_name', {'group_name': |
|
1533 | ('group_name', {'group_name': 'new_group_name'}), | |
1534 |
('group_name', {'group_name': |
|
1534 | ('group_name', {'group_name': 'test_group_for_update'}), | |
1535 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), |
|
1535 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1536 | ('active', {'active': False}), |
|
1536 | ('active', {'active': False}), | |
1537 | ('active', {'active': True}), |
|
1537 | ('active', {'active': True}), | |
1538 | ]) |
|
1538 | ]) | |
1539 | def test_api_update_user_group(self, changing_attr, updates): |
|
1539 | def test_api_update_user_group(self, changing_attr, updates): | |
1540 |
gr_name = |
|
1540 | gr_name = 'test_group_for_update' | |
1541 | user_group = fixture.create_user_group(gr_name) |
|
1541 | user_group = fixture.create_user_group(gr_name) | |
1542 | try: |
|
1542 | try: | |
1543 | id_, params = _build_data(self.apikey, 'update_user_group', |
|
1543 | id_, params = _build_data(self.apikey, 'update_user_group', | |
@@ -1557,7 +1557,7 b' class _BaseTestApi(object):' | |||||
1557 |
|
1557 | |||
1558 | @mock.patch.object(UserGroupModel, 'update', crash) |
|
1558 | @mock.patch.object(UserGroupModel, 'update', crash) | |
1559 | def test_api_update_user_group_exception_occurred(self): |
|
1559 | def test_api_update_user_group_exception_occurred(self): | |
1560 |
gr_name = |
|
1560 | gr_name = 'test_group' | |
1561 | fixture.create_user_group(gr_name) |
|
1561 | fixture.create_user_group(gr_name) | |
1562 | try: |
|
1562 | try: | |
1563 | id_, params = _build_data(self.apikey, 'update_user_group', |
|
1563 | id_, params = _build_data(self.apikey, 'update_user_group', | |
@@ -1569,7 +1569,7 b' class _BaseTestApi(object):' | |||||
1569 | fixture.destroy_user_group(gr_name) |
|
1569 | fixture.destroy_user_group(gr_name) | |
1570 |
|
1570 | |||
1571 | def test_api_add_user_to_user_group(self): |
|
1571 | def test_api_add_user_to_user_group(self): | |
1572 |
gr_name = |
|
1572 | gr_name = 'test_group' | |
1573 | fixture.create_user_group(gr_name) |
|
1573 | fixture.create_user_group(gr_name) | |
1574 | try: |
|
1574 | try: | |
1575 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', |
|
1575 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', | |
@@ -1596,7 +1596,7 b' class _BaseTestApi(object):' | |||||
1596 |
|
1596 | |||
1597 | @mock.patch.object(UserGroupModel, 'add_user_to_group', crash) |
|
1597 | @mock.patch.object(UserGroupModel, 'add_user_to_group', crash) | |
1598 | def test_api_add_user_to_user_group_exception_occurred(self): |
|
1598 | def test_api_add_user_to_user_group_exception_occurred(self): | |
1599 |
gr_name = |
|
1599 | gr_name = 'test_group' | |
1600 | fixture.create_user_group(gr_name) |
|
1600 | fixture.create_user_group(gr_name) | |
1601 | try: |
|
1601 | try: | |
1602 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', |
|
1602 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', | |
@@ -1609,7 +1609,7 b' class _BaseTestApi(object):' | |||||
1609 | fixture.destroy_user_group(gr_name) |
|
1609 | fixture.destroy_user_group(gr_name) | |
1610 |
|
1610 | |||
1611 | def test_api_remove_user_from_user_group(self): |
|
1611 | def test_api_remove_user_from_user_group(self): | |
1612 |
gr_name = |
|
1612 | gr_name = 'test_group_3' | |
1613 | gr = fixture.create_user_group(gr_name) |
|
1613 | gr = fixture.create_user_group(gr_name) | |
1614 | UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN) |
|
1614 | UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN) | |
1615 | Session().commit() |
|
1615 | Session().commit() | |
@@ -1629,7 +1629,7 b' class _BaseTestApi(object):' | |||||
1629 |
|
1629 | |||
1630 | @mock.patch.object(UserGroupModel, 'remove_user_from_group', crash) |
|
1630 | @mock.patch.object(UserGroupModel, 'remove_user_from_group', crash) | |
1631 | def test_api_remove_user_from_user_group_exception_occurred(self): |
|
1631 | def test_api_remove_user_from_user_group_exception_occurred(self): | |
1632 |
gr_name = |
|
1632 | gr_name = 'test_group_3' | |
1633 | gr = fixture.create_user_group(gr_name) |
|
1633 | gr = fixture.create_user_group(gr_name) | |
1634 | UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN) |
|
1634 | UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN) | |
1635 | Session().commit() |
|
1635 | Session().commit() | |
@@ -1644,7 +1644,7 b' class _BaseTestApi(object):' | |||||
1644 | fixture.destroy_user_group(gr_name) |
|
1644 | fixture.destroy_user_group(gr_name) | |
1645 |
|
1645 | |||
1646 | def test_api_delete_user_group(self): |
|
1646 | def test_api_delete_user_group(self): | |
1647 |
gr_name = |
|
1647 | gr_name = 'test_group' | |
1648 | ugroup = fixture.create_user_group(gr_name) |
|
1648 | ugroup = fixture.create_user_group(gr_name) | |
1649 | gr_id = ugroup.users_group_id |
|
1649 | gr_id = ugroup.users_group_id | |
1650 | try: |
|
1650 | try: | |
@@ -1661,7 +1661,7 b' class _BaseTestApi(object):' | |||||
1661 | fixture.destroy_user_group(gr_name) |
|
1661 | fixture.destroy_user_group(gr_name) | |
1662 |
|
1662 | |||
1663 | def test_api_delete_user_group_that_is_assigned(self): |
|
1663 | def test_api_delete_user_group_that_is_assigned(self): | |
1664 |
gr_name = |
|
1664 | gr_name = 'test_group' | |
1665 | ugroup = fixture.create_user_group(gr_name) |
|
1665 | ugroup = fixture.create_user_group(gr_name) | |
1666 | gr_id = ugroup.users_group_id |
|
1666 | gr_id = ugroup.users_group_id | |
1667 |
|
1667 | |||
@@ -1679,7 +1679,7 b' class _BaseTestApi(object):' | |||||
1679 | fixture.destroy_user_group(gr_name) |
|
1679 | fixture.destroy_user_group(gr_name) | |
1680 |
|
1680 | |||
1681 | def test_api_delete_user_group_exception_occurred(self): |
|
1681 | def test_api_delete_user_group_exception_occurred(self): | |
1682 |
gr_name = |
|
1682 | gr_name = 'test_group' | |
1683 | ugroup = fixture.create_user_group(gr_name) |
|
1683 | ugroup = fixture.create_user_group(gr_name) | |
1684 | gr_id = ugroup.users_group_id |
|
1684 | gr_id = ugroup.users_group_id | |
1685 | id_, params = _build_data(self.apikey, 'delete_user_group', |
|
1685 | id_, params = _build_data(self.apikey, 'delete_user_group', | |
@@ -2467,7 +2467,7 b' class _BaseTestApi(object):' | |||||
2467 | id_, params = _build_data(self.apikey, 'get_changeset', |
|
2467 | id_, params = _build_data(self.apikey, 'get_changeset', | |
2468 | repoid=self.REPO, raw_id = '7ab37bc680b4aa72c34d07b230c866c28e9fcfff') |
|
2468 | repoid=self.REPO, raw_id = '7ab37bc680b4aa72c34d07b230c866c28e9fcfff') | |
2469 | response = api_call(self, params) |
|
2469 | response = api_call(self, params) | |
2470 |
expected = |
|
2470 | expected = 'Changeset %s does not exist' % ('7ab37bc680b4aa72c34d07b230c866c28e9fcfff',) | |
2471 | self._compare_error(id_, expected, given=response.body) |
|
2471 | self._compare_error(id_, expected, given=response.body) | |
2472 |
|
2472 | |||
2473 | def test_api_get_changeset_without_permission(self): |
|
2473 | def test_api_get_changeset_without_permission(self): | |
@@ -2477,11 +2477,11 b' class _BaseTestApi(object):' | |||||
2477 | id_, params = _build_data(self.apikey_regular, 'get_changeset', |
|
2477 | id_, params = _build_data(self.apikey_regular, 'get_changeset', | |
2478 | repoid=self.REPO, raw_id=self.TEST_REVISION) |
|
2478 | repoid=self.REPO, raw_id=self.TEST_REVISION) | |
2479 | response = api_call(self, params) |
|
2479 | response = api_call(self, params) | |
2480 |
expected = |
|
2480 | expected = 'Access denied to repo %s' % self.REPO | |
2481 | self._compare_error(id_, expected, given=response.body) |
|
2481 | self._compare_error(id_, expected, given=response.body) | |
2482 |
|
2482 | |||
2483 | def test_api_get_pullrequest(self): |
|
2483 | def test_api_get_pullrequest(self): | |
2484 |
pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, |
|
2484 | pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, 'get test') | |
2485 | random_id = random.randrange(1, 9999) |
|
2485 | random_id = random.randrange(1, 9999) | |
2486 | params = ascii_bytes(ext_json.dumps({ |
|
2486 | params = ascii_bytes(ext_json.dumps({ | |
2487 | "id": random_id, |
|
2487 | "id": random_id, | |
@@ -2512,7 +2512,7 b' class _BaseTestApi(object):' | |||||
2512 | b"2000-01-01T00:00:00", response.body)) |
|
2512 | b"2000-01-01T00:00:00", response.body)) | |
2513 |
|
2513 | |||
2514 | def test_api_close_pullrequest(self): |
|
2514 | def test_api_close_pullrequest(self): | |
2515 |
pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, |
|
2515 | pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, 'close test') | |
2516 | random_id = random.randrange(1, 9999) |
|
2516 | random_id = random.randrange(1, 9999) | |
2517 | params = ascii_bytes(ext_json.dumps({ |
|
2517 | params = ascii_bytes(ext_json.dumps({ | |
2518 | "id": random_id, |
|
2518 | "id": random_id, | |
@@ -2528,7 +2528,7 b' class _BaseTestApi(object):' | |||||
2528 | assert pullrequest.is_closed() == True |
|
2528 | assert pullrequest.is_closed() == True | |
2529 |
|
2529 | |||
2530 | def test_api_status_pullrequest(self): |
|
2530 | def test_api_status_pullrequest(self): | |
2531 |
pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, |
|
2531 | pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, "status test") | |
2532 |
|
2532 | |||
2533 | random_id = random.randrange(1, 9999) |
|
2533 | random_id = random.randrange(1, 9999) | |
2534 | params = ascii_bytes(ext_json.dumps({ |
|
2534 | params = ascii_bytes(ext_json.dumps({ | |
@@ -2553,7 +2553,7 b' class _BaseTestApi(object):' | |||||
2553 | assert ChangesetStatus.STATUS_APPROVED == ChangesetStatusModel().calculate_pull_request_result(pullrequest)[2] |
|
2553 | assert ChangesetStatus.STATUS_APPROVED == ChangesetStatusModel().calculate_pull_request_result(pullrequest)[2] | |
2554 |
|
2554 | |||
2555 | def test_api_comment_pullrequest(self): |
|
2555 | def test_api_comment_pullrequest(self): | |
2556 |
pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, |
|
2556 | pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, "comment test") | |
2557 | random_id = random.randrange(1, 9999) |
|
2557 | random_id = random.randrange(1, 9999) | |
2558 | params = ascii_bytes(ext_json.dumps({ |
|
2558 | params = ascii_bytes(ext_json.dumps({ | |
2559 | "id": random_id, |
|
2559 | "id": random_id, | |
@@ -2564,4 +2564,4 b' class _BaseTestApi(object):' | |||||
2564 | response = api_call(self, params) |
|
2564 | response = api_call(self, params) | |
2565 | self._compare_ok(random_id, True, given=response.body) |
|
2565 | self._compare_ok(random_id, True, given=response.body) | |
2566 | pullrequest = PullRequest().get(pull_request_id) |
|
2566 | pullrequest = PullRequest().get(pull_request_id) | |
2567 |
assert pullrequest.comments[-1].text == |
|
2567 | assert pullrequest.comments[-1].text == 'Looks good to me' |
@@ -20,9 +20,9 b' class TestGitApi(_BaseTestApi, TestContr' | |||||
20 | REPO = GIT_REPO |
|
20 | REPO = GIT_REPO | |
21 | REPO_TYPE = 'git' |
|
21 | REPO_TYPE = 'git' | |
22 | TEST_REVISION = GIT_TEST_REVISION |
|
22 | TEST_REVISION = GIT_TEST_REVISION | |
23 |
TEST_PR_SRC = |
|
23 | TEST_PR_SRC = 'c60f01b77c42dce653d6b1d3b04689862c261929' | |
24 |
TEST_PR_DST = |
|
24 | TEST_PR_DST = '10cddef6b794696066fb346434014f0a56810218' | |
25 |
TEST_PR_REVISIONS = [ |
|
25 | TEST_PR_REVISIONS = ['1bead5880d2dbe831762bf7fb439ba2919b75fdd', | |
26 |
|
|
26 | '9bcd3ecfc8832a8cd881c1c1bbe2d13ffa9d94c7', | |
27 |
|
|
27 | '283de4dfca8479875a1befb8d4059f3bbb725145', | |
28 |
|
|
28 | 'c60f01b77c42dce653d6b1d3b04689862c261929'] |
@@ -20,10 +20,10 b' class TestHgApi(_BaseTestApi, TestContro' | |||||
20 | REPO = HG_REPO |
|
20 | REPO = HG_REPO | |
21 | REPO_TYPE = 'hg' |
|
21 | REPO_TYPE = 'hg' | |
22 | TEST_REVISION = HG_TEST_REVISION |
|
22 | TEST_REVISION = HG_TEST_REVISION | |
23 |
TEST_PR_SRC = |
|
23 | TEST_PR_SRC = '4f7e2131323e0749a740c0a56ab68ae9269c562a' | |
24 |
TEST_PR_DST = |
|
24 | TEST_PR_DST = '92831aebf2f8dd4879e897024b89d09af214df1c' | |
25 |
TEST_PR_REVISIONS = [ |
|
25 | TEST_PR_REVISIONS = ['720bbdb27665d6262b313e8a541b654d0cbd5b27', | |
26 |
|
|
26 | 'f41649565a9e89919a588a163e717b4084f8a3b1', | |
27 |
|
|
27 | '94f45ed825a113e61af7e141f44ca578374abef0', | |
28 |
|
|
28 | 'fef5bfe1dc17611d5fb59a7f6f95c55c3606f933', | |
29 |
|
|
29 | '4f7e2131323e0749a740c0a56ab68ae9269c562a'] |
@@ -66,17 +66,17 b" TEST_USER_REGULAR2_EMAIL = 'test_regular" | |||||
66 |
|
66 | |||
67 | IP_ADDR = '127.0.0.127' |
|
67 | IP_ADDR = '127.0.0.127' | |
68 |
|
68 | |||
69 |
HG_REPO = |
|
69 | HG_REPO = 'vcs_test_hg' | |
70 |
GIT_REPO = |
|
70 | GIT_REPO = 'vcs_test_git' | |
71 |
|
71 | |||
72 |
NEW_HG_REPO = |
|
72 | NEW_HG_REPO = 'vcs_test_hg_new' | |
73 |
NEW_GIT_REPO = |
|
73 | NEW_GIT_REPO = 'vcs_test_git_new' | |
74 |
|
74 | |||
75 |
HG_FORK = |
|
75 | HG_FORK = 'vcs_test_hg_fork' | |
76 |
GIT_FORK = |
|
76 | GIT_FORK = 'vcs_test_git_fork' | |
77 |
|
77 | |||
78 |
HG_TEST_REVISION = |
|
78 | HG_TEST_REVISION = "a53d9201d4bc278910d416d94941b7ea007ecd52" | |
79 |
GIT_TEST_REVISION = |
|
79 | GIT_TEST_REVISION = "7ab37bc680b4aa72c34d07b230c866c28e9fc204" | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | ## VCS |
|
82 | ## VCS | |
@@ -180,14 +180,14 b' class TestController(object):' | |||||
180 |
|
180 | |||
181 | def checkSessionFlash(self, response, msg=None, skip=0, _matcher=lambda msg, m: msg in m): |
|
181 | def checkSessionFlash(self, response, msg=None, skip=0, _matcher=lambda msg, m: msg in m): | |
182 | if 'flash' not in response.session: |
|
182 | if 'flash' not in response.session: | |
183 |
pytest.fail( |
|
183 | pytest.fail('msg `%s` not found - session has no flash:\n%s' % (msg, response)) | |
184 | try: |
|
184 | try: | |
185 | level, m = response.session['flash'][-1 - skip] |
|
185 | level, m = response.session['flash'][-1 - skip] | |
186 | if _matcher(msg, m): |
|
186 | if _matcher(msg, m): | |
187 | return |
|
187 | return | |
188 | except IndexError: |
|
188 | except IndexError: | |
189 | pass |
|
189 | pass | |
190 |
pytest.fail( |
|
190 | pytest.fail('msg `%s` not found in session flash (skipping %s): %s' % | |
191 | (msg, skip, ', '.join('`%s`' % m for level, m in response.session['flash']))) |
|
191 | (msg, skip, ', '.join('`%s`' % m for level, m in response.session['flash']))) | |
192 |
|
192 | |||
193 | def checkSessionFlashRegex(self, response, regex, skip=0): |
|
193 | def checkSessionFlashRegex(self, response, regex, skip=0): |
@@ -92,8 +92,8 b' class Fixture(object):' | |||||
92 | repo_name=None, |
|
92 | repo_name=None, | |
93 | repo_type='hg', |
|
93 | repo_type='hg', | |
94 | clone_uri='', |
|
94 | clone_uri='', | |
95 |
repo_group= |
|
95 | repo_group='-1', | |
96 |
repo_description= |
|
96 | repo_description='DESC', | |
97 | repo_private=False, |
|
97 | repo_private=False, | |
98 | repo_landing_rev='rev:tip', |
|
98 | repo_landing_rev='rev:tip', | |
99 | repo_copy_permissions=False, |
|
99 | repo_copy_permissions=False, | |
@@ -113,8 +113,8 b' class Fixture(object):' | |||||
113 | """Return form values to be validated through RepoGroupForm""" |
|
113 | """Return form values to be validated through RepoGroupForm""" | |
114 | defs = dict( |
|
114 | defs = dict( | |
115 | group_name=None, |
|
115 | group_name=None, | |
116 |
group_description= |
|
116 | group_description='DESC', | |
117 |
parent_group_id= |
|
117 | parent_group_id='-1', | |
118 | perms_updates=[], |
|
118 | perms_updates=[], | |
119 | perms_new=[], |
|
119 | perms_new=[], | |
120 | recursive=False |
|
120 | recursive=False | |
@@ -128,8 +128,8 b' class Fixture(object):' | |||||
128 | username=name, |
|
128 | username=name, | |
129 | password='qweqwe', |
|
129 | password='qweqwe', | |
130 | email='%s+test@example.com' % name, |
|
130 | email='%s+test@example.com' % name, | |
131 |
firstname= |
|
131 | firstname='TestUser', | |
132 |
lastname= |
|
132 | lastname='Test', | |
133 | active=True, |
|
133 | active=True, | |
134 | admin=False, |
|
134 | admin=False, | |
135 | extern_type='internal', |
|
135 | extern_type='internal', | |
@@ -142,7 +142,7 b' class Fixture(object):' | |||||
142 | def _get_user_group_create_params(self, name, **custom): |
|
142 | def _get_user_group_create_params(self, name, **custom): | |
143 | defs = dict( |
|
143 | defs = dict( | |
144 | users_group_name=name, |
|
144 | users_group_name=name, | |
145 |
user_group_description= |
|
145 | user_group_description='DESC', | |
146 | users_group_active=True, |
|
146 | users_group_active=True, | |
147 | user_group_data={}, |
|
147 | user_group_data={}, | |
148 | ) |
|
148 | ) | |
@@ -253,7 +253,7 b' class Fixture(object):' | |||||
253 |
|
253 | |||
254 | def create_gist(self, **kwargs): |
|
254 | def create_gist(self, **kwargs): | |
255 | form_data = { |
|
255 | form_data = { | |
256 |
'description': |
|
256 | 'description': 'new-gist', | |
257 | 'owner': TEST_USER_ADMIN_LOGIN, |
|
257 | 'owner': TEST_USER_ADMIN_LOGIN, | |
258 | 'gist_type': Gist.GIST_PUBLIC, |
|
258 | 'gist_type': Gist.GIST_PUBLIC, | |
259 | 'lifetime': -1, |
|
259 | 'lifetime': -1, | |
@@ -324,12 +324,12 b' class Fixture(object):' | |||||
324 | return cs |
|
324 | return cs | |
325 |
|
325 | |||
326 | def review_changeset(self, repo, revision, status, author=TEST_USER_ADMIN_LOGIN): |
|
326 | def review_changeset(self, repo, revision, status, author=TEST_USER_ADMIN_LOGIN): | |
327 |
comment = ChangesetCommentsModel().create( |
|
327 | comment = ChangesetCommentsModel().create("review comment", repo, author, revision=revision, send_email=False) | |
328 | csm = ChangesetStatusModel().set_status(repo, ChangesetStatus.STATUS_APPROVED, author, comment, revision=revision) |
|
328 | csm = ChangesetStatusModel().set_status(repo, ChangesetStatus.STATUS_APPROVED, author, comment, revision=revision) | |
329 | Session().commit() |
|
329 | Session().commit() | |
330 | return csm |
|
330 | return csm | |
331 |
|
331 | |||
332 |
def create_pullrequest(self, testcontroller, repo_name, pr_src_rev, pr_dst_rev, title= |
|
332 | def create_pullrequest(self, testcontroller, repo_name, pr_src_rev, pr_dst_rev, title='title'): | |
333 | org_ref = 'branch:stable:%s' % pr_src_rev |
|
333 | org_ref = 'branch:stable:%s' % pr_src_rev | |
334 | other_ref = 'branch:default:%s' % pr_dst_rev |
|
334 | other_ref = 'branch:default:%s' % pr_dst_rev | |
335 | with test_context(testcontroller.app): # needed to be able to mock request user |
|
335 | with test_context(testcontroller.app): # needed to be able to mock request user | |
@@ -339,7 +339,7 b' class Fixture(object):' | |||||
339 | request.authuser = AuthUser(dbuser=owner_user) |
|
339 | request.authuser = AuthUser(dbuser=owner_user) | |
340 | # creating a PR sends a message with an absolute URL - without routing that requires mocking |
|
340 | # creating a PR sends a message with an absolute URL - without routing that requires mocking | |
341 | with mock.patch.object(helpers, 'url', (lambda arg, qualified=False, **kwargs: ('https://localhost' if qualified else '') + '/fake/' + arg)): |
|
341 | with mock.patch.object(helpers, 'url', (lambda arg, qualified=False, **kwargs: ('https://localhost' if qualified else '') + '/fake/' + arg)): | |
342 |
cmd = CreatePullRequestAction(org_repo, other_repo, org_ref, other_ref, title, |
|
342 | cmd = CreatePullRequestAction(org_repo, other_repo, org_ref, other_ref, title, 'No description', owner_user, reviewers) | |
343 | pull_request = cmd.execute() |
|
343 | pull_request = cmd.execute() | |
344 | Session().commit() |
|
344 | Session().commit() | |
345 | return pull_request.pull_request_id |
|
345 | return pull_request.pull_request_id |
@@ -26,7 +26,7 b' class TestAuthSettingsController(base.Te' | |||||
26 | self.log_user() |
|
26 | self.log_user() | |
27 |
|
27 | |||
28 | params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap') |
|
28 | params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap') | |
29 |
params.update({'auth_ldap_host': |
|
29 | params.update({'auth_ldap_host': 'dc.example.com', | |
30 | 'auth_ldap_port': '999', |
|
30 | 'auth_ldap_port': '999', | |
31 | 'auth_ldap_tls_kind': 'PLAIN', |
|
31 | 'auth_ldap_tls_kind': 'PLAIN', | |
32 | 'auth_ldap_tls_reqcert': 'NEVER', |
|
32 | 'auth_ldap_tls_reqcert': 'NEVER', | |
@@ -48,7 +48,7 b' class TestAuthSettingsController(base.Te' | |||||
48 | self.checkSessionFlash(response, 'Auth settings updated successfully') |
|
48 | self.checkSessionFlash(response, 'Auth settings updated successfully') | |
49 |
|
49 | |||
50 | new_settings = Setting.get_auth_settings() |
|
50 | new_settings = Setting.get_auth_settings() | |
51 |
assert new_settings['auth_ldap_host'] == |
|
51 | assert new_settings['auth_ldap_host'] == 'dc.example.com', 'fail db write compare' | |
52 |
|
52 | |||
53 | @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib') |
|
53 | @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib') | |
54 | def test_ldap_error_form_wrong_port_number(self): |
|
54 | def test_ldap_error_form_wrong_port_number(self): | |
@@ -239,7 +239,7 b' class TestAuthSettingsController(base.Te' | |||||
239 | self.checkSessionFlash(response, 'Auth settings updated successfully') |
|
239 | self.checkSessionFlash(response, 'Auth settings updated successfully') | |
240 |
|
240 | |||
241 | new_settings = Setting.get_auth_settings() |
|
241 | new_settings = Setting.get_auth_settings() | |
242 |
assert new_settings['auth_crowd_host'] == |
|
242 | assert new_settings['auth_crowd_host'] == 'hostname', 'fail db write compare' | |
243 |
|
243 | |||
244 | @base.skipif(not base.pam_lib_installed, reason='skipping due to missing pam lib') |
|
244 | @base.skipif(not base.pam_lib_installed, reason='skipping due to missing pam lib') | |
245 | def test_pam_save_settings(self): |
|
245 | def test_pam_save_settings(self): | |
@@ -256,4 +256,4 b' class TestAuthSettingsController(base.Te' | |||||
256 | self.checkSessionFlash(response, 'Auth settings updated successfully') |
|
256 | self.checkSessionFlash(response, 'Auth settings updated successfully') | |
257 |
|
257 | |||
258 | new_settings = Setting.get_auth_settings() |
|
258 | new_settings = Setting.get_auth_settings() | |
259 |
assert new_settings['auth_pam_service'] == |
|
259 | assert new_settings['auth_pam_service'] == 'kallithea', 'fail db write compare' |
@@ -5,7 +5,7 b' from kallithea.tests import base' | |||||
5 |
|
5 | |||
6 |
|
6 | |||
7 | def _create_gist(f_name, content='some gist', lifetime=-1, |
|
7 | def _create_gist(f_name, content='some gist', lifetime=-1, | |
8 |
description= |
|
8 | description='gist-desc', gist_type='public', | |
9 | owner=base.TEST_USER_ADMIN_LOGIN): |
|
9 | owner=base.TEST_USER_ADMIN_LOGIN): | |
10 | gist_mapping = { |
|
10 | gist_mapping = { | |
11 | f_name: {'content': content} |
|
11 | f_name: {'content': content} | |
@@ -33,7 +33,7 b' class TestGistsController(base.TestContr' | |||||
33 |
|
33 | |||
34 | g1 = _create_gist('gist1').gist_access_id |
|
34 | g1 = _create_gist('gist1').gist_access_id | |
35 | g2 = _create_gist('gist2', lifetime=1400).gist_access_id |
|
35 | g2 = _create_gist('gist2', lifetime=1400).gist_access_id | |
36 |
g3 = _create_gist('gist3', description= |
|
36 | g3 = _create_gist('gist3', description='gist3-desc').gist_access_id | |
37 | g4 = _create_gist('gist4', gist_type='private').gist_access_id |
|
37 | g4 = _create_gist('gist4', gist_type='private').gist_access_id | |
38 | response = self.app.get(base.url('gists')) |
|
38 | response = self.app.get(base.url('gists')) | |
39 | # Test response... |
|
39 | # Test response... |
@@ -11,7 +11,7 b' class TestRepoGroupsController(TestContr' | |||||
11 |
|
11 | |||
12 | def test_case_insensitivity(self): |
|
12 | def test_case_insensitivity(self): | |
13 | self.log_user() |
|
13 | self.log_user() | |
14 |
group_name = |
|
14 | group_name = 'newgroup' | |
15 | response = self.app.post(url('repos_groups'), |
|
15 | response = self.app.post(url('repos_groups'), | |
16 | fixture._get_repo_group_create_params(group_name=group_name, |
|
16 | fixture._get_repo_group_create_params(group_name=group_name, | |
17 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
17 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
@@ -45,7 +45,7 b' class _BaseTestCase(base.TestController)' | |||||
45 | def test_create(self): |
|
45 | def test_create(self): | |
46 | self.log_user() |
|
46 | self.log_user() | |
47 | repo_name = self.NEW_REPO |
|
47 | repo_name = self.NEW_REPO | |
48 |
description = |
|
48 | description = 'description for newly created repo' | |
49 | response = self.app.post(base.url('repos'), |
|
49 | response = self.app.post(base.url('repos'), | |
50 | fixture._get_repo_create_params(repo_private=False, |
|
50 | fixture._get_repo_create_params(repo_private=False, | |
51 | repo_name=repo_name, |
|
51 | repo_name=repo_name, | |
@@ -54,7 +54,7 b' class _BaseTestCase(base.TestController)' | |||||
54 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
54 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
55 | ## run the check page that triggers the flash message |
|
55 | ## run the check page that triggers the flash message | |
56 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) |
|
56 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) | |
57 |
assert response.json == { |
|
57 | assert response.json == {'result': True} | |
58 | self.checkSessionFlash(response, |
|
58 | self.checkSessionFlash(response, | |
59 | 'Created repository <a href="/%s">%s</a>' |
|
59 | 'Created repository <a href="/%s">%s</a>' | |
60 | % (repo_name, repo_name)) |
|
60 | % (repo_name, repo_name)) | |
@@ -83,7 +83,7 b' class _BaseTestCase(base.TestController)' | |||||
83 | def test_case_insensitivity(self): |
|
83 | def test_case_insensitivity(self): | |
84 | self.log_user() |
|
84 | self.log_user() | |
85 | repo_name = self.NEW_REPO |
|
85 | repo_name = self.NEW_REPO | |
86 |
description = |
|
86 | description = 'description for newly created repo' | |
87 | response = self.app.post(base.url('repos'), |
|
87 | response = self.app.post(base.url('repos'), | |
88 | fixture._get_repo_create_params(repo_private=False, |
|
88 | fixture._get_repo_create_params(repo_private=False, | |
89 | repo_name=repo_name, |
|
89 | repo_name=repo_name, | |
@@ -107,15 +107,15 b' class _BaseTestCase(base.TestController)' | |||||
107 | self.log_user() |
|
107 | self.log_user() | |
108 |
|
108 | |||
109 | ## create GROUP |
|
109 | ## create GROUP | |
110 |
group_name = |
|
110 | group_name = 'sometest_%s' % self.REPO_TYPE | |
111 | gr = RepoGroupModel().create(group_name=group_name, |
|
111 | gr = RepoGroupModel().create(group_name=group_name, | |
112 |
group_description= |
|
112 | group_description='test', | |
113 | owner=base.TEST_USER_ADMIN_LOGIN) |
|
113 | owner=base.TEST_USER_ADMIN_LOGIN) | |
114 | Session().commit() |
|
114 | Session().commit() | |
115 |
|
115 | |||
116 |
repo_name = |
|
116 | repo_name = 'ingroup' | |
117 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
117 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
118 |
description = |
|
118 | description = 'description for newly created repo' | |
119 | response = self.app.post(base.url('repos'), |
|
119 | response = self.app.post(base.url('repos'), | |
120 | fixture._get_repo_create_params(repo_private=False, |
|
120 | fixture._get_repo_create_params(repo_private=False, | |
121 | repo_name=repo_name, |
|
121 | repo_name=repo_name, | |
@@ -125,7 +125,7 b' class _BaseTestCase(base.TestController)' | |||||
125 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
125 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
126 | ## run the check page that triggers the flash message |
|
126 | ## run the check page that triggers the flash message | |
127 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) |
|
127 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) | |
128 |
assert response.json == { |
|
128 | assert response.json == {'result': True} | |
129 | self.checkSessionFlash(response, |
|
129 | self.checkSessionFlash(response, | |
130 | 'Created repository <a href="/%s">%s</a>' |
|
130 | 'Created repository <a href="/%s">%s</a>' | |
131 | % (repo_name_full, repo_name_full)) |
|
131 | % (repo_name_full, repo_name_full)) | |
@@ -178,21 +178,21 b' class _BaseTestCase(base.TestController)' | |||||
178 | Session().commit() |
|
178 | Session().commit() | |
179 |
|
179 | |||
180 | ## create GROUP |
|
180 | ## create GROUP | |
181 |
group_name = |
|
181 | group_name = 'reg_sometest_%s' % self.REPO_TYPE | |
182 | gr = RepoGroupModel().create(group_name=group_name, |
|
182 | gr = RepoGroupModel().create(group_name=group_name, | |
183 |
group_description= |
|
183 | group_description='test', | |
184 | owner=base.TEST_USER_ADMIN_LOGIN) |
|
184 | owner=base.TEST_USER_ADMIN_LOGIN) | |
185 | Session().commit() |
|
185 | Session().commit() | |
186 |
|
186 | |||
187 |
group_name_allowed = |
|
187 | group_name_allowed = 'reg_sometest_allowed_%s' % self.REPO_TYPE | |
188 | gr_allowed = RepoGroupModel().create(group_name=group_name_allowed, |
|
188 | gr_allowed = RepoGroupModel().create(group_name=group_name_allowed, | |
189 |
group_description= |
|
189 | group_description='test', | |
190 | owner=base.TEST_USER_REGULAR_LOGIN) |
|
190 | owner=base.TEST_USER_REGULAR_LOGIN) | |
191 | Session().commit() |
|
191 | Session().commit() | |
192 |
|
192 | |||
193 |
repo_name = |
|
193 | repo_name = 'ingroup' | |
194 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
194 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
195 |
description = |
|
195 | description = 'description for newly created repo' | |
196 | response = self.app.post(base.url('repos'), |
|
196 | response = self.app.post(base.url('repos'), | |
197 | fixture._get_repo_create_params(repo_private=False, |
|
197 | fixture._get_repo_create_params(repo_private=False, | |
198 | repo_name=repo_name, |
|
198 | repo_name=repo_name, | |
@@ -204,9 +204,9 b' class _BaseTestCase(base.TestController)' | |||||
204 | response.mustcontain('Invalid value') |
|
204 | response.mustcontain('Invalid value') | |
205 |
|
205 | |||
206 | # user is allowed to create in this group |
|
206 | # user is allowed to create in this group | |
207 |
repo_name = |
|
207 | repo_name = 'ingroup' | |
208 | repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name]) |
|
208 | repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name]) | |
209 |
description = |
|
209 | description = 'description for newly created repo' | |
210 | response = self.app.post(base.url('repos'), |
|
210 | response = self.app.post(base.url('repos'), | |
211 | fixture._get_repo_create_params(repo_private=False, |
|
211 | fixture._get_repo_create_params(repo_private=False, | |
212 | repo_name=repo_name, |
|
212 | repo_name=repo_name, | |
@@ -217,7 +217,7 b' class _BaseTestCase(base.TestController)' | |||||
217 |
|
217 | |||
218 | ## run the check page that triggers the flash message |
|
218 | ## run the check page that triggers the flash message | |
219 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) |
|
219 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) | |
220 |
assert response.json == { |
|
220 | assert response.json == {'result': True} | |
221 | self.checkSessionFlash(response, |
|
221 | self.checkSessionFlash(response, | |
222 | 'Created repository <a href="/%s">%s</a>' |
|
222 | 'Created repository <a href="/%s">%s</a>' | |
223 | % (repo_name_full, repo_name_full)) |
|
223 | % (repo_name_full, repo_name_full)) | |
@@ -255,9 +255,9 b' class _BaseTestCase(base.TestController)' | |||||
255 | self.log_user() |
|
255 | self.log_user() | |
256 |
|
256 | |||
257 | ## create GROUP |
|
257 | ## create GROUP | |
258 |
group_name = |
|
258 | group_name = 'sometest_%s' % self.REPO_TYPE | |
259 | gr = RepoGroupModel().create(group_name=group_name, |
|
259 | gr = RepoGroupModel().create(group_name=group_name, | |
260 |
group_description= |
|
260 | group_description='test', | |
261 | owner=base.TEST_USER_ADMIN_LOGIN) |
|
261 | owner=base.TEST_USER_ADMIN_LOGIN) | |
262 | perm = Permission.get_by_key('repository.write') |
|
262 | perm = Permission.get_by_key('repository.write') | |
263 | RepoGroupModel().grant_user_permission(gr, base.TEST_USER_REGULAR_LOGIN, perm) |
|
263 | RepoGroupModel().grant_user_permission(gr, base.TEST_USER_REGULAR_LOGIN, perm) | |
@@ -265,9 +265,9 b' class _BaseTestCase(base.TestController)' | |||||
265 | ## add repo permissions |
|
265 | ## add repo permissions | |
266 | Session().commit() |
|
266 | Session().commit() | |
267 |
|
267 | |||
268 |
repo_name = |
|
268 | repo_name = 'ingroup_inherited_%s' % self.REPO_TYPE | |
269 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
269 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
270 |
description = |
|
270 | description = 'description for newly created repo' | |
271 | response = self.app.post(base.url('repos'), |
|
271 | response = self.app.post(base.url('repos'), | |
272 | fixture._get_repo_create_params(repo_private=False, |
|
272 | fixture._get_repo_create_params(repo_private=False, | |
273 | repo_name=repo_name, |
|
273 | repo_name=repo_name, | |
@@ -320,7 +320,7 b' class _BaseTestCase(base.TestController)' | |||||
320 | def test_create_remote_repo_wrong_clone_uri(self): |
|
320 | def test_create_remote_repo_wrong_clone_uri(self): | |
321 | self.log_user() |
|
321 | self.log_user() | |
322 | repo_name = self.NEW_REPO |
|
322 | repo_name = self.NEW_REPO | |
323 |
description = |
|
323 | description = 'description for newly created repo' | |
324 | response = self.app.post(base.url('repos'), |
|
324 | response = self.app.post(base.url('repos'), | |
325 | fixture._get_repo_create_params(repo_private=False, |
|
325 | fixture._get_repo_create_params(repo_private=False, | |
326 | repo_name=repo_name, |
|
326 | repo_name=repo_name, | |
@@ -333,7 +333,7 b' class _BaseTestCase(base.TestController)' | |||||
333 | def test_create_remote_repo_wrong_clone_uri_hg_svn(self): |
|
333 | def test_create_remote_repo_wrong_clone_uri_hg_svn(self): | |
334 | self.log_user() |
|
334 | self.log_user() | |
335 | repo_name = self.NEW_REPO |
|
335 | repo_name = self.NEW_REPO | |
336 |
description = |
|
336 | description = 'description for newly created repo' | |
337 | response = self.app.post(base.url('repos'), |
|
337 | response = self.app.post(base.url('repos'), | |
338 | fixture._get_repo_create_params(repo_private=False, |
|
338 | fixture._get_repo_create_params(repo_private=False, | |
339 | repo_name=repo_name, |
|
339 | repo_name=repo_name, | |
@@ -345,8 +345,8 b' class _BaseTestCase(base.TestController)' | |||||
345 |
|
345 | |||
346 | def test_delete(self): |
|
346 | def test_delete(self): | |
347 | self.log_user() |
|
347 | self.log_user() | |
348 |
repo_name = |
|
348 | repo_name = 'vcs_test_new_to_delete_%s' % self.REPO_TYPE | |
349 |
description = |
|
349 | description = 'description for newly created repo' | |
350 | response = self.app.post(base.url('repos'), |
|
350 | response = self.app.post(base.url('repos'), | |
351 | fixture._get_repo_create_params(repo_private=False, |
|
351 | fixture._get_repo_create_params(repo_private=False, | |
352 | repo_type=self.REPO_TYPE, |
|
352 | repo_type=self.REPO_TYPE, | |
@@ -404,9 +404,9 b' class _BaseTestCase(base.TestController)' | |||||
404 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
404 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
405 | ## run the check page that triggers the flash message |
|
405 | ## run the check page that triggers the flash message | |
406 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) |
|
406 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) | |
407 |
assert response.json == { |
|
407 | assert response.json == {'result': True} | |
408 | self.checkSessionFlash(response, |
|
408 | self.checkSessionFlash(response, | |
409 |
|
|
409 | 'Created repository <a href="/%s">%s</a>' | |
410 | % (urllib.parse.quote(repo_name), repo_name)) |
|
410 | % (urllib.parse.quote(repo_name), repo_name)) | |
411 | # test if the repo was created in the database |
|
411 | # test if the repo was created in the database | |
412 | new_repo = Session().query(Repository) \ |
|
412 | new_repo = Session().query(Repository) \ | |
@@ -505,7 +505,7 b' class _BaseTestCase(base.TestController)' | |||||
505 |
|
505 | |||
506 | def test_set_fork_of_other_repo(self): |
|
506 | def test_set_fork_of_other_repo(self): | |
507 | self.log_user() |
|
507 | self.log_user() | |
508 |
other_repo = |
|
508 | other_repo = 'other_%s' % self.REPO_TYPE | |
509 | fixture.create_repo(other_repo, repo_type=self.REPO_TYPE) |
|
509 | fixture.create_repo(other_repo, repo_type=self.REPO_TYPE) | |
510 | repo = Repository.get_by_repo_name(self.REPO) |
|
510 | repo = Repository.get_by_repo_name(self.REPO) | |
511 | repo2 = Repository.get_by_repo_name(other_repo) |
|
511 | repo2 = Repository.get_by_repo_name(other_repo) | |
@@ -577,7 +577,7 b' class _BaseTestCase(base.TestController)' | |||||
577 |
|
577 | |||
578 | user = User.get(usr['user_id']) |
|
578 | user = User.get(usr['user_id']) | |
579 |
|
579 | |||
580 |
repo_name = self.NEW_REPO + |
|
580 | repo_name = self.NEW_REPO + 'no_perms' | |
581 | description = 'description for newly created repo' |
|
581 | description = 'description for newly created repo' | |
582 | response = self.app.post(base.url('repos'), |
|
582 | response = self.app.post(base.url('repos'), | |
583 | fixture._get_repo_create_params(repo_private=False, |
|
583 | fixture._get_repo_create_params(repo_private=False, |
@@ -4,7 +4,7 b' from kallithea.model.meta import Session' | |||||
4 | from kallithea.tests import base |
|
4 | from kallithea.tests import base | |
5 |
|
5 | |||
6 |
|
6 | |||
7 |
TEST_USER_GROUP = |
|
7 | TEST_USER_GROUP = 'admins_test' | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | class TestAdminUsersGroupsController(base.TestController): |
|
10 | class TestAdminUsersGroupsController(base.TestController): | |
@@ -19,7 +19,7 b' class TestAdminUsersGroupsController(bas' | |||||
19 | users_group_name = TEST_USER_GROUP |
|
19 | users_group_name = TEST_USER_GROUP | |
20 | response = self.app.post(base.url('users_groups'), |
|
20 | response = self.app.post(base.url('users_groups'), | |
21 | {'users_group_name': users_group_name, |
|
21 | {'users_group_name': users_group_name, | |
22 |
'user_group_description': |
|
22 | 'user_group_description': 'DESC', | |
23 | 'active': True, |
|
23 | 'active': True, | |
24 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
24 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
25 | response.follow() |
|
25 | response.follow() | |
@@ -44,7 +44,7 b' class TestAdminUsersGroupsController(bas' | |||||
44 | users_group_name = TEST_USER_GROUP + 'another' |
|
44 | users_group_name = TEST_USER_GROUP + 'another' | |
45 | response = self.app.post(base.url('users_groups'), |
|
45 | response = self.app.post(base.url('users_groups'), | |
46 | {'users_group_name': users_group_name, |
|
46 | {'users_group_name': users_group_name, | |
47 |
'user_group_description': |
|
47 | 'user_group_description': 'DESC', | |
48 | 'active': True, |
|
48 | 'active': True, | |
49 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
49 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
50 | response.follow() |
|
50 | response.follow() | |
@@ -68,7 +68,7 b' class TestAdminUsersGroupsController(bas' | |||||
68 | users_group_name = TEST_USER_GROUP + 'another2' |
|
68 | users_group_name = TEST_USER_GROUP + 'another2' | |
69 | response = self.app.post(base.url('users_groups'), |
|
69 | response = self.app.post(base.url('users_groups'), | |
70 | {'users_group_name': users_group_name, |
|
70 | {'users_group_name': users_group_name, | |
71 |
'user_group_description': |
|
71 | 'user_group_description': 'DESC', | |
72 | 'active': True, |
|
72 | 'active': True, | |
73 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
73 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
74 | response.follow() |
|
74 | response.follow() | |
@@ -137,7 +137,7 b' class TestAdminUsersGroupsController(bas' | |||||
137 | users_group_name = TEST_USER_GROUP + 'another2' |
|
137 | users_group_name = TEST_USER_GROUP + 'another2' | |
138 | response = self.app.post(base.url('users_groups'), |
|
138 | response = self.app.post(base.url('users_groups'), | |
139 | {'users_group_name': users_group_name, |
|
139 | {'users_group_name': users_group_name, | |
140 |
'user_group_description': |
|
140 | 'user_group_description': 'DESC', | |
141 | 'active': True, |
|
141 | 'active': True, | |
142 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
142 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
143 | response.follow() |
|
143 | response.follow() |
@@ -34,7 +34,7 b' fixture = Fixture()' | |||||
34 | @pytest.fixture |
|
34 | @pytest.fixture | |
35 | def user_and_repo_group_fail(): |
|
35 | def user_and_repo_group_fail(): | |
36 | username = 'repogrouperr' |
|
36 | username = 'repogrouperr' | |
37 |
groupname = |
|
37 | groupname = 'repogroup_fail' | |
38 | user = fixture.create_user(name=username) |
|
38 | user = fixture.create_user(name=username) | |
39 | repo_group = fixture.create_repo_group(name=groupname, cur_user=username) |
|
39 | repo_group = fixture.create_repo_group(name=groupname, cur_user=username) | |
40 | yield user, repo_group |
|
40 | yield user, repo_group | |
@@ -62,8 +62,8 b' class TestAdminUsersController(base.Test' | |||||
62 | username = 'newtestuser' |
|
62 | username = 'newtestuser' | |
63 | password = 'test12' |
|
63 | password = 'test12' | |
64 | password_confirmation = password |
|
64 | password_confirmation = password | |
65 |
name = |
|
65 | name = 'name' | |
66 |
lastname = |
|
66 | lastname = 'lastname' | |
67 | email = 'mail@example.com' |
|
67 | email = 'mail@example.com' | |
68 |
|
68 | |||
69 | response = self.app.post(base.url('new_user'), |
|
69 | response = self.app.post(base.url('new_user'), | |
@@ -98,8 +98,8 b' class TestAdminUsersController(base.Test' | |||||
98 | self.log_user() |
|
98 | self.log_user() | |
99 | username = 'new_user' |
|
99 | username = 'new_user' | |
100 | password = '' |
|
100 | password = '' | |
101 |
name = |
|
101 | name = 'name' | |
102 |
lastname = |
|
102 | lastname = 'lastname' | |
103 | email = 'errmail.example.com' |
|
103 | email = 'errmail.example.com' | |
104 |
|
104 | |||
105 | response = self.app.post(base.url('new_user'), |
|
105 | response = self.app.post(base.url('new_user'), | |
@@ -194,7 +194,7 b' class TestAdminUsersController(base.Test' | |||||
194 | def test_delete_repo_err(self): |
|
194 | def test_delete_repo_err(self): | |
195 | self.log_user() |
|
195 | self.log_user() | |
196 | username = 'repoerr' |
|
196 | username = 'repoerr' | |
197 |
reponame = |
|
197 | reponame = 'repoerr_fail' | |
198 |
|
198 | |||
199 | fixture.create_user(name=username) |
|
199 | fixture.create_user(name=username) | |
200 | fixture.create_repo(name=reponame, cur_user=username) |
|
200 | fixture.create_repo(name=reponame, cur_user=username) | |
@@ -245,7 +245,7 b' class TestAdminUsersController(base.Test' | |||||
245 | def test_delete_user_group_err(self): |
|
245 | def test_delete_user_group_err(self): | |
246 | self.log_user() |
|
246 | self.log_user() | |
247 | username = 'usergrouperr' |
|
247 | username = 'usergrouperr' | |
248 |
groupname = |
|
248 | groupname = 'usergroup_fail' | |
249 |
|
249 | |||
250 | fixture.create_user(name=username) |
|
250 | fixture.create_user(name=username) | |
251 | ug = fixture.create_user_group(name=groupname, cur_user=username) |
|
251 | ug = fixture.create_user_group(name=groupname, cur_user=username) | |
@@ -280,8 +280,8 b' class TestAdminUsersController(base.Test' | |||||
280 | perm_create = Permission.get_by_key('hg.create.repository') |
|
280 | perm_create = Permission.get_by_key('hg.create.repository') | |
281 |
|
281 | |||
282 | user = UserModel().create_or_update(username='dummy', password='qwe', |
|
282 | user = UserModel().create_or_update(username='dummy', password='qwe', | |
283 |
email='dummy', firstname= |
|
283 | email='dummy', firstname='a', | |
284 |
lastname= |
|
284 | lastname='b') | |
285 | Session().commit() |
|
285 | Session().commit() | |
286 | uid = user.user_id |
|
286 | uid = user.user_id | |
287 |
|
287 | |||
@@ -310,8 +310,8 b' class TestAdminUsersController(base.Test' | |||||
310 | perm_create = Permission.get_by_key('hg.create.repository') |
|
310 | perm_create = Permission.get_by_key('hg.create.repository') | |
311 |
|
311 | |||
312 | user = UserModel().create_or_update(username='dummy', password='qwe', |
|
312 | user = UserModel().create_or_update(username='dummy', password='qwe', | |
313 |
email='dummy', firstname= |
|
313 | email='dummy', firstname='a', | |
314 |
lastname= |
|
314 | lastname='b') | |
315 | Session().commit() |
|
315 | Session().commit() | |
316 | uid = user.user_id |
|
316 | uid = user.user_id | |
317 |
|
317 | |||
@@ -339,8 +339,8 b' class TestAdminUsersController(base.Test' | |||||
339 | perm_fork = Permission.get_by_key('hg.fork.repository') |
|
339 | perm_fork = Permission.get_by_key('hg.fork.repository') | |
340 |
|
340 | |||
341 | user = UserModel().create_or_update(username='dummy', password='qwe', |
|
341 | user = UserModel().create_or_update(username='dummy', password='qwe', | |
342 |
email='dummy', firstname= |
|
342 | email='dummy', firstname='a', | |
343 |
lastname= |
|
343 | lastname='b') | |
344 | Session().commit() |
|
344 | Session().commit() | |
345 | uid = user.user_id |
|
345 | uid = user.user_id | |
346 |
|
346 | |||
@@ -369,8 +369,8 b' class TestAdminUsersController(base.Test' | |||||
369 | perm_fork = Permission.get_by_key('hg.fork.repository') |
|
369 | perm_fork = Permission.get_by_key('hg.fork.repository') | |
370 |
|
370 | |||
371 | user = UserModel().create_or_update(username='dummy', password='qwe', |
|
371 | user = UserModel().create_or_update(username='dummy', password='qwe', | |
372 |
email='dummy', firstname= |
|
372 | email='dummy', firstname='a', | |
373 |
lastname= |
|
373 | lastname='b') | |
374 | Session().commit() |
|
374 | Session().commit() | |
375 | uid = user.user_id |
|
375 | uid = user.user_id | |
376 |
|
376 | |||
@@ -515,9 +515,9 b' class TestAdminUsersController(base.Test' | |||||
515 | response.mustcontain(no=[api_key]) |
|
515 | response.mustcontain(no=[api_key]) | |
516 |
|
516 | |||
517 | def test_add_ssh_key(self): |
|
517 | def test_add_ssh_key(self): | |
518 |
description = |
|
518 | description = 'something' | |
519 |
public_key = |
|
519 | public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' | |
520 |
fingerprint = |
|
520 | fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
521 |
|
521 | |||
522 | self.log_user() |
|
522 | self.log_user() | |
523 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) |
|
523 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
@@ -538,9 +538,9 b' class TestAdminUsersController(base.Test' | |||||
538 | Session().commit() |
|
538 | Session().commit() | |
539 |
|
539 | |||
540 | def test_remove_ssh_key(self): |
|
540 | def test_remove_ssh_key(self): | |
541 |
description = |
|
541 | description = '' | |
542 |
public_key = |
|
542 | public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' | |
543 |
fingerprint = |
|
543 | fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
544 |
|
544 | |||
545 | self.log_user() |
|
545 | self.log_user() | |
546 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) |
|
546 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
@@ -553,7 +553,7 b' class TestAdminUsersController(base.Test' | |||||
553 | self.checkSessionFlash(response, 'SSH key %s successfully added' % fingerprint) |
|
553 | self.checkSessionFlash(response, 'SSH key %s successfully added' % fingerprint) | |
554 | response.follow() |
|
554 | response.follow() | |
555 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() |
|
555 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() | |
556 |
assert ssh_key.description == |
|
556 | assert ssh_key.description == 'me@localhost' | |
557 |
|
557 | |||
558 | response = self.app.post(base.url('edit_user_ssh_keys_delete', id=user_id), |
|
558 | response = self.app.post(base.url('edit_user_ssh_keys_delete', id=user_id), | |
559 | {'del_public_key_fingerprint': ssh_key.fingerprint, |
|
559 | {'del_public_key_fingerprint': ssh_key.fingerprint, |
@@ -16,7 +16,7 b' class TestChangeSetCommentsController(ba' | |||||
16 | def test_create(self): |
|
16 | def test_create(self): | |
17 | self.log_user() |
|
17 | self.log_user() | |
18 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
18 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
19 |
text = |
|
19 | text = 'general comment on changeset' | |
20 |
|
20 | |||
21 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
21 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
22 | response = self.app.post(base.url(controller='changeset', action='comment', |
|
22 | response = self.app.post(base.url(controller='changeset', action='comment', | |
@@ -39,7 +39,7 b' class TestChangeSetCommentsController(ba' | |||||
39 | def test_create_inline(self): |
|
39 | def test_create_inline(self): | |
40 | self.log_user() |
|
40 | self.log_user() | |
41 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
41 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
42 |
text = |
|
42 | text = 'inline comment on changeset' | |
43 | f_path = 'vcs/web/simplevcs/views/repository.py' |
|
43 | f_path = 'vcs/web/simplevcs/views/repository.py' | |
44 | line = 'n1' |
|
44 | line = 'n1' | |
45 |
|
45 | |||
@@ -70,7 +70,7 b' class TestChangeSetCommentsController(ba' | |||||
70 | self.log_user() |
|
70 | self.log_user() | |
71 |
|
71 | |||
72 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
72 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
73 |
text = |
|
73 | text = '@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN | |
74 |
|
74 | |||
75 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
75 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
76 | response = self.app.post(base.url(controller='changeset', action='comment', |
|
76 | response = self.app.post(base.url(controller='changeset', action='comment', | |
@@ -93,7 +93,7 b' class TestChangeSetCommentsController(ba' | |||||
93 | def test_create_status_change(self): |
|
93 | def test_create_status_change(self): | |
94 | self.log_user() |
|
94 | self.log_user() | |
95 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
95 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
96 |
text = |
|
96 | text = 'general comment on changeset' | |
97 |
|
97 | |||
98 | params = {'text': text, 'changeset_status': 'rejected', |
|
98 | params = {'text': text, 'changeset_status': 'rejected', | |
99 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
99 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
@@ -121,7 +121,7 b' class TestChangeSetCommentsController(ba' | |||||
121 | def test_delete(self): |
|
121 | def test_delete(self): | |
122 | self.log_user() |
|
122 | self.log_user() | |
123 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
123 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
124 |
text = |
|
124 | text = 'general comment on changeset to be deleted' | |
125 |
|
125 | |||
126 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
126 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
127 | response = self.app.post(base.url(controller='changeset', action='comment', |
|
127 | response = self.app.post(base.url(controller='changeset', action='comment', | |
@@ -175,7 +175,7 b' class TestPullrequestsCommentsController' | |||||
175 | self.log_user() |
|
175 | self.log_user() | |
176 | pr_id = self._create_pr() |
|
176 | pr_id = self._create_pr() | |
177 |
|
177 | |||
178 |
text = |
|
178 | text = 'general comment on pullrequest' | |
179 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
179 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
180 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
180 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
181 | repo_name=base.HG_REPO, pull_request_id=pr_id), |
|
181 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
@@ -201,7 +201,7 b' class TestPullrequestsCommentsController' | |||||
201 | self.log_user() |
|
201 | self.log_user() | |
202 | pr_id = self._create_pr() |
|
202 | pr_id = self._create_pr() | |
203 |
|
203 | |||
204 |
text = |
|
204 | text = 'inline comment on changeset' | |
205 | f_path = 'vcs/web/simplevcs/views/repository.py' |
|
205 | f_path = 'vcs/web/simplevcs/views/repository.py' | |
206 | line = 'n1' |
|
206 | line = 'n1' | |
207 | params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
207 | params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
@@ -231,7 +231,7 b' class TestPullrequestsCommentsController' | |||||
231 | self.log_user() |
|
231 | self.log_user() | |
232 | pr_id = self._create_pr() |
|
232 | pr_id = self._create_pr() | |
233 |
|
233 | |||
234 |
text = |
|
234 | text = '@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN | |
235 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
235 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
236 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
236 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
237 | repo_name=base.HG_REPO, pull_request_id=pr_id), |
|
237 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
@@ -254,7 +254,7 b' class TestPullrequestsCommentsController' | |||||
254 | self.log_user() |
|
254 | self.log_user() | |
255 | pr_id = self._create_pr() |
|
255 | pr_id = self._create_pr() | |
256 |
|
256 | |||
257 |
text = |
|
257 | text = 'general comment on pullrequest' | |
258 | params = {'text': text, 'changeset_status': 'rejected', |
|
258 | params = {'text': text, 'changeset_status': 'rejected', | |
259 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
259 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
260 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
260 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
@@ -285,7 +285,7 b' class TestPullrequestsCommentsController' | |||||
285 | self.log_user() |
|
285 | self.log_user() | |
286 | pr_id = self._create_pr() |
|
286 | pr_id = self._create_pr() | |
287 |
|
287 | |||
288 |
text = |
|
288 | text = 'general comment on changeset to be deleted' | |
289 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
289 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
290 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
290 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
291 | repo_name=base.HG_REPO, pull_request_id=pr_id), |
|
291 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
@@ -315,7 +315,7 b' class TestPullrequestsCommentsController' | |||||
315 | self.log_user() |
|
315 | self.log_user() | |
316 | pr_id = self._create_pr() |
|
316 | pr_id = self._create_pr() | |
317 |
|
317 | |||
318 |
text = |
|
318 | text = 'general comment on pullrequest' | |
319 | params = {'text': text, 'save_close': 'close', |
|
319 | params = {'text': text, 'save_close': 'close', | |
320 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
320 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
321 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
321 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
@@ -338,7 +338,7 b' class TestPullrequestsCommentsController' | |||||
338 | self.log_user() |
|
338 | self.log_user() | |
339 | pr_id = self._create_pr() |
|
339 | pr_id = self._create_pr() | |
340 |
|
340 | |||
341 |
text = |
|
341 | text = 'general comment on pullrequest' | |
342 | params = {'text': text, 'save_delete': 'delete', |
|
342 | params = {'text': text, 'save_delete': 'delete', | |
343 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
343 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
344 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
344 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
@@ -358,7 +358,7 b' class TestPullrequestsCommentsController' | |||||
358 | pr_id = self._create_pr() |
|
358 | pr_id = self._create_pr() | |
359 |
|
359 | |||
360 | # first close |
|
360 | # first close | |
361 |
text = |
|
361 | text = 'general comment on pullrequest' | |
362 | params = {'text': text, 'save_close': 'close', |
|
362 | params = {'text': text, 'save_close': 'close', | |
363 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
363 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
364 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
|
364 | response = self.app.post(base.url(controller='pullrequests', action='comment', |
@@ -28,7 +28,7 b' class TestCompareController(base.TestCon' | |||||
28 |
|
28 | |||
29 | def test_compare_forks_on_branch_extra_commits_hg(self): |
|
29 | def test_compare_forks_on_branch_extra_commits_hg(self): | |
30 | self.log_user() |
|
30 | self.log_user() | |
31 |
repo1 = fixture.create_repo( |
|
31 | repo1 = fixture.create_repo('one', repo_type='hg', | |
32 | repo_description='diff-test', |
|
32 | repo_description='diff-test', | |
33 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
33 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
34 | self.r1_id = repo1.repo_id |
|
34 | self.r1_id = repo1.repo_id | |
@@ -38,7 +38,7 b' class TestCompareController(base.TestCon' | |||||
38 | parent=None, newfile=True) |
|
38 | parent=None, newfile=True) | |
39 |
|
39 | |||
40 | # fork this repo |
|
40 | # fork this repo | |
41 |
repo2 = fixture.create_fork( |
|
41 | repo2 = fixture.create_fork('one', 'one-fork') | |
42 | self.r2_id = repo2.repo_id |
|
42 | self.r2_id = repo2.repo_id | |
43 |
|
43 | |||
44 | # add two extra commit into fork |
|
44 | # add two extra commit into fork | |
@@ -79,7 +79,7 b' class TestCompareController(base.TestCon' | |||||
79 |
|
79 | |||
80 | def test_compare_forks_on_branch_extra_commits_git(self): |
|
80 | def test_compare_forks_on_branch_extra_commits_git(self): | |
81 | self.log_user() |
|
81 | self.log_user() | |
82 |
repo1 = fixture.create_repo( |
|
82 | repo1 = fixture.create_repo('one-git', repo_type='git', | |
83 | repo_description='diff-test', |
|
83 | repo_description='diff-test', | |
84 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
84 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
85 | self.r1_id = repo1.repo_id |
|
85 | self.r1_id = repo1.repo_id | |
@@ -89,7 +89,7 b' class TestCompareController(base.TestCon' | |||||
89 | parent=None, newfile=True) |
|
89 | parent=None, newfile=True) | |
90 |
|
90 | |||
91 | # fork this repo |
|
91 | # fork this repo | |
92 |
repo2 = fixture.create_fork( |
|
92 | repo2 = fixture.create_fork('one-git', 'one-git-fork') | |
93 | self.r2_id = repo2.repo_id |
|
93 | self.r2_id = repo2.repo_id | |
94 |
|
94 | |||
95 | # add two extra commit into fork |
|
95 | # add two extra commit into fork | |
@@ -131,7 +131,7 b' class TestCompareController(base.TestCon' | |||||
131 | def test_compare_forks_on_branch_extra_commits_origin_has_incoming_hg(self): |
|
131 | def test_compare_forks_on_branch_extra_commits_origin_has_incoming_hg(self): | |
132 | self.log_user() |
|
132 | self.log_user() | |
133 |
|
133 | |||
134 |
repo1 = fixture.create_repo( |
|
134 | repo1 = fixture.create_repo('one', repo_type='hg', | |
135 | repo_description='diff-test', |
|
135 | repo_description='diff-test', | |
136 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
136 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
137 |
|
137 | |||
@@ -143,7 +143,7 b' class TestCompareController(base.TestCon' | |||||
143 | parent=None, newfile=True) |
|
143 | parent=None, newfile=True) | |
144 |
|
144 | |||
145 | # fork this repo |
|
145 | # fork this repo | |
146 |
repo2 = fixture.create_fork( |
|
146 | repo2 = fixture.create_fork('one', 'one-fork') | |
147 | self.r2_id = repo2.repo_id |
|
147 | self.r2_id = repo2.repo_id | |
148 |
|
148 | |||
149 | # now commit something to origin repo |
|
149 | # now commit something to origin repo | |
@@ -190,7 +190,7 b' class TestCompareController(base.TestCon' | |||||
190 | def test_compare_forks_on_branch_extra_commits_origin_has_incoming_git(self): |
|
190 | def test_compare_forks_on_branch_extra_commits_origin_has_incoming_git(self): | |
191 | self.log_user() |
|
191 | self.log_user() | |
192 |
|
192 | |||
193 |
repo1 = fixture.create_repo( |
|
193 | repo1 = fixture.create_repo('one-git', repo_type='git', | |
194 | repo_description='diff-test', |
|
194 | repo_description='diff-test', | |
195 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
195 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
196 |
|
196 | |||
@@ -202,7 +202,7 b' class TestCompareController(base.TestCon' | |||||
202 | parent=None, newfile=True) |
|
202 | parent=None, newfile=True) | |
203 |
|
203 | |||
204 | # fork this repo |
|
204 | # fork this repo | |
205 |
repo2 = fixture.create_fork( |
|
205 | repo2 = fixture.create_fork('one-git', 'one-git-fork') | |
206 | self.r2_id = repo2.repo_id |
|
206 | self.r2_id = repo2.repo_id | |
207 |
|
207 | |||
208 | # now commit something to origin repo |
|
208 | # now commit something to origin repo | |
@@ -261,7 +261,7 b' class TestCompareController(base.TestCon' | |||||
261 | # make repo1, and cs1+cs2 |
|
261 | # make repo1, and cs1+cs2 | |
262 | self.log_user() |
|
262 | self.log_user() | |
263 |
|
263 | |||
264 |
repo1 = fixture.create_repo( |
|
264 | repo1 = fixture.create_repo('repo1', repo_type='hg', | |
265 | repo_description='diff-test', |
|
265 | repo_description='diff-test', | |
266 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
266 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
267 | self.r1_id = repo1.repo_id |
|
267 | self.r1_id = repo1.repo_id | |
@@ -274,7 +274,7 b' class TestCompareController(base.TestCon' | |||||
274 | content='line1\nline2\n', message='commit2', vcs_type='hg', |
|
274 | content='line1\nline2\n', message='commit2', vcs_type='hg', | |
275 | parent=cs0) |
|
275 | parent=cs0) | |
276 | # fork this repo |
|
276 | # fork this repo | |
277 |
repo2 = fixture.create_fork( |
|
277 | repo2 = fixture.create_fork('repo1', 'repo1-fork') | |
278 | self.r2_id = repo2.repo_id |
|
278 | self.r2_id = repo2.repo_id | |
279 | # now make cs3-6 |
|
279 | # now make cs3-6 | |
280 | cs2 = fixture.commit_change(repo1.repo_name, filename='file1', |
|
280 | cs2 = fixture.commit_change(repo1.repo_name, filename='file1', | |
@@ -329,7 +329,7 b' class TestCompareController(base.TestCon' | |||||
329 | # |
|
329 | # | |
330 | # make repo1, and cs1+cs2 |
|
330 | # make repo1, and cs1+cs2 | |
331 | self.log_user() |
|
331 | self.log_user() | |
332 |
repo1 = fixture.create_repo( |
|
332 | repo1 = fixture.create_repo('repo1', repo_type='hg', | |
333 | repo_description='diff-test', |
|
333 | repo_description='diff-test', | |
334 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
334 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
335 | self.r1_id = repo1.repo_id |
|
335 | self.r1_id = repo1.repo_id | |
@@ -342,7 +342,7 b' class TestCompareController(base.TestCon' | |||||
342 | content='line1\nline2\n', message='commit2', vcs_type='hg', |
|
342 | content='line1\nline2\n', message='commit2', vcs_type='hg', | |
343 | parent=cs0) |
|
343 | parent=cs0) | |
344 | # fork this repo |
|
344 | # fork this repo | |
345 |
repo2 = fixture.create_fork( |
|
345 | repo2 = fixture.create_fork('repo1', 'repo1-fork') | |
346 | self.r2_id = repo2.repo_id |
|
346 | self.r2_id = repo2.repo_id | |
347 | # now make cs3-6 |
|
347 | # now make cs3-6 | |
348 | cs2 = fixture.commit_change(repo1.repo_name, filename='file1', |
|
348 | cs2 = fixture.commit_change(repo1.repo_name, filename='file1', | |
@@ -448,7 +448,7 b' class TestCompareController(base.TestCon' | |||||
448 | def test_org_repo_new_commits_after_forking_simple_diff_hg(self): |
|
448 | def test_org_repo_new_commits_after_forking_simple_diff_hg(self): | |
449 | self.log_user() |
|
449 | self.log_user() | |
450 |
|
450 | |||
451 |
repo1 = fixture.create_repo( |
|
451 | repo1 = fixture.create_repo('one', repo_type='hg', | |
452 | repo_description='diff-test', |
|
452 | repo_description='diff-test', | |
453 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
453 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
454 |
|
454 | |||
@@ -460,7 +460,7 b' class TestCompareController(base.TestCon' | |||||
460 | Session().commit() |
|
460 | Session().commit() | |
461 | assert repo1.scm_instance.revisions == [cs0.raw_id] |
|
461 | assert repo1.scm_instance.revisions == [cs0.raw_id] | |
462 | # fork the repo1 |
|
462 | # fork the repo1 | |
463 |
repo2 = fixture.create_fork(r1_name, |
|
463 | repo2 = fixture.create_fork(r1_name, 'one-fork', | |
464 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
464 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
465 | Session().commit() |
|
465 | Session().commit() | |
466 | assert repo2.scm_instance.revisions == [cs0.raw_id] |
|
466 | assert repo2.scm_instance.revisions == [cs0.raw_id] | |
@@ -520,7 +520,7 b' class TestCompareController(base.TestCon' | |||||
520 | def test_org_repo_new_commits_after_forking_simple_diff_git(self): |
|
520 | def test_org_repo_new_commits_after_forking_simple_diff_git(self): | |
521 | self.log_user() |
|
521 | self.log_user() | |
522 |
|
522 | |||
523 |
repo1 = fixture.create_repo( |
|
523 | repo1 = fixture.create_repo('one-git', repo_type='git', | |
524 | repo_description='diff-test', |
|
524 | repo_description='diff-test', | |
525 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
525 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
526 |
|
526 | |||
@@ -533,7 +533,7 b' class TestCompareController(base.TestCon' | |||||
533 | Session().commit() |
|
533 | Session().commit() | |
534 | assert repo1.scm_instance.revisions == [cs0.raw_id] |
|
534 | assert repo1.scm_instance.revisions == [cs0.raw_id] | |
535 | # fork the repo1 |
|
535 | # fork the repo1 | |
536 |
repo2 = fixture.create_fork(r1_name, |
|
536 | repo2 = fixture.create_fork(r1_name, 'one-git-fork', | |
537 | cur_user=base.TEST_USER_ADMIN_LOGIN) |
|
537 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
538 | Session().commit() |
|
538 | Session().commit() | |
539 | assert repo2.scm_instance.revisions == [cs0.raw_id] |
|
539 | assert repo2.scm_instance.revisions == [cs0.raw_id] |
@@ -252,7 +252,7 b' class TestFilesController(base.TestContr' | |||||
252 |
|
252 | |||
253 | def test_raw_file_wrong_cs(self): |
|
253 | def test_raw_file_wrong_cs(self): | |
254 | self.log_user() |
|
254 | self.log_user() | |
255 |
rev = |
|
255 | rev = 'ERRORce30c96924232dffcd24178a07ffeb5dfc' | |
256 | f_path = 'vcs/nodes.py' |
|
256 | f_path = 'vcs/nodes.py' | |
257 |
|
257 | |||
258 | response = self.app.get(base.url(controller='files', action='rawfile', |
|
258 | response = self.app.get(base.url(controller='files', action='rawfile', | |
@@ -289,7 +289,7 b' class TestFilesController(base.TestContr' | |||||
289 |
|
289 | |||
290 | def test_raw_wrong_cs(self): |
|
290 | def test_raw_wrong_cs(self): | |
291 | self.log_user() |
|
291 | self.log_user() | |
292 |
rev = |
|
292 | rev = 'ERRORcce30c96924232dffcd24178a07ffeb5dfc' | |
293 | f_path = 'vcs/nodes.py' |
|
293 | f_path = 'vcs/nodes.py' | |
294 |
|
294 | |||
295 | response = self.app.get(base.url(controller='files', action='raw', |
|
295 | response = self.app.get(base.url(controller='files', action='raw', | |
@@ -381,7 +381,7 b' class TestFilesController(base.TestContr' | |||||
381 | ]) |
|
381 | ]) | |
382 | def test_add_file_into_hg(self, cnt, location, filename): |
|
382 | def test_add_file_into_hg(self, cnt, location, filename): | |
383 | self.log_user() |
|
383 | self.log_user() | |
384 |
repo = fixture.create_repo( |
|
384 | repo = fixture.create_repo('commit-test-%s' % cnt, repo_type='hg') | |
385 | response = self.app.post(base.url('files_add_home', |
|
385 | response = self.app.post(base.url('files_add_home', | |
386 | repo_name=repo.repo_name, |
|
386 | repo_name=repo.repo_name, | |
387 | revision='tip', f_path='/'), |
|
387 | revision='tip', f_path='/'), | |
@@ -457,7 +457,7 b' class TestFilesController(base.TestContr' | |||||
457 | ]) |
|
457 | ]) | |
458 | def test_add_file_into_git(self, cnt, location, filename): |
|
458 | def test_add_file_into_git(self, cnt, location, filename): | |
459 | self.log_user() |
|
459 | self.log_user() | |
460 |
repo = fixture.create_repo( |
|
460 | repo = fixture.create_repo('commit-test-%s' % cnt, repo_type='git') | |
461 | response = self.app.post(base.url('files_add_home', |
|
461 | response = self.app.post(base.url('files_add_home', | |
462 | repo_name=repo.repo_name, |
|
462 | repo_name=repo.repo_name, | |
463 | revision='tip', f_path='/'), |
|
463 | revision='tip', f_path='/'), | |
@@ -492,7 +492,7 b' class TestFilesController(base.TestContr' | |||||
492 |
|
492 | |||
493 | def test_edit_file_view_not_on_branch_hg(self): |
|
493 | def test_edit_file_view_not_on_branch_hg(self): | |
494 | self.log_user() |
|
494 | self.log_user() | |
495 |
repo = fixture.create_repo( |
|
495 | repo = fixture.create_repo('test-edit-repo', repo_type='hg') | |
496 |
|
496 | |||
497 | ## add file |
|
497 | ## add file | |
498 | location = 'vcs' |
|
498 | location = 'vcs' | |
@@ -522,7 +522,7 b' class TestFilesController(base.TestContr' | |||||
522 |
|
522 | |||
523 | def test_edit_file_view_commit_changes_hg(self): |
|
523 | def test_edit_file_view_commit_changes_hg(self): | |
524 | self.log_user() |
|
524 | self.log_user() | |
525 |
repo = fixture.create_repo( |
|
525 | repo = fixture.create_repo('test-edit-repo', repo_type='hg') | |
526 |
|
526 | |||
527 | ## add file |
|
527 | ## add file | |
528 | location = 'vcs' |
|
528 | location = 'vcs' | |
@@ -566,7 +566,7 b' class TestFilesController(base.TestContr' | |||||
566 |
|
566 | |||
567 | def test_edit_file_view_not_on_branch_git(self): |
|
567 | def test_edit_file_view_not_on_branch_git(self): | |
568 | self.log_user() |
|
568 | self.log_user() | |
569 |
repo = fixture.create_repo( |
|
569 | repo = fixture.create_repo('test-edit-repo', repo_type='git') | |
570 |
|
570 | |||
571 | ## add file |
|
571 | ## add file | |
572 | location = 'vcs' |
|
572 | location = 'vcs' | |
@@ -596,7 +596,7 b' class TestFilesController(base.TestContr' | |||||
596 |
|
596 | |||
597 | def test_edit_file_view_commit_changes_git(self): |
|
597 | def test_edit_file_view_commit_changes_git(self): | |
598 | self.log_user() |
|
598 | self.log_user() | |
599 |
repo = fixture.create_repo( |
|
599 | repo = fixture.create_repo('test-edit-repo', repo_type='git') | |
600 |
|
600 | |||
601 | ## add file |
|
601 | ## add file | |
602 | location = 'vcs' |
|
602 | location = 'vcs' | |
@@ -640,7 +640,7 b' class TestFilesController(base.TestContr' | |||||
640 |
|
640 | |||
641 | def test_delete_file_view_not_on_branch_hg(self): |
|
641 | def test_delete_file_view_not_on_branch_hg(self): | |
642 | self.log_user() |
|
642 | self.log_user() | |
643 |
repo = fixture.create_repo( |
|
643 | repo = fixture.create_repo('test-delete-repo', repo_type='hg') | |
644 |
|
644 | |||
645 | ## add file |
|
645 | ## add file | |
646 | location = 'vcs' |
|
646 | location = 'vcs' | |
@@ -670,7 +670,7 b' class TestFilesController(base.TestContr' | |||||
670 |
|
670 | |||
671 | def test_delete_file_view_commit_changes_hg(self): |
|
671 | def test_delete_file_view_commit_changes_hg(self): | |
672 | self.log_user() |
|
672 | self.log_user() | |
673 |
repo = fixture.create_repo( |
|
673 | repo = fixture.create_repo('test-delete-repo', repo_type='hg') | |
674 |
|
674 | |||
675 | ## add file |
|
675 | ## add file | |
676 | location = 'vcs' |
|
676 | location = 'vcs' | |
@@ -713,7 +713,7 b' class TestFilesController(base.TestContr' | |||||
713 |
|
713 | |||
714 | def test_delete_file_view_not_on_branch_git(self): |
|
714 | def test_delete_file_view_not_on_branch_git(self): | |
715 | self.log_user() |
|
715 | self.log_user() | |
716 |
repo = fixture.create_repo( |
|
716 | repo = fixture.create_repo('test-delete-repo', repo_type='git') | |
717 |
|
717 | |||
718 | ## add file |
|
718 | ## add file | |
719 | location = 'vcs' |
|
719 | location = 'vcs' | |
@@ -743,7 +743,7 b' class TestFilesController(base.TestContr' | |||||
743 |
|
743 | |||
744 | def test_delete_file_view_commit_changes_git(self): |
|
744 | def test_delete_file_view_commit_changes_git(self): | |
745 | self.log_user() |
|
745 | self.log_user() | |
746 |
repo = fixture.create_repo( |
|
746 | repo = fixture.create_repo('test-delete-repo', repo_type='git') | |
747 |
|
747 | |||
748 | ## add file |
|
748 | ## add file | |
749 | location = 'vcs' |
|
749 | location = 'vcs' |
@@ -23,9 +23,9 b' class _BaseTestCase(base.TestController)' | |||||
23 | REPO_FORK = None |
|
23 | REPO_FORK = None | |
24 |
|
24 | |||
25 | def setup_method(self, method): |
|
25 | def setup_method(self, method): | |
26 |
self.username = |
|
26 | self.username = 'forkuser' | |
27 |
self.password = |
|
27 | self.password = 'qweqwe' | |
28 |
u1 = fixture.create_user(self.username, password=self.password, email= |
|
28 | u1 = fixture.create_user(self.username, password=self.password, email='fork_king@example.com') | |
29 | self.u1_id = u1.user_id |
|
29 | self.u1_id = u1.user_id | |
30 | Session().commit() |
|
30 | Session().commit() | |
31 |
|
31 | |||
@@ -69,7 +69,7 b' class _BaseTestCase(base.TestController)' | |||||
69 | org_repo = Repository.get_by_repo_name(repo_name) |
|
69 | org_repo = Repository.get_by_repo_name(repo_name) | |
70 | creation_args = { |
|
70 | creation_args = { | |
71 | 'repo_name': fork_name, |
|
71 | 'repo_name': fork_name, | |
72 |
'repo_group': |
|
72 | 'repo_group': '-1', | |
73 | 'fork_parent_id': org_repo.repo_id, |
|
73 | 'fork_parent_id': org_repo.repo_id, | |
74 | 'repo_type': self.REPO_TYPE, |
|
74 | 'repo_type': self.REPO_TYPE, | |
75 | 'description': description, |
|
75 | 'description': description, | |
@@ -93,7 +93,7 b' class _BaseTestCase(base.TestController)' | |||||
93 |
|
93 | |||
94 | def test_fork_create_into_group(self): |
|
94 | def test_fork_create_into_group(self): | |
95 | self.log_user() |
|
95 | self.log_user() | |
96 |
group = fixture.create_repo_group( |
|
96 | group = fixture.create_repo_group('vc') | |
97 | group_id = group.group_id |
|
97 | group_id = group.group_id | |
98 | fork_name = self.REPO_FORK |
|
98 | fork_name = self.REPO_FORK | |
99 | fork_name_full = 'vc/%s' % fork_name |
|
99 | fork_name_full = 'vc/%s' % fork_name | |
@@ -143,10 +143,10 b' class _BaseTestCase(base.TestController)' | |||||
143 | # create a fork |
|
143 | # create a fork | |
144 | repo_name = self.REPO |
|
144 | repo_name = self.REPO | |
145 | org_repo = Repository.get_by_repo_name(repo_name) |
|
145 | org_repo = Repository.get_by_repo_name(repo_name) | |
146 |
fork_name = self.REPO_FORK + |
|
146 | fork_name = self.REPO_FORK + '-rΓΈdgrΓΈd' | |
147 | creation_args = { |
|
147 | creation_args = { | |
148 | 'repo_name': fork_name, |
|
148 | 'repo_name': fork_name, | |
149 |
'repo_group': |
|
149 | 'repo_group': '-1', | |
150 | 'fork_parent_id': org_repo.repo_id, |
|
150 | 'fork_parent_id': org_repo.repo_id, | |
151 | 'repo_type': self.REPO_TYPE, |
|
151 | 'repo_type': self.REPO_TYPE, | |
152 | 'description': 'unicode repo 1', |
|
152 | 'description': 'unicode repo 1', | |
@@ -164,10 +164,10 b' class _BaseTestCase(base.TestController)' | |||||
164 | assert fork_repo |
|
164 | assert fork_repo | |
165 |
|
165 | |||
166 | # fork the fork |
|
166 | # fork the fork | |
167 |
fork_name_2 = self.REPO_FORK + |
|
167 | fork_name_2 = self.REPO_FORK + '-blΓ₯bΓ¦rgrΓΈd' | |
168 | creation_args = { |
|
168 | creation_args = { | |
169 | 'repo_name': fork_name_2, |
|
169 | 'repo_name': fork_name_2, | |
170 |
'repo_group': |
|
170 | 'repo_group': '-1', | |
171 | 'fork_parent_id': fork_repo.repo_id, |
|
171 | 'fork_parent_id': fork_repo.repo_id, | |
172 | 'repo_type': self.REPO_TYPE, |
|
172 | 'repo_type': self.REPO_TYPE, | |
173 | 'description': 'unicode repo 2', |
|
173 | 'description': 'unicode repo 2', | |
@@ -196,7 +196,7 b' class _BaseTestCase(base.TestController)' | |||||
196 | org_repo = Repository.get_by_repo_name(repo_name) |
|
196 | org_repo = Repository.get_by_repo_name(repo_name) | |
197 | creation_args = { |
|
197 | creation_args = { | |
198 | 'repo_name': fork_name, |
|
198 | 'repo_name': fork_name, | |
199 |
'repo_group': |
|
199 | 'repo_group': '-1', | |
200 | 'fork_parent_id': org_repo.repo_id, |
|
200 | 'fork_parent_id': org_repo.repo_id, | |
201 | 'repo_type': self.REPO_TYPE, |
|
201 | 'repo_type': self.REPO_TYPE, | |
202 | 'description': description, |
|
202 | 'description': description, |
@@ -53,35 +53,35 b' class TestHomeController(base.TestContro' | |||||
53 |
|
53 | |||
54 | def test_index_page_on_groups(self): |
|
54 | def test_index_page_on_groups(self): | |
55 | self.log_user() |
|
55 | self.log_user() | |
56 |
gr = fixture.create_repo_group( |
|
56 | gr = fixture.create_repo_group('gr1') | |
57 |
fixture.create_repo(name= |
|
57 | fixture.create_repo(name='gr1/repo_in_group', repo_group=gr) | |
58 |
response = self.app.get(base.url('repos_group_home', group_name= |
|
58 | response = self.app.get(base.url('repos_group_home', group_name='gr1')) | |
59 |
|
59 | |||
60 | try: |
|
60 | try: | |
61 |
response.mustcontain( |
|
61 | response.mustcontain("gr1/repo_in_group") | |
62 | finally: |
|
62 | finally: | |
63 |
RepoModel().delete( |
|
63 | RepoModel().delete('gr1/repo_in_group') | |
64 |
RepoGroupModel().delete(repo_group= |
|
64 | RepoGroupModel().delete(repo_group='gr1', force_delete=True) | |
65 | Session().commit() |
|
65 | Session().commit() | |
66 |
|
66 | |||
67 | def test_users_and_groups_data(self): |
|
67 | def test_users_and_groups_data(self): | |
68 |
fixture.create_user('evil', firstname= |
|
68 | fixture.create_user('evil', firstname='D\'o\'ct"o"r', lastname='ΓvΓl') | |
69 |
fixture.create_user_group( |
|
69 | fixture.create_user_group('grrrr', user_group_description="GroΓΌp") | |
70 |
response = self.app.get(base.url('users_and_groups_data', query= |
|
70 | response = self.app.get(base.url('users_and_groups_data', query='evi')) | |
71 | assert response.status_code == 302 |
|
71 | assert response.status_code == 302 | |
72 | assert base.url('login_home') in response.location |
|
72 | assert base.url('login_home') in response.location | |
73 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) |
|
73 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
74 |
response = self.app.get(base.url('users_and_groups_data', query= |
|
74 | response = self.app.get(base.url('users_and_groups_data', query='evi')) | |
75 | result = json.loads(response.body)['results'] |
|
75 | result = json.loads(response.body)['results'] | |
76 |
assert result[0].get('fname') == |
|
76 | assert result[0].get('fname') == 'D\'o\'ct"o"r' | |
77 |
assert result[0].get('lname') == |
|
77 | assert result[0].get('lname') == 'ΓvΓl' | |
78 |
response = self.app.get(base.url('users_and_groups_data', key= |
|
78 | response = self.app.get(base.url('users_and_groups_data', key='evil')) | |
79 | result = json.loads(response.body)['results'] |
|
79 | result = json.loads(response.body)['results'] | |
80 |
assert result[0].get('fname') == |
|
80 | assert result[0].get('fname') == 'D\'o\'ct"o"r' | |
81 |
assert result[0].get('lname') == |
|
81 | assert result[0].get('lname') == 'ΓvΓl' | |
82 |
response = self.app.get(base.url('users_and_groups_data', query= |
|
82 | response = self.app.get(base.url('users_and_groups_data', query='rrrr')) | |
83 | result = json.loads(response.body)['results'] |
|
83 | result = json.loads(response.body)['results'] | |
84 | assert not result |
|
84 | assert not result | |
85 |
response = self.app.get(base.url('users_and_groups_data', types='users,groups', query= |
|
85 | response = self.app.get(base.url('users_and_groups_data', types='users,groups', query='rrrr')) | |
86 | result = json.loads(response.body)['results'] |
|
86 | result = json.loads(response.body)['results'] | |
87 |
assert result[0].get('grname') == |
|
87 | assert result[0].get('grname') == 'grrrr' |
@@ -164,7 +164,7 b' class TestLoginController(base.TestContr' | |||||
164 |
|
164 | |||
165 | @base.parametrize('args', [ |
|
165 | @base.parametrize('args', [ | |
166 | {'foo':'one', 'bar':'two'}, |
|
166 | {'foo':'one', 'bar':'two'}, | |
167 |
{'blue': |
|
167 | {'blue': 'blΓ₯', 'green': 'grΓΈn'}, | |
168 | ]) |
|
168 | ]) | |
169 | def test_redirection_to_login_form_preserves_get_args(self, args): |
|
169 | def test_redirection_to_login_form_preserves_get_args(self, args): | |
170 | with fixture.anon_access(False): |
|
170 | with fixture.anon_access(False): | |
@@ -178,7 +178,7 b' class TestLoginController(base.TestContr' | |||||
178 |
|
178 | |||
179 | @base.parametrize('args,args_encoded', [ |
|
179 | @base.parametrize('args,args_encoded', [ | |
180 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), |
|
180 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), | |
181 |
({'blue': |
|
181 | ({'blue': 'blΓ₯', 'green':'grΓΈn'}, | |
182 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), |
|
182 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), | |
183 | ]) |
|
183 | ]) | |
184 | def test_login_form_preserves_get_args(self, args, args_encoded): |
|
184 | def test_login_form_preserves_get_args(self, args, args_encoded): | |
@@ -190,7 +190,7 b' class TestLoginController(base.TestContr' | |||||
190 |
|
190 | |||
191 | @base.parametrize('args,args_encoded', [ |
|
191 | @base.parametrize('args,args_encoded', [ | |
192 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), |
|
192 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), | |
193 |
({'blue': |
|
193 | ({'blue': 'blΓ₯', 'green':'grΓΈn'}, | |
194 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), |
|
194 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), | |
195 | ]) |
|
195 | ]) | |
196 | def test_redirection_after_successful_login_preserves_get_args(self, args, args_encoded): |
|
196 | def test_redirection_after_successful_login_preserves_get_args(self, args, args_encoded): | |
@@ -205,7 +205,7 b' class TestLoginController(base.TestContr' | |||||
205 |
|
205 | |||
206 | @base.parametrize('args,args_encoded', [ |
|
206 | @base.parametrize('args,args_encoded', [ | |
207 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), |
|
207 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), | |
208 |
({'blue': |
|
208 | ({'blue': 'blΓ₯', 'green':'grΓΈn'}, | |
209 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), |
|
209 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), | |
210 | ]) |
|
210 | ]) | |
211 | def test_login_form_after_incorrect_login_preserves_get_args(self, args, args_encoded): |
|
211 | def test_login_form_after_incorrect_login_preserves_get_args(self, args, args_encoded): | |
@@ -392,8 +392,8 b' class TestLoginController(base.TestContr' | |||||
392 | username = 'test_password_reset_1' |
|
392 | username = 'test_password_reset_1' | |
393 | password = 'qweqwe' |
|
393 | password = 'qweqwe' | |
394 | email = 'username@example.com' |
|
394 | email = 'username@example.com' | |
395 |
name = |
|
395 | name = 'passwd' | |
396 |
lastname = |
|
396 | lastname = 'reset' | |
397 | timestamp = int(time.time()) |
|
397 | timestamp = int(time.time()) | |
398 |
|
398 | |||
399 | new = User() |
|
399 | new = User() | |
@@ -521,12 +521,12 b' class TestLoginController(base.TestContr' | |||||
521 | self._api_key_test(api_key, code) |
|
521 | self._api_key_test(api_key, code) | |
522 |
|
522 | |||
523 | def test_access_page_via_extra_api_key(self): |
|
523 | def test_access_page_via_extra_api_key(self): | |
524 |
new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, |
|
524 | new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, 'test') | |
525 | Session().commit() |
|
525 | Session().commit() | |
526 | self._api_key_test(new_api_key.api_key, status=200) |
|
526 | self._api_key_test(new_api_key.api_key, status=200) | |
527 |
|
527 | |||
528 | def test_access_page_via_expired_api_key(self): |
|
528 | def test_access_page_via_expired_api_key(self): | |
529 |
new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, |
|
529 | new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, 'test') | |
530 | Session().commit() |
|
530 | Session().commit() | |
531 | # patch the API key and make it expired |
|
531 | # patch the API key and make it expired | |
532 | new_api_key.expires = 0 |
|
532 | new_api_key.expires = 0 |
@@ -161,8 +161,8 b' class TestMyAccountController(base.TestC' | |||||
161 | username=base.TEST_USER_ADMIN_LOGIN, |
|
161 | username=base.TEST_USER_ADMIN_LOGIN, | |
162 | new_password=base.TEST_USER_ADMIN_PASS, |
|
162 | new_password=base.TEST_USER_ADMIN_PASS, | |
163 | password_confirmation='test122', |
|
163 | password_confirmation='test122', | |
164 |
firstname= |
|
164 | firstname='NewName', | |
165 |
lastname= |
|
165 | lastname='NewLastname', | |
166 | email=new_email, |
|
166 | email=new_email, | |
167 | _session_csrf_secret_token=self.session_csrf_secret_token()) |
|
167 | _session_csrf_secret_token=self.session_csrf_secret_token()) | |
168 | ) |
|
168 | ) | |
@@ -178,8 +178,8 b' class TestMyAccountController(base.TestC' | |||||
178 | username=base.TEST_USER_ADMIN_LOGIN, |
|
178 | username=base.TEST_USER_ADMIN_LOGIN, | |
179 | new_password=base.TEST_USER_ADMIN_PASS, |
|
179 | new_password=base.TEST_USER_ADMIN_PASS, | |
180 | password_confirmation='test122', |
|
180 | password_confirmation='test122', | |
181 |
firstname= |
|
181 | firstname='NewName', | |
182 |
lastname= |
|
182 | lastname='NewLastname', | |
183 | email=new_email, |
|
183 | email=new_email, | |
184 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
184 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
185 |
|
185 | |||
@@ -252,9 +252,9 b' class TestMyAccountController(base.TestC' | |||||
252 | response.mustcontain(no=[api_key]) |
|
252 | response.mustcontain(no=[api_key]) | |
253 |
|
253 | |||
254 | def test_my_account_add_ssh_key(self): |
|
254 | def test_my_account_add_ssh_key(self): | |
255 |
description = |
|
255 | description = 'something' | |
256 |
public_key = |
|
256 | public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' | |
257 |
fingerprint = |
|
257 | fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
258 |
|
258 | |||
259 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) |
|
259 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
260 | response = self.app.post(base.url('my_account_ssh_keys'), |
|
260 | response = self.app.post(base.url('my_account_ssh_keys'), | |
@@ -273,9 +273,9 b' class TestMyAccountController(base.TestC' | |||||
273 | Session().commit() |
|
273 | Session().commit() | |
274 |
|
274 | |||
275 | def test_my_account_remove_ssh_key(self): |
|
275 | def test_my_account_remove_ssh_key(self): | |
276 |
description = |
|
276 | description = '' | |
277 |
public_key = |
|
277 | public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' | |
278 |
fingerprint = |
|
278 | fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
279 |
|
279 | |||
280 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) |
|
280 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
281 | response = self.app.post(base.url('my_account_ssh_keys'), |
|
281 | response = self.app.post(base.url('my_account_ssh_keys'), | |
@@ -286,7 +286,7 b' class TestMyAccountController(base.TestC' | |||||
286 | response.follow() |
|
286 | response.follow() | |
287 | user_id = response.session['authuser']['user_id'] |
|
287 | user_id = response.session['authuser']['user_id'] | |
288 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() |
|
288 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() | |
289 |
assert ssh_key.description == |
|
289 | assert ssh_key.description == 'me@localhost' | |
290 |
|
290 | |||
291 | response = self.app.post(base.url('my_account_ssh_keys_delete'), |
|
291 | response = self.app.post(base.url('my_account_ssh_keys_delete'), | |
292 | {'del_public_key_fingerprint': ssh_key.fingerprint, |
|
292 | {'del_public_key_fingerprint': ssh_key.fingerprint, |
@@ -292,14 +292,14 b' class TestPullrequestsController(base.Te' | |||||
292 | class TestPullrequestsGetRepoRefs(base.TestController): |
|
292 | class TestPullrequestsGetRepoRefs(base.TestController): | |
293 |
|
293 | |||
294 | def setup_method(self, method): |
|
294 | def setup_method(self, method): | |
295 |
self.repo_name = |
|
295 | self.repo_name = 'main' | |
296 | repo = fixture.create_repo(self.repo_name, repo_type='hg') |
|
296 | repo = fixture.create_repo(self.repo_name, repo_type='hg') | |
297 | self.repo_scm_instance = repo.scm_instance |
|
297 | self.repo_scm_instance = repo.scm_instance | |
298 | Session().commit() |
|
298 | Session().commit() | |
299 | self.c = PullrequestsController() |
|
299 | self.c = PullrequestsController() | |
300 |
|
300 | |||
301 | def teardown_method(self, method): |
|
301 | def teardown_method(self, method): | |
302 |
fixture.destroy_repo( |
|
302 | fixture.destroy_repo('main') | |
303 | Session().commit() |
|
303 | Session().commit() | |
304 | Session.remove() |
|
304 | Session.remove() | |
305 |
|
305 |
@@ -39,12 +39,12 b' def init_stopword_test(repo):' | |||||
39 |
|
39 | |||
40 | repos = [ |
|
40 | repos = [ | |
41 | # reponame, init func or fork base, groupname |
|
41 | # reponame, init func or fork base, groupname | |
42 |
( |
|
42 | ('indexing_test', init_indexing_test, None), | |
43 |
( |
|
43 | ('indexing_test-fork', 'indexing_test', None), | |
44 |
( |
|
44 | ('group/indexing_test', 'indexing_test', 'group'), | |
45 |
( |
|
45 | ('this-is-it', 'indexing_test', None), | |
46 |
( |
|
46 | ('indexing_test-foo', 'indexing_test', None), | |
47 |
( |
|
47 | ('stopword_test', init_stopword_test, None), | |
48 | ] |
|
48 | ] | |
49 |
|
49 | |||
50 |
|
50 | |||
@@ -109,12 +109,12 b' class TestSearchControllerIndexing(base.' | |||||
109 | rebuild_index(full_index=True) # rebuild fully for subsequent tests |
|
109 | rebuild_index(full_index=True) # rebuild fully for subsequent tests | |
110 |
|
110 | |||
111 | @base.parametrize('reponame', [ |
|
111 | @base.parametrize('reponame', [ | |
112 |
( |
|
112 | ('indexing_test'), | |
113 |
( |
|
113 | ('indexing_test-fork'), | |
114 |
( |
|
114 | ('group/indexing_test'), | |
115 |
( |
|
115 | ('this-is-it'), | |
116 |
( |
|
116 | ('*-fork'), | |
117 |
( |
|
117 | ('group/*'), | |
118 | ]) |
|
118 | ]) | |
119 | @base.parametrize('searchtype,query,hit', [ |
|
119 | @base.parametrize('searchtype,query,hit', [ | |
120 | ('content', 'this_should_be_unique_content', 1), |
|
120 | ('content', 'this_should_be_unique_content', 1), | |
@@ -130,10 +130,10 b' class TestSearchControllerIndexing(base.' | |||||
130 | response.mustcontain('>%d results' % hit) |
|
130 | response.mustcontain('>%d results' % hit) | |
131 |
|
131 | |||
132 | @base.parametrize('reponame', [ |
|
132 | @base.parametrize('reponame', [ | |
133 |
( |
|
133 | ('indexing_test'), | |
134 |
( |
|
134 | ('indexing_test-fork'), | |
135 |
( |
|
135 | ('group/indexing_test'), | |
136 |
( |
|
136 | ('this-is-it'), | |
137 | ]) |
|
137 | ]) | |
138 | @base.parametrize('searchtype,query,hit', [ |
|
138 | @base.parametrize('searchtype,query,hit', [ | |
139 | ('content', 'this_should_be_unique_content', 1), |
|
139 | ('content', 'this_should_be_unique_content', 1), |
@@ -111,7 +111,7 b' class TestSummaryController(base.TestCon' | |||||
111 |
|
111 | |||
112 | def test_index_by_repo_having_id_path_in_name_hg(self): |
|
112 | def test_index_by_repo_having_id_path_in_name_hg(self): | |
113 | self.log_user() |
|
113 | self.log_user() | |
114 |
fixture.create_repo(name= |
|
114 | fixture.create_repo(name='repo_1') | |
115 | response = self.app.get(base.url(controller='summary', |
|
115 | response = self.app.get(base.url(controller='summary', | |
116 | action='index', |
|
116 | action='index', | |
117 | repo_name='repo_1')) |
|
117 | repo_name='repo_1')) | |
@@ -119,7 +119,7 b' class TestSummaryController(base.TestCon' | |||||
119 | try: |
|
119 | try: | |
120 | response.mustcontain("repo_1") |
|
120 | response.mustcontain("repo_1") | |
121 | finally: |
|
121 | finally: | |
122 |
RepoModel().delete(Repository.get_by_repo_name( |
|
122 | RepoModel().delete(Repository.get_by_repo_name('repo_1')) | |
123 | Session().commit() |
|
123 | Session().commit() | |
124 |
|
124 | |||
125 | def test_index_by_id_git(self): |
|
125 | def test_index_by_id_git(self): |
@@ -12,7 +12,7 b' fixture = Fixture()' | |||||
12 |
|
12 | |||
13 | def _destroy_project_tree(test_u1_id): |
|
13 | def _destroy_project_tree(test_u1_id): | |
14 | Session.remove() |
|
14 | Session.remove() | |
15 |
repo_group = RepoGroup.get_by_group_name(group_name= |
|
15 | repo_group = RepoGroup.get_by_group_name(group_name='g0') | |
16 | for el in reversed(repo_group.recursive_groups_and_repos()): |
|
16 | for el in reversed(repo_group.recursive_groups_and_repos()): | |
17 | if isinstance(el, Repository): |
|
17 | if isinstance(el, Repository): | |
18 | RepoModel().delete(el) |
|
18 | RepoModel().delete(el) | |
@@ -50,21 +50,21 b' def _create_project_tree():' | |||||
50 |
|
50 | |||
51 | """ |
|
51 | """ | |
52 | test_u1 = UserModel().create_or_update( |
|
52 | test_u1 = UserModel().create_or_update( | |
53 |
username= |
|
53 | username='test_u1', password='qweqwe', | |
54 |
email= |
|
54 | email='test_u1@example.com', firstname='test_u1', lastname='test_u1' | |
55 | ) |
|
55 | ) | |
56 |
g0 = fixture.create_repo_group( |
|
56 | g0 = fixture.create_repo_group('g0') | |
57 |
g0_1 = fixture.create_repo_group( |
|
57 | g0_1 = fixture.create_repo_group('g0_1', parent_group_id=g0) | |
58 |
g0_1_1 = fixture.create_repo_group( |
|
58 | g0_1_1 = fixture.create_repo_group('g0_1_1', parent_group_id=g0_1) | |
59 |
g0_1_1_r1 = fixture.create_repo( |
|
59 | g0_1_1_r1 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r1', repo_group=g0_1_1) | |
60 |
g0_1_1_r2 = fixture.create_repo( |
|
60 | g0_1_1_r2 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r2', repo_group=g0_1_1) | |
61 |
g0_1_r1 = fixture.create_repo( |
|
61 | g0_1_r1 = fixture.create_repo('g0/g0_1/g0_1_r1', repo_group=g0_1) | |
62 |
g0_2 = fixture.create_repo_group( |
|
62 | g0_2 = fixture.create_repo_group('g0_2', parent_group_id=g0) | |
63 |
g0_2_r1 = fixture.create_repo( |
|
63 | g0_2_r1 = fixture.create_repo('g0/g0_2/g0_2_r1', repo_group=g0_2) | |
64 |
g0_2_r2 = fixture.create_repo( |
|
64 | g0_2_r2 = fixture.create_repo('g0/g0_2/g0_2_r2', repo_group=g0_2) | |
65 |
g0_3 = fixture.create_repo_group( |
|
65 | g0_3 = fixture.create_repo_group('g0_3', parent_group_id=g0) | |
66 |
g0_3_r1 = fixture.create_repo( |
|
66 | g0_3_r1 = fixture.create_repo('g0/g0_3/g0_3_r1', repo_group=g0_3) | |
67 |
g0_3_r2_private = fixture.create_repo( |
|
67 | g0_3_r2_private = fixture.create_repo('g0/g0_3/g0_3_r1_private', | |
68 | repo_group=g0_3, repo_private=True) |
|
68 | repo_group=g0_3, repo_private=True) | |
69 | return test_u1 |
|
69 | return test_u1 | |
70 |
|
70 |
@@ -29,7 +29,7 b' class TestComments(base.TestController):' | |||||
29 | self._check_comment_count(repo_id, revision, |
|
29 | self._check_comment_count(repo_id, revision, | |
30 | expected_len_comments=0, expected_len_inline_comments=0) |
|
30 | expected_len_comments=0, expected_len_inline_comments=0) | |
31 |
|
31 | |||
32 |
text = |
|
32 | text = 'a comment' | |
33 | new_comment = ChangesetCommentsModel().create( |
|
33 | new_comment = ChangesetCommentsModel().create( | |
34 | text=text, |
|
34 | text=text, | |
35 | repo=base.HG_REPO, |
|
35 | repo=base.HG_REPO, | |
@@ -53,9 +53,9 b' class TestComments(base.TestController):' | |||||
53 | self._check_comment_count(repo_id, revision, |
|
53 | self._check_comment_count(repo_id, revision, | |
54 | expected_len_comments=0, expected_len_inline_comments=0) |
|
54 | expected_len_comments=0, expected_len_inline_comments=0) | |
55 |
|
55 | |||
56 |
text = |
|
56 | text = 'an inline comment' | |
57 |
f_path = |
|
57 | f_path = 'vcs/tests/base.py' | |
58 |
line_no = |
|
58 | line_no = 'n50' | |
59 | new_comment = ChangesetCommentsModel().create( |
|
59 | new_comment = ChangesetCommentsModel().create( | |
60 | text=text, |
|
60 | text=text, | |
61 | repo=base.HG_REPO, |
|
61 | repo=base.HG_REPO, | |
@@ -87,9 +87,9 b' class TestComments(base.TestController):' | |||||
87 | self._check_comment_count(repo_id, revision, |
|
87 | self._check_comment_count(repo_id, revision, | |
88 | expected_len_comments=0, expected_len_inline_comments=0) |
|
88 | expected_len_comments=0, expected_len_inline_comments=0) | |
89 |
|
89 | |||
90 |
text = |
|
90 | text = 'an inline comment' | |
91 |
f_path = |
|
91 | f_path = 'vcs/tests/base.py' | |
92 |
line_no = |
|
92 | line_no = 'n50' | |
93 | new_comment = ChangesetCommentsModel().create( |
|
93 | new_comment = ChangesetCommentsModel().create( | |
94 | text=text, |
|
94 | text=text, | |
95 | repo=base.HG_REPO, |
|
95 | repo=base.HG_REPO, | |
@@ -99,8 +99,8 b' class TestComments(base.TestController):' | |||||
99 | line_no=line_no, |
|
99 | line_no=line_no, | |
100 | send_email=False) |
|
100 | send_email=False) | |
101 |
|
101 | |||
102 |
text2 = |
|
102 | text2 = 'another inline comment, same file' | |
103 |
line_no2 = |
|
103 | line_no2 = 'o41' | |
104 | new_comment2 = ChangesetCommentsModel().create( |
|
104 | new_comment2 = ChangesetCommentsModel().create( | |
105 | text=text2, |
|
105 | text=text2, | |
106 | repo=base.HG_REPO, |
|
106 | repo=base.HG_REPO, | |
@@ -110,9 +110,9 b' class TestComments(base.TestController):' | |||||
110 | line_no=line_no2, |
|
110 | line_no=line_no2, | |
111 | send_email=False) |
|
111 | send_email=False) | |
112 |
|
112 | |||
113 |
text3 = |
|
113 | text3 = 'another inline comment, same file' | |
114 |
f_path3 = |
|
114 | f_path3 = 'vcs/tests/test_hg.py' | |
115 |
line_no3 = |
|
115 | line_no3 = 'n159' | |
116 | new_comment3 = ChangesetCommentsModel().create( |
|
116 | new_comment3 = ChangesetCommentsModel().create( | |
117 | text=text3, |
|
117 | text=text3, | |
118 | repo=base.HG_REPO, |
|
118 | repo=base.HG_REPO, | |
@@ -167,9 +167,9 b' class TestComments(base.TestController):' | |||||
167 | self._check_comment_count(repo_id, revision, |
|
167 | self._check_comment_count(repo_id, revision, | |
168 | expected_len_comments=0, expected_len_inline_comments=0) |
|
168 | expected_len_comments=0, expected_len_inline_comments=0) | |
169 |
|
169 | |||
170 |
text = |
|
170 | text = 'an inline comment' | |
171 |
f_path = |
|
171 | f_path = 'vcs/tests/base.py' | |
172 |
line_no = |
|
172 | line_no = 'n50' | |
173 | new_comment = ChangesetCommentsModel().create( |
|
173 | new_comment = ChangesetCommentsModel().create( | |
174 | text=text, |
|
174 | text=text, | |
175 | repo=base.HG_REPO, |
|
175 | repo=base.HG_REPO, | |
@@ -179,8 +179,8 b' class TestComments(base.TestController):' | |||||
179 | line_no=line_no, |
|
179 | line_no=line_no, | |
180 | send_email=False) |
|
180 | send_email=False) | |
181 |
|
181 | |||
182 |
text2 = |
|
182 | text2 = 'another inline comment, same file' | |
183 |
line_no2 = |
|
183 | line_no2 = 'o41' | |
184 | new_comment2 = ChangesetCommentsModel().create( |
|
184 | new_comment2 = ChangesetCommentsModel().create( | |
185 | text=text2, |
|
185 | text=text2, | |
186 | repo=base.HG_REPO, |
|
186 | repo=base.HG_REPO, | |
@@ -190,9 +190,9 b' class TestComments(base.TestController):' | |||||
190 | line_no=line_no2, |
|
190 | line_no=line_no2, | |
191 | send_email=False) |
|
191 | send_email=False) | |
192 |
|
192 | |||
193 |
text3 = |
|
193 | text3 = 'another inline comment, same file' | |
194 |
f_path3 = |
|
194 | f_path3 = 'vcs/tests/test_hg.py' | |
195 |
line_no3 = |
|
195 | line_no3 = 'n159' | |
196 | new_comment3 = ChangesetCommentsModel().create( |
|
196 | new_comment3 = ChangesetCommentsModel().create( | |
197 | text=text3, |
|
197 | text=text3, | |
198 | repo=base.HG_REPO, |
|
198 | repo=base.HG_REPO, |
@@ -18,24 +18,24 b' class TestNotifications(base.TestControl' | |||||
18 |
|
18 | |||
19 | def setup_method(self, method): |
|
19 | def setup_method(self, method): | |
20 | Session.remove() |
|
20 | Session.remove() | |
21 |
u1 = UserModel().create_or_update(username= |
|
21 | u1 = UserModel().create_or_update(username='u1', | |
22 |
password= |
|
22 | password='qweqwe', | |
23 |
email= |
|
23 | email='u1@example.com', | |
24 |
firstname= |
|
24 | firstname='u1', lastname='u1') | |
25 | Session().commit() |
|
25 | Session().commit() | |
26 | self.u1 = u1.user_id |
|
26 | self.u1 = u1.user_id | |
27 |
|
27 | |||
28 |
u2 = UserModel().create_or_update(username= |
|
28 | u2 = UserModel().create_or_update(username='u2', | |
29 |
password= |
|
29 | password='qweqwe', | |
30 |
email= |
|
30 | email='u2@example.com', | |
31 |
firstname= |
|
31 | firstname='u2', lastname='u3') | |
32 | Session().commit() |
|
32 | Session().commit() | |
33 | self.u2 = u2.user_id |
|
33 | self.u2 = u2.user_id | |
34 |
|
34 | |||
35 |
u3 = UserModel().create_or_update(username= |
|
35 | u3 = UserModel().create_or_update(username='u3', | |
36 |
password= |
|
36 | password='qweqwe', | |
37 |
email= |
|
37 | email='u3@example.com', | |
38 |
firstname= |
|
38 | firstname='u3', lastname='u3') | |
39 | Session().commit() |
|
39 | Session().commit() | |
40 | self.u3 = u3.user_id |
|
40 | self.u3 = u3.user_id | |
41 |
|
41 | |||
@@ -46,12 +46,12 b' class TestNotifications(base.TestControl' | |||||
46 | def send_email(recipients, subject, body='', html_body='', headers=None, author=None): |
|
46 | def send_email(recipients, subject, body='', html_body='', headers=None, author=None): | |
47 | assert recipients == ['u2@example.com'] |
|
47 | assert recipients == ['u2@example.com'] | |
48 | assert subject == 'Test Message' |
|
48 | assert subject == 'Test Message' | |
49 |
assert body == |
|
49 | assert body == "hi there" | |
50 | assert '>hi there<' in html_body |
|
50 | assert '>hi there<' in html_body | |
51 | assert author.username == 'u1' |
|
51 | assert author.username == 'u1' | |
52 | with mock.patch.object(kallithea.lib.celerylib.tasks, 'send_email', send_email): |
|
52 | with mock.patch.object(kallithea.lib.celerylib.tasks, 'send_email', send_email): | |
53 | NotificationModel().create(created_by=self.u1, |
|
53 | NotificationModel().create(created_by=self.u1, | |
54 |
subject= |
|
54 | subject='subj', body='hi there', | |
55 | recipients=usrs) |
|
55 | recipients=usrs) | |
56 |
|
56 | |||
57 | @mock.patch.object(h, 'canonical_url', (lambda arg, **kwargs: 'http://%s/?%s' % (arg, '&'.join('%s=%s' % (k, v) for (k, v) in sorted(kwargs.items()))))) |
|
57 | @mock.patch.object(h, 'canonical_url', (lambda arg, **kwargs: 'http://%s/?%s' % (arg, '&'.join('%s=%s' % (k, v) for (k, v) in sorted(kwargs.items()))))) | |
@@ -90,7 +90,7 b' class TestNotifications(base.TestControl' | |||||
90 |
|
90 | |||
91 | for type_, body, kwargs in [ |
|
91 | for type_, body, kwargs in [ | |
92 | (NotificationModel.TYPE_CHANGESET_COMMENT, |
|
92 | (NotificationModel.TYPE_CHANGESET_COMMENT, | |
93 |
|
|
93 | 'This is the new \'comment\'.\n\n - and here it ends indented.', | |
94 | dict( |
|
94 | dict( | |
95 | short_id='cafe1234', |
|
95 | short_id='cafe1234', | |
96 | raw_id='cafe1234c0ffeecafe', |
|
96 | raw_id='cafe1234c0ffeecafe', | |
@@ -105,18 +105,18 b' class TestNotifications(base.TestControl' | |||||
105 | cs_url='http://changeset.com', |
|
105 | cs_url='http://changeset.com', | |
106 | cs_author=User.get(self.u2))), |
|
106 | cs_author=User.get(self.u2))), | |
107 | (NotificationModel.TYPE_MESSAGE, |
|
107 | (NotificationModel.TYPE_MESSAGE, | |
108 |
|
|
108 | 'This is the \'body\' of the "test" message\n - nothing interesting here except indentation.', | |
109 | dict()), |
|
109 | dict()), | |
110 | #(NotificationModel.TYPE_MENTION, '$body', None), # not used |
|
110 | #(NotificationModel.TYPE_MENTION, '$body', None), # not used | |
111 | (NotificationModel.TYPE_REGISTRATION, |
|
111 | (NotificationModel.TYPE_REGISTRATION, | |
112 |
|
|
112 | 'Registration body', | |
113 | dict( |
|
113 | dict( | |
114 | new_username='newbie', |
|
114 | new_username='newbie', | |
115 | registered_user_url='http://newbie.org', |
|
115 | registered_user_url='http://newbie.org', | |
116 | new_email='new@email.com', |
|
116 | new_email='new@email.com', | |
117 | new_full_name='New Full Name')), |
|
117 | new_full_name='New Full Name')), | |
118 | (NotificationModel.TYPE_PULL_REQUEST, |
|
118 | (NotificationModel.TYPE_PULL_REQUEST, | |
119 |
|
|
119 | 'This PR is \'awesome\' because it does <stuff>\n - please approve indented!', | |
120 | dict( |
|
120 | dict( | |
121 | pr_user_created='Requesting User (root)', # pr_owner should perhaps be used for @mention in description ... |
|
121 | pr_user_created='Requesting User (root)', # pr_owner should perhaps be used for @mention in description ... | |
122 | is_mention=[False, True], |
|
122 | is_mention=[False, True], | |
@@ -124,7 +124,7 b' class TestNotifications(base.TestControl' | |||||
124 | org_repo_name='repo_org', |
|
124 | org_repo_name='repo_org', | |
125 | **pr_kwargs)), |
|
125 | **pr_kwargs)), | |
126 | (NotificationModel.TYPE_PULL_REQUEST_COMMENT, |
|
126 | (NotificationModel.TYPE_PULL_REQUEST_COMMENT, | |
127 |
|
|
127 | 'Me too!\n\n - and indented on second line', | |
128 | dict( |
|
128 | dict( | |
129 | closing_pr=[False, True], |
|
129 | closing_pr=[False, True], | |
130 | is_mention=[False, True], |
|
130 | is_mention=[False, True], | |
@@ -133,7 +133,7 b' class TestNotifications(base.TestControl' | |||||
133 | status_change=[None, 'Under Review'], |
|
133 | status_change=[None, 'Under Review'], | |
134 | **pr_kwargs)), |
|
134 | **pr_kwargs)), | |
135 | ]: |
|
135 | ]: | |
136 |
kwargs['repo_name'] = |
|
136 | kwargs['repo_name'] = 'repo/name' | |
137 | params = [(type_, type_, body, kwargs)] |
|
137 | params = [(type_, type_, body, kwargs)] | |
138 | for param_name in ['is_mention', 'status_change', 'closing_pr']: # TODO: inline/general |
|
138 | for param_name in ['is_mention', 'status_change', 'closing_pr']: # TODO: inline/general | |
139 | if not isinstance(kwargs.get(param_name), list): |
|
139 | if not isinstance(kwargs.get(param_name), list): | |
@@ -149,7 +149,7 b' class TestNotifications(base.TestControl' | |||||
149 | for desc, type_, body, kwargs in params: |
|
149 | for desc, type_, body, kwargs in params: | |
150 | # desc is used as "global" variable |
|
150 | # desc is used as "global" variable | |
151 | NotificationModel().create(created_by=self.u1, |
|
151 | NotificationModel().create(created_by=self.u1, | |
152 |
subject= |
|
152 | subject='unused', body=body, email_kwargs=kwargs, | |
153 | recipients=[self.u2], type_=type_) |
|
153 | recipients=[self.u2], type_=type_) | |
154 |
|
154 | |||
155 | # Email type TYPE_PASSWORD_RESET has no corresponding notification type - test it directly: |
|
155 | # Email type TYPE_PASSWORD_RESET has no corresponding notification type - test it directly: |
@@ -24,21 +24,21 b' class TestPermissions(base.TestControlle' | |||||
24 |
|
24 | |||
25 | def setup_method(self, method): |
|
25 | def setup_method(self, method): | |
26 | self.u1 = UserModel().create_or_update( |
|
26 | self.u1 = UserModel().create_or_update( | |
27 |
username= |
|
27 | username='u1', password='qweqwe', | |
28 |
email= |
|
28 | email='u1@example.com', firstname='u1', lastname='u1' | |
29 | ) |
|
29 | ) | |
30 | self.u2 = UserModel().create_or_update( |
|
30 | self.u2 = UserModel().create_or_update( | |
31 |
username= |
|
31 | username='u2', password='qweqwe', | |
32 |
email= |
|
32 | email='u2@example.com', firstname='u2', lastname='u2' | |
33 | ) |
|
33 | ) | |
34 | self.u3 = UserModel().create_or_update( |
|
34 | self.u3 = UserModel().create_or_update( | |
35 |
username= |
|
35 | username='u3', password='qweqwe', | |
36 |
email= |
|
36 | email='u3@example.com', firstname='u3', lastname='u3' | |
37 | ) |
|
37 | ) | |
38 | self.anon = User.get_default_user() |
|
38 | self.anon = User.get_default_user() | |
39 | self.a1 = UserModel().create_or_update( |
|
39 | self.a1 = UserModel().create_or_update( | |
40 |
username= |
|
40 | username='a1', password='qweqwe', | |
41 |
email= |
|
41 | email='a1@example.com', firstname='a1', lastname='a1', admin=True | |
42 | ) |
|
42 | ) | |
43 | Session().commit() |
|
43 | Session().commit() | |
44 |
|
44 | |||
@@ -100,11 +100,11 b' class TestPermissions(base.TestControlle' | |||||
100 | assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] |
|
100 | assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] | |
101 |
|
101 | |||
102 | def test_default_group_perms(self): |
|
102 | def test_default_group_perms(self): | |
103 |
self.g1 = fixture.create_repo_group( |
|
103 | self.g1 = fixture.create_repo_group('test1', skip_if_exists=True) | |
104 |
self.g2 = fixture.create_repo_group( |
|
104 | self.g2 = fixture.create_repo_group('test2', skip_if_exists=True) | |
105 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
105 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
106 | perms = { |
|
106 | perms = { | |
107 |
'repositories_groups': { |
|
107 | 'repositories_groups': {'test1': 'group.read', 'test2': 'group.read'}, | |
108 | 'global': set(Permission.DEFAULT_USER_PERMISSIONS), |
|
108 | 'global': set(Permission.DEFAULT_USER_PERMISSIONS), | |
109 | 'repositories': {base.HG_REPO: 'repository.read'} |
|
109 | 'repositories': {base.HG_REPO: 'repository.read'} | |
110 | } |
|
110 | } | |
@@ -113,11 +113,11 b' class TestPermissions(base.TestControlle' | |||||
113 | assert u1_auth.permissions['global'] == perms['global'] |
|
113 | assert u1_auth.permissions['global'] == perms['global'] | |
114 |
|
114 | |||
115 | def test_default_admin_group_perms(self): |
|
115 | def test_default_admin_group_perms(self): | |
116 |
self.g1 = fixture.create_repo_group( |
|
116 | self.g1 = fixture.create_repo_group('test1', skip_if_exists=True) | |
117 |
self.g2 = fixture.create_repo_group( |
|
117 | self.g2 = fixture.create_repo_group('test2', skip_if_exists=True) | |
118 | a1_auth = AuthUser(user_id=self.a1.user_id) |
|
118 | a1_auth = AuthUser(user_id=self.a1.user_id) | |
119 | perms = { |
|
119 | perms = { | |
120 |
'repositories_groups': { |
|
120 | 'repositories_groups': {'test1': 'group.admin', 'test2': 'group.admin'}, | |
121 | 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), |
|
121 | 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), | |
122 | 'repositories': {base.HG_REPO: 'repository.admin'} |
|
122 | 'repositories': {base.HG_REPO: 'repository.admin'} | |
123 | } |
|
123 | } | |
@@ -127,7 +127,7 b' class TestPermissions(base.TestControlle' | |||||
127 |
|
127 | |||
128 | def test_propagated_permission_from_users_group_by_explicit_perms_exist(self): |
|
128 | def test_propagated_permission_from_users_group_by_explicit_perms_exist(self): | |
129 | # make group |
|
129 | # make group | |
130 |
self.ug1 = fixture.create_user_group( |
|
130 | self.ug1 = fixture.create_user_group('G1') | |
131 | UserGroupModel().add_user_to_group(self.ug1, self.u1) |
|
131 | UserGroupModel().add_user_to_group(self.ug1, self.u1) | |
132 |
|
132 | |||
133 | # set user permission none |
|
133 | # set user permission none | |
@@ -147,7 +147,7 b' class TestPermissions(base.TestControlle' | |||||
147 |
|
147 | |||
148 | def test_propagated_permission_from_users_group(self): |
|
148 | def test_propagated_permission_from_users_group(self): | |
149 | # make group |
|
149 | # make group | |
150 |
self.ug1 = fixture.create_user_group( |
|
150 | self.ug1 = fixture.create_user_group('G1') | |
151 | UserGroupModel().add_user_to_group(self.ug1, self.u3) |
|
151 | UserGroupModel().add_user_to_group(self.ug1, self.u3) | |
152 |
|
152 | |||
153 | # grant perm for group this should override default permission from user |
|
153 | # grant perm for group this should override default permission from user | |
@@ -168,7 +168,7 b' class TestPermissions(base.TestControlle' | |||||
168 |
|
168 | |||
169 | def test_propagated_permission_from_users_group_lower_weight(self): |
|
169 | def test_propagated_permission_from_users_group_lower_weight(self): | |
170 | # make group |
|
170 | # make group | |
171 |
self.ug1 = fixture.create_user_group( |
|
171 | self.ug1 = fixture.create_user_group('G1') | |
172 | # add user to group |
|
172 | # add user to group | |
173 | UserGroupModel().add_user_to_group(self.ug1, self.u1) |
|
173 | UserGroupModel().add_user_to_group(self.ug1, self.u1) | |
174 |
|
174 | |||
@@ -198,14 +198,14 b' class TestPermissions(base.TestControlle' | |||||
198 | assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] |
|
198 | assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] | |
199 |
|
199 | |||
200 | def test_repo_in_group_permissions(self): |
|
200 | def test_repo_in_group_permissions(self): | |
201 |
self.g1 = fixture.create_repo_group( |
|
201 | self.g1 = fixture.create_repo_group('group1', skip_if_exists=True) | |
202 |
self.g2 = fixture.create_repo_group( |
|
202 | self.g2 = fixture.create_repo_group('group2', skip_if_exists=True) | |
203 | # both perms should be read ! |
|
203 | # both perms should be read ! | |
204 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
204 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
205 |
assert u1_auth.permissions['repositories_groups'] == { |
|
205 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.read', 'group2': 'group.read'} | |
206 |
|
206 | |||
207 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
207 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
208 |
assert a1_auth.permissions['repositories_groups'] == { |
|
208 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.read', 'group2': 'group.read'} | |
209 |
|
209 | |||
210 | # Change perms to none for both groups |
|
210 | # Change perms to none for both groups | |
211 | RepoGroupModel().grant_user_permission(repo_group=self.g1, |
|
211 | RepoGroupModel().grant_user_permission(repo_group=self.g1, | |
@@ -216,10 +216,10 b' class TestPermissions(base.TestControlle' | |||||
216 | perm='group.none') |
|
216 | perm='group.none') | |
217 |
|
217 | |||
218 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
218 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
219 |
assert u1_auth.permissions['repositories_groups'] == { |
|
219 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'} | |
220 |
|
220 | |||
221 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
221 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
222 |
assert a1_auth.permissions['repositories_groups'] == { |
|
222 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'} | |
223 |
|
223 | |||
224 | # add repo to group |
|
224 | # add repo to group | |
225 | name = RepoGroup.url_sep().join([self.g1.group_name, 'test_perm']) |
|
225 | name = RepoGroup.url_sep().join([self.g1.group_name, 'test_perm']) | |
@@ -229,10 +229,10 b' class TestPermissions(base.TestControlle' | |||||
229 | cur_user=self.u1,) |
|
229 | cur_user=self.u1,) | |
230 |
|
230 | |||
231 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
231 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
232 |
assert u1_auth.permissions['repositories_groups'] == { |
|
232 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'} | |
233 |
|
233 | |||
234 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
234 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
235 |
assert a1_auth.permissions['repositories_groups'] == { |
|
235 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'} | |
236 |
|
236 | |||
237 | # grant permission for u2 ! |
|
237 | # grant permission for u2 ! | |
238 | RepoGroupModel().grant_user_permission(repo_group=self.g1, user=self.u2, |
|
238 | RepoGroupModel().grant_user_permission(repo_group=self.g1, user=self.u2, | |
@@ -243,27 +243,27 b' class TestPermissions(base.TestControlle' | |||||
243 | assert self.u1 != self.u2 |
|
243 | assert self.u1 != self.u2 | |
244 | # u1 and anon should have not change perms while u2 should ! |
|
244 | # u1 and anon should have not change perms while u2 should ! | |
245 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
245 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
246 |
assert u1_auth.permissions['repositories_groups'] == { |
|
246 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'} | |
247 |
|
247 | |||
248 | u2_auth = AuthUser(user_id=self.u2.user_id) |
|
248 | u2_auth = AuthUser(user_id=self.u2.user_id) | |
249 |
assert u2_auth.permissions['repositories_groups'] == { |
|
249 | assert u2_auth.permissions['repositories_groups'] == {'group1': 'group.read', 'group2': 'group.read'} | |
250 |
|
250 | |||
251 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
251 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
252 |
assert a1_auth.permissions['repositories_groups'] == { |
|
252 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'} | |
253 |
|
253 | |||
254 | def test_repo_group_user_as_user_group_member(self): |
|
254 | def test_repo_group_user_as_user_group_member(self): | |
255 | # create Group1 |
|
255 | # create Group1 | |
256 |
self.g1 = fixture.create_repo_group( |
|
256 | self.g1 = fixture.create_repo_group('group1', skip_if_exists=True) | |
257 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
257 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
258 |
|
258 | |||
259 |
assert a1_auth.permissions['repositories_groups'] == { |
|
259 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.read'} | |
260 |
|
260 | |||
261 | # set default permission to none |
|
261 | # set default permission to none | |
262 | RepoGroupModel().grant_user_permission(repo_group=self.g1, |
|
262 | RepoGroupModel().grant_user_permission(repo_group=self.g1, | |
263 | user=self.anon, |
|
263 | user=self.anon, | |
264 | perm='group.none') |
|
264 | perm='group.none') | |
265 | # make group |
|
265 | # make group | |
266 |
self.ug1 = fixture.create_user_group( |
|
266 | self.ug1 = fixture.create_user_group('G1') | |
267 | # add user to group |
|
267 | # add user to group | |
268 | UserGroupModel().add_user_to_group(self.ug1, self.u1) |
|
268 | UserGroupModel().add_user_to_group(self.ug1, self.u1) | |
269 | Session().commit() |
|
269 | Session().commit() | |
@@ -275,10 +275,10 b' class TestPermissions(base.TestControlle' | |||||
275 |
|
275 | |||
276 | # check his permissions |
|
276 | # check his permissions | |
277 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
277 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
278 |
assert a1_auth.permissions['repositories_groups'] == { |
|
278 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none'} | |
279 |
|
279 | |||
280 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
280 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
281 |
assert u1_auth.permissions['repositories_groups'] == { |
|
281 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none'} | |
282 |
|
282 | |||
283 | # grant ug1 read permissions for |
|
283 | # grant ug1 read permissions for | |
284 | RepoGroupModel().grant_user_group_permission(repo_group=self.g1, |
|
284 | RepoGroupModel().grant_user_group_permission(repo_group=self.g1, | |
@@ -294,10 +294,10 b' class TestPermissions(base.TestControlle' | |||||
294 |
|
294 | |||
295 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
295 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
296 |
|
296 | |||
297 |
assert a1_auth.permissions['repositories_groups'] == { |
|
297 | assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none'} | |
298 |
|
298 | |||
299 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
299 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
300 |
assert u1_auth.permissions['repositories_groups'] == { |
|
300 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.read'} | |
301 |
|
301 | |||
302 | def test_inherit_nice_permissions_from_default_user(self): |
|
302 | def test_inherit_nice_permissions_from_default_user(self): | |
303 | user_model = UserModel() |
|
303 | user_model = UserModel() | |
@@ -388,7 +388,7 b' class TestPermissions(base.TestControlle' | |||||
388 | def test_inactive_user_group_does_not_affect_global_permissions(self): |
|
388 | def test_inactive_user_group_does_not_affect_global_permissions(self): | |
389 | # Add user to inactive user group, set specific permissions on user |
|
389 | # Add user to inactive user group, set specific permissions on user | |
390 | # group and and verify it really is inactive. |
|
390 | # group and and verify it really is inactive. | |
391 |
self.ug1 = fixture.create_user_group( |
|
391 | self.ug1 = fixture.create_user_group('G1') | |
392 | user_group_model = UserGroupModel() |
|
392 | user_group_model = UserGroupModel() | |
393 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
393 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
394 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
394 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
@@ -420,7 +420,7 b' class TestPermissions(base.TestControlle' | |||||
420 | def test_inactive_user_group_does_not_affect_global_permissions_inverse(self): |
|
420 | def test_inactive_user_group_does_not_affect_global_permissions_inverse(self): | |
421 | # Add user to inactive user group, set specific permissions on user |
|
421 | # Add user to inactive user group, set specific permissions on user | |
422 | # group and and verify it really is inactive. |
|
422 | # group and and verify it really is inactive. | |
423 |
self.ug1 = fixture.create_user_group( |
|
423 | self.ug1 = fixture.create_user_group('G1') | |
424 | user_group_model = UserGroupModel() |
|
424 | user_group_model = UserGroupModel() | |
425 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
425 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
426 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
426 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
@@ -450,14 +450,14 b' class TestPermissions(base.TestControlle' | |||||
450 | 'hg.create.write_on_repogroup.true']) |
|
450 | 'hg.create.write_on_repogroup.true']) | |
451 |
|
451 | |||
452 | def test_inactive_user_group_does_not_affect_repo_permissions(self): |
|
452 | def test_inactive_user_group_does_not_affect_repo_permissions(self): | |
453 |
self.ug1 = fixture.create_user_group( |
|
453 | self.ug1 = fixture.create_user_group('G1') | |
454 | user_group_model = UserGroupModel() |
|
454 | user_group_model = UserGroupModel() | |
455 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
455 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
456 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
456 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
457 |
|
457 | |||
458 | # note: make u2 repo owner rather than u1, because the owner always has |
|
458 | # note: make u2 repo owner rather than u1, because the owner always has | |
459 | # admin permissions |
|
459 | # admin permissions | |
460 |
self.test_repo = fixture.create_repo(name= |
|
460 | self.test_repo = fixture.create_repo(name='myownrepo', | |
461 | repo_type='hg', |
|
461 | repo_type='hg', | |
462 | cur_user=self.u2) |
|
462 | cur_user=self.u2) | |
463 |
|
463 | |||
@@ -474,14 +474,14 b' class TestPermissions(base.TestControlle' | |||||
474 | assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.write' |
|
474 | assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.write' | |
475 |
|
475 | |||
476 | def test_inactive_user_group_does_not_affect_repo_permissions_inverse(self): |
|
476 | def test_inactive_user_group_does_not_affect_repo_permissions_inverse(self): | |
477 |
self.ug1 = fixture.create_user_group( |
|
477 | self.ug1 = fixture.create_user_group('G1') | |
478 | user_group_model = UserGroupModel() |
|
478 | user_group_model = UserGroupModel() | |
479 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
479 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
480 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
480 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
481 |
|
481 | |||
482 | # note: make u2 repo owner rather than u1, because the owner always has |
|
482 | # note: make u2 repo owner rather than u1, because the owner always has | |
483 | # admin permissions |
|
483 | # admin permissions | |
484 |
self.test_repo = fixture.create_repo(name= |
|
484 | self.test_repo = fixture.create_repo(name='myownrepo', | |
485 | repo_type='hg', |
|
485 | repo_type='hg', | |
486 | cur_user=self.u2) |
|
486 | cur_user=self.u2) | |
487 |
|
487 | |||
@@ -498,12 +498,12 b' class TestPermissions(base.TestControlle' | |||||
498 | assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.admin' |
|
498 | assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.admin' | |
499 |
|
499 | |||
500 | def test_inactive_user_group_does_not_affect_repo_group_permissions(self): |
|
500 | def test_inactive_user_group_does_not_affect_repo_group_permissions(self): | |
501 |
self.ug1 = fixture.create_user_group( |
|
501 | self.ug1 = fixture.create_user_group('G1') | |
502 | user_group_model = UserGroupModel() |
|
502 | user_group_model = UserGroupModel() | |
503 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
503 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
504 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
504 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
505 |
|
505 | |||
506 |
self.g1 = fixture.create_repo_group( |
|
506 | self.g1 = fixture.create_repo_group('group1', skip_if_exists=True) | |
507 |
|
507 | |||
508 | # enable admin access for user group on repo group |
|
508 | # enable admin access for user group on repo group | |
509 | RepoGroupModel().grant_user_group_permission(self.g1, |
|
509 | RepoGroupModel().grant_user_group_permission(self.g1, | |
@@ -515,15 +515,15 b' class TestPermissions(base.TestControlle' | |||||
515 | perm='group.write') |
|
515 | perm='group.write') | |
516 | Session().commit() |
|
516 | Session().commit() | |
517 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
517 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
518 |
assert u1_auth.permissions['repositories_groups'] == { |
|
518 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.write'} | |
519 |
|
519 | |||
520 | def test_inactive_user_group_does_not_affect_repo_group_permissions_inverse(self): |
|
520 | def test_inactive_user_group_does_not_affect_repo_group_permissions_inverse(self): | |
521 |
self.ug1 = fixture.create_user_group( |
|
521 | self.ug1 = fixture.create_user_group('G1') | |
522 | user_group_model = UserGroupModel() |
|
522 | user_group_model = UserGroupModel() | |
523 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
523 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
524 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
524 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
525 |
|
525 | |||
526 |
self.g1 = fixture.create_repo_group( |
|
526 | self.g1 = fixture.create_repo_group('group1', skip_if_exists=True) | |
527 |
|
527 | |||
528 | # enable only write access for user group on repo group |
|
528 | # enable only write access for user group on repo group | |
529 | RepoGroupModel().grant_user_group_permission(self.g1, |
|
529 | RepoGroupModel().grant_user_group_permission(self.g1, | |
@@ -535,15 +535,15 b' class TestPermissions(base.TestControlle' | |||||
535 | perm='group.admin') |
|
535 | perm='group.admin') | |
536 | Session().commit() |
|
536 | Session().commit() | |
537 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
537 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
538 |
assert u1_auth.permissions['repositories_groups'] == { |
|
538 | assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.admin'} | |
539 |
|
539 | |||
540 | def test_inactive_user_group_does_not_affect_user_group_permissions(self): |
|
540 | def test_inactive_user_group_does_not_affect_user_group_permissions(self): | |
541 |
self.ug1 = fixture.create_user_group( |
|
541 | self.ug1 = fixture.create_user_group('G1') | |
542 | user_group_model = UserGroupModel() |
|
542 | user_group_model = UserGroupModel() | |
543 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
543 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
544 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
544 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
545 |
|
545 | |||
546 |
self.ug2 = fixture.create_user_group( |
|
546 | self.ug2 = fixture.create_user_group('G2') | |
547 |
|
547 | |||
548 | # enable admin access for user group on user group |
|
548 | # enable admin access for user group on user group | |
549 | UserGroupModel().grant_user_group_permission(self.ug2, |
|
549 | UserGroupModel().grant_user_group_permission(self.ug2, | |
@@ -555,16 +555,16 b' class TestPermissions(base.TestControlle' | |||||
555 | perm='usergroup.write') |
|
555 | perm='usergroup.write') | |
556 | Session().commit() |
|
556 | Session().commit() | |
557 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
557 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
558 |
assert u1_auth.permissions['user_groups'][ |
|
558 | assert u1_auth.permissions['user_groups']['G1'] == 'usergroup.read' | |
559 |
assert u1_auth.permissions['user_groups'][ |
|
559 | assert u1_auth.permissions['user_groups']['G2'] == 'usergroup.write' | |
560 |
|
560 | |||
561 | def test_inactive_user_group_does_not_affect_user_group_permissions_inverse(self): |
|
561 | def test_inactive_user_group_does_not_affect_user_group_permissions_inverse(self): | |
562 |
self.ug1 = fixture.create_user_group( |
|
562 | self.ug1 = fixture.create_user_group('G1') | |
563 | user_group_model = UserGroupModel() |
|
563 | user_group_model = UserGroupModel() | |
564 | user_group_model.add_user_to_group(self.ug1, self.u1) |
|
564 | user_group_model.add_user_to_group(self.ug1, self.u1) | |
565 | user_group_model.update(self.ug1, {'users_group_active': False}) |
|
565 | user_group_model.update(self.ug1, {'users_group_active': False}) | |
566 |
|
566 | |||
567 |
self.ug2 = fixture.create_user_group( |
|
567 | self.ug2 = fixture.create_user_group('G2') | |
568 |
|
568 | |||
569 | # enable only write access for user group on user group |
|
569 | # enable only write access for user group on user group | |
570 | UserGroupModel().grant_user_group_permission(self.ug2, |
|
570 | UserGroupModel().grant_user_group_permission(self.ug2, | |
@@ -576,12 +576,12 b' class TestPermissions(base.TestControlle' | |||||
576 | perm='usergroup.admin') |
|
576 | perm='usergroup.admin') | |
577 | Session().commit() |
|
577 | Session().commit() | |
578 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
578 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
579 |
assert u1_auth.permissions['user_groups'][ |
|
579 | assert u1_auth.permissions['user_groups']['G1'] == 'usergroup.read' | |
580 |
assert u1_auth.permissions['user_groups'][ |
|
580 | assert u1_auth.permissions['user_groups']['G2'] == 'usergroup.admin' | |
581 |
|
581 | |||
582 | def test_owner_permissions_doesnot_get_overwritten_by_group(self): |
|
582 | def test_owner_permissions_doesnot_get_overwritten_by_group(self): | |
583 | # create repo as USER, |
|
583 | # create repo as USER, | |
584 |
self.test_repo = fixture.create_repo(name= |
|
584 | self.test_repo = fixture.create_repo(name='myownrepo', | |
585 | repo_type='hg', |
|
585 | repo_type='hg', | |
586 | cur_user=self.u1) |
|
586 | cur_user=self.u1) | |
587 |
|
587 | |||
@@ -589,7 +589,7 b' class TestPermissions(base.TestControlle' | |||||
589 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
589 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
590 | assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.admin' |
|
590 | assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.admin' | |
591 | # set his permission as user group, he should still be admin |
|
591 | # set his permission as user group, he should still be admin | |
592 |
self.ug1 = fixture.create_user_group( |
|
592 | self.ug1 = fixture.create_user_group('G1') | |
593 | UserGroupModel().add_user_to_group(self.ug1, self.u1) |
|
593 | UserGroupModel().add_user_to_group(self.ug1, self.u1) | |
594 | RepoModel().grant_user_group_permission(self.test_repo, |
|
594 | RepoModel().grant_user_group_permission(self.test_repo, | |
595 | group_name=self.ug1, |
|
595 | group_name=self.ug1, | |
@@ -601,7 +601,7 b' class TestPermissions(base.TestControlle' | |||||
601 |
|
601 | |||
602 | def test_owner_permissions_doesnot_get_overwritten_by_others(self): |
|
602 | def test_owner_permissions_doesnot_get_overwritten_by_others(self): | |
603 | # create repo as USER, |
|
603 | # create repo as USER, | |
604 |
self.test_repo = fixture.create_repo(name= |
|
604 | self.test_repo = fixture.create_repo(name='myownrepo', | |
605 | repo_type='hg', |
|
605 | repo_type='hg', | |
606 | cur_user=self.u1) |
|
606 | cur_user=self.u1) | |
607 |
|
607 |
@@ -14,7 +14,7 b' from kallithea.tests.fixture import Fixt' | |||||
14 | fixture = Fixture() |
|
14 | fixture = Fixture() | |
15 |
|
15 | |||
16 |
|
16 | |||
17 |
def _update_repo_group(id_, group_name, desc= |
|
17 | def _update_repo_group(id_, group_name, desc='desc', parent_id=None): | |
18 | form_data = dict( |
|
18 | form_data = dict( | |
19 | group_name=group_name, |
|
19 | group_name=group_name, | |
20 | group_description=desc, |
|
20 | group_description=desc, | |
@@ -37,9 +37,9 b' def _update_repo(name, **kwargs):' | |||||
37 | class TestRepoGroups(base.TestController): |
|
37 | class TestRepoGroups(base.TestController): | |
38 |
|
38 | |||
39 | def setup_method(self, method): |
|
39 | def setup_method(self, method): | |
40 |
self.g1 = fixture.create_repo_group( |
|
40 | self.g1 = fixture.create_repo_group('test1', skip_if_exists=True) | |
41 |
self.g2 = fixture.create_repo_group( |
|
41 | self.g2 = fixture.create_repo_group('test2', skip_if_exists=True) | |
42 |
self.g3 = fixture.create_repo_group( |
|
42 | self.g3 = fixture.create_repo_group('test3', skip_if_exists=True) | |
43 |
|
43 | |||
44 | def teardown_method(self, method): |
|
44 | def teardown_method(self, method): | |
45 | Session.remove() |
|
45 | Session.remove() | |
@@ -56,7 +56,7 b' class TestRepoGroups(base.TestController' | |||||
56 | RepoGroupModel().delete(id_) |
|
56 | RepoGroupModel().delete(id_) | |
57 |
|
57 | |||
58 | def test_create_group(self): |
|
58 | def test_create_group(self): | |
59 |
g = fixture.create_repo_group( |
|
59 | g = fixture.create_repo_group('newGroup') | |
60 | Session().commit() |
|
60 | Session().commit() | |
61 | assert g.full_path == 'newGroup' |
|
61 | assert g.full_path == 'newGroup' | |
62 |
|
62 | |||
@@ -64,71 +64,71 b' class TestRepoGroups(base.TestController' | |||||
64 |
|
64 | |||
65 | def test_create_same_name_group(self): |
|
65 | def test_create_same_name_group(self): | |
66 | with pytest.raises(IntegrityError): |
|
66 | with pytest.raises(IntegrityError): | |
67 |
fixture.create_repo_group( |
|
67 | fixture.create_repo_group('newGroup') | |
68 | Session().rollback() |
|
68 | Session().rollback() | |
69 |
|
69 | |||
70 | def test_same_subgroup(self): |
|
70 | def test_same_subgroup(self): | |
71 |
sg1 = fixture.create_repo_group( |
|
71 | sg1 = fixture.create_repo_group('sub1', parent_group_id=self.g1.group_id) | |
72 | assert sg1.parent_group == self.g1 |
|
72 | assert sg1.parent_group == self.g1 | |
73 | assert sg1.full_path == 'test1/sub1' |
|
73 | assert sg1.full_path == 'test1/sub1' | |
74 | assert self.__check_path('test1', 'sub1') |
|
74 | assert self.__check_path('test1', 'sub1') | |
75 |
|
75 | |||
76 |
ssg1 = fixture.create_repo_group( |
|
76 | ssg1 = fixture.create_repo_group('subsub1', parent_group_id=sg1.group_id) | |
77 | assert ssg1.parent_group == sg1 |
|
77 | assert ssg1.parent_group == sg1 | |
78 | assert ssg1.full_path == 'test1/sub1/subsub1' |
|
78 | assert ssg1.full_path == 'test1/sub1/subsub1' | |
79 | assert self.__check_path('test1', 'sub1', 'subsub1') |
|
79 | assert self.__check_path('test1', 'sub1', 'subsub1') | |
80 |
|
80 | |||
81 | def test_remove_group(self): |
|
81 | def test_remove_group(self): | |
82 |
sg1 = fixture.create_repo_group( |
|
82 | sg1 = fixture.create_repo_group('deleteme') | |
83 | self.__delete_group(sg1.group_id) |
|
83 | self.__delete_group(sg1.group_id) | |
84 |
|
84 | |||
85 | assert RepoGroup.get(sg1.group_id) is None |
|
85 | assert RepoGroup.get(sg1.group_id) is None | |
86 | assert not self.__check_path('deteteme') |
|
86 | assert not self.__check_path('deteteme') | |
87 |
|
87 | |||
88 |
sg1 = fixture.create_repo_group( |
|
88 | sg1 = fixture.create_repo_group('deleteme', parent_group_id=self.g1.group_id) | |
89 | self.__delete_group(sg1.group_id) |
|
89 | self.__delete_group(sg1.group_id) | |
90 |
|
90 | |||
91 | assert RepoGroup.get(sg1.group_id) is None |
|
91 | assert RepoGroup.get(sg1.group_id) is None | |
92 | assert not self.__check_path('test1', 'deteteme') |
|
92 | assert not self.__check_path('test1', 'deteteme') | |
93 |
|
93 | |||
94 | def test_rename_single_group(self): |
|
94 | def test_rename_single_group(self): | |
95 |
sg1 = fixture.create_repo_group( |
|
95 | sg1 = fixture.create_repo_group('initial') | |
96 |
|
96 | |||
97 |
new_sg1 = _update_repo_group(sg1.group_id, |
|
97 | new_sg1 = _update_repo_group(sg1.group_id, 'after') | |
98 | assert self.__check_path('after') |
|
98 | assert self.__check_path('after') | |
99 |
assert RepoGroup.get_by_group_name( |
|
99 | assert RepoGroup.get_by_group_name('initial') is None | |
100 |
|
100 | |||
101 | def test_update_group_parent(self): |
|
101 | def test_update_group_parent(self): | |
102 |
|
102 | |||
103 |
sg1 = fixture.create_repo_group( |
|
103 | sg1 = fixture.create_repo_group('initial', parent_group_id=self.g1.group_id) | |
104 |
|
104 | |||
105 |
new_sg1 = _update_repo_group(sg1.group_id, |
|
105 | new_sg1 = _update_repo_group(sg1.group_id, 'after', parent_id=self.g1.group_id) | |
106 | assert self.__check_path('test1', 'after') |
|
106 | assert self.__check_path('test1', 'after') | |
107 |
assert RepoGroup.get_by_group_name( |
|
107 | assert RepoGroup.get_by_group_name('test1/initial') is None | |
108 |
|
108 | |||
109 |
new_sg1 = _update_repo_group(sg1.group_id, |
|
109 | new_sg1 = _update_repo_group(sg1.group_id, 'after', parent_id=self.g3.group_id) | |
110 | assert self.__check_path('test3', 'after') |
|
110 | assert self.__check_path('test3', 'after') | |
111 |
assert RepoGroup.get_by_group_name( |
|
111 | assert RepoGroup.get_by_group_name('test3/initial') == None | |
112 |
|
112 | |||
113 |
new_sg1 = _update_repo_group(sg1.group_id, |
|
113 | new_sg1 = _update_repo_group(sg1.group_id, 'hello') | |
114 | assert self.__check_path('hello') |
|
114 | assert self.__check_path('hello') | |
115 |
|
115 | |||
116 |
assert RepoGroup.get_by_group_name( |
|
116 | assert RepoGroup.get_by_group_name('hello') == new_sg1 | |
117 |
|
117 | |||
118 | def test_subgrouping_with_repo(self): |
|
118 | def test_subgrouping_with_repo(self): | |
119 |
|
119 | |||
120 |
g1 = fixture.create_repo_group( |
|
120 | g1 = fixture.create_repo_group('g1') | |
121 |
g2 = fixture.create_repo_group( |
|
121 | g2 = fixture.create_repo_group('g2') | |
122 | # create new repo |
|
122 | # create new repo | |
123 |
r = fixture.create_repo( |
|
123 | r = fixture.create_repo('john') | |
124 |
|
124 | |||
125 | assert r.repo_name == 'john' |
|
125 | assert r.repo_name == 'john' | |
126 | # put repo into group |
|
126 | # put repo into group | |
127 |
r = _update_repo( |
|
127 | r = _update_repo('john', repo_group=g1.group_id) | |
128 | Session().commit() |
|
128 | Session().commit() | |
129 | assert r.repo_name == 'g1/john' |
|
129 | assert r.repo_name == 'g1/john' | |
130 |
|
130 | |||
131 |
_update_repo_group(g1.group_id, |
|
131 | _update_repo_group(g1.group_id, 'g1', parent_id=g2.group_id) | |
132 | assert self.__check_path('g2', 'g1') |
|
132 | assert self.__check_path('g2', 'g1') | |
133 |
|
133 | |||
134 | # test repo |
|
134 | # test repo | |
@@ -136,13 +136,13 b' class TestRepoGroups(base.TestController' | |||||
136 | r.just_name]) |
|
136 | r.just_name]) | |
137 |
|
137 | |||
138 | def test_move_to_root(self): |
|
138 | def test_move_to_root(self): | |
139 |
g1 = fixture.create_repo_group( |
|
139 | g1 = fixture.create_repo_group('t11') | |
140 |
g2 = fixture.create_repo_group( |
|
140 | g2 = fixture.create_repo_group('t22', parent_group_id=g1.group_id) | |
141 |
|
141 | |||
142 | assert g2.full_path == 't11/t22' |
|
142 | assert g2.full_path == 't11/t22' | |
143 | assert self.__check_path('t11', 't22') |
|
143 | assert self.__check_path('t11', 't22') | |
144 |
|
144 | |||
145 |
g2 = _update_repo_group(g2.group_id, |
|
145 | g2 = _update_repo_group(g2.group_id, 'g22', parent_id=None) | |
146 | Session().commit() |
|
146 | Session().commit() | |
147 |
|
147 | |||
148 | assert g2.group_name == 'g22' |
|
148 | assert g2.group_name == 'g22' | |
@@ -152,14 +152,14 b' class TestRepoGroups(base.TestController' | |||||
152 | assert self.__check_path('g22') |
|
152 | assert self.__check_path('g22') | |
153 |
|
153 | |||
154 | def test_rename_top_level_group_in_nested_setup(self): |
|
154 | def test_rename_top_level_group_in_nested_setup(self): | |
155 |
g1 = fixture.create_repo_group( |
|
155 | g1 = fixture.create_repo_group('L1') | |
156 |
g2 = fixture.create_repo_group( |
|
156 | g2 = fixture.create_repo_group('L2', parent_group_id=g1.group_id) | |
157 |
g3 = fixture.create_repo_group( |
|
157 | g3 = fixture.create_repo_group('L3', parent_group_id=g2.group_id) | |
158 |
|
158 | |||
159 |
r = fixture.create_repo( |
|
159 | r = fixture.create_repo('L1/L2/L3/L3_REPO', repo_group=g3.group_id) | |
160 |
|
160 | |||
161 | ## rename L1 all groups should be now changed |
|
161 | ## rename L1 all groups should be now changed | |
162 |
_update_repo_group(g1.group_id, |
|
162 | _update_repo_group(g1.group_id, 'L1_NEW') | |
163 | Session().commit() |
|
163 | Session().commit() | |
164 | assert g1.full_path == 'L1_NEW' |
|
164 | assert g1.full_path == 'L1_NEW' | |
165 | assert g2.full_path == 'L1_NEW/L2' |
|
165 | assert g2.full_path == 'L1_NEW/L2' | |
@@ -167,14 +167,14 b' class TestRepoGroups(base.TestController' | |||||
167 | assert r.repo_name == 'L1_NEW/L2/L3/L3_REPO' |
|
167 | assert r.repo_name == 'L1_NEW/L2/L3/L3_REPO' | |
168 |
|
168 | |||
169 | def test_change_parent_of_top_level_group_in_nested_setup(self): |
|
169 | def test_change_parent_of_top_level_group_in_nested_setup(self): | |
170 |
g1 = fixture.create_repo_group( |
|
170 | g1 = fixture.create_repo_group('R1') | |
171 |
g2 = fixture.create_repo_group( |
|
171 | g2 = fixture.create_repo_group('R2', parent_group_id=g1.group_id) | |
172 |
g3 = fixture.create_repo_group( |
|
172 | g3 = fixture.create_repo_group('R3', parent_group_id=g2.group_id) | |
173 |
g4 = fixture.create_repo_group( |
|
173 | g4 = fixture.create_repo_group('R1_NEW') | |
174 |
|
174 | |||
175 |
r = fixture.create_repo( |
|
175 | r = fixture.create_repo('R1/R2/R3/R3_REPO', repo_group=g3.group_id) | |
176 | ## rename L1 all groups should be now changed |
|
176 | ## rename L1 all groups should be now changed | |
177 |
_update_repo_group(g1.group_id, |
|
177 | _update_repo_group(g1.group_id, 'R1', parent_id=g4.group_id) | |
178 | Session().commit() |
|
178 | Session().commit() | |
179 | assert g1.full_path == 'R1_NEW/R1' |
|
179 | assert g1.full_path == 'R1_NEW/R1' | |
180 | assert g2.full_path == 'R1_NEW/R1/R2' |
|
180 | assert g2.full_path == 'R1_NEW/R1/R2' | |
@@ -182,15 +182,15 b' class TestRepoGroups(base.TestController' | |||||
182 | assert r.repo_name == 'R1_NEW/R1/R2/R3/R3_REPO' |
|
182 | assert r.repo_name == 'R1_NEW/R1/R2/R3/R3_REPO' | |
183 |
|
183 | |||
184 | def test_change_parent_of_top_level_group_in_nested_setup_with_rename(self): |
|
184 | def test_change_parent_of_top_level_group_in_nested_setup_with_rename(self): | |
185 |
g1 = fixture.create_repo_group( |
|
185 | g1 = fixture.create_repo_group('X1') | |
186 |
g2 = fixture.create_repo_group( |
|
186 | g2 = fixture.create_repo_group('X2', parent_group_id=g1.group_id) | |
187 |
g3 = fixture.create_repo_group( |
|
187 | g3 = fixture.create_repo_group('X3', parent_group_id=g2.group_id) | |
188 |
g4 = fixture.create_repo_group( |
|
188 | g4 = fixture.create_repo_group('X1_NEW') | |
189 |
|
189 | |||
190 |
r = fixture.create_repo( |
|
190 | r = fixture.create_repo('X1/X2/X3/X3_REPO', repo_group=g3.group_id) | |
191 |
|
191 | |||
192 | ## rename L1 all groups should be now changed |
|
192 | ## rename L1 all groups should be now changed | |
193 |
_update_repo_group(g1.group_id, |
|
193 | _update_repo_group(g1.group_id, 'X1_PRIM', parent_id=g4.group_id) | |
194 | Session().commit() |
|
194 | Session().commit() | |
195 | assert g1.full_path == 'X1_NEW/X1_PRIM' |
|
195 | assert g1.full_path == 'X1_NEW/X1_PRIM' | |
196 | assert g2.full_path == 'X1_NEW/X1_PRIM/X2' |
|
196 | assert g2.full_path == 'X1_NEW/X1_PRIM/X2' |
@@ -17,65 +17,65 b' class TestRepos(base.TestController):' | |||||
17 | Session.remove() |
|
17 | Session.remove() | |
18 |
|
18 | |||
19 | def test_remove_repo(self): |
|
19 | def test_remove_repo(self): | |
20 |
repo = fixture.create_repo(name= |
|
20 | repo = fixture.create_repo(name='test-repo-1') | |
21 | Session().commit() |
|
21 | Session().commit() | |
22 |
|
22 | |||
23 | RepoModel().delete(repo=repo) |
|
23 | RepoModel().delete(repo=repo) | |
24 | Session().commit() |
|
24 | Session().commit() | |
25 |
|
25 | |||
26 |
assert Repository.get_by_repo_name(repo_name= |
|
26 | assert Repository.get_by_repo_name(repo_name='test-repo-1') is None | |
27 |
|
27 | |||
28 | def test_remove_repo_repo_raises_exc_when_attached_forks(self): |
|
28 | def test_remove_repo_repo_raises_exc_when_attached_forks(self): | |
29 |
repo = fixture.create_repo(name= |
|
29 | repo = fixture.create_repo(name='test-repo-1') | |
30 | Session().commit() |
|
30 | Session().commit() | |
31 |
|
31 | |||
32 |
fixture.create_fork(repo.repo_name, |
|
32 | fixture.create_fork(repo.repo_name, 'test-repo-fork-1') | |
33 | Session().commit() |
|
33 | Session().commit() | |
34 |
|
34 | |||
35 | with pytest.raises(AttachedForksError): |
|
35 | with pytest.raises(AttachedForksError): | |
36 | RepoModel().delete(repo=repo) |
|
36 | RepoModel().delete(repo=repo) | |
37 | # cleanup |
|
37 | # cleanup | |
38 |
RepoModel().delete(repo= |
|
38 | RepoModel().delete(repo='test-repo-fork-1') | |
39 |
RepoModel().delete(repo= |
|
39 | RepoModel().delete(repo='test-repo-1') | |
40 | Session().commit() |
|
40 | Session().commit() | |
41 |
|
41 | |||
42 | def test_remove_repo_delete_forks(self): |
|
42 | def test_remove_repo_delete_forks(self): | |
43 |
repo = fixture.create_repo(name= |
|
43 | repo = fixture.create_repo(name='test-repo-1') | |
44 | Session().commit() |
|
44 | Session().commit() | |
45 |
|
45 | |||
46 |
fork = fixture.create_fork(repo.repo_name, |
|
46 | fork = fixture.create_fork(repo.repo_name, 'test-repo-fork-1') | |
47 | Session().commit() |
|
47 | Session().commit() | |
48 |
|
48 | |||
49 | # fork of fork |
|
49 | # fork of fork | |
50 |
fixture.create_fork(fork.repo_name, |
|
50 | fixture.create_fork(fork.repo_name, 'test-repo-fork-fork-1') | |
51 | Session().commit() |
|
51 | Session().commit() | |
52 |
|
52 | |||
53 | RepoModel().delete(repo=repo, forks='delete') |
|
53 | RepoModel().delete(repo=repo, forks='delete') | |
54 | Session().commit() |
|
54 | Session().commit() | |
55 |
|
55 | |||
56 |
assert Repository.get_by_repo_name(repo_name= |
|
56 | assert Repository.get_by_repo_name(repo_name='test-repo-1') is None | |
57 |
assert Repository.get_by_repo_name(repo_name= |
|
57 | assert Repository.get_by_repo_name(repo_name='test-repo-fork-1') is None | |
58 |
assert Repository.get_by_repo_name(repo_name= |
|
58 | assert Repository.get_by_repo_name(repo_name='test-repo-fork-fork-1') is None | |
59 |
|
59 | |||
60 | def test_remove_repo_detach_forks(self): |
|
60 | def test_remove_repo_detach_forks(self): | |
61 |
repo = fixture.create_repo(name= |
|
61 | repo = fixture.create_repo(name='test-repo-1') | |
62 | Session().commit() |
|
62 | Session().commit() | |
63 |
|
63 | |||
64 |
fork = fixture.create_fork(repo.repo_name, |
|
64 | fork = fixture.create_fork(repo.repo_name, 'test-repo-fork-1') | |
65 | Session().commit() |
|
65 | Session().commit() | |
66 |
|
66 | |||
67 | # fork of fork |
|
67 | # fork of fork | |
68 |
fixture.create_fork(fork.repo_name, |
|
68 | fixture.create_fork(fork.repo_name, 'test-repo-fork-fork-1') | |
69 | Session().commit() |
|
69 | Session().commit() | |
70 |
|
70 | |||
71 | RepoModel().delete(repo=repo, forks='detach') |
|
71 | RepoModel().delete(repo=repo, forks='detach') | |
72 | Session().commit() |
|
72 | Session().commit() | |
73 |
|
73 | |||
74 | try: |
|
74 | try: | |
75 |
assert Repository.get_by_repo_name(repo_name= |
|
75 | assert Repository.get_by_repo_name(repo_name='test-repo-1') is None | |
76 |
assert Repository.get_by_repo_name(repo_name= |
|
76 | assert Repository.get_by_repo_name(repo_name='test-repo-fork-1') is not None | |
77 |
assert Repository.get_by_repo_name(repo_name= |
|
77 | assert Repository.get_by_repo_name(repo_name='test-repo-fork-fork-1') is not None | |
78 | finally: |
|
78 | finally: | |
79 |
RepoModel().delete(repo= |
|
79 | RepoModel().delete(repo='test-repo-fork-fork-1') | |
80 |
RepoModel().delete(repo= |
|
80 | RepoModel().delete(repo='test-repo-fork-1') | |
81 | Session().commit() |
|
81 | Session().commit() |
@@ -35,7 +35,7 b' def test_list_valued_setting_update():' | |||||
35 | setting = Setting.create_or_update(name, 'spam', type='list') |
|
35 | setting = Setting.create_or_update(name, 'spam', type='list') | |
36 | Session().flush() # must flush so we can delete it below |
|
36 | Session().flush() # must flush so we can delete it below | |
37 | try: |
|
37 | try: | |
38 |
assert setting.app_settings_value == [ |
|
38 | assert setting.app_settings_value == ['spam'] | |
39 | # Assign back setting value. |
|
39 | # Assign back setting value. | |
40 | setting.app_settings_value = setting.app_settings_value |
|
40 | setting.app_settings_value = setting.app_settings_value | |
41 | # Quirk: value is stringified on write and listified on read. |
|
41 | # Quirk: value is stringified on write and listified on read. |
@@ -16,7 +16,7 b' test_u2_gr_id = None' | |||||
16 | _get_group_perms = None |
|
16 | _get_group_perms = None | |
17 |
|
17 | |||
18 |
|
18 | |||
19 |
def permissions_setup_func(group_name= |
|
19 | def permissions_setup_func(group_name='g0', perm='group.read', recursive='all'): | |
20 | """ |
|
20 | """ | |
21 | Resets all permissions to perm attribute |
|
21 | Resets all permissions to perm attribute | |
22 | """ |
|
22 | """ | |
@@ -43,7 +43,7 b' def setup_module():' | |||||
43 | Session().commit() |
|
43 | Session().commit() | |
44 | test_u2_id = test_u2.user_id |
|
44 | test_u2_id = test_u2.user_id | |
45 |
|
45 | |||
46 |
gr1 = fixture.create_user_group( |
|
46 | gr1 = fixture.create_user_group('perms_group_1') | |
47 | Session().commit() |
|
47 | Session().commit() | |
48 | test_u2_gr_id = gr1.users_group_id |
|
48 | test_u2_gr_id = gr1.users_group_id | |
49 | UserGroupModel().add_user_to_group(gr1, user=test_u2_id) |
|
49 | UserGroupModel().add_user_to_group(gr1, user=test_u2_id) | |
@@ -57,13 +57,13 b' def setup_module():' | |||||
57 |
|
57 | |||
58 | def teardown_module(): |
|
58 | def teardown_module(): | |
59 | _destroy_project_tree(test_u2_id) |
|
59 | _destroy_project_tree(test_u2_id) | |
60 |
fixture.destroy_user_group( |
|
60 | fixture.destroy_user_group('perms_group_1') | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | def test_user_permissions_on_group_without_recursive_mode(): |
|
63 | def test_user_permissions_on_group_without_recursive_mode(): | |
64 | # set permission to g0 non-recursive mode |
|
64 | # set permission to g0 non-recursive mode | |
65 | recursive = 'none' |
|
65 | recursive = 'none' | |
66 |
group = |
|
66 | group = 'g0' | |
67 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
67 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
68 |
|
68 | |||
69 | items = [x for x in _get_repo_perms(group, recursive)] |
|
69 | items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -82,7 +82,7 b' def test_user_permissions_on_group_witho' | |||||
82 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): |
|
82 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): | |
83 | # set permission to g0 non-recursive mode |
|
83 | # set permission to g0 non-recursive mode | |
84 | recursive = 'none' |
|
84 | recursive = 'none' | |
85 |
group = |
|
85 | group = 'g0/g0_1' | |
86 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
86 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
87 |
|
87 | |||
88 | items = [x for x in _get_repo_perms(group, recursive)] |
|
88 | items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -103,7 +103,7 b' def test_user_permissions_on_group_with_' | |||||
103 | # set permission to g0 recursive mode, all children including |
|
103 | # set permission to g0 recursive mode, all children including | |
104 | # other repos and groups should have this permission now set ! |
|
104 | # other repos and groups should have this permission now set ! | |
105 | recursive = 'all' |
|
105 | recursive = 'all' | |
106 |
group = |
|
106 | group = 'g0' | |
107 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
107 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
108 |
|
108 | |||
109 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
109 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -120,7 +120,7 b' def test_user_permissions_on_group_with_' | |||||
120 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): |
|
120 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): | |
121 | ## set permission to g0_3 group to none |
|
121 | ## set permission to g0_3 group to none | |
122 | recursive = 'all' |
|
122 | recursive = 'all' | |
123 |
group = |
|
123 | group = 'g0/g0_3' | |
124 | permissions_setup_func(group, 'group.none', recursive=recursive) |
|
124 | permissions_setup_func(group, 'group.none', recursive=recursive) | |
125 |
|
125 | |||
126 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
126 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -137,7 +137,7 b' def test_user_permissions_on_group_with_' | |||||
137 | def test_user_permissions_on_group_with_recursive_mode_deepest(): |
|
137 | def test_user_permissions_on_group_with_recursive_mode_deepest(): | |
138 | ## set permission to g0/g0_1/g0_1_1 group to write |
|
138 | ## set permission to g0/g0_1/g0_1_1 group to write | |
139 | recursive = 'all' |
|
139 | recursive = 'all' | |
140 |
group = |
|
140 | group = 'g0/g0_1/g0_1_1' | |
141 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
141 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
142 |
|
142 | |||
143 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
143 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -154,7 +154,7 b' def test_user_permissions_on_group_with_' | |||||
154 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): |
|
154 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): | |
155 | ## set permission to g0/g0_2 group to admin |
|
155 | ## set permission to g0/g0_2 group to admin | |
156 | recursive = 'all' |
|
156 | recursive = 'all' | |
157 |
group = |
|
157 | group = 'g0/g0_2' | |
158 | permissions_setup_func(group, 'group.admin', recursive=recursive) |
|
158 | permissions_setup_func(group, 'group.admin', recursive=recursive) | |
159 |
|
159 | |||
160 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
160 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -171,7 +171,7 b' def test_user_permissions_on_group_with_' | |||||
171 | def test_user_permissions_on_group_with_recursive_mode_on_repos(): |
|
171 | def test_user_permissions_on_group_with_recursive_mode_on_repos(): | |
172 | # set permission to g0/g0_1 with recursive mode on just repositories |
|
172 | # set permission to g0/g0_1 with recursive mode on just repositories | |
173 | recursive = 'repos' |
|
173 | recursive = 'repos' | |
174 |
group = |
|
174 | group = 'g0/g0_1' | |
175 | perm = 'group.write' |
|
175 | perm = 'group.write' | |
176 | permissions_setup_func(group, perm, recursive=recursive) |
|
176 | permissions_setup_func(group, perm, recursive=recursive) | |
177 |
|
177 | |||
@@ -195,7 +195,7 b' def test_user_permissions_on_group_with_' | |||||
195 | def test_user_permissions_on_group_with_recursive_mode_on_repo_groups(): |
|
195 | def test_user_permissions_on_group_with_recursive_mode_on_repo_groups(): | |
196 | # set permission to g0/g0_1 with recursive mode on just repository groups |
|
196 | # set permission to g0/g0_1 with recursive mode on just repository groups | |
197 | recursive = 'groups' |
|
197 | recursive = 'groups' | |
198 |
group = |
|
198 | group = 'g0/g0_1' | |
199 | perm = 'group.none' |
|
199 | perm = 'group.none' | |
200 | permissions_setup_func(group, perm, recursive=recursive) |
|
200 | permissions_setup_func(group, perm, recursive=recursive) | |
201 |
|
201 |
@@ -18,12 +18,12 b' class TestUserGroups(base.TestController' | |||||
18 |
|
18 | |||
19 | @base.parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [ |
|
19 | @base.parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [ | |
20 | ([], [], [], [], []), |
|
20 | ([], [], [], [], []), | |
21 |
([], [ |
|
21 | ([], ['regular'], [], [], ['regular']), # no changes of regular | |
22 |
([ |
|
22 | (['some_other'], [], [], ['some_other'], []), # not added to regular group | |
23 |
([], [ |
|
23 | ([], ['regular'], ['container'], ['container'], ['regular', 'container']), | |
24 |
([], [ |
|
24 | ([], ['regular'], [], ['container', 'container2'], ['regular', 'container', 'container2']), | |
25 |
([], [ |
|
25 | ([], ['regular'], ['other'], [], ['regular']), # remove not used | |
26 |
([ |
|
26 | (['some_other'], ['regular'], ['other', 'container'], ['container', 'container2'], ['regular', 'container', 'container2']), | |
27 | ]) |
|
27 | ]) | |
28 | def test_enforce_groups(self, pre_existing, regular_should_be, |
|
28 | def test_enforce_groups(self, pre_existing, regular_should_be, | |
29 | external_should_be, groups, expected): |
|
29 | external_should_be, groups, expected): |
@@ -11,7 +11,7 b' test_u1_id = None' | |||||
11 | _get_group_perms = None |
|
11 | _get_group_perms = None | |
12 |
|
12 | |||
13 |
|
13 | |||
14 |
def permissions_setup_func(group_name= |
|
14 | def permissions_setup_func(group_name='g0', perm='group.read', recursive='all', | |
15 | user_id=None): |
|
15 | user_id=None): | |
16 | """ |
|
16 | """ | |
17 | Resets all permissions to perm attribute |
|
17 | Resets all permissions to perm attribute | |
@@ -56,7 +56,7 b' def teardown_module():' | |||||
56 | def test_user_permissions_on_group_without_recursive_mode(): |
|
56 | def test_user_permissions_on_group_without_recursive_mode(): | |
57 | # set permission to g0 non-recursive mode |
|
57 | # set permission to g0 non-recursive mode | |
58 | recursive = 'none' |
|
58 | recursive = 'none' | |
59 |
group = |
|
59 | group = 'g0' | |
60 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
60 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
61 |
|
61 | |||
62 | items = [x for x in _get_repo_perms(group, recursive)] |
|
62 | items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -75,7 +75,7 b' def test_user_permissions_on_group_witho' | |||||
75 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): |
|
75 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): | |
76 | # set permission to g0 non-recursive mode |
|
76 | # set permission to g0 non-recursive mode | |
77 | recursive = 'none' |
|
77 | recursive = 'none' | |
78 |
group = |
|
78 | group = 'g0/g0_1' | |
79 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
79 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
80 |
|
80 | |||
81 | items = [x for x in _get_repo_perms(group, recursive)] |
|
81 | items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -96,7 +96,7 b' def test_user_permissions_on_group_with_' | |||||
96 | # set permission to g0 recursive mode, all children including |
|
96 | # set permission to g0 recursive mode, all children including | |
97 | # other repos and groups should have this permission now set ! |
|
97 | # other repos and groups should have this permission now set ! | |
98 | recursive = 'all' |
|
98 | recursive = 'all' | |
99 |
group = |
|
99 | group = 'g0' | |
100 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
100 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
101 |
|
101 | |||
102 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
102 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -115,7 +115,7 b' def test_user_permissions_on_group_with_' | |||||
115 | # set permission to g0 recursive mode, all children including |
|
115 | # set permission to g0 recursive mode, all children including | |
116 | # other repos and groups should have this permission now set ! |
|
116 | # other repos and groups should have this permission now set ! | |
117 | recursive = 'all' |
|
117 | recursive = 'all' | |
118 |
group = |
|
118 | group = 'g0' | |
119 | default_user_id = User.get_default_user().user_id |
|
119 | default_user_id = User.get_default_user().user_id | |
120 | permissions_setup_func(group, 'group.write', recursive=recursive, |
|
120 | permissions_setup_func(group, 'group.write', recursive=recursive, | |
121 | user_id=default_user_id) |
|
121 | user_id=default_user_id) | |
@@ -142,7 +142,7 b' def test_user_permissions_on_group_with_' | |||||
142 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): |
|
142 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): | |
143 | ## set permission to g0_3 group to none |
|
143 | ## set permission to g0_3 group to none | |
144 | recursive = 'all' |
|
144 | recursive = 'all' | |
145 |
group = |
|
145 | group = 'g0/g0_3' | |
146 | permissions_setup_func(group, 'group.none', recursive=recursive) |
|
146 | permissions_setup_func(group, 'group.none', recursive=recursive) | |
147 |
|
147 | |||
148 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
148 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -159,7 +159,7 b' def test_user_permissions_on_group_with_' | |||||
159 | def test_user_permissions_on_group_with_recursive_mode_deepest(): |
|
159 | def test_user_permissions_on_group_with_recursive_mode_deepest(): | |
160 | ## set permission to g0_3 group to none |
|
160 | ## set permission to g0_3 group to none | |
161 | recursive = 'all' |
|
161 | recursive = 'all' | |
162 |
group = |
|
162 | group = 'g0/g0_1/g0_1_1' | |
163 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
163 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
164 |
|
164 | |||
165 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
165 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -176,7 +176,7 b' def test_user_permissions_on_group_with_' | |||||
176 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): |
|
176 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): | |
177 | ## set permission to g0_3 group to none |
|
177 | ## set permission to g0_3 group to none | |
178 | recursive = 'all' |
|
178 | recursive = 'all' | |
179 |
group = |
|
179 | group = 'g0/g0_2' | |
180 | permissions_setup_func(group, 'group.admin', recursive=recursive) |
|
180 | permissions_setup_func(group, 'group.admin', recursive=recursive) | |
181 |
|
181 | |||
182 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
182 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
@@ -194,7 +194,7 b' def test_user_permissions_on_group_with_' | |||||
194 | # set permission to g0/g0_1 recursive repos only mode, all children including |
|
194 | # set permission to g0/g0_1 recursive repos only mode, all children including | |
195 | # other repos should have this permission now set, inner groups are excluded! |
|
195 | # other repos should have this permission now set, inner groups are excluded! | |
196 | recursive = 'repos' |
|
196 | recursive = 'repos' | |
197 |
group = |
|
197 | group = 'g0/g0_1' | |
198 | perm = 'group.none' |
|
198 | perm = 'group.none' | |
199 | default_user_id = User.get_default_user().user_id |
|
199 | default_user_id = User.get_default_user().user_id | |
200 |
|
200 | |||
@@ -227,7 +227,7 b' def test_user_permissions_on_group_with_' | |||||
227 | def test_user_permissions_on_group_with_recursive_repo_mode_inner_group(): |
|
227 | def test_user_permissions_on_group_with_recursive_repo_mode_inner_group(): | |
228 | ## set permission to g0_3 group to none, with recursive repos only |
|
228 | ## set permission to g0_3 group to none, with recursive repos only | |
229 | recursive = 'repos' |
|
229 | recursive = 'repos' | |
230 |
group = |
|
230 | group = 'g0/g0_3' | |
231 | perm = 'group.none' |
|
231 | perm = 'group.none' | |
232 | permissions_setup_func(group, perm, recursive=recursive) |
|
232 | permissions_setup_func(group, perm, recursive=recursive) | |
233 |
|
233 | |||
@@ -253,7 +253,7 b' def test_user_permissions_on_group_with_' | |||||
253 | # other groups should have this permission now set. repositories should |
|
253 | # other groups should have this permission now set. repositories should | |
254 | # remain intact as we use groups only mode ! |
|
254 | # remain intact as we use groups only mode ! | |
255 | recursive = 'groups' |
|
255 | recursive = 'groups' | |
256 |
group = |
|
256 | group = 'g0/g0_1' | |
257 | default_user_id = User.get_default_user().user_id |
|
257 | default_user_id = User.get_default_user().user_id | |
258 | permissions_setup_func(group, 'group.write', recursive=recursive, |
|
258 | permissions_setup_func(group, 'group.write', recursive=recursive, | |
259 | user_id=default_user_id) |
|
259 | user_id=default_user_id) | |
@@ -278,7 +278,7 b' def test_user_permissions_on_group_with_' | |||||
278 | def test_user_permissions_on_group_with_recursive_group_mode_inner_group(): |
|
278 | def test_user_permissions_on_group_with_recursive_group_mode_inner_group(): | |
279 | ## set permission to g0_3 group to none, with recursive mode for groups only |
|
279 | ## set permission to g0_3 group to none, with recursive mode for groups only | |
280 | recursive = 'groups' |
|
280 | recursive = 'groups' | |
281 |
group = |
|
281 | group = 'g0/g0_3' | |
282 | permissions_setup_func(group, 'group.none', recursive=recursive) |
|
282 | permissions_setup_func(group, 'group.none', recursive=recursive) | |
283 |
|
283 | |||
284 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
284 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
@@ -21,21 +21,21 b' class TestUser(base.TestController):' | |||||
21 | Session.remove() |
|
21 | Session.remove() | |
22 |
|
22 | |||
23 | def test_create_and_remove(self): |
|
23 | def test_create_and_remove(self): | |
24 |
usr = UserModel().create_or_update(username= |
|
24 | usr = UserModel().create_or_update(username='test_user', | |
25 |
password= |
|
25 | password='qweqwe', | |
26 |
email= |
|
26 | email='u232@example.com', | |
27 |
firstname= |
|
27 | firstname='u1', lastname='u1') | |
28 | Session().commit() |
|
28 | Session().commit() | |
29 |
assert User.get_by_username( |
|
29 | assert User.get_by_username('test_user') == usr | |
30 |
assert User.get_by_username( |
|
30 | assert User.get_by_username('test_USER', case_insensitive=True) == usr | |
31 | # User.get_by_username without explicit request for case insensitivty |
|
31 | # User.get_by_username without explicit request for case insensitivty | |
32 | # will use database case sensitivity. The following will thus return |
|
32 | # will use database case sensitivity. The following will thus return | |
33 | # None on for example PostgreSQL but find test_user on MySQL - we are |
|
33 | # None on for example PostgreSQL but find test_user on MySQL - we are | |
34 | # fine with leaving that as undefined as long as it doesn't crash. |
|
34 | # fine with leaving that as undefined as long as it doesn't crash. | |
35 |
User.get_by_username( |
|
35 | User.get_by_username('test_USER', case_insensitive=False) | |
36 |
|
36 | |||
37 | # make user group |
|
37 | # make user group | |
38 |
user_group = fixture.create_user_group( |
|
38 | user_group = fixture.create_user_group('some_example_group') | |
39 | Session().commit() |
|
39 | Session().commit() | |
40 |
|
40 | |||
41 | UserGroupModel().add_user_to_group(user_group, usr) |
|
41 | UserGroupModel().add_user_to_group(user_group, usr) | |
@@ -49,15 +49,15 b' class TestUser(base.TestController):' | |||||
49 | assert UserGroupMember.query().all() == [] |
|
49 | assert UserGroupMember.query().all() == [] | |
50 |
|
50 | |||
51 | def test_additional_email_as_main(self): |
|
51 | def test_additional_email_as_main(self): | |
52 |
usr = UserModel().create_or_update(username= |
|
52 | usr = UserModel().create_or_update(username='test_user', | |
53 |
password= |
|
53 | password='qweqwe', | |
54 |
email= |
|
54 | email='main_email@example.com', | |
55 |
firstname= |
|
55 | firstname='u1', lastname='u1') | |
56 | Session().commit() |
|
56 | Session().commit() | |
57 |
|
57 | |||
58 | with pytest.raises(AttributeError): |
|
58 | with pytest.raises(AttributeError): | |
59 | m = UserEmailMap() |
|
59 | m = UserEmailMap() | |
60 |
m.email = |
|
60 | m.email = 'main_email@example.com' | |
61 | m.user = usr |
|
61 | m.user = usr | |
62 | Session().add(m) |
|
62 | Session().add(m) | |
63 | Session().commit() |
|
63 | Session().commit() | |
@@ -66,14 +66,14 b' class TestUser(base.TestController):' | |||||
66 | Session().commit() |
|
66 | Session().commit() | |
67 |
|
67 | |||
68 | def test_extra_email_map(self): |
|
68 | def test_extra_email_map(self): | |
69 |
usr = UserModel().create_or_update(username= |
|
69 | usr = UserModel().create_or_update(username='test_user', | |
70 |
password= |
|
70 | password='qweqwe', | |
71 |
email= |
|
71 | email='main_email@example.com', | |
72 |
firstname= |
|
72 | firstname='u1', lastname='u1') | |
73 | Session().commit() |
|
73 | Session().commit() | |
74 |
|
74 | |||
75 | m = UserEmailMap() |
|
75 | m = UserEmailMap() | |
76 |
m.email = |
|
76 | m.email = 'main_email2@example.com' | |
77 | m.user = usr |
|
77 | m.user = usr | |
78 | Session().add(m) |
|
78 | Session().add(m) | |
79 | Session().commit() |
|
79 | Session().commit() | |
@@ -104,10 +104,10 b' class TestUser(base.TestController):' | |||||
104 | class TestUsers(base.TestController): |
|
104 | class TestUsers(base.TestController): | |
105 |
|
105 | |||
106 | def setup_method(self, method): |
|
106 | def setup_method(self, method): | |
107 |
self.u1 = UserModel().create_or_update(username= |
|
107 | self.u1 = UserModel().create_or_update(username='u1', | |
108 |
password= |
|
108 | password='qweqwe', | |
109 |
email= |
|
109 | email='u1@example.com', | |
110 |
firstname= |
|
110 | firstname='u1', lastname='u1') | |
111 |
|
111 | |||
112 | def teardown_method(self, method): |
|
112 | def teardown_method(self, method): | |
113 | perm = Permission.query().all() |
|
113 | perm = Permission.query().all() |
@@ -22,8 +22,8 b' class _AuthLdapMock():' | |||||
22 | pass |
|
22 | pass | |
23 |
|
23 | |||
24 | def authenticate_ldap(self, username, password): |
|
24 | def authenticate_ldap(self, username, password): | |
25 |
return 'spam dn', dict(test_ldap_firstname=[ |
|
25 | return 'spam dn', dict(test_ldap_firstname=['spam ldap first name'], | |
26 |
test_ldap_lastname=[ |
|
26 | test_ldap_lastname=['spam ldap last name'], | |
27 | test_ldap_email=['spam ldap email']) |
|
27 | test_ldap_email=['spam ldap email']) | |
28 |
|
28 | |||
29 |
|
29 | |||
@@ -39,8 +39,8 b' def test_update_user_attributes_from_lda' | |||||
39 | user_input = dict(username='test-user-{0}'.format(uniqifier), |
|
39 | user_input = dict(username='test-user-{0}'.format(uniqifier), | |
40 | password='spam password', |
|
40 | password='spam password', | |
41 | email='spam-email-{0}'.format(uniqifier), |
|
41 | email='spam-email-{0}'.format(uniqifier), | |
42 |
firstname= |
|
42 | firstname='spam first name', | |
43 |
lastname= |
|
43 | lastname='spam last name', | |
44 | active=True, |
|
44 | active=True, | |
45 | admin=False) |
|
45 | admin=False) | |
46 | user = create_test_user(user_input) |
|
46 | user = create_test_user(user_input) | |
@@ -54,14 +54,14 b' def test_update_user_attributes_from_lda' | |||||
54 | # Verify that authenication succeeded and retrieved correct attributes |
|
54 | # Verify that authenication succeeded and retrieved correct attributes | |
55 | # from LDAP. |
|
55 | # from LDAP. | |
56 | assert user_data is not None |
|
56 | assert user_data is not None | |
57 |
assert user_data.get('firstname') == |
|
57 | assert user_data.get('firstname') == 'spam ldap first name' | |
58 |
assert user_data.get('lastname') == |
|
58 | assert user_data.get('lastname') == 'spam ldap last name' | |
59 | assert user_data.get('email') == 'spam ldap email' |
|
59 | assert user_data.get('email') == 'spam ldap email' | |
60 |
|
60 | |||
61 | # Verify that authentication overwrote user attributes with the ones |
|
61 | # Verify that authentication overwrote user attributes with the ones | |
62 | # retrieved from LDAP. |
|
62 | # retrieved from LDAP. | |
63 |
assert user.firstname == |
|
63 | assert user.firstname == 'spam ldap first name' | |
64 |
assert user.lastname == |
|
64 | assert user.lastname == 'spam ldap last name' | |
65 | assert user.email == 'spam ldap email' |
|
65 | assert user.email == 'spam ldap email' | |
66 |
|
66 | |||
67 |
|
67 | |||
@@ -83,16 +83,16 b' def test_init_user_attributes_from_ldap(' | |||||
83 | # Verify that authenication succeeded and retrieved correct attributes |
|
83 | # Verify that authenication succeeded and retrieved correct attributes | |
84 | # from LDAP. |
|
84 | # from LDAP. | |
85 | assert user_data is not None |
|
85 | assert user_data is not None | |
86 |
assert user_data.get('firstname') == |
|
86 | assert user_data.get('firstname') == 'spam ldap first name' | |
87 |
assert user_data.get('lastname') == |
|
87 | assert user_data.get('lastname') == 'spam ldap last name' | |
88 | assert user_data.get('email') == 'spam ldap email' |
|
88 | assert user_data.get('email') == 'spam ldap email' | |
89 |
|
89 | |||
90 | # Verify that authentication created new user with attributes |
|
90 | # Verify that authentication created new user with attributes | |
91 | # retrieved from LDAP. |
|
91 | # retrieved from LDAP. | |
92 | new_user = User.get_by_username(username) |
|
92 | new_user = User.get_by_username(username) | |
93 | assert new_user is not None |
|
93 | assert new_user is not None | |
94 |
assert new_user.firstname == |
|
94 | assert new_user.firstname == 'spam ldap first name' | |
95 |
assert new_user.lastname == |
|
95 | assert new_user.lastname == 'spam ldap last name' | |
96 | assert new_user.email == 'spam ldap email' |
|
96 | assert new_user.email == 'spam ldap email' | |
97 |
|
97 | |||
98 |
|
98 | |||
@@ -126,14 +126,14 b' def test_init_user_attributes_from_ldap_' | |||||
126 | # Verify that authenication succeeded and retrieved correct attributes |
|
126 | # Verify that authenication succeeded and retrieved correct attributes | |
127 | # from LDAP, with empty email. |
|
127 | # from LDAP, with empty email. | |
128 | assert user_data is not None |
|
128 | assert user_data is not None | |
129 |
assert user_data.get('firstname') == |
|
129 | assert user_data.get('firstname') == 'spam ldap first name' | |
130 |
assert user_data.get('lastname') == |
|
130 | assert user_data.get('lastname') == 'spam ldap last name' | |
131 | assert user_data.get('email') == '' |
|
131 | assert user_data.get('email') == '' | |
132 |
|
132 | |||
133 | # Verify that authentication created new user with attributes |
|
133 | # Verify that authentication created new user with attributes | |
134 | # retrieved from LDAP, with email == None. |
|
134 | # retrieved from LDAP, with email == None. | |
135 | new_user = User.get_by_username(username) |
|
135 | new_user = User.get_by_username(username) | |
136 | assert new_user is not None |
|
136 | assert new_user is not None | |
137 |
assert new_user.firstname == |
|
137 | assert new_user.firstname == 'spam ldap first name' | |
138 |
assert new_user.lastname == |
|
138 | assert new_user.lastname == 'spam ldap last name' | |
139 | assert new_user.email is None |
|
139 | assert new_user.email is None |
@@ -142,20 +142,20 b' class TestLibs(base.TestController):' | |||||
142 | assert expected == set(extract_mentioned_usernames(sample)) |
|
142 | assert expected == set(extract_mentioned_usernames(sample)) | |
143 |
|
143 | |||
144 | @base.parametrize('age_args,expected', [ |
|
144 | @base.parametrize('age_args,expected', [ | |
145 |
(dict(), |
|
145 | (dict(), 'just now'), | |
146 |
(dict(seconds= -1), |
|
146 | (dict(seconds= -1), '1 second ago'), | |
147 |
(dict(seconds= -60 * 2), |
|
147 | (dict(seconds= -60 * 2), '2 minutes ago'), | |
148 |
(dict(hours= -1), |
|
148 | (dict(hours= -1), '1 hour ago'), | |
149 |
(dict(hours= -24), |
|
149 | (dict(hours= -24), '1 day ago'), | |
150 |
(dict(hours= -24 * 5), |
|
150 | (dict(hours= -24 * 5), '5 days ago'), | |
151 |
(dict(months= -1), |
|
151 | (dict(months= -1), '1 month ago'), | |
152 |
(dict(months= -1, days= -2), |
|
152 | (dict(months= -1, days= -2), '1 month and 2 days ago'), | |
153 |
(dict(months= -1, days= -20), |
|
153 | (dict(months= -1, days= -20), '1 month and 19 days ago'), | |
154 |
(dict(years= -1, months= -1), |
|
154 | (dict(years= -1, months= -1), '1 year and 1 month ago'), | |
155 |
(dict(years= -1, months= -10), |
|
155 | (dict(years= -1, months= -10), '1 year and 10 months ago'), | |
156 |
(dict(years= -2, months= -4), |
|
156 | (dict(years= -2, months= -4), '2 years and 4 months ago'), | |
157 |
(dict(years= -2, months= -11), |
|
157 | (dict(years= -2, months= -11), '2 years and 11 months ago'), | |
158 |
(dict(years= -3, months= -2), |
|
158 | (dict(years= -3, months= -2), '3 years and 2 months ago'), | |
159 | ]) |
|
159 | ]) | |
160 | def test_age(self, age_args, expected): |
|
160 | def test_age(self, age_args, expected): | |
161 | from kallithea.lib.utils2 import age |
|
161 | from kallithea.lib.utils2 import age | |
@@ -166,21 +166,21 b' class TestLibs(base.TestController):' | |||||
166 | assert age(n + delt(**age_args), now=n) == expected |
|
166 | assert age(n + delt(**age_args), now=n) == expected | |
167 |
|
167 | |||
168 | @base.parametrize('age_args,expected', [ |
|
168 | @base.parametrize('age_args,expected', [ | |
169 |
(dict(), |
|
169 | (dict(), 'just now'), | |
170 |
(dict(seconds= -1), |
|
170 | (dict(seconds= -1), '1 second ago'), | |
171 |
(dict(seconds= -60 * 2), |
|
171 | (dict(seconds= -60 * 2), '2 minutes ago'), | |
172 |
(dict(hours= -1), |
|
172 | (dict(hours= -1), '1 hour ago'), | |
173 |
(dict(hours= -24), |
|
173 | (dict(hours= -24), '1 day ago'), | |
174 |
(dict(hours= -24 * 5), |
|
174 | (dict(hours= -24 * 5), '5 days ago'), | |
175 |
(dict(months= -1), |
|
175 | (dict(months= -1), '1 month ago'), | |
176 |
(dict(months= -1, days= -2), |
|
176 | (dict(months= -1, days= -2), '1 month ago'), | |
177 |
(dict(months= -1, days= -20), |
|
177 | (dict(months= -1, days= -20), '1 month ago'), | |
178 |
(dict(years= -1, months= -1), |
|
178 | (dict(years= -1, months= -1), '13 months ago'), | |
179 |
(dict(years= -1, months= -10), |
|
179 | (dict(years= -1, months= -10), '22 months ago'), | |
180 |
(dict(years= -2, months= -4), |
|
180 | (dict(years= -2, months= -4), '2 years ago'), | |
181 |
(dict(years= -2, months= -11), |
|
181 | (dict(years= -2, months= -11), '3 years ago'), | |
182 |
(dict(years= -3, months= -2), |
|
182 | (dict(years= -3, months= -2), '3 years ago'), | |
183 |
(dict(years= -4, months= -8), |
|
183 | (dict(years= -4, months= -8), '5 years ago'), | |
184 | ]) |
|
184 | ]) | |
185 | def test_age_short(self, age_args, expected): |
|
185 | def test_age_short(self, age_args, expected): | |
186 | from kallithea.lib.utils2 import age |
|
186 | from kallithea.lib.utils2 import age | |
@@ -191,15 +191,15 b' class TestLibs(base.TestController):' | |||||
191 | assert age(n + delt(**age_args), show_short_version=True, now=n) == expected |
|
191 | assert age(n + delt(**age_args), show_short_version=True, now=n) == expected | |
192 |
|
192 | |||
193 | @base.parametrize('age_args,expected', [ |
|
193 | @base.parametrize('age_args,expected', [ | |
194 |
(dict(), |
|
194 | (dict(), 'just now'), | |
195 |
(dict(seconds=1), |
|
195 | (dict(seconds=1), 'in 1 second'), | |
196 |
(dict(seconds=60 * 2), |
|
196 | (dict(seconds=60 * 2), 'in 2 minutes'), | |
197 |
(dict(hours=1), |
|
197 | (dict(hours=1), 'in 1 hour'), | |
198 |
(dict(hours=24), |
|
198 | (dict(hours=24), 'in 1 day'), | |
199 |
(dict(hours=24 * 5), |
|
199 | (dict(hours=24 * 5), 'in 5 days'), | |
200 |
(dict(months=1), |
|
200 | (dict(months=1), 'in 1 month'), | |
201 |
(dict(months=1, days=1), |
|
201 | (dict(months=1, days=1), 'in 1 month and 1 day'), | |
202 |
(dict(years=1, months=1), |
|
202 | (dict(years=1, months=1), 'in 1 year and 1 month') | |
203 | ]) |
|
203 | ]) | |
204 | def test_age_in_future(self, age_args, expected): |
|
204 | def test_age_in_future(self, age_args, expected): | |
205 | from kallithea.lib.utils2 import age |
|
205 | from kallithea.lib.utils2 import age |
@@ -175,7 +175,7 b' class TestMail(base.TestController):' | |||||
175 | subject = 'subject' |
|
175 | subject = 'subject' | |
176 | body = 'body' |
|
176 | body = 'body' | |
177 | html_body = 'html_body' |
|
177 | html_body = 'html_body' | |
178 |
author = User(name='foo', lastname= |
|
178 | author = User(name='foo', lastname='(fubar) "baz"') | |
179 | headers = {'extra': 'yes'} |
|
179 | headers = {'extra': 'yes'} | |
180 |
|
180 | |||
181 | config_mock = { |
|
181 | config_mock = { |
@@ -54,26 +54,26 b' class TestRepoGroups(base.TestController' | |||||
54 | def test_ValidUserGroup(self): |
|
54 | def test_ValidUserGroup(self): | |
55 | validator = v.ValidUserGroup() |
|
55 | validator = v.ValidUserGroup() | |
56 | with pytest.raises(formencode.Invalid): |
|
56 | with pytest.raises(formencode.Invalid): | |
57 |
validator.to_python( |
|
57 | validator.to_python('default') | |
58 | with pytest.raises(formencode.Invalid): |
|
58 | with pytest.raises(formencode.Invalid): | |
59 |
validator.to_python( |
|
59 | validator.to_python('.,') | |
60 |
|
60 | |||
61 |
gr = fixture.create_user_group( |
|
61 | gr = fixture.create_user_group('test') | |
62 |
gr2 = fixture.create_user_group( |
|
62 | gr2 = fixture.create_user_group('tes2') | |
63 | Session().commit() |
|
63 | Session().commit() | |
64 | with pytest.raises(formencode.Invalid): |
|
64 | with pytest.raises(formencode.Invalid): | |
65 |
validator.to_python( |
|
65 | validator.to_python('test') | |
66 | assert gr.users_group_id is not None |
|
66 | assert gr.users_group_id is not None | |
67 | validator = v.ValidUserGroup(edit=True, |
|
67 | validator = v.ValidUserGroup(edit=True, | |
68 | old_data={'users_group_id': |
|
68 | old_data={'users_group_id': | |
69 | gr2.users_group_id}) |
|
69 | gr2.users_group_id}) | |
70 |
|
70 | |||
71 | with pytest.raises(formencode.Invalid): |
|
71 | with pytest.raises(formencode.Invalid): | |
72 |
validator.to_python( |
|
72 | validator.to_python('test') | |
73 | with pytest.raises(formencode.Invalid): |
|
73 | with pytest.raises(formencode.Invalid): | |
74 |
validator.to_python( |
|
74 | validator.to_python('TesT') | |
75 | with pytest.raises(formencode.Invalid): |
|
75 | with pytest.raises(formencode.Invalid): | |
76 |
validator.to_python( |
|
76 | validator.to_python('TEST') | |
77 | UserGroupModel().delete(gr) |
|
77 | UserGroupModel().delete(gr) | |
78 | UserGroupModel().delete(gr2) |
|
78 | UserGroupModel().delete(gr2) | |
79 | Session().commit() |
|
79 | Session().commit() | |
@@ -83,7 +83,7 b' class TestRepoGroups(base.TestController' | |||||
83 | model = RepoGroupModel() |
|
83 | model = RepoGroupModel() | |
84 | with pytest.raises(formencode.Invalid): |
|
84 | with pytest.raises(formencode.Invalid): | |
85 | validator.to_python({'group_name': base.HG_REPO, }) |
|
85 | validator.to_python({'group_name': base.HG_REPO, }) | |
86 |
gr = model.create(group_name= |
|
86 | gr = model.create(group_name='test_gr', group_description='desc', | |
87 | parent=None, |
|
87 | parent=None, | |
88 | just_db=True, |
|
88 | just_db=True, | |
89 | owner=base.TEST_USER_ADMIN_LOGIN) |
|
89 | owner=base.TEST_USER_ADMIN_LOGIN) | |
@@ -147,8 +147,8 b' class TestRepoGroups(base.TestController' | |||||
147 | with pytest.raises(formencode.Invalid): |
|
147 | with pytest.raises(formencode.Invalid): | |
148 | validator.to_python({'repo_name': base.HG_REPO}) |
|
148 | validator.to_python({'repo_name': base.HG_REPO}) | |
149 |
|
149 | |||
150 |
gr = RepoGroupModel().create(group_name= |
|
150 | gr = RepoGroupModel().create(group_name='group_test', | |
151 |
group_description= |
|
151 | group_description='desc', | |
152 | parent=None, |
|
152 | parent=None, | |
153 | owner=base.TEST_USER_ADMIN_LOGIN) |
|
153 | owner=base.TEST_USER_ADMIN_LOGIN) | |
154 | with pytest.raises(formencode.Invalid): |
|
154 | with pytest.raises(formencode.Invalid): |
@@ -65,8 +65,8 b' class HttpVcsTest(object):' | |||||
65 |
|
65 | |||
66 | class SshVcsTest(object): |
|
66 | class SshVcsTest(object): | |
67 | public_keys = { |
|
67 | public_keys = { | |
68 |
base.TEST_USER_REGULAR_LOGIN: |
|
68 | base.TEST_USER_REGULAR_LOGIN: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost', | |
69 |
base.TEST_USER_ADMIN_LOGIN: |
|
69 | base.TEST_USER_ADMIN_LOGIN: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost', | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | @classmethod |
|
72 | @classmethod | |
@@ -76,7 +76,7 b' class SshVcsTest(object):' | |||||
76 | ssh_key = user.ssh_keys[0] |
|
76 | ssh_key = user.ssh_keys[0] | |
77 | else: |
|
77 | else: | |
78 | sshkeymodel = SshKeyModel() |
|
78 | sshkeymodel = SshKeyModel() | |
79 |
ssh_key = sshkeymodel.create(user, |
|
79 | ssh_key = sshkeymodel.create(user, 'test key', cls.public_keys[user.username]) | |
80 | Session().commit() |
|
80 | Session().commit() | |
81 |
|
81 | |||
82 | return cls._ssh_param(repo_name, user, ssh_key, client_ip) |
|
82 | return cls._ssh_param(repo_name, user, ssh_key, client_ip) | |
@@ -263,9 +263,9 b' class TestVCSOperations(base.TestControl' | |||||
263 | @pytest.fixture(scope="module") |
|
263 | @pytest.fixture(scope="module") | |
264 | def testfork(self): |
|
264 | def testfork(self): | |
265 | # create fork so the repo stays untouched |
|
265 | # create fork so the repo stays untouched | |
266 |
git_fork_name = |
|
266 | git_fork_name = '%s_fork%s' % (base.GIT_REPO, next(_RandomNameSequence())) | |
267 | fixture.create_fork(base.GIT_REPO, git_fork_name) |
|
267 | fixture.create_fork(base.GIT_REPO, git_fork_name) | |
268 |
hg_fork_name = |
|
268 | hg_fork_name = '%s_fork%s' % (base.HG_REPO, next(_RandomNameSequence())) | |
269 | fixture.create_fork(base.HG_REPO, hg_fork_name) |
|
269 | fixture.create_fork(base.HG_REPO, hg_fork_name) | |
270 | return {'git': git_fork_name, 'hg': hg_fork_name} |
|
270 | return {'git': git_fork_name, 'hg': hg_fork_name} | |
271 |
|
271 | |||
@@ -319,7 +319,7 b' class TestVCSOperations(base.TestControl' | |||||
319 | Session().commit() |
|
319 | Session().commit() | |
320 |
|
320 | |||
321 | # Create an empty server repo using the API |
|
321 | # Create an empty server repo using the API | |
322 |
repo_name = |
|
322 | repo_name = 'new_%s_%s' % (vt.repo_type, next(_RandomNameSequence())) | |
323 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) |
|
323 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
324 | params = { |
|
324 | params = { | |
325 | "id": 7, |
|
325 | "id": 7, | |
@@ -337,7 +337,7 b' class TestVCSOperations(base.TestControl' | |||||
337 | result = json.loads(response.read()) |
|
337 | result = json.loads(response.read()) | |
338 | # Expect something like: |
|
338 | # Expect something like: | |
339 | # {u'result': {u'msg': u'Created new repository `new_XXX`', u'task': None, u'success': True}, u'id': 7, u'error': None} |
|
339 | # {u'result': {u'msg': u'Created new repository `new_XXX`', u'task': None, u'success': True}, u'id': 7, u'error': None} | |
340 |
assert result[ |
|
340 | assert result['result']['success'] | |
341 |
|
341 | |||
342 | # Create local clone of the empty server repo |
|
342 | # Create local clone of the empty server repo | |
343 | local_clone_dir = _get_tmp_dir() |
|
343 | local_clone_dir = _get_tmp_dir() | |
@@ -362,15 +362,15 b' class TestVCSOperations(base.TestControl' | |||||
362 | # <UserLog('id:new_git_XXX:push:aed9d4c1732a1927da3be42c47eb9afdc200d427,d38b083a07af10a9f44193486959a96a23db78da,4841ff9a2b385bec995f4679ef649adb3f437622')> |
|
362 | # <UserLog('id:new_git_XXX:push:aed9d4c1732a1927da3be42c47eb9afdc200d427,d38b083a07af10a9f44193486959a96a23db78da,4841ff9a2b385bec995f4679ef649adb3f437622')> | |
363 | action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)] |
|
363 | action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)] | |
364 | assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == ([ |
|
364 | assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == ([ | |
365 |
( |
|
365 | ('started_following_repo', 0), | |
366 |
( |
|
366 | ('user_created_repo', 0), | |
367 |
( |
|
367 | ('pull', 0), | |
368 |
( |
|
368 | ('push', 3)] | |
369 | if vt.repo_type == 'git' else [ |
|
369 | if vt.repo_type == 'git' else [ | |
370 |
( |
|
370 | ('started_following_repo', 0), | |
371 |
( |
|
371 | ('user_created_repo', 0), | |
372 | # (u'pull', 0), # Mercurial outgoing hook is not called for empty clones |
|
372 | # (u'pull', 0), # Mercurial outgoing hook is not called for empty clones | |
373 |
( |
|
373 | ('push', 3)]) | |
374 |
|
374 | |||
375 | @parametrize_vcs_test |
|
375 | @parametrize_vcs_test | |
376 | def test_push_new_file(self, webserver, testfork, vt): |
|
376 | def test_push_new_file(self, webserver, testfork, vt): | |
@@ -393,7 +393,7 b' class TestVCSOperations(base.TestControl' | |||||
393 |
|
393 | |||
394 | action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)] |
|
394 | action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)] | |
395 | assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \ |
|
395 | assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \ | |
396 |
[( |
|
396 | [('pull', 0), ('push', 3)] | |
397 |
|
397 | |||
398 | @parametrize_vcs_test |
|
398 | @parametrize_vcs_test | |
399 | def test_pull(self, webserver, testfork, vt): |
|
399 | def test_pull(self, webserver, testfork, vt): | |
@@ -412,7 +412,7 b' class TestVCSOperations(base.TestControl' | |||||
412 | assert 'new changesets' in stdout |
|
412 | assert 'new changesets' in stdout | |
413 |
|
413 | |||
414 | action_parts = [ul.action for ul in UserLog.query().order_by(UserLog.user_log_id)] |
|
414 | action_parts = [ul.action for ul in UserLog.query().order_by(UserLog.user_log_id)] | |
415 |
assert action_parts == [ |
|
415 | assert action_parts == ['pull'] | |
416 |
|
416 | |||
417 | # Test handling of URLs with extra '/' around repo_name |
|
417 | # Test handling of URLs with extra '/' around repo_name | |
418 | stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/./%s/' % vt.repo_name), ignoreReturnCode=True) |
|
418 | stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/./%s/' % vt.repo_name), ignoreReturnCode=True) | |
@@ -502,7 +502,7 b' class TestVCSOperations(base.TestControl' | |||||
502 |
|
502 | |||
503 | action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)] |
|
503 | action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)] | |
504 | assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \ |
|
504 | assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \ | |
505 |
[( |
|
505 | [('pull', 0)] | |
506 |
|
506 | |||
507 | @parametrize_vcs_test |
|
507 | @parametrize_vcs_test | |
508 | def test_push_back_to_wrong_url(self, webserver, vt): |
|
508 | def test_push_back_to_wrong_url(self, webserver, vt): |
@@ -27,8 +27,8 b' class _BackendTestMixin(object):' | |||||
27 | def _get_commits(cls): |
|
27 | def _get_commits(cls): | |
28 | commits = [ |
|
28 | commits = [ | |
29 | { |
|
29 | { | |
30 |
'message': |
|
30 | 'message': 'Initial commit', | |
31 |
'author': |
|
31 | 'author': 'Joe Doe <joe.doe@example.com>', | |
32 | 'date': datetime.datetime(2010, 1, 1, 20), |
|
32 | 'date': datetime.datetime(2010, 1, 1, 20), | |
33 | 'added': [ |
|
33 | 'added': [ | |
34 | FileNode('foobar', content='Foobar'), |
|
34 | FileNode('foobar', content='Foobar'), | |
@@ -37,8 +37,8 b' class _BackendTestMixin(object):' | |||||
37 | ], |
|
37 | ], | |
38 | }, |
|
38 | }, | |
39 | { |
|
39 | { | |
40 |
'message': |
|
40 | 'message': 'Changes...', | |
41 |
'author': |
|
41 | 'author': 'Jane Doe <jane.doe@example.com>', | |
42 | 'date': datetime.datetime(2010, 1, 1, 21), |
|
42 | 'date': datetime.datetime(2010, 1, 1, 21), | |
43 | 'added': [ |
|
43 | 'added': [ | |
44 | FileNode('some/new.txt', content='news...'), |
|
44 | FileNode('some/new.txt', content='news...'), |
@@ -46,8 +46,8 b' class BranchesTestCaseMixin(_BackendTest' | |||||
46 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', |
|
46 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', | |
47 | content='Documentation\n')) |
|
47 | content='Documentation\n')) | |
48 | foobar_tip = self.imc.commit( |
|
48 | foobar_tip = self.imc.commit( | |
49 |
message= |
|
49 | message='New branch: foobar', | |
50 |
author= |
|
50 | author='joe', | |
51 | branch='foobar', |
|
51 | branch='foobar', | |
52 | ) |
|
52 | ) | |
53 | assert 'foobar' in self.repo.branches |
|
53 | assert 'foobar' in self.repo.branches | |
@@ -59,23 +59,23 b' class BranchesTestCaseMixin(_BackendTest' | |||||
59 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', |
|
59 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', | |
60 | content='Documentation\n')) |
|
60 | content='Documentation\n')) | |
61 | foobar_tip = self.imc.commit( |
|
61 | foobar_tip = self.imc.commit( | |
62 |
message= |
|
62 | message='New branch: foobar', | |
63 |
author= |
|
63 | author='joe', | |
64 | branch='foobar', |
|
64 | branch='foobar', | |
65 | parents=[tip], |
|
65 | parents=[tip], | |
66 | ) |
|
66 | ) | |
67 | self.imc.change(vcs.nodes.FileNode('docs/index.txt', |
|
67 | self.imc.change(vcs.nodes.FileNode('docs/index.txt', | |
68 | content='Documentation\nand more...\n')) |
|
68 | content='Documentation\nand more...\n')) | |
69 | newtip = self.imc.commit( |
|
69 | newtip = self.imc.commit( | |
70 |
message= |
|
70 | message='At default branch', | |
71 |
author= |
|
71 | author='joe', | |
72 | branch=foobar_tip.branch, |
|
72 | branch=foobar_tip.branch, | |
73 | parents=[foobar_tip], |
|
73 | parents=[foobar_tip], | |
74 | ) |
|
74 | ) | |
75 |
|
75 | |||
76 | newest_tip = self.imc.commit( |
|
76 | newest_tip = self.imc.commit( | |
77 |
message= |
|
77 | message='Merged with %s' % foobar_tip.raw_id, | |
78 |
author= |
|
78 | author='joe', | |
79 | branch=self.backend_class.DEFAULT_BRANCH_NAME, |
|
79 | branch=self.backend_class.DEFAULT_BRANCH_NAME, | |
80 | parents=[newtip, foobar_tip], |
|
80 | parents=[newtip, foobar_tip], | |
81 | ) |
|
81 | ) | |
@@ -85,16 +85,16 b' class BranchesTestCaseMixin(_BackendTest' | |||||
85 |
|
85 | |||
86 | def test_branch_with_slash_in_name(self): |
|
86 | def test_branch_with_slash_in_name(self): | |
87 | self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n')) |
|
87 | self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n')) | |
88 |
self.imc.commit( |
|
88 | self.imc.commit('Branch with a slash!', author='joe', | |
89 | branch='issue/123') |
|
89 | branch='issue/123') | |
90 | assert 'issue/123' in self.repo.branches |
|
90 | assert 'issue/123' in self.repo.branches | |
91 |
|
91 | |||
92 | def test_branch_with_slash_in_name_and_similar_without(self): |
|
92 | def test_branch_with_slash_in_name_and_similar_without(self): | |
93 | self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n')) |
|
93 | self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n')) | |
94 |
self.imc.commit( |
|
94 | self.imc.commit('Branch with a slash!', author='joe', | |
95 | branch='issue/123') |
|
95 | branch='issue/123') | |
96 | self.imc.add(vcs.nodes.FileNode('extrafile II', content='Some data\n')) |
|
96 | self.imc.add(vcs.nodes.FileNode('extrafile II', content='Some data\n')) | |
97 |
self.imc.commit( |
|
97 | self.imc.commit('Branch without a slash...', author='joe', | |
98 | branch='123') |
|
98 | branch='123') | |
99 | assert 'issue/123' in self.repo.branches |
|
99 | assert 'issue/123' in self.repo.branches | |
100 | assert '123' in self.repo.branches |
|
100 | assert '123' in self.repo.branches |
@@ -21,7 +21,7 b' class TestBaseChangeset(object):' | |||||
21 | changeset.date = datetime.datetime(2011, 1, 30, 1, 45) |
|
21 | changeset.date = datetime.datetime(2011, 1, 30, 1, 45) | |
22 | changeset.message = 'Message of a commit' |
|
22 | changeset.message = 'Message of a commit' | |
23 | changeset.author = 'Joe Doe <joe.doe@example.com>' |
|
23 | changeset.author = 'Joe Doe <joe.doe@example.com>' | |
24 |
changeset.added = [FileNode('foo/bar/baz'), FileNode( |
|
24 | changeset.added = [FileNode('foo/bar/baz'), FileNode('foobar'), FileNode('blΓ₯bΓ¦rgrΓΈd')] | |
25 | changeset.changed = [] |
|
25 | changeset.changed = [] | |
26 | changeset.removed = [] |
|
26 | changeset.removed = [] | |
27 | assert changeset.as_dict() == { |
|
27 | assert changeset.as_dict() == { | |
@@ -34,7 +34,7 b' class TestBaseChangeset(object):' | |||||
34 | 'name': 'Joe Doe', |
|
34 | 'name': 'Joe Doe', | |
35 | 'email': 'joe.doe@example.com', |
|
35 | 'email': 'joe.doe@example.com', | |
36 | }, |
|
36 | }, | |
37 |
'added': ['foo/bar/baz', 'foobar', |
|
37 | 'added': ['foo/bar/baz', 'foobar', 'bl\xe5b\xe6rgr\xf8d'], | |
38 | 'changed': [], |
|
38 | 'changed': [], | |
39 | 'removed': [], |
|
39 | 'removed': [], | |
40 | } |
|
40 | } | |
@@ -59,8 +59,8 b' class _ChangesetsWithCommitsTestCaseixin' | |||||
59 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', |
|
59 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', | |
60 | content='Documentation\n')) |
|
60 | content='Documentation\n')) | |
61 | foobar_tip = self.imc.commit( |
|
61 | foobar_tip = self.imc.commit( | |
62 |
message= |
|
62 | message='New branch: foobar', | |
63 |
author= |
|
63 | author='joe', | |
64 | branch='foobar', |
|
64 | branch='foobar', | |
65 | ) |
|
65 | ) | |
66 | assert 'foobar' in self.repo.branches |
|
66 | assert 'foobar' in self.repo.branches | |
@@ -75,23 +75,23 b' class _ChangesetsWithCommitsTestCaseixin' | |||||
75 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', |
|
75 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', | |
76 | content='Documentation\n')) |
|
76 | content='Documentation\n')) | |
77 | foobar_tip = self.imc.commit( |
|
77 | foobar_tip = self.imc.commit( | |
78 |
message= |
|
78 | message='New branch: foobar', | |
79 |
author= |
|
79 | author='joe', | |
80 | branch='foobar', |
|
80 | branch='foobar', | |
81 | parents=[tip], |
|
81 | parents=[tip], | |
82 | ) |
|
82 | ) | |
83 | self.imc.change(vcs.nodes.FileNode('docs/index.txt', |
|
83 | self.imc.change(vcs.nodes.FileNode('docs/index.txt', | |
84 | content='Documentation\nand more...\n')) |
|
84 | content='Documentation\nand more...\n')) | |
85 | newtip = self.imc.commit( |
|
85 | newtip = self.imc.commit( | |
86 |
message= |
|
86 | message='At default branch', | |
87 |
author= |
|
87 | author='joe', | |
88 | branch=foobar_tip.branch, |
|
88 | branch=foobar_tip.branch, | |
89 | parents=[foobar_tip], |
|
89 | parents=[foobar_tip], | |
90 | ) |
|
90 | ) | |
91 |
|
91 | |||
92 | newest_tip = self.imc.commit( |
|
92 | newest_tip = self.imc.commit( | |
93 |
message= |
|
93 | message='Merged with %s' % foobar_tip.raw_id, | |
94 |
author= |
|
94 | author='joe', | |
95 | branch=self.backend_class.DEFAULT_BRANCH_NAME, |
|
95 | branch=self.backend_class.DEFAULT_BRANCH_NAME, | |
96 | parents=[newtip, foobar_tip], |
|
96 | parents=[newtip, foobar_tip], | |
97 | ) |
|
97 | ) | |
@@ -104,14 +104,14 b' class _ChangesetsWithCommitsTestCaseixin' | |||||
104 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', |
|
104 | self.imc.add(vcs.nodes.FileNode('docs/index.txt', | |
105 | content='Documentation\n')) |
|
105 | content='Documentation\n')) | |
106 | doc_changeset = self.imc.commit( |
|
106 | doc_changeset = self.imc.commit( | |
107 |
message= |
|
107 | message='New branch: docs', | |
108 |
author= |
|
108 | author='joe', | |
109 | branch='docs', |
|
109 | branch='docs', | |
110 | ) |
|
110 | ) | |
111 | self.imc.add(vcs.nodes.FileNode('newfile', content='')) |
|
111 | self.imc.add(vcs.nodes.FileNode('newfile', content='')) | |
112 | self.imc.commit( |
|
112 | self.imc.commit( | |
113 |
message= |
|
113 | message='Back in default branch', | |
114 |
author= |
|
114 | author='joe', | |
115 | parents=[tip], |
|
115 | parents=[tip], | |
116 | ) |
|
116 | ) | |
117 | default_branch_changesets = self.repo.get_changesets( |
|
117 | default_branch_changesets = self.repo.get_changesets( | |
@@ -145,8 +145,8 b' class _ChangesetsTestCaseMixin(_BackendT' | |||||
145 | start_date = datetime.datetime(2010, 1, 1, 20) |
|
145 | start_date = datetime.datetime(2010, 1, 1, 20) | |
146 | for x in range(5): |
|
146 | for x in range(5): | |
147 | yield { |
|
147 | yield { | |
148 |
'message': |
|
148 | 'message': 'Commit %d' % x, | |
149 |
'author': |
|
149 | 'author': 'Joe Doe <joe.doe@example.com>', | |
150 | 'date': start_date + datetime.timedelta(hours=12 * x), |
|
150 | 'date': start_date + datetime.timedelta(hours=12 * x), | |
151 | 'added': [ |
|
151 | 'added': [ | |
152 | FileNode('file_%d.txt' % x, content='Foobar %d' % x), |
|
152 | FileNode('file_%d.txt' % x, content='Foobar %d' % x), | |
@@ -247,15 +247,15 b' class _ChangesetsTestCaseMixin(_BackendT' | |||||
247 |
|
247 | |||
248 | def test_author(self): |
|
248 | def test_author(self): | |
249 | tip = self.repo.get_changeset() |
|
249 | tip = self.repo.get_changeset() | |
250 |
assert tip.author == |
|
250 | assert tip.author == 'Joe Doe <joe.doe@example.com>' | |
251 |
|
251 | |||
252 | def test_author_name(self): |
|
252 | def test_author_name(self): | |
253 | tip = self.repo.get_changeset() |
|
253 | tip = self.repo.get_changeset() | |
254 |
assert tip.author_name == |
|
254 | assert tip.author_name == 'Joe Doe' | |
255 |
|
255 | |||
256 | def test_author_email(self): |
|
256 | def test_author_email(self): | |
257 | tip = self.repo.get_changeset() |
|
257 | tip = self.repo.get_changeset() | |
258 |
assert tip.author_email == |
|
258 | assert tip.author_email == 'joe.doe@example.com' | |
259 |
|
259 | |||
260 | def test_get_changesets_raise_changesetdoesnotexist_for_wrong_start(self): |
|
260 | def test_get_changesets_raise_changesetdoesnotexist_for_wrong_start(self): | |
261 | with pytest.raises(ChangesetDoesNotExistError): |
|
261 | with pytest.raises(ChangesetDoesNotExistError): | |
@@ -297,8 +297,8 b' class _ChangesetsChangesTestCaseMixin(_B' | |||||
297 | def _get_commits(cls): |
|
297 | def _get_commits(cls): | |
298 | return [ |
|
298 | return [ | |
299 | { |
|
299 | { | |
300 |
'message': |
|
300 | 'message': 'Initial', | |
301 |
'author': |
|
301 | 'author': 'Joe Doe <joe.doe@example.com>', | |
302 | 'date': datetime.datetime(2010, 1, 1, 20), |
|
302 | 'date': datetime.datetime(2010, 1, 1, 20), | |
303 | 'added': [ |
|
303 | 'added': [ | |
304 | FileNode('foo/bar', content='foo'), |
|
304 | FileNode('foo/bar', content='foo'), | |
@@ -308,8 +308,8 b' class _ChangesetsChangesTestCaseMixin(_B' | |||||
308 | ], |
|
308 | ], | |
309 | }, |
|
309 | }, | |
310 | { |
|
310 | { | |
311 |
'message': |
|
311 | 'message': 'Massive changes', | |
312 |
'author': |
|
312 | 'author': 'Joe Doe <joe.doe@example.com>', | |
313 | 'date': datetime.datetime(2010, 1, 1, 22), |
|
313 | 'date': datetime.datetime(2010, 1, 1, 22), | |
314 | 'added': [FileNode('fallout', content='War never changes')], |
|
314 | 'added': [FileNode('fallout', content='War never changes')], | |
315 | 'changed': [ |
|
315 | 'changed': [ | |
@@ -330,8 +330,8 b' class _ChangesetsChangesTestCaseMixin(_B' | |||||
330 | ]) |
|
330 | ]) | |
331 | assert list(changeset.changed) == [] |
|
331 | assert list(changeset.changed) == [] | |
332 | assert list(changeset.removed) == [] |
|
332 | assert list(changeset.removed) == [] | |
333 |
assert |
|
333 | assert 'foo/ba\u0142' in changeset.as_dict()['added'] | |
334 |
assert |
|
334 | assert 'foo/ba\u0142' in changeset.__json__(with_file_list=True)['added'] | |
335 |
|
335 | |||
336 | def test_head_added(self): |
|
336 | def test_head_added(self): | |
337 | changeset = self.repo.get_changeset() |
|
337 | changeset = self.repo.get_changeset() | |
@@ -355,7 +355,7 b' class _ChangesetsChangesTestCaseMixin(_B' | |||||
355 | def test_get_filemode_non_ascii(self): |
|
355 | def test_get_filemode_non_ascii(self): | |
356 | changeset = self.repo.get_changeset() |
|
356 | changeset = self.repo.get_changeset() | |
357 | assert 33188 == changeset.get_file_mode('foo/baΕ') |
|
357 | assert 33188 == changeset.get_file_mode('foo/baΕ') | |
358 |
assert 33188 == changeset.get_file_mode( |
|
358 | assert 33188 == changeset.get_file_mode('foo/baΕ') | |
359 |
|
359 | |||
360 |
|
360 | |||
361 | class TestGitChangesetsWithCommits(_ChangesetsWithCommitsTestCaseixin): |
|
361 | class TestGitChangesetsWithCommits(_ChangesetsWithCommitsTestCaseixin): |
@@ -8,7 +8,7 b' from kallithea.tests.vcs.base import _Ba' | |||||
8 |
|
8 | |||
9 | class FileNodeUnicodePathTestsMixin(_BackendTestMixin): |
|
9 | class FileNodeUnicodePathTestsMixin(_BackendTestMixin): | |
10 |
|
10 | |||
11 |
fname = |
|
11 | fname = 'Δ ΕΓ°Δ ΔΕΔ Δ.txt' | |
12 |
|
12 | |||
13 | @classmethod |
|
13 | @classmethod | |
14 | def _get_commits(cls): |
|
14 | def _get_commits(cls): |
@@ -27,7 +27,7 b' class TestMercurialRepository(object):' | |||||
27 |
|
27 | |||
28 | def test_unicode_path_repo(self): |
|
28 | def test_unicode_path_repo(self): | |
29 | with pytest.raises(VCSError): |
|
29 | with pytest.raises(VCSError): | |
30 |
MercurialRepository( |
|
30 | MercurialRepository('iShouldFail') | |
31 |
|
31 | |||
32 | def test_repo_clone(self): |
|
32 | def test_repo_clone(self): | |
33 | self.__check_for_existing_repo() |
|
33 | self.__check_for_existing_repo() |
@@ -36,7 +36,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
36 | for node in self.nodes] |
|
36 | for node in self.nodes] | |
37 | for node in to_add: |
|
37 | for node in to_add: | |
38 | self.imc.add(node) |
|
38 | self.imc.add(node) | |
39 |
message = |
|
39 | message = 'Added: %s' % ', '.join((node.path for node in self.nodes)) | |
40 | author = str(self.__class__) |
|
40 | author = str(self.__class__) | |
41 | changeset = self.imc.commit(message=message, author=author) |
|
41 | changeset = self.imc.commit(message=message, author=author) | |
42 |
|
42 | |||
@@ -58,7 +58,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
58 | to_add = [FileNode(node.path, content=node.content) |
|
58 | to_add = [FileNode(node.path, content=node.content) | |
59 | for node in self.nodes] |
|
59 | for node in self.nodes] | |
60 | self.imc.add(*to_add) |
|
60 | self.imc.add(*to_add) | |
61 |
message = |
|
61 | message = 'Added: %s' % ', '.join((node.path for node in self.nodes)) | |
62 | author = str(self.__class__) |
|
62 | author = str(self.__class__) | |
63 | changeset = self.imc.commit(message=message, author=author) |
|
63 | changeset = self.imc.commit(message=message, author=author) | |
64 |
|
64 | |||
@@ -78,7 +78,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
78 | def test_add_actually_adds_all_nodes_at_second_commit_too(self): |
|
78 | def test_add_actually_adds_all_nodes_at_second_commit_too(self): | |
79 | self.imc.add(FileNode('foo/bar/image.png', content='\0')) |
|
79 | self.imc.add(FileNode('foo/bar/image.png', content='\0')) | |
80 | self.imc.add(FileNode('foo/README.txt', content='readme!')) |
|
80 | self.imc.add(FileNode('foo/README.txt', content='readme!')) | |
81 |
changeset = self.imc.commit( |
|
81 | changeset = self.imc.commit('Initial', 'joe.doe@example.com') | |
82 | assert isinstance(changeset.get_node('foo'), DirNode) |
|
82 | assert isinstance(changeset.get_node('foo'), DirNode) | |
83 | assert isinstance(changeset.get_node('foo/bar'), DirNode) |
|
83 | assert isinstance(changeset.get_node('foo/bar'), DirNode) | |
84 | assert changeset.get_node('foo/bar/image.png').content == b'\0' |
|
84 | assert changeset.get_node('foo/bar/image.png').content == b'\0' | |
@@ -93,7 +93,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
93 | FileNode('foobar/barbaz', content='foo'), |
|
93 | FileNode('foobar/barbaz', content='foo'), | |
94 | ] |
|
94 | ] | |
95 | self.imc.add(*to_add) |
|
95 | self.imc.add(*to_add) | |
96 |
changeset = self.imc.commit( |
|
96 | changeset = self.imc.commit('Another', 'joe.doe@example.com') | |
97 | changeset.get_node('foo/bar/foobaz/bar').content == b'foo' |
|
97 | changeset.get_node('foo/bar/foobaz/bar').content == b'foo' | |
98 | changeset.get_node('foo/bar/another/bar').content == b'foo' |
|
98 | changeset.get_node('foo/bar/another/bar').content == b'foo' | |
99 | changeset.get_node('foo/baz.txt').content == b'foo' |
|
99 | changeset.get_node('foo/baz.txt').content == b'foo' | |
@@ -104,11 +104,11 b' class InMemoryChangesetTestMixin(_Backen' | |||||
104 | rev_count = len(self.repo.revisions) |
|
104 | rev_count = len(self.repo.revisions) | |
105 | to_add = [ |
|
105 | to_add = [ | |
106 | FileNode('ΕΌΓ³Εwik/zwierzΔ tko', content='ΔΔΔΔ'), |
|
106 | FileNode('ΕΌΓ³Εwik/zwierzΔ tko', content='ΔΔΔΔ'), | |
107 |
FileNode( |
|
107 | FileNode('ΕΌΓ³Εwik/zwierzΔ tko_uni', content='ΔΔΔΔ'), | |
108 | ] |
|
108 | ] | |
109 | for node in to_add: |
|
109 | for node in to_add: | |
110 | self.imc.add(node) |
|
110 | self.imc.add(node) | |
111 |
message = |
|
111 | message = 'Added: %s' % ', '.join((node.path for node in self.nodes)) | |
112 | author = str(self.__class__) |
|
112 | author = str(self.__class__) | |
113 | changeset = self.imc.commit(message=message, author=author) |
|
113 | changeset = self.imc.commit(message=message, author=author) | |
114 |
|
114 | |||
@@ -134,7 +134,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
134 | def test_check_integrity_raise_already_exist(self): |
|
134 | def test_check_integrity_raise_already_exist(self): | |
135 | node = FileNode('foobar', content='baz') |
|
135 | node = FileNode('foobar', content='baz') | |
136 | self.imc.add(node) |
|
136 | self.imc.add(node) | |
137 |
self.imc.commit(message= |
|
137 | self.imc.commit(message='Added foobar', author=str(self)) | |
138 | self.imc.add(node) |
|
138 | self.imc.add(node) | |
139 | with pytest.raises(NodeAlreadyExistsError): |
|
139 | with pytest.raises(NodeAlreadyExistsError): | |
140 | self.imc.commit(message='new message', |
|
140 | self.imc.commit(message='new message', | |
@@ -143,12 +143,12 b' class InMemoryChangesetTestMixin(_Backen' | |||||
143 | def test_change(self): |
|
143 | def test_change(self): | |
144 | self.imc.add(FileNode('foo/bar/baz', content='foo')) |
|
144 | self.imc.add(FileNode('foo/bar/baz', content='foo')) | |
145 | self.imc.add(FileNode('foo/fbar', content='foobar')) |
|
145 | self.imc.add(FileNode('foo/fbar', content='foobar')) | |
146 |
tip = self.imc.commit( |
|
146 | tip = self.imc.commit('Initial', 'joe.doe@example.com') | |
147 |
|
147 | |||
148 | # Change node's content |
|
148 | # Change node's content | |
149 | node = FileNode('foo/bar/baz', content='My **changed** content') |
|
149 | node = FileNode('foo/bar/baz', content='My **changed** content') | |
150 | self.imc.change(node) |
|
150 | self.imc.change(node) | |
151 |
self.imc.commit( |
|
151 | self.imc.commit('Changed %s' % node.path, 'joe.doe@example.com') | |
152 |
|
152 | |||
153 | newtip = self.repo.get_changeset() |
|
153 | newtip = self.repo.get_changeset() | |
154 | assert tip != newtip |
|
154 | assert tip != newtip | |
@@ -158,21 +158,21 b' class InMemoryChangesetTestMixin(_Backen' | |||||
158 | def test_change_non_ascii(self): |
|
158 | def test_change_non_ascii(self): | |
159 | to_add = [ |
|
159 | to_add = [ | |
160 | FileNode('ΕΌΓ³Εwik/zwierzΔ tko', content='ΔΔΔΔ'), |
|
160 | FileNode('ΕΌΓ³Εwik/zwierzΔ tko', content='ΔΔΔΔ'), | |
161 |
FileNode( |
|
161 | FileNode('ΕΌΓ³Εwik/zwierzΔ tko_uni', content='ΔΔΔΔ'), | |
162 | ] |
|
162 | ] | |
163 | for node in to_add: |
|
163 | for node in to_add: | |
164 | self.imc.add(node) |
|
164 | self.imc.add(node) | |
165 |
|
165 | |||
166 |
tip = self.imc.commit( |
|
166 | tip = self.imc.commit('Initial', 'joe.doe@example.com') | |
167 |
|
167 | |||
168 | # Change node's content |
|
168 | # Change node's content | |
169 | node = FileNode('ΕΌΓ³Εwik/zwierzΔ tko', content='My **changed** content') |
|
169 | node = FileNode('ΕΌΓ³Εwik/zwierzΔ tko', content='My **changed** content') | |
170 | self.imc.change(node) |
|
170 | self.imc.change(node) | |
171 |
self.imc.commit( |
|
171 | self.imc.commit('Changed %s' % node.path, 'joe.doe@example.com') | |
172 |
|
172 | |||
173 |
node = FileNode( |
|
173 | node = FileNode('ΕΌΓ³Εwik/zwierzΔ tko_uni', content='My **changed** content') | |
174 | self.imc.change(node) |
|
174 | self.imc.change(node) | |
175 |
self.imc.commit( |
|
175 | self.imc.commit('Changed %s' % node.path, 'joe.doe@example.com') | |
176 |
|
176 | |||
177 | newtip = self.repo.get_changeset() |
|
177 | newtip = self.repo.get_changeset() | |
178 | assert tip != newtip |
|
178 | assert tip != newtip | |
@@ -189,7 +189,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
189 | def test_check_integrity_change_raise_node_does_not_exist(self): |
|
189 | def test_check_integrity_change_raise_node_does_not_exist(self): | |
190 | node = FileNode('foobar', content='baz') |
|
190 | node = FileNode('foobar', content='baz') | |
191 | self.imc.add(node) |
|
191 | self.imc.add(node) | |
192 |
self.imc.commit(message= |
|
192 | self.imc.commit(message='Added foobar', author=str(self)) | |
193 | node = FileNode('not-foobar', content='') |
|
193 | node = FileNode('not-foobar', content='') | |
194 | self.imc.change(node) |
|
194 | self.imc.change(node) | |
195 | with pytest.raises(NodeDoesNotExistError): |
|
195 | with pytest.raises(NodeDoesNotExistError): | |
@@ -198,7 +198,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
198 | def test_change_raise_node_already_changed(self): |
|
198 | def test_change_raise_node_already_changed(self): | |
199 | node = FileNode('foobar', content='baz') |
|
199 | node = FileNode('foobar', content='baz') | |
200 | self.imc.add(node) |
|
200 | self.imc.add(node) | |
201 |
self.imc.commit(message= |
|
201 | self.imc.commit(message='Added foobar', author=str(self)) | |
202 | node = FileNode('foobar', content='more baz') |
|
202 | node = FileNode('foobar', content='more baz') | |
203 | self.imc.change(node) |
|
203 | self.imc.change(node) | |
204 | with pytest.raises(NodeAlreadyChangedError): |
|
204 | with pytest.raises(NodeAlreadyChangedError): | |
@@ -211,14 +211,14 b' class InMemoryChangesetTestMixin(_Backen' | |||||
211 | self.imc.change(node) |
|
211 | self.imc.change(node) | |
212 | with pytest.raises(NodeNotChangedError): |
|
212 | with pytest.raises(NodeNotChangedError): | |
213 | self.imc.commit( |
|
213 | self.imc.commit( | |
214 |
message= |
|
214 | message='Trying to mark node as changed without touching it', | |
215 | author=str(self), |
|
215 | author=str(self), | |
216 | ) |
|
216 | ) | |
217 |
|
217 | |||
218 | def test_change_raise_node_already_removed(self): |
|
218 | def test_change_raise_node_already_removed(self): | |
219 | node = FileNode('foobar', content='baz') |
|
219 | node = FileNode('foobar', content='baz') | |
220 | self.imc.add(node) |
|
220 | self.imc.add(node) | |
221 |
self.imc.commit(message= |
|
221 | self.imc.commit(message='Added foobar', author=str(self)) | |
222 | self.imc.remove(FileNode('foobar')) |
|
222 | self.imc.remove(FileNode('foobar')) | |
223 | with pytest.raises(NodeAlreadyRemovedError): |
|
223 | with pytest.raises(NodeAlreadyRemovedError): | |
224 | self.imc.change(node) |
|
224 | self.imc.change(node) | |
@@ -230,7 +230,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
230 | node = self.nodes[0] |
|
230 | node = self.nodes[0] | |
231 | assert node.content == tip.get_node(node.path).content |
|
231 | assert node.content == tip.get_node(node.path).content | |
232 | self.imc.remove(node) |
|
232 | self.imc.remove(node) | |
233 |
self.imc.commit(message= |
|
233 | self.imc.commit(message='Removed %s' % node.path, author=str(self)) | |
234 |
|
234 | |||
235 | newtip = self.repo.get_changeset() |
|
235 | newtip = self.repo.get_changeset() | |
236 | assert tip != newtip |
|
236 | assert tip != newtip | |
@@ -241,10 +241,10 b' class InMemoryChangesetTestMixin(_Backen' | |||||
241 | def test_remove_last_file_from_directory(self): |
|
241 | def test_remove_last_file_from_directory(self): | |
242 | node = FileNode('omg/qwe/foo/bar', content='foobar') |
|
242 | node = FileNode('omg/qwe/foo/bar', content='foobar') | |
243 | self.imc.add(node) |
|
243 | self.imc.add(node) | |
244 |
self.imc.commit( |
|
244 | self.imc.commit('added', 'joe doe') | |
245 |
|
245 | |||
246 | self.imc.remove(node) |
|
246 | self.imc.remove(node) | |
247 |
tip = self.imc.commit( |
|
247 | tip = self.imc.commit('removed', 'joe doe') | |
248 | with pytest.raises(NodeDoesNotExistError): |
|
248 | with pytest.raises(NodeDoesNotExistError): | |
249 | tip.get_node('omg/qwe/foo/bar') |
|
249 | tip.get_node('omg/qwe/foo/bar') | |
250 |
|
250 | |||
@@ -263,7 +263,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
263 | self.imc.remove(node) |
|
263 | self.imc.remove(node) | |
264 | with pytest.raises(NodeDoesNotExistError): |
|
264 | with pytest.raises(NodeDoesNotExistError): | |
265 | self.imc.commit( |
|
265 | self.imc.commit( | |
266 |
message= |
|
266 | message='Trying to remove not existing node', | |
267 | author=str(self), |
|
267 | author=str(self), | |
268 | ) |
|
268 | ) | |
269 |
|
269 | |||
@@ -302,7 +302,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
302 | content = 'foobar\n' * x |
|
302 | content = 'foobar\n' * x | |
303 | node = FileNode(fname, content=content) |
|
303 | node = FileNode(fname, content=content) | |
304 | self.imc.add(node) |
|
304 | self.imc.add(node) | |
305 |
commit = self.imc.commit( |
|
305 | commit = self.imc.commit("Commit no. %s" % (x + 1), author='vcs') | |
306 | assert last != commit |
|
306 | assert last != commit | |
307 | last = commit |
|
307 | last = commit | |
308 |
|
308 | |||
@@ -316,8 +316,8 b' class InMemoryChangesetTestMixin(_Backen' | |||||
316 | node = FileNode('foobar.txt', content='Foobared!') |
|
316 | node = FileNode('foobar.txt', content='Foobared!') | |
317 | self.imc.add(node) |
|
317 | self.imc.add(node) | |
318 | date = datetime.datetime(1985, 1, 30, 1, 45) |
|
318 | date = datetime.datetime(1985, 1, 30, 1, 45) | |
319 |
commit = self.imc.commit( |
|
319 | commit = self.imc.commit("Committed at time when I was born ;-)", | |
320 |
author= |
|
320 | author='lb <lb@example.com>', date=date) | |
321 |
|
321 | |||
322 | assert commit.date == date |
|
322 | assert commit.date == date | |
323 |
|
323 |
@@ -85,7 +85,7 b' class RepositoryGetDiffTest(_BackendTest' | |||||
85 | 'removed': [FileNode('foobar')], |
|
85 | 'removed': [FileNode('foobar')], | |
86 | }, |
|
86 | }, | |
87 | { |
|
87 | { | |
88 |
'message': |
|
88 | 'message': 'Commit that contains glob pattern in filename', | |
89 | 'author': 'Jane Doe <jane.doe@example.com>', |
|
89 | 'author': 'Jane Doe <jane.doe@example.com>', | |
90 | 'date': datetime.datetime(2010, 1, 1, 22), |
|
90 | 'date': datetime.datetime(2010, 1, 1, 22), | |
91 | 'added': [ |
|
91 | 'added': [ |
@@ -191,8 +191,8 b' class TestAuthorExtractors(object):' | |||||
191 | ('justname', '')), |
|
191 | ('justname', '')), | |
192 | ('Mr Double Name withemail@example.com ', |
|
192 | ('Mr Double Name withemail@example.com ', | |
193 | ('Mr Double Name', 'withemail@example.com')), |
|
193 | ('Mr Double Name', 'withemail@example.com')), | |
194 |
( |
|
194 | ('John Doe <Π΄ΠΆΠΎΠ½Π΄ΠΎ Γ Γ©αΊΓ αΉαΉΕΓͺ.ç°ḿ>', | |
195 |
( |
|
195 | ('John Doe <\u0434\u0436\u043e\u043d\u0434\u043e \xe0 \xe9\u1e8b\xe0\u1e41\u1e57\u0142\xea.\xe7\xb0\u1e3f>', '')), | |
196 | ] |
|
196 | ] | |
197 |
|
197 | |||
198 | def test_author_email(self): |
|
198 | def test_author_email(self): |
@@ -12,8 +12,8 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
12 | def _get_commits(cls): |
|
12 | def _get_commits(cls): | |
13 | commits = [ |
|
13 | commits = [ | |
14 | { |
|
14 | { | |
15 |
'message': |
|
15 | 'message': 'Initial commit', | |
16 |
'author': |
|
16 | 'author': 'Joe Doe <joe.doe@example.com>', | |
17 | 'date': datetime.datetime(2010, 1, 1, 20), |
|
17 | 'date': datetime.datetime(2010, 1, 1, 20), | |
18 | 'added': [ |
|
18 | 'added': [ | |
19 | FileNode('foobar', content='Foobar'), |
|
19 | FileNode('foobar', content='Foobar'), | |
@@ -22,8 +22,8 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
22 | ], |
|
22 | ], | |
23 | }, |
|
23 | }, | |
24 | { |
|
24 | { | |
25 |
'message': |
|
25 | 'message': 'Changes...', | |
26 |
'author': |
|
26 | 'author': 'Jane Doe <jane.doe@example.com>', | |
27 | 'date': datetime.datetime(2010, 1, 1, 21), |
|
27 | 'date': datetime.datetime(2010, 1, 1, 21), | |
28 | 'added': [ |
|
28 | 'added': [ | |
29 | FileNode('some/new.txt', content='news...'), |
|
29 | FileNode('some/new.txt', content='news...'), | |
@@ -43,8 +43,8 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
43 | self.imc.add(FileNode('docs/index.txt', |
|
43 | self.imc.add(FileNode('docs/index.txt', | |
44 | content='Documentation\n')) |
|
44 | content='Documentation\n')) | |
45 | self.imc.commit( |
|
45 | self.imc.commit( | |
46 |
message= |
|
46 | message='New branch: foobar', | |
47 |
author= |
|
47 | author='joe', | |
48 | branch='foobar', |
|
48 | branch='foobar', | |
49 | ) |
|
49 | ) | |
50 | assert self.repo.workdir.get_branch() == self.default_branch |
|
50 | assert self.repo.workdir.get_branch() == self.default_branch | |
@@ -54,8 +54,8 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
54 | self.imc.add(FileNode('docs/index.txt', |
|
54 | self.imc.add(FileNode('docs/index.txt', | |
55 | content='Documentation\n')) |
|
55 | content='Documentation\n')) | |
56 | head = self.imc.commit( |
|
56 | head = self.imc.commit( | |
57 |
message= |
|
57 | message='New branch: foobar', | |
58 |
author= |
|
58 | author='joe', | |
59 | branch='foobar', |
|
59 | branch='foobar', | |
60 | ) |
|
60 | ) | |
61 | assert self.repo.workdir.get_branch() == self.default_branch |
|
61 | assert self.repo.workdir.get_branch() == self.default_branch | |
@@ -73,7 +73,7 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
73 | self.repo.workdir.checkout_branch(branch='foobranch') |
|
73 | self.repo.workdir.checkout_branch(branch='foobranch') | |
74 | # create new branch 'foobranch'. |
|
74 | # create new branch 'foobranch'. | |
75 | self.imc.add(FileNode('file1', content='blah')) |
|
75 | self.imc.add(FileNode('file1', content='blah')) | |
76 |
self.imc.commit(message= |
|
76 | self.imc.commit(message='asd', author='john', branch='foobranch') | |
77 | # go back to the default branch |
|
77 | # go back to the default branch | |
78 | self.repo.workdir.checkout_branch() |
|
78 | self.repo.workdir.checkout_branch() | |
79 | assert self.repo.workdir.get_branch() == self.backend_class.DEFAULT_BRANCH_NAME |
|
79 | assert self.repo.workdir.get_branch() == self.backend_class.DEFAULT_BRANCH_NAME |
@@ -55,7 +55,7 b' def sortkey(x):' | |||||
55 | return (x[0] and -int(x[0][-1]), |
|
55 | return (x[0] and -int(x[0][-1]), | |
56 | x[0] and int(x[0][0]), |
|
56 | x[0] and int(x[0][0]), | |
57 | -len(x[0]), |
|
57 | -len(x[0]), | |
58 |
x[1].decode('utf-8').lower().replace( |
|
58 | x[1].decode('utf-8').lower().replace('\xe9', 'e').replace('\u0142', 'l') | |
59 | ) |
|
59 | ) | |
60 |
|
60 | |||
61 |
|
61 |
General Comments 0
You need to be logged in to leave comments.
Login now