mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
gitweb: Fix modifying git repositories when gitweb app is disabled
Fixes #2408. - When app is disabled, continue to update the app shortcut's login required property. Otherwise, the value is current after the app is re-enabled. - When public access is enabled, the gitweb-freedombox-auth.conf configuration must be disabled. This can be done even if the configuration is already disabled or does not exist. So, continue doing this. Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil: Perform enable public access even if app is disabled] [sunil: Perform shortcut update in all cases even if app is disabled] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
c217fdb5c6
commit
1268898176
@ -98,7 +98,7 @@ class GitwebApp(app_module.App):
|
||||
|
||||
def post_init(self):
|
||||
"""Perform post initialization operations."""
|
||||
if not self.needs_setup() and self.is_enabled():
|
||||
if not self.needs_setup():
|
||||
self.update_service_access()
|
||||
|
||||
def set_shortcut_login_required(self, login_required):
|
||||
@ -122,7 +122,7 @@ class GitwebApp(app_module.App):
|
||||
|
||||
def _disable_public_access(self):
|
||||
"""Allow Gitweb app to be accessed by logged-in users only."""
|
||||
if not self.auth_webserver.is_conf_enabled():
|
||||
if self.is_enabled() and not self.auth_webserver.is_conf_enabled():
|
||||
self.auth_webserver.enable()
|
||||
|
||||
self.set_shortcut_login_required(True)
|
||||
|
||||
@ -63,23 +63,30 @@ class TestGitwebApp(functional.BaseAppTests):
|
||||
|
||||
@pytest.mark.parametrize('access', ['public', 'private'])
|
||||
@pytest.mark.parametrize('repo_name', ['Test-repo', 'Test-repo.git'])
|
||||
def test_create_delete_repo(self, session_browser, access, repo_name):
|
||||
@pytest.mark.parametrize('app_status', ['enabled', 'disabled'])
|
||||
def test_create_delete_repo(self, session_browser, access, repo_name,
|
||||
app_status):
|
||||
"""Test creating and deleting a repo and accessing with a git
|
||||
client."""
|
||||
if app_status == "disabled":
|
||||
functional.app_disable(session_browser, 'gitweb')
|
||||
|
||||
_delete_repo(session_browser, repo_name, ignore_missing=True)
|
||||
_create_repo(session_browser, repo_name, access)
|
||||
|
||||
assert _repo_exists(session_browser, repo_name, access)
|
||||
assert _site_repo_exists(session_browser, repo_name)
|
||||
|
||||
if access == "public":
|
||||
assert _repo_is_readable(repo_name)
|
||||
else:
|
||||
assert not _repo_is_readable(repo_name)
|
||||
if app_status == "enabled":
|
||||
assert _site_repo_exists(session_browser, repo_name)
|
||||
|
||||
assert not _repo_is_writable(repo_name)
|
||||
assert _repo_is_readable(repo_name, with_auth=True)
|
||||
assert _repo_is_writable(repo_name, with_auth=True)
|
||||
if access == "public":
|
||||
assert _repo_is_readable(repo_name)
|
||||
else:
|
||||
assert not _repo_is_readable(repo_name)
|
||||
|
||||
assert not _repo_is_writable(repo_name)
|
||||
assert _repo_is_readable(repo_name, with_auth=True)
|
||||
assert _repo_is_writable(repo_name, with_auth=True)
|
||||
|
||||
_delete_repo(session_browser, repo_name)
|
||||
assert not _repo_exists(session_browser, repo_name)
|
||||
@ -93,8 +100,12 @@ class TestGitwebApp(functional.BaseAppTests):
|
||||
assert _site_repo_exists(session_browser, 'Test-repo')
|
||||
assert not _site_repo_exists(session_browser, 'Test-repo-private')
|
||||
|
||||
def test_edit_repo_metadata(self, session_browser):
|
||||
@pytest.mark.parametrize('app_status', ['enabled', 'disabled'])
|
||||
def test_edit_repo_metadata(self, session_browser, app_status):
|
||||
"""Test edit repo metadata."""
|
||||
if app_status == "disabled":
|
||||
functional.app_disable(session_browser, 'gitweb')
|
||||
|
||||
_create_repo(session_browser, 'Test-repo2', 'public',
|
||||
ok_if_exists=True)
|
||||
_delete_repo(session_browser, 'Test-repo', ignore_missing=True)
|
||||
@ -108,10 +119,12 @@ class TestGitwebApp(functional.BaseAppTests):
|
||||
assert _get_repo_metadata(session_browser,
|
||||
"Test-repo") == repo_metadata
|
||||
|
||||
_create_branch('Test-repo', 'branch1')
|
||||
_set_default_branch(session_browser, 'Test-repo', 'branch1')
|
||||
assert _get_gitweb_site_default_repo_branch(session_browser,
|
||||
'Test-repo') == 'branch1'
|
||||
if app_status == "enabled":
|
||||
_create_branch('Test-repo', 'branch1')
|
||||
_set_default_branch(session_browser, 'Test-repo', 'branch1')
|
||||
|
||||
assert _get_gitweb_site_default_repo_branch(
|
||||
session_browser, 'Test-repo') == 'branch1'
|
||||
|
||||
|
||||
def _create_local_repo(path):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user