Commit 190c6ece2537e76a078c8eca02d3164b5c24d8d4

Authored by Alexis Koralewski
1 parent 8077341c
Exists in dev

Fixing test with new logout call

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