Browse Source

Remove PagerDuty Connect

PagerDuty Connect is deprecated and will be discontinued.
It is replaced by PagerDuty Simple Install Flow (see
README for setup instructions).
pull/537/head
Pēteris Caune 3 years ago
parent
commit
2d20f439dd
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
14 changed files with 13 additions and 289 deletions
  1. +2
    -2
      CHANGELOG.md
  2. +0
    -47
      hc/front/tests/test_add_pdc.py
  3. +0
    -45
      hc/front/tests/test_add_pdc_complete.py
  4. +3
    -3
      hc/front/tests/test_pd_help.py
  5. +1
    -3
      hc/front/urls.py
  6. +4
    -54
      hc/front/views.py
  7. +0
    -1
      hc/settings.py
  8. BIN
      static/img/integrations/setup_pdc_0.png
  9. BIN
      static/img/integrations/setup_pdc_1.png
  10. BIN
      static/img/integrations/setup_pdc_2.png
  11. BIN
      static/img/integrations/setup_pdc_3.png
  12. +1
    -6
      templates/front/channels.html
  13. +2
    -2
      templates/front/welcome.html
  14. +0
    -126
      templates/integrations/add_pdc.html

+ 2
- 2
CHANGELOG.md View File

@ -9,8 +9,8 @@ All notable changes to this project will be documented in this file.
- Improve the handling of unknown email addresses in the Sign In form - Improve the handling of unknown email addresses in the Sign In form
- Add support for "... is UP" SMS notifications - Add support for "... is UP" SMS notifications
- Add an option for weekly reports (in addition to monthly) - Add an option for weekly reports (in addition to monthly)
- Implement PagerDuty Simple Install Flow
- Implement dark mode (using prefers-color-scheme: dark)
- Implement PagerDuty Simple Install Flow, remove PD Connect
- Implement dark mode
## v1.20.0 - 2020-04-22 ## v1.20.0 - 2020-04-22


+ 0
- 47
hc/front/tests/test_add_pdc.py View File

@ -1,47 +0,0 @@
from django.test.utils import override_settings
from hc.api.models import Channel
from hc.test import BaseTestCase
@override_settings(PD_VENDOR_KEY="foo")
class AddPdConnectTestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.url = "/projects/%s/add_pdc/" % self.project.code
def test_it_works(self):
session = self.client.session
session["pd"] = "1234567890AB" # 12 characters
session.save()
self.client.login(username="[email protected]", password="password")
url = self.url + "1234567890AB/?service_key=123"
r = self.client.get(url, follow=True)
self.assertRedirects(r, self.channels_url)
c = Channel.objects.get()
self.assertEqual(c.kind, "pd")
self.assertEqual(c.pd_service_key, "123")
self.assertEqual(c.project, self.project)
@override_settings(PD_VENDOR_KEY=None)
def test_it_requires_vendor_key(self):
self.client.login(username="[email protected]", 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="[email protected]", 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="[email protected]", password="password")
r = self.client.get(self.url)
self.assertEqual(r.status_code, 403)

+ 0
- 45
hc/front/tests/test_add_pdc_complete.py View File

@ -1,45 +0,0 @@
from django.test.utils import override_settings
from hc.test import BaseTestCase
@override_settings(PD_VENDOR_KEY="foo")
class AddPdcCompleteTestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.url = "/projects/%s/add_pdc/" % self.project.code
self.url += "XXXXXXXXXXXX/?service_key=123"
def test_it_validates_code(self):
session = self.client.session
session["pd"] = "1234567890AB"
session.save()
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertEqual(r.status_code, 400)
@override_settings(PD_VENDOR_KEY=None)
def test_it_requires_vendor_key(self):
self.client.login(username="[email protected]", 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="[email protected]", 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()
session = self.client.session
session["pd"] = "1234567890AB"
session.save()
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertEqual(r.status_code, 403)

hc/front/tests/test_add_pdc_help.py → hc/front/tests/test_pd_help.py View File


+ 1
- 3
hc/front/urls.py View File

@ -31,7 +31,7 @@ channel_urls = [
path("add_pushover/", views.pushover_help, name="hc-pushover-help"), path("add_pushover/", views.pushover_help, name="hc-pushover-help"),
path("telegram/", views.telegram_help, name="hc-telegram-help"), path("telegram/", views.telegram_help, name="hc-telegram-help"),
path("telegram/bot/", views.telegram_bot, name="hc-telegram-webhook"), path("telegram/bot/", views.telegram_bot, name="hc-telegram-webhook"),
path("add_pdc/", views.pdc_help, name="hc-pdc-help"),
path("pagerduty/", views.pd_help, name="hc-pagerduty-help"),
path("add_slack/", views.slack_help, name="hc-slack-help"), path("add_slack/", views.slack_help, name="hc-slack-help"),
path("add_slack_btn/", views.add_slack_complete), path("add_slack_btn/", views.add_slack_complete),
path("add_telegram/", views.add_telegram, name="hc-add-telegram"), path("add_telegram/", views.add_telegram, name="hc-add-telegram"),
@ -63,8 +63,6 @@ project_urls = [
path("add_opsgenie/", views.add_opsgenie, name="hc-add-opsgenie"), path("add_opsgenie/", views.add_opsgenie, name="hc-add-opsgenie"),
path("add_pagertree/", views.add_pagertree, name="hc-add-pagertree"), path("add_pagertree/", views.add_pagertree, name="hc-add-pagertree"),
path("add_pd/", views.add_pd, name="hc-add-pd"), path("add_pd/", views.add_pd, name="hc-add-pd"),
path("add_pdc/", views.add_pdc, name="hc-add-pdc"),
path("add_pdc/<str:state>/", views.add_pdc_complete, name="hc-add-pdc-complete"),
path("add_prometheus/", views.add_prometheus, name="hc-add-prometheus"), path("add_prometheus/", views.add_prometheus, name="hc-add-prometheus"),
path("add_pushbullet/", views.add_pushbullet, name="hc-add-pushbullet"), path("add_pushbullet/", views.add_pushbullet, name="hc-add-pushbullet"),
path("add_pushover/", views.add_pushover, name="hc-add-pushover"), path("add_pushover/", views.add_pushover, name="hc-add-pushover"),


+ 4
- 54
hc/front/views.py View File

@ -311,7 +311,7 @@ def index(request):
"enable_opsgenie": settings.OPSGENIE_ENABLED is True, "enable_opsgenie": settings.OPSGENIE_ENABLED is True,
"enable_pagertree": settings.PAGERTREE_ENABLED is True, "enable_pagertree": settings.PAGERTREE_ENABLED is True,
"enable_pd": settings.PD_ENABLED is True, "enable_pd": settings.PD_ENABLED is True,
"enable_pdc": settings.PD_VENDOR_KEY is not None,
"enable_pd_simple": settings.PD_APP_ID is not None,
"enable_prometheus": settings.PROMETHEUS_ENABLED is True, "enable_prometheus": settings.PROMETHEUS_ENABLED is True,
"enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None, "enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None,
"enable_pushover": settings.PUSHOVER_API_TOKEN is not None, "enable_pushover": settings.PUSHOVER_API_TOKEN is not None,
@ -822,7 +822,6 @@ def channels(request, code):
"enable_opsgenie": settings.OPSGENIE_ENABLED is True, "enable_opsgenie": settings.OPSGENIE_ENABLED is True,
"enable_pagertree": settings.PAGERTREE_ENABLED is True, "enable_pagertree": settings.PAGERTREE_ENABLED is True,
"enable_pd": settings.PD_ENABLED is True, "enable_pd": settings.PD_ENABLED is True,
"enable_pdc": settings.PD_VENDOR_KEY is not None,
"enable_prometheus": settings.PROMETHEUS_ENABLED is True, "enable_prometheus": settings.PROMETHEUS_ENABLED is True,
"enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None, "enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None,
"enable_pushover": settings.PUSHOVER_API_TOKEN is not None, "enable_pushover": settings.PUSHOVER_API_TOKEN is not None,
@ -1148,59 +1147,10 @@ def add_pd_complete(request):
@require_setting("PD_ENABLED") @require_setting("PD_ENABLED")
@require_setting("PD_VENDOR_KEY")
def pdc_help(request):
@require_setting("PD_APP_ID")
def pd_help(request):
ctx = {"page": "channels"} ctx = {"page": "channels"}
return render(request, "integrations/add_pdc.html", ctx)
@require_setting("PD_ENABLED")
@require_setting("PD_VENDOR_KEY")
@login_required
def add_pdc(request, code):
project = _get_rw_project_for_user(request, code)
state = token_urlsafe()
callback = settings.SITE_ROOT + reverse(
"hc-add-pdc-complete", args=[project.code, state]
)
connect_url = "https://connect.pagerduty.com/connect?" + urlencode(
{"vendor": settings.PD_VENDOR_KEY, "callback": callback}
)
ctx = {"page": "channels", "project": project, "connect_url": connect_url}
request.session["pd"] = state
return render(request, "integrations/add_pdc.html", ctx)
@require_setting("PD_ENABLED")
@require_setting("PD_VENDOR_KEY")
@login_required
def add_pdc_complete(request, code, state):
if "pd" not in request.session:
return HttpResponseBadRequest()
project = _get_rw_project_for_user(request, code)
session_state = request.session.pop("pd")
if session_state != state:
return HttpResponseBadRequest()
if request.GET.get("error") == "cancelled":
messages.warning(request, "PagerDuty setup was cancelled.")
return redirect("hc-channels", project.code)
channel = Channel(kind="pd", project=project)
channel.value = json.dumps(
{
"service_key": request.GET.get("service_key"),
"account": request.GET.get("account"),
}
)
channel.save()
channel.assign_all_checks()
messages.success(request, "The PagerDuty integration has been added!")
return redirect("hc-channels", project.code)
return render(request, "integrations/add_pd_simple.html", ctx)
@require_setting("PAGERTREE_ENABLED") @require_setting("PAGERTREE_ENABLED")


+ 0
- 1
hc/settings.py View File

@ -214,7 +214,6 @@ PAGERTREE_ENABLED = envbool("PAGERTREE_ENABLED", "True")
# PagerDuty # PagerDuty
PD_ENABLED = envbool("PD_ENABLED", "True") PD_ENABLED = envbool("PD_ENABLED", "True")
PD_VENDOR_KEY = os.getenv("PD_VENDOR_KEY")
PD_APP_ID = os.getenv("PD_APP_ID") PD_APP_ID = os.getenv("PD_APP_ID")
# Prometheus # Prometheus


BIN
static/img/integrations/setup_pdc_0.png View File

Before After
Width: 1054  |  Height: 776  |  Size: 92 KiB

BIN
static/img/integrations/setup_pdc_1.png View File

Before After
Width: 752  |  Height: 584  |  Size: 34 KiB

BIN
static/img/integrations/setup_pdc_2.png View File

Before After
Width: 742  |  Height: 441  |  Size: 26 KiB

BIN
static/img/integrations/setup_pdc_3.png View File

Before After
Width: 981  |  Height: 404  |  Size: 18 KiB

+ 1
- 6
templates/front/channels.html View File

@ -311,12 +311,7 @@
<h2>PagerDuty</h2> <h2>PagerDuty</h2>
<p>On-call scheduling, alerting, and incident tracking.</p> <p>On-call scheduling, alerting, and incident tracking.</p>
{% if enable_pdc %}
<a href="{% url 'hc-add-pdc' project.code %}" class="btn btn-primary">Add Integration</a>
{% else %}
<a href="{% url 'hc-add-pd' project.code %}" class="btn btn-primary">Add Integration</a>
{% endif %}
<a href="{% url 'hc-add-pd' project.code %}" class="btn btn-primary">Add Integration</a>
</li> </li>
{% endif %} {% endif %}


+ 2
- 2
templates/front/welcome.html View File

@ -498,8 +498,8 @@
{% if enable_pd %} {% if enable_pd %}
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
{% if enable_pdc %}
<a href="{% url 'hc-pdc-help' %}" class="integration">
{% if enable_pd_simple %}
<a href="{% url 'hc-pagerduty-help' %}" class="integration">
<img src="{% static 'img/integrations/pd.png' %}" class="icon" alt="" /> <img src="{% static 'img/integrations/pd.png' %}" class="icon" alt="" />
<h3> <h3>
PagerDuty<br> PagerDuty<br>


+ 0
- 126
templates/integrations/add_pdc.html View File

@ -1,126 +0,0 @@
{% 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 connect_url %}
<div class="text-center">
<div class="text-center">
<a href="{{ connect_url|safe }}">
<img
alt="Alert with PagerDuty"
height="55" width="299"
src="{% static 'img/integrations/pd_connect_button.png' %}" />
</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_pdc_0.png' %}">
</div>
</div>
{% endif %}
<div class="row ai-step">
<div class="col-sm-6">
<span class="step-no"></span>
<p>
Click on "Alert with 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_pdc_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 name and escalation policy
for this integration.
</p>
</div>
<div class="col-sm-6">
<img
class="ai-guide-screenshot"
alt="Screenshot"
src="{% static 'img/integrations/setup_pdc_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_pdc_3.png' %}">
</div>
</div>
</div>
</div>
{% endblock %}

Loading…
Cancel
Save