def test_prayer_subscription(self):
     with app.test_client() as tester:
         signup(tester, parish="")
         login(tester)
         response = tester.post(
             "/prayer/addgroup",
             data=dict(group=TESTING_GROUP_SIGNUP_CODE),
             follow_redirects=True,
         )
     with app.test_client() as tester:
         login(tester)
         response = tester.get("/account/testing")
         self.assertTrue(b"Testing" in response.data)
         self.assertEqual(200, response.status_code)
Beispiel #2
0
 def test_counter_displayed(self):
     tester = app.test_client(self)
     response = tester.get("/barrelracing/counter", content_type="html/text")
     self.assertTrue(b"is currently" in response.data)
     with open("/var/www/jforseth.tech/text/barrel_racing_current_number.txt", "r") as file:
         original_value = file.read()
     self.assertTrue(original_value, str(response.data))
Beispiel #3
0
 def test_todo_relocation(self):
     with app.test_client() as tester:
         taskname = token_urlsafe(10)
         taskid = 0
         login(tester)
         add_todo(tester, taskname)
         #Add some made up tasks
         add_todo(tester, "This is another todo.")
         add_todo(tester, "As is this.")
         add_todo(tester, "As is this.")
         add_todo(tester, "As is this.")
         add_todo(tester, "As is this.")
         with open("userdata/testing/todo/list.csv") as file:
             tasks = file.readlines()
         tasks.reverse()
         taskid = find_index(tasks, taskname)
         new_location = taskid
         while new_location == taskid:
             new_location = random.randint(0, len(tasks) - 1)
         tester.post("/todo/reorder", data=dict(taskid=taskid, taskloc=new_location))
         with open("userdata/testing/todo/list.csv") as file:
             tasks = file.readlines()
         tasks.reverse()
         taskid = find_index(tasks, taskname)
         self.assertEqual(taskid, new_location)
 def setUpClass(cls):
     app.config["TESTING"] = True
     backup("/var/www/jforseth.tech/text/videos.txt")
     backup("/var/www/jforseth.tech/database.db")
     backuptree("userdata/")
     signup(app.test_client())
     grant_access("testing", "admin")
 def test_account_no_login(self):
     tester = app.test_client(self)
     response = tester.get(
         "/account/testing", content_type="html/text", follow_redirects=False
     )
     self.assertEqual(response.status_code, 403)
     self.assertTrue(b"Oops" in response.data)
 def test_login_page(self):
     tester = app.test_client(self)
     response = tester.get("/login/", content_type="html/text")
     self.assertEqual(response.status_code, 200)
     self.assertTrue(b"Username" in response.data)
     self.assertTrue(b"Password" in response.data)
     self.assertTrue(b"Forgot Password" in response.data)
Beispiel #7
0
 def test_other_lqa_pages_logged_in(self):
     with app.test_client(self) as tester:
         response = login(tester)
         for page in range(15):
             response = tester.get("/lqa/" + str(page + 1))
             self.assertIs(200, response.status_code)
             self.assertTrue("Station " + str(page + 1), str(response.data))
 def test_writer_home_logged_in(self):
     with app.test_client() as tester:
         login(tester)
         response = tester.get("/writer")
         documents = os.listdir("userdata/testing/writer/documents/")
         for document in documents:
             self.assertTrue(document, str(response.data))
 def test_quickdraw_big_screen_begin(self):
     tester = app.test_client()
     for i in range(1, 30):
         response = tester.get("/quickdraw/bigscreen/begin")
         self.assertIs(200, response.status_code)
         self.assertTrue(b"GO!" in response.data
                         or b"Not yet" in response.data)
Beispiel #10
0
 def test_other_lqa_pages_logged_out(self):
     tester = app.test_client(self)
     for page in range(15):
         response = tester.get("/lqa/" + str(page + 1),
                               follow_redirects=True)
         self.assertIs(200, response.status_code)
         self.assertTrue(
             b"You need to sign in to use this feature." in response.data)
Beispiel #11
0
 def test_chat_submission(self):
     tester = app.test_client(self)
     response = tester.post("/messenger/result",
                            data=dict(message="Hi"),
                            follow_redirects=True)
     self.assertEqual(response.status_code, 200)
     # print(response.data)
     self.assertTrue(b"<li class='message'> Hi </li>" in response.data)
 def test_instructions_page(self):
     tester = app.test_client()
     response = tester.get("/instructions")
     self.assertEqual(200, response.status_code)
     self.assertTrue(
         b"This is the place to find more detailed instructions for all of the various pages on my site. ",
         response.data,
     )
 def test_password_change_correctly(self):
     with app.test_client() as tester:
         signup(tester)
         login(tester)
         new_password = secrets.token_urlsafe(10)
         response = tester.post(
             "/changepw",
             data=dict(
                 old_password=PROJECT_PASSWORD,
                 new_password=new_password,
                 confirm_new_password=new_password,
             ),
             follow_redirects=True,
         )
         self.assertTrue(b"Success!" in response.data)
     with app.test_client() as tester:
         login(tester, password=new_password)
Beispiel #14
0
 def test_admin_disabled(self):
     # Admin contains a number of security risks.
     # It has been disabled and should return 404.
     tester = app.test_client(self)
     response = tester.get("/DBbrowser", content_type="html/text")
     self.assertTrue(404 == response.status_code)
     response = tester.get("/error", content_type="html/text")
     self.assertTrue(404 == response.status_code)
 def test_password_change_missmatched_pws(self):
     with app.test_client() as tester:
         signup(tester)
         login(tester)
         new_password = secrets.token_urlsafe(10)
         response = tester.post(
             "/changepw",
             data=dict(
                 old_password=PROJECT_PASSWORD,
                 new_password=new_password,
                 confirm_new_password="******",
             ),
             follow_redirects=True,
         )
         self.assertTrue(b"New passwords do not match!" in response.data)
     with app.test_client() as tester:
         response = login(tester, password=new_password)
         self.assertTrue(b"Incorrect password." in response.data)
 def test_password_change_incorrect_old_pw(self):
     with app.test_client() as tester:
         signup(tester)
         login(tester)
         new_password = secrets.token_urlsafe(10)
         response = tester.post(
             "/changepw",
             data=dict(
                 old_password="******",
                 new_password=new_password,
                 confirm_new_password=new_password,
             ),
             follow_redirects=True,
         )
         self.assertTrue(b"Old password incorrect." in response.data)
     with app.test_client() as tester:
         response = login(tester, password=new_password)
         self.assertTrue(b"Incorrect password." in response.data)
 def test_delete_video(self):
     with app.test_client() as tester:
         login(tester)
         video = choose_random_video()[1]
         response = tester.post(
             "/videos/deletion", data=dict(youtube_id=video), follow_redirects=True
         )
         self.assertIs(200, response.status_code)
         self.assertNotIn(video, str(response.data))
 def test_videos_logged_out(self):
     tester = app.test_client()
     response = tester.get("/videos")
     self.assertIs(200, response.status_code)
     with open("/var/www/jforseth.tech/text/videos.txt") as file:
         videos = file.readlines()
     videos = [video.split("|")[0] for video in videos]
     for video in videos:
         self.assertTrue(video, str(response.data))
Beispiel #19
0
 def test_todo_submission(self):
     with app.test_client() as tester:
         taskname = token_urlsafe(10)
         login(tester)
         response = add_todo(tester, taskname)
         self.assertEqual(302, response.status_code)
         response = tester.get("/todo")
         self.assertEqual(200, response.status_code)
         self.assertTrue(taskname, str(response.data))
Beispiel #20
0
 def test_lucky_shoe_order(self):
     data = dict(
         testing="True", testing_well="False", code_working="True", code_good="False"
     )
     tester = app.test_client(self)
     response = tester.post("/luckyshoe/order", data=data)
     self.assertIs(200, response.status_code)
     for key, value in data.items():
         self.assertTrue(key, str(response.data))
         self.assertTrue(value, str(response.data))
 def test_correct_login_no_csrf(self):
     with app.test_client() as tester:
         response = tester.get("/login/")
         response = tester.post(
             "/login",
             data=dict(username="******", password=PROJECT_PASSWORD, next="/"),
             follow_redirects=True,
         )
         self.assertTrue(b"token is missing" in response.data)
         self.assertEqual(response.status_code, 200)
 def test_upload_video(self):
     with app.test_client() as tester:
         login(tester)
         response = tester.post(
             "/videos/newupload",
             data=dict(
                 title="Great Video", youtube_id="https://youtu.be/DLzxrzFCyOs"
             ),
             follow_redirects=True,
         )
         self.assertIs(200, response.status_code)
         self.assertTrue(b"Great Video" in response.data)
 def test_videos_as_admin(self):
     with app.test_client() as tester:
         login(tester)
         response = tester.get("/videos")
         self.assertIs(200, response.status_code)
         with open("/var/www/jforseth.tech/text/videos.txt") as file:
             videos = file.readlines()
         videos = [video.split("|")[0] for video in videos]
         for video in videos:
             self.assertTrue(video, str(response.data))
         #print(BeautifulSoup(response.data,'html.parser').prettify())
         self.assertTrue(b"YouTube Link" in response.data)
Beispiel #24
0
 def test_decrement(self):
     with app.test_client() as tester:
         response = tester.get("/barrelracing/counter")
         soup = BeautifulSoup(response.data, "html.parser")
         minus_value = soup.find(id="minushidden")["value"]
         response = tester.post(
             "/barrelracing/current_number_update",
             data=dict(current_number=minus_value),
             follow_redirects=True,
         )
         self.assertTrue(bytes(minus_value, "ascii") in response.data)
         self.assertIs(200, response.status_code)
 def test_account_deletion(self):
     with app.test_client() as tester:
         signup(tester)
         login(tester)
         response = tester.post(
             "/accountdel",
             data=dict(confirm_password=PROJECT_PASSWORD, follow_redirects=True),
         )
         self.assertEqual(302, response.status_code)
         self.assertTrue(
             b'<p>You should be redirected automatically to target URL: <a href="/logout">/logout</a>',
             response.data,
         )
Beispiel #26
0
 def test_chat_deletion(self):
     tester = app.test_client(self)
     response = tester.post(
         "/messenger/result",
         data=dict(
             message="This shouldn't show up after the db is cleared."),
         follow_redirects=True,
     )
     response = tester.post("/messenger/clear",
                            content_type="html/text",
                            follow_redirects=True)
     self.assertEqual(response.status_code, 200)
     self.assertTrue(b"<li class='message'>" not in response.data)
 def test_prayer_request(self):
     name = "Testing"
     parish = "TestParish"
     prequest = "This should only go to the test user. If it doesn't, something has broken. Please email me at [email protected]"
     tester = app.test_client(self)
     response = tester.post(
         "/prayer/prayerrequest",
         data=dict(name=name, parish=parish, prequest=prequest),
     )
     responsedict = json.loads(response.data.decode("utf-8"))
     self.assertEqual(type(responsedict["emails"]), type([]))
     self.assertTrue(parish, responsedict["subject_template"])
     self.assertTrue(name, responsedict["subject_template"])
     self.assertTrue(prequest, html.unescape(responsedict["message_template"]))
Beispiel #28
0
 def test_todo_deletion(self):
     with app.test_client() as tester:
         taskname = token_urlsafe(10)
         taskid = 0
         login(tester)
         add_todo(tester, taskname)
         with open("userdata/testing/todo/list.csv") as file:
             tasks = file.readlines()
         tasks.reverse()
         taskid = find_index(tasks, taskname)
         response = tester.post("/todo/delete", data=dict(taskid=taskid))
         self.assertEqual(302, response.status_code)
         response = tester.get("/todo")
         self.assertEqual(200, response.status_code)
         self.assertNotIn(taskname, str(response.data))
    def test_editing_sign(self):
        tester = app.test_client()

        random_string = secrets.token_urlsafe(10)

        with open("/var/www/jforseth.tech/text/sign_text.txt", "r") as file:
            original_text = file.read()
        self.assertNotEqual(original_text, random_string)

        response = tester.get("/sign/update",
                              query_string=dict(text=random_string))
        self.assertEqual(200, response.status_code)

        with open("/var/www/jforseth.tech/text/sign_text.txt", "r") as file:
            current_text = file.read()
        self.assertEqual(current_text, random_string)
 def test_incorrect_username(self):
     with app.test_client() as tester:
         response = tester.get("/login/")
         soup = BeautifulSoup(response.data, "html.parser")
         token = soup.find(id="csrf_token")["value"]
         response = tester.post(
             "/login",
             data=dict(
                 csrf_token=token,
                 username="******",
                 password=PROJECT_PASSWORD,
                 next="/",
             ),
             follow_redirects=True,
         )
         self.assertTrue(b"Account not found" in response.data)
         self.assertEqual(response.status_code, 401)