Pēteris Caune
3 years ago
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
16 changed files with 291 additions and 11 deletions
-
1CHANGELOG.md
-
10README.md
-
1docker/.env
-
9hc/api/models.py
-
63hc/front/tests/test_add_pagerduty_complete.py
-
8hc/front/tests/test_add_pd.py
-
1hc/front/urls.py
-
44hc/front/views.py
-
1hc/settings.py
-
BINstatic/img/integrations/setup_pd_simple_0.png
-
BINstatic/img/integrations/setup_pd_simple_1.png
-
BINstatic/img/integrations/setup_pd_simple_2.png
-
BINstatic/img/integrations/setup_pd_simple_3.png
-
17templates/docs/self_hosted_configuration.html
-
23templates/docs/self_hosted_configuration.md
-
124templates/integrations/add_pd_simple.html
@ -0,0 +1,63 @@ |
|||
import json |
|||
|
|||
from django.test.utils import override_settings |
|||
from hc.api.models import Channel |
|||
from hc.test import BaseTestCase |
|||
from urllib.parse import urlencode |
|||
|
|||
|
|||
@override_settings(PD_APP_ID="FOOBAR") |
|||
class AddPagerDutyCompleteTestCase(BaseTestCase): |
|||
def setUp(self): |
|||
super().setUp() |
|||
|
|||
session = self.client.session |
|||
session["pagerduty"] = ("ABC", str(self.project.code)) |
|||
session.save() |
|||
|
|||
def _url(self, state="ABC"): |
|||
config = { |
|||
"account": {"name": "Foo"}, |
|||
"integration_keys": [{"integration_key": "foo", "name": "bar"}], |
|||
} |
|||
|
|||
url = "/integrations/add_pagerduty/?" |
|||
url += urlencode({"state": state, "config": json.dumps(config)}) |
|||
return url |
|||
|
|||
def test_it_adds_channel(self): |
|||
self.client.login(username="alice@example.org", password="password") |
|||
r = self.client.get(self._url()) |
|||
self.assertRedirects(r, self.channels_url) |
|||
|
|||
channel = Channel.objects.get() |
|||
self.assertEqual(channel.kind, "pd") |
|||
self.assertEqual(channel.pd_service_key, "foo") |
|||
self.assertEqual(channel.pd_account, "Foo") |
|||
|
|||
def test_it_validates_state(self): |
|||
self.client.login(username="alice@example.org", password="password") |
|||
r = self.client.get(self._url(state="XYZ")) |
|||
self.assertEqual(r.status_code, 403) |
|||
|
|||
@override_settings(PD_APP_ID=None) |
|||
def test_it_requires_app_id(self): |
|||
self.client.login(username="alice@example.org", password="password") |
|||
|
|||
r = self.client.get(self._url()) |
|||
self.assertEqual(r.status_code, 404) |
|||
|
|||
@override_settings(PD_ENABLED=False) |
|||
def test_it_requires_pd_enabled(self): |
|||
self.client.login(username="alice@example.org", password="password") |
|||
|
|||
r = self.client.get(self._url()) |
|||
self.assertEqual(r.status_code, 404) |
|||
|
|||
def test_it_requires_rw_access(self): |
|||
self.bobs_membership.rw = False |
|||
self.bobs_membership.save() |
|||
|
|||
self.client.login(username="bob@example.org", password="password") |
|||
r = self.client.get(self._url()) |
|||
self.assertEqual(r.status_code, 403) |
After Width: 1054 | Height: 776 | Size: 92 KiB |
After Width: 420 | Height: 690 | Size: 44 KiB |
After Width: 720 | Height: 559 | Size: 49 KiB |
After Width: 1007 | Height: 435 | Size: 46 KiB |
@ -0,0 +1,124 @@ |
|||
{% extends "base.html" %} |
|||
{% load humanize static hc_extras %} |
|||
|
|||
{% block title %}PagerDuty Integration for {{ site_name }}{% endblock %} |
|||
|
|||
{% block description %} |
|||
<meta name="description" content="Use {{ site_name }} with PagerDuty: configure {{ site_name }} to create a PagerDuty incident when a check goes down, and resolve it when a check goes back up."> |
|||
{% endblock %} |
|||
|
|||
{% block content %} |
|||
<div class="row"> |
|||
<div class="col-sm-12"> |
|||
<h1>PagerDuty</h1> |
|||
|
|||
<div class="jumbotron"> |
|||
{% if request.user.is_authenticated %} |
|||
<p>If your team uses <a href="https://www.pagerduty.com">PagerDuty</a>, |
|||
you can set up {{ site_name }} to create a PagerDuty incident when |
|||
a check goes down, and resolve it when a check goes back up.</p> |
|||
|
|||
{% if install_url %} |
|||
<div class="text-center"> |
|||
<div class="text-center"> |
|||
<a href="{{ install_url|safe }}" class="btn btn-lg btn-default"> |
|||
<img class="ai-icon" src="{% static 'img/integrations/pd.png' %}" alt="PagerDuty" /> |
|||
Connect PagerDuty |
|||
</a> |
|||
</div> |
|||
</div> |
|||
{% endif %} |
|||
|
|||
{% else %} |
|||
<p> |
|||
{{ site_name }} is a <strong>free</strong> and |
|||
<a href="https://github.com/healthchecks/healthchecks">open source</a> |
|||
service for monitoring your cron jobs, background processes and |
|||
scheduled tasks. Before adding PagerDuty integration, please log into |
|||
{{ site_name }}:</p> |
|||
|
|||
<div class="text-center"> |
|||
<a href="{% url 'hc-login' %}" |
|||
class="btn btn-primary btn-lg">Sign In</a> |
|||
</div> |
|||
{% endif %} |
|||
</div> |
|||
|
|||
<h2>Setup Guide</h2> |
|||
|
|||
{% if not connect_url %} |
|||
<div class="row ai-step"> |
|||
<div class="col-sm-6"> |
|||
<span class="step-no"></span> |
|||
<p> |
|||
{% if request.user.is_authenticated %} |
|||
Go |
|||
{% else %} |
|||
After logging in, go |
|||
{% endif %} |
|||
|
|||
to the <strong>Integrations</strong> page, |
|||
and click on <strong>Add Integration</strong> next to the |
|||
PagerDuty integration. |
|||
</p> |
|||
</div> |
|||
<div class="col-sm-6"> |
|||
<img |
|||
class="ai-guide-screenshot" |
|||
alt="Screenshot" |
|||
src="{% static 'img/integrations/setup_pd_simple_0.png' %}"> |
|||
</div> |
|||
</div> |
|||
{% endif %} |
|||
|
|||
<div class="row ai-step"> |
|||
<div class="col-sm-6"> |
|||
<span class="step-no"></span> |
|||
<p> |
|||
Click on "Connect PagerDuty", and you will be |
|||
asked to log into your PagerDuty account. |
|||
</p> |
|||
</div> |
|||
<div class="col-sm-6"> |
|||
<img |
|||
class="ai-guide-screenshot" |
|||
alt="Screenshot" |
|||
src="{% static 'img/integrations/setup_pd_simple_1.png' %}"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row ai-step"> |
|||
<div class="col-sm-6"> |
|||
<span class="step-no"></span> |
|||
<p> |
|||
Next, PagerDuty will let set the services |
|||
for this integration. |
|||
</p> |
|||
</div> |
|||
<div class="col-sm-6"> |
|||
<img |
|||
class="ai-guide-screenshot" |
|||
alt="Screenshot" |
|||
src="{% static 'img/integrations/setup_pd_simple_2.png' %}"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row ai-step"> |
|||
<div class="col-sm-6"> |
|||
<span class="step-no"></span> |
|||
<p> |
|||
And that is all! You will then be redirected back to |
|||
"Integrations" page on {{ site_name }} and see |
|||
the new integration! |
|||
</p> |
|||
</div> |
|||
<div class="col-sm-6"> |
|||
<img |
|||
class="ai-guide-screenshot" |
|||
alt="Screenshot" |
|||
src="{% static 'img/integrations/setup_pd_simple_3.png' %}"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
{% endblock %} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue