How to use delete_password method in tempest

Best Python code snippet using tempest_python

test_keyring.py

Source:test_keyring.py Github

copy

Full Screen

...29# pylint: disable=redefined-outer-name30def test_keyring_get_set_delete(keyring_filepath):31 """32 Test function for Keyring.get_password() / set_password() /33 delete_password()34 """35 kr = Keyring()36 password = 'mypassword'37 # Test that the password does not exist38 act_password = kr.get_password(keyring_filepath)39 assert act_password is None40 # Test that the password does not exist41 existed = kr.delete_password(keyring_filepath)42 assert existed is False43 # Test that setting a password succeeds44 kr.set_password(keyring_filepath, password)45 # Test that getting a password succeeds and is as expected46 act_password = kr.get_password(keyring_filepath)47 assert act_password == password48 # Delete the password49 existed = kr.delete_password(keyring_filepath)50 assert existed is True51 # Test that the password does not exist52 existed = kr.delete_password(keyring_filepath)53 assert existed is False54def test_keyring_available():55 """56 Test function for Keyring.is_available()57 """58 kr = Keyring()59 # Code to be tested60 is_avail = kr.is_available()61 assert isinstance(is_avail, bool)62 check_avail = True63 try:64 # Code to be tested65 kr.check_available()66 except Exception as exc: # pylint: disable=broad-except67 assert isinstance(exc, KeyringNotAvailable)68 check_avail = False69 assert check_avail == is_avail70@pytest.mark.skipif(71 not is_keyring_available(), reason="No keyring service available")72@pytest.mark.parametrize(73 "keyring_exc, exp_exc",74 [75 (NO_KEYRING_EXCEPTION, KeyringNotAvailable),76 (keyring.errors.KeyringError, KeyringError),77 ]78)79# pylint: disable=redefined-outer-name80def test_keyring_get_password_fail(keyring_filepath, keyring_exc, exp_exc):81 """82 Test function for Keyring.get_password() when it raises an exception83 """84 kr = Keyring()85 with mock.patch.object(keyring, 'get_password', side_effect=keyring_exc):86 with pytest.raises(exp_exc):87 # Code to be tested88 kr.get_password(keyring_filepath)89@pytest.mark.skipif(90 not is_keyring_available(), reason="No keyring service available")91@pytest.mark.parametrize(92 "keyring_exc, exp_exc",93 [94 (NO_KEYRING_EXCEPTION, KeyringNotAvailable),95 (keyring.errors.KeyringError, KeyringError),96 ]97)98# pylint: disable=redefined-outer-name99def test_keyring_set_password_fail(keyring_filepath, keyring_exc, exp_exc):100 """101 Test function for Keyring.set_password() when it raises an exception102 """103 kr = Keyring()104 with mock.patch.object(keyring, 'set_password', side_effect=keyring_exc):105 with pytest.raises(exp_exc):106 # Code to be tested107 kr.set_password(keyring_filepath, 'dummy')108@pytest.mark.skipif(109 not is_keyring_available(), reason="No keyring service available")110@pytest.mark.parametrize(111 "keyring_exc, exp_exc",112 [113 (NO_KEYRING_EXCEPTION, KeyringNotAvailable),114 (keyring.errors.KeyringError, KeyringError),115 ]116)117# pylint: disable=redefined-outer-name118def test_keyring_delete_password_fail1(keyring_filepath, keyring_exc, exp_exc):119 """120 Test function for Keyring.delete_password() when it raises an exception121 in keyring.get_password().122 """123 kr = Keyring()124 with mock.patch.object(keyring, 'get_password', side_effect=keyring_exc):125 with pytest.raises(exp_exc):126 # Code to be tested127 kr.delete_password(keyring_filepath)128@pytest.mark.skipif(129 not is_keyring_available(), reason="No keyring service available")130@pytest.mark.parametrize(131 "keyring_exc, exp_exc",132 [133 (NO_KEYRING_EXCEPTION, KeyringNotAvailable),134 (keyring.errors.KeyringError, KeyringError),135 ]136)137# pylint: disable=redefined-outer-name138def test_keyring_delete_password_fail2(keyring_filepath, keyring_exc, exp_exc):139 """140 Test function for Keyring.delete_password() when it raises an exception141 in keyring.delete_password().142 """143 kr = Keyring()144 kr.set_password(keyring_filepath, 'dummy')145 with mock.patch.object(keyring, 'delete_password', side_effect=keyring_exc):146 with pytest.raises(exp_exc):147 # Code to be tested148 kr.delete_password(keyring_filepath)149@pytest.mark.skipif(150 not is_keyring_available(), reason="No keyring service available")151@pytest.mark.parametrize(152 "keyring_exc, exp_result",153 [154 (NO_KEYRING_EXCEPTION, False),155 (keyring.errors.KeyringError, KeyringError),156 ]157)158def test_keyring_is_available_fail1(keyring_exc, exp_result):159 """160 Test function for Keyring.is_available() when it raises an exception161 in keyring.set_password().162 """163 kr = Keyring()164 with mock.patch.object(keyring, 'set_password', side_effect=keyring_exc):165 if isinstance(exp_result, type) and issubclass(exp_result, Exception):166 with pytest.raises(exp_result):167 # Code to be tested168 kr.is_available()169 else:170 # Code to be tested171 available = kr.is_available()172 assert available == exp_result173@pytest.mark.skipif(174 not is_keyring_available(), reason="No keyring service available")175@pytest.mark.parametrize(176 "keyring_exc",177 [178 (NO_KEYRING_EXCEPTION),179 (keyring.errors.KeyringError),180 ]181)182def test_keyring_is_available_fail2(keyring_exc):183 """184 Test function for Keyring.is_available() when it raises an exception185 in keyring.delete_password().186 """187 kr = Keyring()188 with mock.patch.object(189 keyring, 'delete_password', side_effect=keyring_exc):190 # Code to be tested191 available = kr.is_available()192 assert available is False193@pytest.mark.skipif(194 not is_keyring_available(), reason="No keyring service available")195def test_keyring_is_available_fail3():196 """197 Test function for Keyring.is_available() when the backend is the Chainer198 backend with an empty list of backends.199 """200 kr = Keyring()201 backend_class = keyring.backends.chainer.ChainerBackend202 with mock.patch.object(203 keyring, 'get_keyring', return_value=backend_class()):204 with mock.patch.object(205 backend_class, 'backends',206 new_callable=mock.PropertyMock) as backends_mock:207 backends_mock.return_value = []208 # Code to be tested209 available = kr.is_available()210 assert available is False211@pytest.mark.skipif(212 not is_keyring_available(), reason="No keyring service available")213def test_keyring_is_available_fail4():214 """215 Test function for Keyring.is_available() when the backend is the fail216 backend.217 """218 kr = Keyring()219 backend_class = keyring.backends.fail.Keyring220 with mock.patch.object(221 keyring, 'get_keyring', return_value=backend_class()):222 # Code to be tested223 available = kr.is_available()224 assert available is False225@pytest.mark.skipif(226 not is_keyring_available(), reason="No keyring service available")227def test_keyring_is_available_fail5():228 """229 Test function for Keyring.is_available() when the backend is the null230 backend.231 """232 kr = Keyring()233 backend_class = keyring.backends.null.Keyring234 with mock.patch.object(235 keyring, 'get_keyring', return_value=backend_class()):236 # Code to be tested237 available = kr.is_available()238 assert available is False239@pytest.mark.skipif(240 not is_keyring_available(), reason="No keyring service available")241@pytest.mark.parametrize(242 "keyring_exc, exp_exc",243 [244 (NO_KEYRING_EXCEPTION, KeyringNotAvailable),245 (keyring.errors.KeyringError, KeyringError),246 ]247)248def test_keyring_check_available_fail1(keyring_exc, exp_exc):249 """250 Test function for Keyring.check_available() when it raises an exception251 in keyring.set_password().252 """253 kr = Keyring()254 with mock.patch.object(255 keyring, 'set_password', side_effect=keyring_exc):256 with pytest.raises(exp_exc):257 # Code to be tested258 kr.check_available()259@pytest.mark.skipif(260 not is_keyring_available(), reason="No keyring service available")261@pytest.mark.parametrize(262 "keyring_exc",263 [264 (NO_KEYRING_EXCEPTION),265 (keyring.errors.KeyringError),266 ]267)268def test_keyring_check_available_fail2(keyring_exc):269 """270 Test function for Keyring.check_available() when it raises an exception271 in keyring.delete_password().272 """273 kr = Keyring()274 with mock.patch.object(275 keyring, 'delete_password', side_effect=keyring_exc):276 with pytest.raises(KeyringNotAvailable):277 # Code to be tested278 kr.check_available()279@pytest.mark.skipif(280 not is_keyring_available(), reason="No keyring service available")281def test_keyring_check_available_fail3():282 """283 Test function for Keyring.check_available() when the backend is the Chainer284 backend with an empty list of backends.285 """...

Full Screen

Full Screen

test_security.py

Source:test_security.py Github

copy

Full Screen

...3 from blackmamba.framework.security import (4 set_password, get_password, get_services, delete_password5 )6@Pythonista()7def test_delete_password():8 set_password('s', 'a', 'password')9 assert (get_password('s', 'a') == 'password')10 delete_password('s', 'a')11 assert (get_password('s', 'a') is None)12@Pythonista()13def test_pythonista_compatibility_delete_password_does_not_raise():14 delete_password('s', 'a')15 delete_password('s', 'a')16@Pythonista()17def test_set_password():18 delete_password('s', 'a')19 assert (get_password('s', 'a') is None)20 set_password('s', 'a', 'password')21 assert (get_password('s', 'a') == 'password')22 delete_password('s', 'a')23@Pythonista()24def test_pythonista_compatibility_set_password_does_not_raise():25 set_password('s', 'a', 'password')26 set_password('s', 'a', 'password2')27 delete_password('s', 'a')28@Pythonista()29def test_get_password():30 set_password('s', 'a', 'password')31 assert (get_password('s', 'a') == 'password')32 delete_password('s', 'a')33@Pythonista()34def test_pythonista_compatibility_get_password_does_not_raise():35 delete_password('s', 'a')36 assert (get_password('s', 'a') is None)37@Pythonista()38def test_against_pythonista_keychain():39 import keychain40 set_password('s', 'a', 'password')41 assert (keychain.get_password('s', 'a') == 'password')42 keychain.set_password('s', 'a', 'anotherone')43 assert (get_password('s', 'a') == 'anotherone')44 keychain.delete_password('s', 'a')45 assert (get_password('s', 'a') is None)46@Pythonista()47def test_get_services():48 # We do not want to delete all items in tests -> no test for []49 set_password('s', 'a', 'password')50 set_password('s', 'a2', 'password')51 services = get_services()52 s_services = list(filter(lambda x: x[0] == 's', services))53 assert (len(s_services) == 2)54 s_accounts = sorted([x[1] for x in s_services])55 assert (s_accounts == ['a', 'a2'])56 delete_password('s', 'a')57 delete_password('s', 'a2')58 services = get_services()59 s_services = list(filter(lambda x: x[0] == 's', services))...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1from django.urls import re_path, path2from password_manager import settings3from django.conf.urls.static import static4from . views import ( create_category, password_home, create_password, detail_password, update_hints, update_password,5 delete_password, create_generated_password, update_generated_password, delete_generated_password,6 list_generated_password, file_delete_view, file_detail_view, file_list, upload_file,7 )8urlpatterns = [9 re_path(r'^$', password_home, name='home'),10 re_path(r'^create_category$', create_category, name='create_category'),11 re_path(r'^create_password$', create_password, name='create_password'),12 path('detail/<int:pk>', detail_password, name='detail_password'),13 path('update_hints/<int:pk>', update_hints, name='update_hints'),14 path('update_password/<int:pk>', update_password, name='update_password'),15 path('delete_password/<int:pk>', delete_password, name='delete_password'),16 re_path(r'^create_generated_password$', create_generated_password, name='create_generated_password'),17 path('update_generated_password/<int:pk>', update_generated_password, name='update_generated_password'),18 path('delete_generated_password/<int:pk>', delete_generated_password, name='delete_generated_password'),19 re_path(r'^generated_passwords$', list_generated_password, name='generated_passwords'),20 re_path(r'^upload_file$', upload_file, name='upload_file'),21 re_path(r'^file_list', file_list, name='file_list'),22 path('file_detail/<int:pk>', file_detail_view, name='file_detail'),23 path('file_delete/<int:pk>', file_delete_view, name='file_delete'),24]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful