Skip to content
Snippets Groups Projects
Commit 7c7283f4 authored by robinwilliam.hundt's avatar robinwilliam.hundt Committed by Dominik Seeger
Browse files

Added AutoLogout test

parent 3bc6af98
No related branches found
No related tags found
1 merge request!128Merge improve testing
Pipeline #88415 failed
......@@ -4,7 +4,7 @@
max-width="30%"
v-model="logoutDialog"
>
<v-card>
<v-card id="logout-dialog">
<v-card-title class="headline">
You'll be logged out!
</v-card-title>
......@@ -82,7 +82,7 @@ export default {
this.logoutDialog = true
}
}
}, 5 * 1e3)
}, 1 * 1e3)
},
beforeDestroy () {
clearInterval(this.timer)
......
......@@ -11,7 +11,6 @@ export enum ExportType {
@Component
export class parseCSVMapMixin extends Vue {
parseCSVMap (csvMap: string) {
console.log('parsing')
let lines = csvMap.split('\n')
lines.shift() // drop the first line since it contains only headings
// TODO remove any type
......
import datetime
import time
import logging
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from core.models import UserAccount
from functional_tests.util import (login, create_browser)
from util import factory_boys as fact
log = logging.getLogger(__name__)
class TestAutoLogout(LiveServerTestCase):
browser: webdriver.Firefox = None
username = None
password = None
role = None
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.browser = create_browser()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
cls.browser.quit()
def setUp(self):
self.username = 'reviewer'
self.password = 'p'
self.role = UserAccount.TUTOR
fact.UserAccountFactory(
username=self.username,
password=self.password,
role=self.role
)
def _login(self):
login(self.browser, self.live_server_url, self.username, self.password)
def test_auto_logout_can_continue(self):
with self.settings(JWT_AUTH={
'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=5),
'JWT_ALLOW_REFRESH': True,
}
):
self._login()
initial_token = self.browser.execute_script(
'return sessionStorage["token"]'
)
logout_dialog = self.browser.find_element_by_id('logout-dialog')
WebDriverWait(self.browser, 5).until(
ec.visibility_of_element_located((By.ID, 'logout-dialog')))
logout_dialog.find_element_by_id('continue-btn').click()
# explicit sleep is unfortunately necessary here, since we need to wait
# for the initial token to expire and the site to be the same
time.sleep(2)
self.assertNotIn('login', self.browser.current_url)
new_token = self.browser.execute_script(
'return sessionStorage["token"]'
)
self.assertNotEqual(initial_token, new_token)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment