Esempio n. 1
0
    def test_email_send_reservation_order_to_all_contacts(self):
        admin_user = User.objects.create_superuser("myuser", "*****@*****.**", "flobble")
        self.client.login(username=admin_user.username, password="******")
        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="*****@*****.**")
        manager2 = BookingContact(initial="S", surname="Tennisball", email="*****@*****.**")
        manager1.save()
        manager2.save()

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

        data = {
            "csrfmiddlewaretoken": ["L7AuiXeExZJRmqdvPe4HgxlUXbpZorJp"],
            "emails": ["*****@*****.**", "*****@*****.**"],
            "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, ["*****@*****.**", "*****@*****.**"])
Esempio n. 2
0
    def test_contacts_right(self):
        admin_user = User.objects.create_superuser("myuser", "*****@*****.**", "flobble")
        self.client.login(username=admin_user.username, password="******")
        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="*****@*****.**")
        c2 = BookingContact(initial="S", surname="Tennisball", email="*****@*****.**")
        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, "*****@*****.**")
        self.assertContains(response, "Tennisball")
        self.assertContains(response, "*****@*****.**")
        self.assertNotContains(response, "Irrelevant")
Esempio n. 3
0
    def test_email_security_resorder(self):
        admin_user = User.objects.create_superuser("myuser", "*****@*****.**", "flobble")
        self.client.login(username=admin_user.username, password="******")
        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="*****@*****.**")
        c2 = BookingContact(initial="S", surname="Tennisball", email="*****@*****.**")
        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": ["*****@*****.**"],
            "id": b.id,
        }
        response = self.client.post("/bookings_sys/sendresorder/%s/" % b.id, data)
        # nothing is sent
        self.assertEqual(len(mail.outbox), 0)