Skip to content
Snippets Groups Projects
Commit e346cae0 authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'gitlab-check' into 'master'

Add a system check for GitLab settings

See merge request !241
parents 210db4b6 c7557127
No related branches found
No related tags found
1 merge request!241Add a system check for GitLab settings
......@@ -230,3 +230,25 @@ def internal_group_check(*args, **kwargs):
id='arkindex.W002',
)]
return []
@register()
@only_runserver
def gitlab_oauth_check(*args, **kwargs):
from django.conf import settings
warnings = []
app_id = getattr(settings, 'GITLAB_APP_ID', None)
app_secret = getattr(settings, 'GITLAB_APP_SECRET', None)
if not app_id:
warnings.append(Warning(
'GitLab app ID is not set; Git imports will fail.',
hint='settings.GITLAB_APP_ID = {}'.format(repr(app_id)),
id='arkindex.W003',
))
if not app_secret:
warnings.append(Warning(
'GitLab app secret is not set; Git imports will fail.',
hint='settings.GITLAB_APP_SECRET = {}'.format(repr(app_secret)),
id='arkindex.W004',
))
return warnings
......@@ -254,3 +254,28 @@ class ChecksTestCase(TestCase):
g = Group.objects.create()
settings.INTERNAL_GROUP_ID = g.id
self.assertListEqual(internal_group_check(), [])
@override_settings()
def test_gitlab_oauth_check(self):
from arkindex.project.checks import gitlab_oauth_check
del settings.GITLAB_APP_ID
del settings.GITLAB_APP_SECRET
self.assertListEqual(gitlab_oauth_check(), [
Warning(
'GitLab app ID is not set; Git imports will fail.',
hint='settings.GITLAB_APP_ID = None',
id='arkindex.W003',
),
Warning(
'GitLab app secret is not set; Git imports will fail.',
hint='settings.GITLAB_APP_SECRET = None',
id='arkindex.W004',
),
])
settings.GITLAB_APP_ID = '1234'
settings.GITLAB_APP_SECRET = 's3kr3t'
self.assertListEqual(gitlab_oauth_check(), [])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment