Exemple #1
0
    def test_correct_edit(self):
        client = self.app.test_client()
        client.set_app(self.app)
        do_login(client, "*****@*****.**", "alice")
        reply = client.t_get('/edit')
        self.assertEqual(reply.status_code, 200)
        form = {
            "old_password": "******",
            "firstname": "Alice Beatrice",
            "lastname": "alice",
            "new_password": "******",
            "password_repeat": "pass12",
            "email": "*****@*****.**",
            "dateofbirth": "01/01/1970",
            "telephone": "12345678900",
        }
        reply = client.t_post('/edit', data=form)
        self.assertEqual(reply.status_code,
                         302,
                         msg=reply.get_data(as_text=True))

        form = {
            "old_password": "******",
            "firstname": "Alice Beatrice",
            "lastname": "alice",
            "new_password": "******",
            "password_repeat": "alice",
            "email": "*****@*****.**",
            "dateofbirth": "01/01/1970",
            "telephone": "12345678900",
        }
        reply = client.t_post('/edit', data=form)
        self.assertEqual(reply.status_code,
                         302,
                         msg=reply.get_data(as_text=True))
    def test_delete_post_wrong_mail(self):
        client = self.setup_app()
        form = {
            "email": "*****@*****.**",
            "firstname": "asjdn",
            "lastname": "asjdn",
            "password": "******",
            "password_repeat": "42",
            "dateofbirth": "01/01/1970",
            "telephone": "01234567890",
            "ssn": ""
        }

        reply = send_registration_form(client, '/create_user', form)

        self.assertEqual(reply["status_code"], 302, msg=reply)
        do_login(client, "*****@*****.**", "42")

        reply = client.t_get('/delete')
        self.assertEqual(reply.status_code,
                         200,
                         msg=reply.get_data(as_text=True))
        reply = self.do_delete(client, "*****@*****.**", "42")
        self.assertEqual(reply.status_code,
                         400,
                         msg=reply.get_data(as_text=True))
        do_logout(client)
    def test_delete_log_as_operator(self):
        client = self.setup_app()
        form = {
            "email": "*****@*****.**",
            "firstname": "Operator",
            "lastname": "delete",
            "password": "******",
            "password_repeat": "operator",
            "dateofbirth": "01/01/1970",
            "telephone": "12345671234",
            "ssn": "",
        }

        rest = {
            "name": "deleted restaurant",
            "phone": "12345671234",
            "lat": "43.431489",
            "lon": "10.242911",
            "first_opening_hour": "13",
            "first_closing_hour": "15",
            "second_opening_hour": "19",
            "second_closing_hour": "23",
            "occupation_time": "2",
            "closed_days": ["1", "2"],
            "cuisine_type": "Pizzoria",
            "menu": "Napolitano"
        }
        reply = send_registration_form(client, '/create_operator', form)
        self.assertEqual(reply["status_code"], 302, msg=reply["html"])
        reply = client.t_get('/')
        reply = send_registration_form(client, '/create_restaurant', rest)
        self.assertEqual(reply["status_code"], 302, msg=reply["html"])

        reply = client.t_get('/delete')
        self.assertEqual(reply.status_code,
                         200,
                         msg=reply.get_data(as_text=True))

        form = {'email': "*****@*****.**", 'password': "******"}
        reply = client.t_post('/delete', data=form)
        self.assertEqual(reply.status_code,
                         302,
                         msg=reply.get_data(as_text=True))

        do_login(client, "*****@*****.**", "admin")

        reply = client.t_get('/restaurants')
        self.assertNotIn("deleted restaurant",
                         reply.get_data(as_text=True),
                         msg=reply.get_data(as_text=True))

        reply = client.t_get('/users')
        self.assertNotIn("Operator delete",
                         reply.get_data(as_text=True),
                         msg=reply.get_data(as_text=True))

        do_logout(client)

        reply = do_login(client, "*****@*****.**", "operator")
        self.assertEqual(reply.status_code, 401)
    def test_delete_log_as_health_authority(self):
        client = self.setup_app()
        do_login(client, "*****@*****.**", "health")

        reply = client.t_get('/delete')
        self.assertEqual(reply.status_code,
                         401,
                         msg=reply.get_data(as_text=True))
 def test_delete_post_bad_mail(self):
     client = self.setup_app()
     do_login(client, "*****@*****.**", "gianni")
     reply = self.do_delete(client, None, "gianni")
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
     do_logout(client)
 def test_delete_post_wrong_pass(self):
     client = self.setup_app()
     do_login(client, "*****@*****.**", "gianni")
     reply = self.do_delete(client, "*****@*****.**", "the_customer")
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
     do_logout(client)
Exemple #7
0
 def test_telephone_exist400(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "gianni")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code, 200)
     form = {"telephone": "2354673561", "old_password": "******"}
     reply = client.t_post('/edit', data=form)
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
Exemple #8
0
 def test_dateerror400(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "gianni")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code, 200)
     form = {"dateofbirth": "11/11/2030", "old_password": "******"}
     reply = client.t_post('/edit', data=form)
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
Exemple #9
0
 def test_password400(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "gianni")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code, 200)
     form = {"firstname": "Anna", "old_password": "******"}
     reply = client.t_post('/edit', data=form)
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
    def test_delete_log_as_positive_customer(self):
        client = self.setup_app()
        do_login(client, "*****@*****.**", "alice")

        reply = self.do_delete(client, "*****@*****.**", "alice")
        self.assertEqual(reply.status_code,
                         400,
                         msg=reply.get_data(as_text=True))
        self.assertIn(
            "You cannot delete your data as long as you are positive",
            reply.get_data(as_text=True),
            msg=reply.get_data(as_text=True))
Exemple #11
0
 def test_existing_ssn400(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "operator")
     form = {
         "firstname": "Operator",
         "lastname": "Operator",
         "ssn": "1234567890",
         "password": "******",
     }
     reply = client.t_post('/edit', data=form)
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
Exemple #12
0
 def test_password_repeat400(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "gianni")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code, 200)
     form = {
         "new_password": "******",
         "password_repeat": "ciao421",
         "old_password": "******"
     }
     reply = client.t_post('/edit', data=form)
     self.assertEqual(reply.status_code,
                      400,
                      msg=reply.get_data(as_text=True))
Exemple #13
0
 def test_error401(self):
     client = self.app.test_client()
     client.set_app(self.app)
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code,
                      401,
                      msg=reply.get_data(as_text=True))
     do_login(client, "*****@*****.**", "admin")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code,
                      401,
                      msg=reply.get_data(as_text=True))
     do_logout(client)
     do_login(client, "*****@*****.**", "health")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code,
                      401,
                      msg=reply.get_data(as_text=True))
    def test_delete_log_as_customer(self):
        client = self.setup_app()

        form = {
            "email": "*****@*****.**",
            "firstname": "asjdn",
            "lastname": "asjdn",
            "password": "******",
            "password_repeat": "42",
            "dateofbirth": "01/01/1970",
            "telephone": "01234567890",
            "ssn": ""
        }

        reply = send_registration_form(client, '/create_user', form)

        self.assertEqual(reply["status_code"], 302, msg=reply)
        do_login(client, "*****@*****.**", "42")

        reply = client.t_get('/delete')
        self.assertEqual(reply.status_code,
                         200,
                         msg=reply.get_data(as_text=True))

        form = {"email": form["email"], "password": form["password"]}
        reply = client.t_post('/delete', data=form)
        self.assertEqual(reply.status_code,
                         302,
                         msg=reply.get_data(as_text=True))
        reply = client.t_get('/')
        self.assertIn("success",
                      reply.get_data(as_text=True),
                      msg=reply.get_data(as_text=True))

        do_login(client, "*****@*****.**", "admin")
        reply = client.t_get('/users')
        self.assertNotIn("asjdn asjdn",
                         reply.get_data(as_text=True),
                         msg=reply.get_data(as_text=True))
        do_logout(client)

        reply = do_login(client, "*****@*****.**", "42")
        self.assertEqual(reply.status_code, 401)
Exemple #15
0
 def test_get_operator200(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "operator")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code, 200)
Exemple #16
0
 def test_get_customer200(self):
     client = self.app.test_client()
     client.set_app(self.app)
     do_login(client, "*****@*****.**", "gianni")
     reply = client.t_get('/edit')
     self.assertEqual(reply.status_code, 200)