Commit 190c6ece2537e76a078c8eca02d3164b5c24d8d4
1 parent
8077341c
Exists in
dev
Fixing test with new logout call
Showing
7 changed files
with
18 additions
and
14 deletions
Show diff stats
CHANGELOG
1 | -30-08-2022 (AKo): v0.5.3.1 | 1 | +30-08-2022 (AKo): v0.5.3.2 |
2 | - Pyros container has fix hostname (hostname of local machine) | 2 | - Pyros container has fix hostname (hostname of local machine) |
3 | - Adding switch of database if we're not in docker and not on the computer that host the database | 3 | - Adding switch of database if we're not in docker and not on the computer that host the database |
4 | - Add fix IP adress for db_pyros and pyros container, updating database.env files to connect to db_pyros | 4 | - Add fix IP adress for db_pyros and pyros container, updating database.env files to connect to db_pyros |
5 | - Add new shell script for build (with verification that user isn't root) | 5 | - Add new shell script for build (with verification that user isn't root) |
6 | - Fixing endofline issue of windows | 6 | - Fixing endofline issue of windows |
7 | - Update logout for Django 4.1 (Send form POST) | 7 | - Update logout for Django 4.1 (Send form POST) |
8 | - | 8 | + - Fixing test with new logout call |
9 | + | ||
9 | 29-08-2022 (AKo): v0.5.2.1 | 10 | 29-08-2022 (AKo): v0.5.2.1 |
10 | - Adding colors for recieved and sended commands of an agent. | 11 | - Adding colors for recieved and sended commands of an agent. |
11 | - Renabling print when pulling git repo of guitastro | 12 | - Renabling print when pulling git repo of guitastro |
VERSION
pyros.py
@@ -705,6 +705,9 @@ def test(app): | @@ -705,6 +705,9 @@ def test(app): | ||
705 | print("Running tests") | 705 | print("Running tests") |
706 | os.environ["PATH_TO_OBSCONF_FOLDER"] = os.path.join( | 706 | os.environ["PATH_TO_OBSCONF_FOLDER"] = os.path.join( |
707 | os.path.abspath(PYROS_DJANGO_BASE_DIR), "obsconfig/fixtures/") | 707 | os.path.abspath(PYROS_DJANGO_BASE_DIR), "obsconfig/fixtures/") |
708 | + | ||
709 | + os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath( | ||
710 | + PYROS_DJANGO_BASE_DIR), "obsconfig/fixtures/observatory_configuration_ok_simple.yml") | ||
708 | os.environ["unit_name"] = "" | 711 | os.environ["unit_name"] = "" |
709 | configfile = 'config_pyros.yml' | 712 | configfile = 'config_pyros.yml' |
710 | os.environ["pyros_config_file"] = os.path.join(os.path.abspath( | 713 | os.environ["pyros_config_file"] = os.path.join(os.path.abspath( |
src/core/pyros_django/routine_manager/tests.py
@@ -124,7 +124,7 @@ class SequencesTests(TestCase): | @@ -124,7 +124,7 @@ class SequencesTests(TestCase): | ||
124 | seq.save() | 124 | seq.save() |
125 | 125 | ||
126 | def logout(self): | 126 | def logout(self): |
127 | - self.client.get(reverse("user_logout")) | 127 | + self.client.post(reverse("user_logout")) |
128 | print("Log out") | 128 | print("Log out") |
129 | 129 | ||
130 | def login_as_user(self, number): | 130 | def login_as_user(self, number): |
src/core/pyros_django/scientific_program/tests.py
@@ -50,7 +50,7 @@ class ScientificProgramTests(TestCase): | @@ -50,7 +50,7 @@ class ScientificProgramTests(TestCase): | ||
50 | self.usr8.save() | 50 | self.usr8.save() |
51 | 51 | ||
52 | def logout(self): | 52 | def logout(self): |
53 | - self.client.get(reverse("user_logout")) | 53 | + self.client.post(reverse("user_logout")) |
54 | print("Log out") | 54 | print("Log out") |
55 | def login_as_user(self,number): | 55 | def login_as_user(self,number): |
56 | if number == 1: | 56 | if number == 1: |
src/core/pyros_django/user_manager/tests.py
@@ -204,7 +204,7 @@ class UserManagerTests(TestCase): | @@ -204,7 +204,7 @@ class UserManagerTests(TestCase): | ||
204 | self.assertTrue(new_user.is_active) | 204 | self.assertTrue(new_user.is_active) |
205 | # log out as unit_pi | 205 | # log out as unit_pi |
206 | path = reverse("user_logout") | 206 | path = reverse("user_logout") |
207 | - self.client.get(path) | 207 | + self.client.post(path) |
208 | # log in as new user (toto) | 208 | # log in as new user (toto) |
209 | response = self.client.post(reverse("login_validation"),{"email":"toto@titi.fr","password":"aze"}) | 209 | response = self.client.post(reverse("login_validation"),{"email":"toto@titi.fr","password":"aze"}) |
210 | self.assertEqual(int(self.client.session['_auth_user_id']), new_user.pk) | 210 | self.assertEqual(int(self.client.session['_auth_user_id']), new_user.pk) |
@@ -243,7 +243,7 @@ class UserManagerTests(TestCase): | @@ -243,7 +243,7 @@ class UserManagerTests(TestCase): | ||
243 | response = self.client.get(reverse("user_detail",args=[user.id])) | 243 | response = self.client.get(reverse("user_detail",args=[user.id])) |
244 | self.assertEqual(response.status_code,200) | 244 | self.assertEqual(response.status_code,200) |
245 | # disconnect | 245 | # disconnect |
246 | - response = self.client.get(reverse("user_logout")) | 246 | + response = self.client.post(reverse("user_logout")) |
247 | # redirected to home page | 247 | # redirected to home page |
248 | self.assertEqual(response.status_code,302) | 248 | self.assertEqual(response.status_code,302) |
249 | self.assertNotIn('_auth_user_id',self.client.session.keys()) | 249 | self.assertNotIn('_auth_user_id',self.client.session.keys()) |
@@ -287,7 +287,7 @@ class UserManagerTests(TestCase): | @@ -287,7 +287,7 @@ class UserManagerTests(TestCase): | ||
287 | self.assertNotContains(response,"u5") | 287 | self.assertNotContains(response,"u5") |
288 | 288 | ||
289 | # disconnect u1 | 289 | # disconnect u1 |
290 | - self.client.get(reverse("user_logout")) | 290 | + self.client.post(reverse("user_logout")) |
291 | 291 | ||
292 | # connect as u2 | 292 | # connect as u2 |
293 | 293 | ||
@@ -409,7 +409,7 @@ class UserManagerTests(TestCase): | @@ -409,7 +409,7 @@ class UserManagerTests(TestCase): | ||
409 | # When a user attempt to modify another user's attribute, he will be redirected | 409 | # When a user attempt to modify another user's attribute, he will be redirected |
410 | self.assertEqual(response.status_code,302) | 410 | self.assertEqual(response.status_code,302) |
411 | # log out as u1 | 411 | # log out as u1 |
412 | - self.client.get(reverse("user_logout")) | 412 | + self.client.post(reverse("user_logout")) |
413 | # log in as u2 | 413 | # log in as u2 |
414 | response = self.client.post(reverse("login_validation"),{"email":user2.email,"password":"password123"}) | 414 | response = self.client.post(reverse("login_validation"),{"email":user2.email,"password":"password123"}) |
415 | self.assertEqual(response.status_code,302) | 415 | self.assertEqual(response.status_code,302) |
@@ -454,7 +454,7 @@ class UserManagerTests(TestCase): | @@ -454,7 +454,7 @@ class UserManagerTests(TestCase): | ||
454 | self.assertEqual(response.status_code,302) | 454 | self.assertEqual(response.status_code,302) |
455 | self.assertFalse(user.is_active) | 455 | self.assertFalse(user.is_active) |
456 | # log out as u2 | 456 | # log out as u2 |
457 | - self.client.get(reverse("user_logout")) | 457 | + self.client.post(reverse("user_logout")) |
458 | # u1 attempt to connect on PyROS | 458 | # u1 attempt to connect on PyROS |
459 | response = self.client.post(reverse("login_validation"),{"email":user.email,"password":"password123"}) | 459 | response = self.client.post(reverse("login_validation"),{"email":user.email,"password":"password123"}) |
460 | self.assertEqual(response.status_code,200) | 460 | self.assertEqual(response.status_code,200) |
@@ -470,7 +470,7 @@ class UserManagerTests(TestCase): | @@ -470,7 +470,7 @@ class UserManagerTests(TestCase): | ||
470 | self.assertEqual(response.status_code,302) | 470 | self.assertEqual(response.status_code,302) |
471 | self.assertTrue(user.is_active) | 471 | self.assertTrue(user.is_active) |
472 | # log out as u2 | 472 | # log out as u2 |
473 | - self.client.get(reverse("user_logout")) | 473 | + self.client.post(reverse("user_logout")) |
474 | # connect as u1 | 474 | # connect as u1 |
475 | response = self.client.post(reverse("login_validation"),{"email":user.email,"password":"password123"}) | 475 | response = self.client.post(reverse("login_validation"),{"email":user.email,"password":"password123"}) |
476 | self.assertEqual(response.status_code,302) | 476 | self.assertEqual(response.status_code,302) |
@@ -522,7 +522,7 @@ class UserManagerTests(TestCase): | @@ -522,7 +522,7 @@ class UserManagerTests(TestCase): | ||
522 | self.assertEqual("Unit-PI",user2.get_roles_str()) | 522 | self.assertEqual("Unit-PI",user2.get_roles_str()) |
523 | 523 | ||
524 | # log out as u1 | 524 | # log out as u1 |
525 | - self.client.get(reverse("user_logout")) | 525 | + self.client.post(reverse("user_logout")) |
526 | # log in a u2 | 526 | # log in a u2 |
527 | response = self.client.post(reverse("login_validation"),{"email":user2.email,"password":"password123"}) | 527 | response = self.client.post(reverse("login_validation"),{"email":user2.email,"password":"password123"}) |
528 | self.assertEqual(response.status_code,302) | 528 | self.assertEqual(response.status_code,302) |
@@ -640,7 +640,7 @@ class UserManagerTests(TestCase): | @@ -640,7 +640,7 @@ class UserManagerTests(TestCase): | ||
640 | self.assertNotEqual(is_user_delete,True) | 640 | self.assertNotEqual(is_user_delete,True) |
641 | 641 | ||
642 | # log out as u1 | 642 | # log out as u1 |
643 | - self.client.get(reverse("user_logout")) | 643 | + self.client.post(reverse("user_logout")) |
644 | 644 | ||
645 | # log in as u2 | 645 | # log in as u2 |
646 | response = self.client.post(reverse("login_validation"),{"email":user2.email,"password":"password123"}) | 646 | response = self.client.post(reverse("login_validation"),{"email":user2.email,"password":"password123"}) |
src/core/pyros_django/user_manager/views.py
@@ -178,7 +178,7 @@ def user_logout(request): | @@ -178,7 +178,7 @@ def user_logout(request): | ||
178 | ''' | 178 | ''' |
179 | View called to log out. Redirects on login page. | 179 | View called to log out. Redirects on login page. |
180 | ''' | 180 | ''' |
181 | - if request.POST: | 181 | + if request.method == "POST": |
182 | log.info(f"User {request.user} did action logout") | 182 | log.info(f"User {request.user} did action logout") |
183 | logout(request) | 183 | logout(request) |
184 | config = OBSConfig( | 184 | config = OBSConfig( |