@ -10,7 +10,8 @@ class CheckTokenTestCase(TestCase): | |||||
def setUp(self): | def setUp(self): | ||||
super(CheckTokenTestCase, self).setUp() | super(CheckTokenTestCase, self).setUp() | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | |||||
self.alice.save() | self.alice.save() | ||||
self.profile = Profile(user=self.alice) | self.profile = Profile(user=self.alice) | ||||
@ -21,13 +22,13 @@ class CheckTokenTestCase(TestCase): | |||||
r = self.client.get("/accounts/check_token/alice/secret-token/") | r = self.client.get("/accounts/check_token/alice/secret-token/") | ||||
self.assertRedirects(r, "/checks/") | self.assertRedirects(r, "/checks/") | ||||
# After login, password should be unusable | |||||
self.alice.refresh_from_db() | |||||
assert not self.alice.has_usable_password() | |||||
# After login, token should be blank | |||||
self.profile.refresh_from_db() | |||||
self.assertEqual(self.profile.token, "") | |||||
def test_it_redirects_already_logged_in(self): | def test_it_redirects_already_logged_in(self): | ||||
# Login | # Login | ||||
self.client.get("/accounts/check_token/alice/secret-token/") | |||||
self.client.login(username="[email protected]", password="password") | |||||
# Login again, when already authenticated | # Login again, when already authenticated | ||||
r = self.client.get("/accounts/check_token/alice/secret-token/") | r = self.client.get("/accounts/check_token/alice/secret-token/") | ||||
@ -7,7 +7,7 @@ from hc.api.models import Channel | |||||
class AddChannelTestCase(TestCase): | class AddChannelTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -18,7 +18,7 @@ class AddChannelTestCase(TestCase): | |||||
url = "/integrations/add/" | url = "/integrations/add/" | ||||
form = {"kind": "email", "value": "[email protected]"} | form = {"kind": "email", "value": "[email protected]"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, form) | r = self.client.post(url, form) | ||||
self.assertRedirects(r, "/integrations/") | self.assertRedirects(r, "/integrations/") | ||||
@ -30,7 +30,7 @@ class AddChannelTestCase(TestCase): | |||||
url = "/integrations/add/" | url = "/integrations/add/" | ||||
form = {"kind": "email", "value": " [email protected] "} | form = {"kind": "email", "value": " [email protected] "} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
self.client.post(url, form) | self.client.post(url, form) | ||||
q = Channel.objects.filter(value="[email protected]") | q = Channel.objects.filter(value="[email protected]") | ||||
@ -40,20 +40,20 @@ class AddChannelTestCase(TestCase): | |||||
url = "/integrations/add/" | url = "/integrations/add/" | ||||
form = {"kind": "dog", "value": "Lassie"} | form = {"kind": "dog", "value": "Lassie"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, form) | r = self.client.post(url, form) | ||||
assert r.status_code == 400, r.status_code | assert r.status_code == 400, r.status_code | ||||
def test_instructions_work(self): | def test_instructions_work(self): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
for frag in ("email", "webhook", "pd", "pushover", "slack", "hipchat"): | for frag in ("email", "webhook", "pd", "pushover", "slack", "hipchat"): | ||||
url = "/integrations/add_%s/" % frag | url = "/integrations/add_%s/" % frag | ||||
r = self.client.get(url) | r = self.client.get(url) | ||||
self.assertContains(r, "Integration Settings", status_code=200) | self.assertContains(r, "Integration Settings", status_code=200) | ||||
def test_it_adds_pushover_channel(self): | def test_it_adds_pushover_channel(self): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
session = self.client.session | session = self.client.session | ||||
session["po_nonce"] = "n" | session["po_nonce"] = "n" | ||||
@ -68,7 +68,7 @@ class AddChannelTestCase(TestCase): | |||||
assert channels[0].value == "a|0" | assert channels[0].value == "a|0" | ||||
def test_it_validates_pushover_priority(self): | def test_it_validates_pushover_priority(self): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
session = self.client.session | session = self.client.session | ||||
session["po_nonce"] = "n" | session["po_nonce"] = "n" | ||||
@ -79,7 +79,7 @@ class AddChannelTestCase(TestCase): | |||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
def test_it_validates_pushover_nonce(self): | def test_it_validates_pushover_nonce(self): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
session = self.client.session | session = self.client.session | ||||
session["po_nonce"] = "n" | session["po_nonce"] = "n" | ||||
@ -6,13 +6,13 @@ from hc.api.models import Check | |||||
class AddCheckTestCase(TestCase): | class AddCheckTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
def test_it_works(self): | def test_it_works(self): | ||||
url = "/checks/add/" | url = "/checks/add/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
self.assertRedirects(r, "/checks/") | self.assertRedirects(r, "/checks/") | ||||
assert Check.objects.count() == 1 | assert Check.objects.count() == 1 |
@ -6,7 +6,7 @@ from hc.api.models import Channel | |||||
class ChannelChecksTestCase(TestCase): | class ChannelChecksTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -17,19 +17,19 @@ class ChannelChecksTestCase(TestCase): | |||||
def test_it_works(self): | def test_it_works(self): | ||||
url = "/integrations/%s/checks/" % self.channel.code | url = "/integrations/%s/checks/" % self.channel.code | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
self.assertContains(r, "[email protected]", status_code=200) | self.assertContains(r, "[email protected]", status_code=200) | ||||
def test_it_checks_owner(self): | def test_it_checks_owner(self): | ||||
mallory = User(username="mallory") | |||||
mallory = User(username="mallory", email="[email protected]") | |||||
mallory.set_password("password") | mallory.set_password("password") | ||||
mallory.save() | mallory.save() | ||||
# channel does not belong to mallory so this should come back | # channel does not belong to mallory so this should come back | ||||
# with 403 Forbidden: | # with 403 Forbidden: | ||||
url = "/integrations/%s/checks/" % self.channel.code | url = "/integrations/%s/checks/" % self.channel.code | ||||
self.client.login(username="mallory", password="password") | |||||
self.client.login(username="mallory@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 403 | assert r.status_code == 403 | ||||
@ -37,6 +37,6 @@ class ChannelChecksTestCase(TestCase): | |||||
# Valid UUID but there is no channel for it: | # Valid UUID but there is no channel for it: | ||||
url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/checks/" | url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/checks/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 404 | assert r.status_code == 404 |
@ -6,7 +6,7 @@ from hc.api.models import Check, Ping | |||||
class LogTestCase(TestCase): | class LogTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -19,14 +19,14 @@ class LogTestCase(TestCase): | |||||
def test_it_works(self): | def test_it_works(self): | ||||
url = "/checks/%s/log/" % self.check.code | url = "/checks/%s/log/" % self.check.code | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
self.assertContains(r, "Dates and times are", status_code=200) | self.assertContains(r, "Dates and times are", status_code=200) | ||||
def test_it_handles_bad_uuid(self): | def test_it_handles_bad_uuid(self): | ||||
url = "/checks/not-uuid/log/" | url = "/checks/not-uuid/log/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
@ -34,16 +34,16 @@ class LogTestCase(TestCase): | |||||
# Valid UUID but there is no check for it: | # Valid UUID but there is no check for it: | ||||
url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/log/" | url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/log/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 404 | assert r.status_code == 404 | ||||
def test_it_checks_ownership(self): | def test_it_checks_ownership(self): | ||||
charlie = User(username="charlie") | |||||
charlie = User(username="charlie", email="[email protected]") | |||||
charlie.set_password("password") | charlie.set_password("password") | ||||
charlie.save() | charlie.save() | ||||
url = "/checks/%s/log/" % self.check.code | url = "/checks/%s/log/" % self.check.code | ||||
self.client.login(username="charlie", password="password") | |||||
self.client.login(username="charlie@example.org", password="password") | |||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 403 | assert r.status_code == 403 |
@ -6,7 +6,7 @@ from hc.api.models import Check | |||||
class MyChecksTestCase(TestCase): | class MyChecksTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -14,6 +14,6 @@ class MyChecksTestCase(TestCase): | |||||
self.check.save() | self.check.save() | ||||
def test_it_works(self): | def test_it_works(self): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get("/checks/") | r = self.client.get("/checks/") | ||||
self.assertContains(r, "Alice Was Here", status_code=200) | self.assertContains(r, "Alice Was Here", status_code=200) |
@ -6,7 +6,7 @@ from hc.api.models import Channel | |||||
class RemoveChannelTestCase(TestCase): | class RemoveChannelTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -17,7 +17,7 @@ class RemoveChannelTestCase(TestCase): | |||||
def test_it_works(self): | def test_it_works(self): | ||||
url = "/integrations/%s/remove/" % self.channel.code | url = "/integrations/%s/remove/" % self.channel.code | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
self.assertRedirects(r, "/integrations/") | self.assertRedirects(r, "/integrations/") | ||||
@ -26,18 +26,18 @@ class RemoveChannelTestCase(TestCase): | |||||
def test_it_handles_bad_uuid(self): | def test_it_handles_bad_uuid(self): | ||||
url = "/integrations/not-uuid/remove/" | url = "/integrations/not-uuid/remove/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
def test_it_checks_owner(self): | def test_it_checks_owner(self): | ||||
url = "/integrations/%s/remove/" % self.channel.code | url = "/integrations/%s/remove/" % self.channel.code | ||||
mallory = User(username="mallory") | |||||
mallory = User(username="mallory", email="[email protected]") | |||||
mallory.set_password("password") | mallory.set_password("password") | ||||
mallory.save() | mallory.save() | ||||
self.client.login(username="mallory", password="password") | |||||
self.client.login(username="mallory@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 403 | assert r.status_code == 403 | ||||
@ -45,6 +45,6 @@ class RemoveChannelTestCase(TestCase): | |||||
# Valid UUID but there is no channel for it: | # Valid UUID but there is no channel for it: | ||||
url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/" | url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 404 | assert r.status_code == 404 |
@ -6,7 +6,7 @@ from hc.api.models import Check | |||||
class RemoveCheckTestCase(TestCase): | class RemoveCheckTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -16,7 +16,7 @@ class RemoveCheckTestCase(TestCase): | |||||
def test_it_works(self): | def test_it_works(self): | ||||
url = "/checks/%s/remove/" % self.check.code | url = "/checks/%s/remove/" % self.check.code | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
self.assertRedirects(r, "/checks/") | self.assertRedirects(r, "/checks/") | ||||
@ -25,18 +25,18 @@ class RemoveCheckTestCase(TestCase): | |||||
def test_it_handles_bad_uuid(self): | def test_it_handles_bad_uuid(self): | ||||
url = "/checks/not-uuid/remove/" | url = "/checks/not-uuid/remove/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
def test_it_checks_owner(self): | def test_it_checks_owner(self): | ||||
url = "/checks/%s/remove/" % self.check.code | url = "/checks/%s/remove/" % self.check.code | ||||
mallory = User(username="mallory") | |||||
mallory = User(username="mallory", email="[email protected]") | |||||
mallory.set_password("password") | mallory.set_password("password") | ||||
mallory.save() | mallory.save() | ||||
self.client.login(username="mallory", password="password") | |||||
self.client.login(username="mallory@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 403 | assert r.status_code == 403 | ||||
@ -44,6 +44,6 @@ class RemoveCheckTestCase(TestCase): | |||||
# Valid UUID but there is no check for it: | # Valid UUID but there is no check for it: | ||||
url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/" | url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 404 | assert r.status_code == 404 |
@ -6,7 +6,7 @@ from hc.api.models import Channel, Check | |||||
class UpdateChannelTestCase(TestCase): | class UpdateChannelTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -23,7 +23,7 @@ class UpdateChannelTestCase(TestCase): | |||||
"check-%s" % self.check.code: True | "check-%s" % self.check.code: True | ||||
} | } | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post("/integrations/", data=payload) | r = self.client.post("/integrations/", data=payload) | ||||
self.assertRedirects(r, "/integrations/") | self.assertRedirects(r, "/integrations/") | ||||
@ -33,20 +33,20 @@ class UpdateChannelTestCase(TestCase): | |||||
assert checks[0].code == self.check.code | assert checks[0].code == self.check.code | ||||
def test_it_checks_channel_user(self): | def test_it_checks_channel_user(self): | ||||
mallory = User(username="mallory") | |||||
mallory = User(username="mallory", email="[email protected]") | |||||
mallory.set_password("password") | mallory.set_password("password") | ||||
mallory.save() | mallory.save() | ||||
payload = {"channel": self.channel.code} | payload = {"channel": self.channel.code} | ||||
self.client.login(username="mallory", password="password") | |||||
self.client.login(username="mallory@example.org", password="password") | |||||
r = self.client.post("/integrations/", data=payload) | r = self.client.post("/integrations/", data=payload) | ||||
# self.channel does not belong to mallory, this should fail-- | # self.channel does not belong to mallory, this should fail-- | ||||
assert r.status_code == 403 | assert r.status_code == 403 | ||||
def test_it_checks_check_user(self): | def test_it_checks_check_user(self): | ||||
mallory = User(username="mallory") | |||||
mallory = User(username="mallory", email="[email protected]") | |||||
mallory.set_password("password") | mallory.set_password("password") | ||||
mallory.save() | mallory.save() | ||||
@ -58,7 +58,7 @@ class UpdateChannelTestCase(TestCase): | |||||
"channel": mc.code, | "channel": mc.code, | ||||
"check-%s" % self.check.code: True | "check-%s" % self.check.code: True | ||||
} | } | ||||
self.client.login(username="mallory", password="password") | |||||
self.client.login(username="mallory@example.org", password="password") | |||||
r = self.client.post("/integrations/", data=payload) | r = self.client.post("/integrations/", data=payload) | ||||
# mc belongs to mallorym but self.check does not-- | # mc belongs to mallorym but self.check does not-- | ||||
@ -68,7 +68,7 @@ class UpdateChannelTestCase(TestCase): | |||||
# Correct UUID but there is no channel for it: | # Correct UUID but there is no channel for it: | ||||
payload = {"channel": "6837d6ec-fc08-4da5-a67f-08a9ed1ccf62"} | payload = {"channel": "6837d6ec-fc08-4da5-a67f-08a9ed1ccf62"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post("/integrations/", data=payload) | r = self.client.post("/integrations/", data=payload) | ||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
@ -79,6 +79,6 @@ class UpdateChannelTestCase(TestCase): | |||||
"check-6837d6ec-fc08-4da5-a67f-08a9ed1ccf62": True | "check-6837d6ec-fc08-4da5-a67f-08a9ed1ccf62": True | ||||
} | } | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post("/integrations/", data=payload) | r = self.client.post("/integrations/", data=payload) | ||||
assert r.status_code == 400 | assert r.status_code == 400 |
@ -6,7 +6,7 @@ from hc.api.models import Check | |||||
class UpdateNameTestCase(TestCase): | class UpdateNameTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -17,7 +17,7 @@ class UpdateNameTestCase(TestCase): | |||||
url = "/checks/%s/name/" % self.check.code | url = "/checks/%s/name/" % self.check.code | ||||
payload = {"name": "Alice Was Here"} | payload = {"name": "Alice Was Here"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
self.assertRedirects(r, "/checks/") | self.assertRedirects(r, "/checks/") | ||||
@ -26,14 +26,14 @@ class UpdateNameTestCase(TestCase): | |||||
def test_it_checks_ownership(self): | def test_it_checks_ownership(self): | ||||
charlie = User(username="charlie") | |||||
charlie = User(username="charlie", email="[email protected]") | |||||
charlie.set_password("password") | charlie.set_password("password") | ||||
charlie.save() | charlie.save() | ||||
url = "/checks/%s/name/" % self.check.code | url = "/checks/%s/name/" % self.check.code | ||||
payload = {"name": "Charlie Sent This"} | payload = {"name": "Charlie Sent This"} | ||||
self.client.login(username="charlie", password="password") | |||||
self.client.login(username="charlie@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
assert r.status_code == 403 | assert r.status_code == 403 | ||||
@ -41,7 +41,7 @@ class UpdateNameTestCase(TestCase): | |||||
url = "/checks/not-uuid/name/" | url = "/checks/not-uuid/name/" | ||||
payload = {"name": "Alice Was Here"} | payload = {"name": "Alice Was Here"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
@ -50,7 +50,7 @@ class UpdateNameTestCase(TestCase): | |||||
url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/name/" | url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/name/" | ||||
payload = {"name": "Alice Was Here"} | payload = {"name": "Alice Was Here"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
assert r.status_code == 404 | assert r.status_code == 404 | ||||
@ -58,7 +58,7 @@ class UpdateNameTestCase(TestCase): | |||||
url = "/checks/%s/name/" % self.check.code | url = "/checks/%s/name/" % self.check.code | ||||
payload = {"tags": " foo bar\r\t \n baz \n"} | payload = {"tags": " foo bar\r\t \n baz \n"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
self.client.post(url, data=payload) | self.client.post(url, data=payload) | ||||
check = Check.objects.get(id=self.check.id) | check = Check.objects.get(id=self.check.id) | ||||
@ -6,7 +6,7 @@ from hc.api.models import Check | |||||
class UpdateTimeoutTestCase(TestCase): | class UpdateTimeoutTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -17,7 +17,7 @@ class UpdateTimeoutTestCase(TestCase): | |||||
url = "/checks/%s/timeout/" % self.check.code | url = "/checks/%s/timeout/" % self.check.code | ||||
payload = {"timeout": 3600, "grace": 60} | payload = {"timeout": 3600, "grace": 60} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
self.assertRedirects(r, "/checks/") | self.assertRedirects(r, "/checks/") | ||||
@ -29,7 +29,7 @@ class UpdateTimeoutTestCase(TestCase): | |||||
url = "/checks/not-uuid/timeout/" | url = "/checks/not-uuid/timeout/" | ||||
payload = {"timeout": 3600, "grace": 60} | payload = {"timeout": 3600, "grace": 60} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
assert r.status_code == 400 | assert r.status_code == 400 | ||||
@ -38,18 +38,18 @@ class UpdateTimeoutTestCase(TestCase): | |||||
url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/timeout/" | url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/timeout/" | ||||
payload = {"timeout": 3600, "grace": 60} | payload = {"timeout": 3600, "grace": 60} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
assert r.status_code == 404 | assert r.status_code == 404 | ||||
def test_it_checks_ownership(self): | def test_it_checks_ownership(self): | ||||
charlie = User(username="charlie") | |||||
charlie = User(username="charlie", email="[email protected]") | |||||
charlie.set_password("password") | charlie.set_password("password") | ||||
charlie.save() | charlie.save() | ||||
url = "/checks/%s/timeout/" % self.check.code | url = "/checks/%s/timeout/" % self.check.code | ||||
payload = {"timeout": 3600, "grace": 60} | payload = {"timeout": 3600, "grace": 60} | ||||
self.client.login(username="charlie", password="password") | |||||
self.client.login(username="charlie@example.org", password="password") | |||||
r = self.client.post(url, data=payload) | r = self.client.post(url, data=payload) | ||||
assert r.status_code == 403 | assert r.status_code == 403 |
@ -6,7 +6,7 @@ from hc.api.models import Channel | |||||
class VerifyEmailTestCase(TestCase): | class VerifyEmailTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -7,7 +7,7 @@ from mock import Mock, patch | |||||
class BillingTestCase(TestCase): | class BillingTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -23,7 +23,7 @@ class BillingTestCase(TestCase): | |||||
m2 = Mock(id="def456", amount=456) | m2 = Mock(id="def456", amount=456) | ||||
mock_braintree.Transaction.search.return_value = [m1, m2] | mock_braintree.Transaction.search.return_value = [m1, m2] | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get("/billing/") | r = self.client.get("/billing/") | ||||
self.assertContains(r, "123") | self.assertContains(r, "123") | ||||
self.assertContains(r, "def456") | self.assertContains(r, "def456") |
@ -7,7 +7,7 @@ from mock import patch | |||||
class CancelPlanTestCase(TestCase): | class CancelPlanTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -19,7 +19,7 @@ class CancelPlanTestCase(TestCase): | |||||
@patch("hc.payments.views.braintree") | @patch("hc.payments.views.braintree") | ||||
def test_it_works(self, mock_braintree): | def test_it_works(self, mock_braintree): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.post("/pricing/cancel_plan/") | r = self.client.post("/pricing/cancel_plan/") | ||||
self.assertRedirects(r, "/pricing/") | self.assertRedirects(r, "/pricing/") | ||||
@ -8,7 +8,7 @@ from mock import patch | |||||
class CreatePlanTestCase(TestCase): | class CreatePlanTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -26,7 +26,7 @@ class CreatePlanTestCase(TestCase): | |||||
def run_create_plan(self, plan_id="P5"): | def run_create_plan(self, plan_id="P5"): | ||||
form = {"plan_id": plan_id, "payment_method_nonce": "test-nonce"} | form = {"plan_id": plan_id, "payment_method_nonce": "test-nonce"} | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
return self.client.post("/pricing/create_plan/", form, follow=True) | return self.client.post("/pricing/create_plan/", form, follow=True) | ||||
@patch("hc.payments.views.braintree") | @patch("hc.payments.views.braintree") | ||||
@ -7,14 +7,14 @@ from mock import patch | |||||
class GetClientTokenTestCase(TestCase): | class GetClientTokenTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@patch("hc.payments.views.braintree") | @patch("hc.payments.views.braintree") | ||||
def test_it_works(self, mock_braintree): | def test_it_works(self, mock_braintree): | ||||
mock_braintree.ClientToken.generate.return_value = "test-token" | mock_braintree.ClientToken.generate.return_value = "test-token" | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get("/pricing/get_client_token/") | r = self.client.get("/pricing/get_client_token/") | ||||
self.assertContains(r, "test-token", status_code=200) | self.assertContains(r, "test-token", status_code=200) | ||||
@ -7,7 +7,7 @@ from mock import Mock, patch | |||||
class InvoiceTestCase(TestCase): | class InvoiceTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -25,7 +25,7 @@ class InvoiceTestCase(TestCase): | |||||
tx.created_at = None | tx.created_at = None | ||||
mock_braintree.Transaction.find.return_value = tx | mock_braintree.Transaction.find.return_value = tx | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get("/invoice/abc123/") | r = self.client.get("/invoice/abc123/") | ||||
self.assertContains(r, "ABC123") # tx.id in uppercase | self.assertContains(r, "ABC123") # tx.id in uppercase | ||||
@ -38,6 +38,6 @@ class InvoiceTestCase(TestCase): | |||||
tx.created_at = None | tx.created_at = None | ||||
mock_braintree.Transaction.find.return_value = tx | mock_braintree.Transaction.find.return_value = tx | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get("/invoice/abc123/") | r = self.client.get("/invoice/abc123/") | ||||
self.assertEqual(r.status_code, 403) | self.assertEqual(r.status_code, 403) |
@ -6,7 +6,7 @@ from hc.payments.models import Subscription | |||||
class PricingTestCase(TestCase): | class PricingTestCase(TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.alice = User(username="alice") | |||||
self.alice = User(username="alice", email="[email protected]") | |||||
self.alice.set_password("password") | self.alice.set_password("password") | ||||
self.alice.save() | self.alice.save() | ||||
@ -18,7 +18,7 @@ class PricingTestCase(TestCase): | |||||
assert Subscription.objects.count() == 0 | assert Subscription.objects.count() == 0 | ||||
def test_authenticated(self): | def test_authenticated(self): | ||||
self.client.login(username="alice", password="password") | |||||
self.client.login(username="alice@example.org", password="password") | |||||
r = self.client.get("/pricing/") | r = self.client.get("/pricing/") | ||||
self.assertContains(r, "Unlimited Checks", status_code=200) | self.assertContains(r, "Unlimited Checks", status_code=200) | ||||
@ -0,0 +1,7 @@ | |||||
$(function () { | |||||
$("#password-toggle").click(function() { | |||||
$("#password-toggle").hide(); | |||||
$("#password-block").removeClass("hide"); | |||||
}); | |||||
}); |
@ -0,0 +1,39 @@ | |||||
{% extends "base.html" %} | |||||
{% block content %} | |||||
<div class="row"> | |||||
<div class="col-sm-6 col-sm-offset-3"> | |||||
<div class="hc-dialog"> | |||||
<h1>Set a Password</h1> | |||||
<div class="dialog-body"> | |||||
<p> | |||||
Please pick a password for your healthchecks.io account. | |||||
</p> | |||||
</div> | |||||
<form method="post"> | |||||
{% csrf_token %} | |||||
<div class="form-group"> | |||||
<div class="input-group input-group-lg"> | |||||
<div class="input-group-addon"> | |||||
<span class="glyphicon glyphicon-user"></span> | |||||
</div> | |||||
<input | |||||
type="password" | |||||
class="form-control" | |||||
name="password" | |||||
placeholder="pick a password"> | |||||
</div> | |||||
</div> | |||||
<div class="clearfix"> | |||||
<button type="submit" class="btn btn-lg btn-primary pull-right"> | |||||
Set Password | |||||
</button> | |||||
</div> | |||||
</form> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endblock %} |
@ -0,0 +1,18 @@ | |||||
{% extends "base.html" %} | |||||
{% block content %} | |||||
<div class="row"> | |||||
<div class="col-sm-6 col-sm-offset-3"> | |||||
<div class="hc-dialog"> | |||||
<h1>Email with Instructions Sent!</h1> | |||||
<br /> | |||||
<p> | |||||
We've sent you an email with instructions to set | |||||
a password for your account. Please check your inbox! | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endblock %} |
@ -0,0 +1,10 @@ | |||||
<p>Hello,</p> | |||||
<p>Here's a link to set a password for your account on healthchecks.io:</p> | |||||
<p><a href="{{ set_password_link }}">{{ set_password_link }}</a></p> | |||||
<p> | |||||
--<br /> | |||||
Regards,<br /> | |||||
healthchecks.io | |||||
</p> |
@ -0,0 +1 @@ | |||||
Set password on healthchecks.io |