X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest_admin_topics.py;h=90f4acdbe088e54b2d0101bca802d8466f0674af;hb=refs%2Fchanges%2F20%2F13320%2F3;hp=734a2896ad81c835f08ae8918dafa48bb280eea6;hpb=4568a372eb5a204e04d917213de03ec51f9110c1;p=osm%2FNBI.git diff --git a/osm_nbi/tests/test_admin_topics.py b/osm_nbi/tests/test_admin_topics.py index 734a289..90f4acd 100755 --- a/osm_nbi/tests/test_admin_topics.py +++ b/osm_nbi/tests/test_admin_topics.py @@ -18,12 +18,12 @@ __author__ = "Pedro de la Cruz Ramos, pedro.delacruzramos@altran.com" __date__ = "$2019-10-019" import unittest +import random from unittest import TestCase from unittest.mock import Mock, patch, call from uuid import uuid4 from http import HTTPStatus from time import time -from random import randint from osm_common import dbbase, fsbase, msgbase from osm_nbi import authconn, validation from osm_nbi.admin_topics import ( @@ -240,7 +240,10 @@ class Test_ProjectTopicAuth(TestCase): with self.subTest(i=1): self.auth.get_project_list.side_effect = [[proj], []] new_name = "new-project-name" - quotas = {"vnfds": randint(0, 100), "nsds": randint(0, 100)} + quotas = { + "vnfds": random.SystemRandom().randint(0, 100), + "nsds": random.SystemRandom().randint(0, 100), + } self.topic.edit( self.fake_session, pid, {"name": new_name, "quotas": quotas} ) @@ -255,7 +258,7 @@ class Test_ProjectTopicAuth(TestCase): self.assertEqual(content["quotas"], quotas, "Wrong quotas") with self.subTest(i=2): new_name = "other-project-name" - quotas = {"baditems": randint(0, 100)} + quotas = {"baditems": random.SystemRandom().randint(0, 100)} self.auth.get_project_list.side_effect = [[proj], []] with self.assertRaises(EngineException, msg="Accepted wrong quotas") as e: self.topic.edit( @@ -999,6 +1002,24 @@ class Test_UserTopicAuth(TestCase): norm(str(e.exception)), "Wrong exception text", ) + with self.subTest(i=3): + self.auth.get_user_list.side_effect = [[user], []] + self.auth.get_user.return_value = user + old_password = self.test_name + new_pasw = "new-password" + self.topic.edit( + self.fake_session, + uid, + { + "old_password": old_password, + "password": new_pasw, + }, + ) + content = self.auth.update_user.call_args[0][0] + self.assertEqual( + content["old_password"], old_password, "Wrong old password" + ) + self.assertEqual(content["password"], new_pasw, "Wrong user password") def test_delete_user(self): with self.subTest(i=1):