Example #1
0
    def test_email_send_reservation_order_to_all_contacts(self):
        admin_user = User.objects.create_superuser("myuser", "[email protected]", "flobble")
        self.client.login(username=admin_user.username, password="flobble")
        b = Booking(**getData.getModelData(self))
        villa1 = Villa.objects.create(sleeps=9, name="Villa Fabuloso", calendar="somecalendarid")
        b.house = villa1
        manager1 = BookingContact(initial="S", surname="Aardvark", email="[email protected]")
        manager2 = BookingContact(initial="S", surname="Tennisball", email="[email protected]")
        manager1.save()
        manager2.save()

        manager1.villas.add(villa1)
        manager2.villas.add(villa1)
        b.save()

        data = {
            "csrfmiddlewaretoken": ["L7AuiXeExZJRmqdvPe4HgxlUXbpZorJp"],
            "emails": ["[email protected]", "[email protected]"],
            "id": b.id,
        }

        response = self.client.post("/bookings_sys/sendresorder/%s/" % b.id, data)
        self.assertEqual(len(mail.outbox), 1)
        # One email to 2 recipients
        self.assertEqual(mail.outbox[0].to, ["[email protected]", "[email protected]"])
Example #2
0
    def test_contacts_right(self):
        admin_user = User.objects.create_superuser("myuser", "[email protected]", "flobble")
        self.client.login(username=admin_user.username, password="flobble")
        b = Booking(**getData.getModelData(self))
        villa1 = Villa.objects.create(sleeps=9, name="Villa Fabuloso", calendar="somecalendarid")
        b.house = villa1
        c1 = BookingContact(initial="S", surname="Aardvark", email="[email protected]")
        c2 = BookingContact(initial="S", surname="Tennisball", email="[email protected]")
        c1.save()
        c2.save()

        c1.villas.add(villa1)
        c2.villas.add(villa1)
        b.save()
        # print('/bookings_sys/documents/%s/' % (b.id))
        response = self.client.get("/bookings_sys/sendresorder/%s/" % (b.id))

        self.assertContains(response, "Aardvark")
        self.assertContains(response, "[email protected]")
        self.assertContains(response, "Tennisball")
        self.assertContains(response, "[email protected]")
        self.assertNotContains(response, "Irrelevant")
Example #3
0
    def test_email_security_resorder(self):
        admin_user = User.objects.create_superuser("myuser", "[email protected]", "flobble")
        self.client.login(username=admin_user.username, password="flobble")
        b = Booking(**getData.getModelData(self))
        villa1 = Villa.objects.create(sleeps=9, name="Villa Fabuloso", calendar="somecalendarid")
        b.house = villa1
        c1 = BookingContact(initial="S", surname="Aardvark", email="[email protected]")
        c2 = BookingContact(initial="S", surname="Tennisball", email="[email protected]")
        c1.save()
        c2.save()

        c1.villas.add(villa1)
        c2.villas.add(villa1)
        b.save()

        # somebody is posting unrelated email addresses to us maliciously
        data = {
            "csrfmiddlewaretoken": ["L7AuiXeExZJRmqdvPe4HgxlUXbpZorJp"],
            "emails": ["[email protected]"],
            "id": b.id,
        }
        response = self.client.post("/bookings_sys/sendresorder/%s/" % b.id, data)
        # nothing is sent
        self.assertEqual(len(mail.outbox), 0)