Best Python code snippet using fMBT_python
signin_forms_test.py
Source:signin_forms_test.py  
1# Copyright 2016 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4import unittest5from form_classification_test import FormClassificationTest6"""Unittest class for testing signin forms.7The test methods were generated by the form annotation extension8(components/test/data/password_manager/form_annotation_extension)9"""10class SignInFormsTest(FormClassificationTest):11  def test_i_360_cn(self):12    self.GoTo("http://i.360.cn/login/")13    self.CheckPwdField("INPUT[name='password'][type='password']",14                       is_pwd_creation=False)15  def test_9gag_com(self):16    self.GoTo("http://9gag.com/")17    self.Click("A.btn-mute")18    self.CheckPwdField(19        "INPUT[id='login-email-password'][name='password'][type='password']",20        is_pwd_creation=False)21  def test_login_adf_ly(self):22    self.GoTo("https://login.adf.ly/login")23    self.CheckPwdField("INPUT#loginPassword[name='password'][type='password']",24                       is_pwd_creation=False)25  def test_adobeid_na1_services_adobe_com(self):26    self.GoTo("http://www.adobe.com/")27    self.Click("SPAN.close > A")28    self.Click("LI[class*='signin'] > BUTTON")29    self.CheckPwdField(30        "INPUT[id='adobeid_password'][name='password'][type='password']"31        ".text-center",32        is_pwd_creation=False)33  def test_publishers_adsterra_net(self):34    self.GoTo("http://publishers.adsterra.net/login")35    self.CheckPwdField("INPUT[name='password'][type='password']",36                       is_pwd_creation=False)37  def test_ssl_allegro_pl(self):38    self.GoTo("http://allegro.pl/")39    SignInFormsTest.driver.maximize_window()40    self.Click(41        "DIV.header-namespace > DIV.user-links-wrapper > DIV.wrapper-fluid > "42        "UL.user-nav > LI.login:nth-child(10) > A")43    self.CheckPwdField(44        "INPUT[id='password'][name='password'][type='password'].ng-untouched",45        is_pwd_creation=False)46  def test_www_amazon_com(self):47    self.GoTo("http://www.amazon.com/")48    self.Click("A[id='nav-link-yourAccount']")49    self.CheckPwdField(50        "INPUT[id='ap_password'][name='password'][type='password']"51        ".a-input-text",52        is_pwd_creation=False)53  def test_my_screenname_aol_com(self):54    self.GoTo(55        "https://my.screenname.aol.com/_cqr/login/login.psp?sitedomain="56        "www.aol.com&lang=en&locale=us&authLev=0")57    self.CheckPwdField(58        "INPUT#pwdId1[name='password'][type='password'].inputBox",59        is_pwd_creation=False)60  def test_secure2_store_apple_com(self):61    self.GoTo("http://www.apple.com/")62    self.Click("LI[id='ac-gn-bag'].ac-gn-bag:nth-child(10) > A.ac-gn-link-bag")63    self.Click("A.ac-gn-bagview-nav-link-signIn")64    self.CheckPwdField(65        "INPUT[id='login-password'][name='login-password'][type='password']"66        ".password",67        is_pwd_creation=False)68  def test_www_baidu_com(self):69    self.GoTo("http://www.baidu.com/")70    self.Click("DIV#u1 > A[name='tj_login'].lb")71    self.CheckPwdField(72        "INPUT#TANGRAM__PSP_8__password[name='password'][type='password']"73        ".pass-text-input-password",74        is_pwd_creation=False)75  def test_blogs_forbes_com(self):76    self.GoTo("http://blogs.forbes.com/account/login/")77    self.CheckPwdField(78        "INPUT[id='login_form_password'][name='pass'][type='password']",79        is_pwd_creation=False)80  def test_secure_fly_cnet_com(self):81    self.GoTo("https://secure-fly.cnet.com/uk/user/login/")82    self.CheckPwdField(83        "INPUT#login_password[name='login[password]'][type='password']",84        is_pwd_creation=False)85  def test_passport_csdn_net(self):86    self.GoTo("https://passport.csdn.net/account/login")87    self.CheckPwdField(88        "INPUT#password[name='password'][type='password'].pass-word",89        is_pwd_creation=False)90  def test_signin_ebay_com(self):91    self.GoTo("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn")92    self.CheckPwdField("DIV#pri_signin INPUT[type='password']",93                       is_pwd_creation=False)94  def test_email_163_com(self):95    self.GoTo("http://email.163.com/")96    self.CheckPwdField("INPUT#pwdInput[name='password'][type='password']",97                       is_pwd_creation=False)98  def test_en_softonic_com(self):99    self.GoTo("http://en.softonic.com/")100    self.Click("A#header-login-link.header-site-user-btn")  # Close overlay.101    self.Click("A#header-login-link.header-site-user-btn")102    self.CheckPwdField(103        "INPUT#password[name='password'][type='password'].field-default",104        is_pwd_creation=False)105  def test_id_orange_fr(self):106    self.GoTo("https://id.orange.fr/auth_user/bin/auth_user.cgi")107    self.CheckPwdField(108        "INPUT#default_f_password[name='password'][type='password'].password",109        is_pwd_creation=False)110  def test_feedly_com(self):111    self.GoTo("https://feedly.com/v3/auth/login")112    self.CheckPwdField("INPUT[name='password'][type='password'].input-bottom",113                       is_pwd_creation=False)114  def test_gfycat_com(self):115    self.GoTo("http://gfycat.com/")116    self.Click("BUTTON.login-btn")117    self.CheckPwdField("INPUT[type='password']", is_pwd_creation=False)118  def test_github_com(self):119    self.GoTo("https://github.com/login")120    self.CheckPwdField(121        "INPUT#password[name='password'][type='password'].form-control",122        is_pwd_creation=False)123  def test_login_globo_com(self):124    self.GoTo("https://login.globo.com/login/4728")125    self.CheckPwdField(126        "INPUT[id='password'][name='password'][type='password'].password",127        is_pwd_creation=False)128  def test_www_gmx_net(self):129    self.GoTo("http://www.gmx.net/")130    self.CheckPwdField(131        "INPUT#inpLoginFreemailPassword[name='password'][type='password']",132        is_pwd_creation=False)133  def test_uk_godaddy_com(self):134    self.GoTo("https://uk.godaddy.com/")135    self.Click(136        "DIV[id='sign-in'].pc-menu-item.ux-tray > A.ux-tray-toggle.menu-title")137    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",138                       is_pwd_creation=False)139  def test_id_ifeng_com(self):140    self.GoTo("https://id.ifeng.com/user/login")141    self.CheckPwdField(142        "INPUT#userLogin_pwd[name='userLogin_pwd'][type='password'].txt_270",143        is_pwd_creation=False)144  def test_secure_imdb_com(self):145    self.GoTo("http://www.imdb.com/")146    self.Click(147        "LI[id='navUserMenu'].css_nav_menu:nth-child(1) > P.singleLine > "148        "A[id='nblogin'].cboxElement")149    self.SwitchTo("IFRAME.cboxIframe")150    self.Click("A[id='imdb-toggle'].oauth-link")151    self.CheckPwdField(152        "INPUT[id='passwordprompt'][name='password'][type='password']",153        is_pwd_creation=False)154  def test_imgur_com(self):155    self.GoTo("https://imgur.com/signin")156    self.CheckPwdField(" INPUT[name='password'][type='password']",157                       is_pwd_creation=False)158  def test_secure_indeed_com(self):159    self.GoTo("https://secure.indeed.com/account/login")160    self.CheckPwdField(161        "INPUT#signin_password[name='password'][type='password']"162        ".input_password",163        is_pwd_creation=False)164  def test_www_instagram_com(self):165    self.GoTo("https://www.instagram.com/")166    self.Click("A._k6cv7")167    self.CheckPwdField("INPUT[name='password'][type='password']._kp5f7",168                       is_pwd_creation=False)169  def test_ssl_kakaku_com(self):170    self.GoTo("https://ssl.kakaku.com/auth/id/login.asp")171    self.CheckPwdField(172        "INPUT#password[name='password'][type='password'].secPwFrm",173        is_pwd_creation=False)174  def test_kat_cr(self):175    self.GoTo("https://kat.cr/")176    self.Click("DIV.land-login > A.ajaxLink")177    self.CheckPwdField(178        "INPUT#field_password[name='password'][type='password'].botmarg5px",179        is_pwd_creation=False)180  def test_www_linkedin_com(self):181    self.GoTo("https://www.linkedin.com/")182    self.CheckPwdField(183        "INPUT#login-password[name='session_password'][type='password']",184        is_pwd_creation=False)185  def test_login_live_com(self):186    self.GoTo("https://login.live.com/login.srf")187    self.CheckPwdField("INPUT[name='passwd'][type='password'].form-control",188                       is_pwd_creation=False)189  def test_mail_ru(self):190    self.GoTo("https://mail.ru/")191    self.CheckPwdField(192        "INPUT#mailbox__password[name='Password'][type='password']"193        ".mailbox__password",194        is_pwd_creation=False)195  def test_mega_nz(self):196    self.GoTo("https://mega.nz/")197    self.Click("A.top-login-button")198    self.CheckPwdField(199        "INPUT#login-password[name='login-password'][type='password']",200        is_pwd_creation=False)201  def test_member_livedoor_com(self):202    self.GoTo("https://member.livedoor.com/login/")203    self.CheckPwdField(204        "INPUT#password[name='password'][type='password'].password",205        is_pwd_creation=False)206  def test_my_outbrain_com(self):207    self.GoTo("https://my.outbrain.com/")208    self.CheckPwdField(209        "INPUT#signin-member-password[name='loginPassword'][type='password']"210        ".input-text",211        is_pwd_creation=False)212  def test_www_naver_com(self):213    self.GoTo("http://www.naver.com/")214    self.CheckPwdField("INPUT#pw[name='pw'][type='password']",215                       is_pwd_creation=False)216  def test_ssl_naver_jp(self):217    self.GoTo("https://ssl.naver.jp/login")218    self.CheckPwdField(219        "INPUT#_passwd[name='password'][type='password'].mdInputTxt03Input",220        is_pwd_creation=False)221  def test_www_netflix_com(self):222    self.GoTo("https://www.netflix.com/gb/")223    self.Click("DIV.nfHeader > A.authLinks")224    self.CheckPwdField("INPUT[name='password'][type='password'].ui-text-input",225                       is_pwd_creation=False)226  def test_passport_bilibili_com(self):227    self.GoTo("https://passport.bilibili.com/login")228    self.CheckPwdField("INPUT#passwdTxt[name='pwd'][type='password'].password",229                       is_pwd_creation=False)230  def test_passport_china_com(self):231    self.GoTo("http://passport.china.com/")232    self.CheckPwdField("INPUT[id='55'][name='password'][type='password']",233                       is_pwd_creation=False)234  def test_www_pinterest_com(self):235    self.GoTo("https://www.pinterest.com/login/")236    self.CheckPwdField("INPUT[name='password'][type='password']",237                       is_pwd_creation=False)238  def test_www_pixnet_net(self):239    self.GoTo("https://www.pixnet.net/")240    self.CheckPwdField(241        "INPUT[id='input-password'][name='password'][type='password']",242        is_pwd_creation=False)243  def test_qq_com(self):244    self.GoTo("http://www.qq.com/")245    self.Click("A[id='loginGrayLayout'].login")246    self.SwitchTo("#login_frame")247    self.CheckPwdField("INPUT[id='p'][name='p'][type='password'].password",248                       is_pwd_creation=False)249  def test_www_rakuten_co_jp(self):250    self.GoTo("https://www.rakuten.co.jp/myrakuten/login.html")251    self.CheckPwdField("INPUT[id='passwd'][name='p'][type='password'].textBox",252                       is_pwd_creation=False)253  def test_www_reddit_com(self):254    self.GoTo("https://www.reddit.com/")255    self.Click("SPAN.user > A.login-required")256    self.CheckPwdField(257        "INPUT[id='passwd_login'][name='passwd'][type='password']"258        ".c-form-control",259        is_pwd_creation=False)260  def test_login_sina_com_cn(self):261    self.GoTo("https://login.sina.com.cn/signup/signin.php")262    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",263                       is_pwd_creation=False)264  def test_login_skype_com(self):265    self.GoTo("https://login.skype.com/login")266    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",267                       is_pwd_creation=False)268  def test_www_sohu_com(self):269    self.GoTo("http://www.sohu.com/")270    self.CheckPwdField("INPUT[name='password'][type='password'].simple-pwd",271                       is_pwd_creation=False)272  def test_soundcloud_com(self):273    self.GoTo(274        "https://soundcloud.com/connect?client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c"275        "72Ea&response_type=token&scope=non-expiring%20fast-connect%20purchase"276        "%20upload&display=next&redirect_uri=https%3A//soundcloud.com/"277        "soundcloud-callback.html")278    self.CheckPwdField(279        "INPUT[id='password'][name='password'][type='password'].sc-input",280        is_pwd_creation=False)281  def test_ssl_bbc_com(self):282    self.GoTo("https://ssl.bbc.com/id/signin")283    self.CheckPwdField(284        "INPUT[id='bbcid_password'][name='password'][type='password'].password",285        is_pwd_creation=False)286  def test_openid_stackexchange_com(self):287    self.GoTo("https://stackexchange.com/users/login?#log-in")288    self.SwitchTo("#affiliate-signin-iframe")289    self.CheckPwdField(290        "INPUT[id='password'][name='password'][type='password']"291        ".framed-text-field",292        is_pwd_creation=False)293  def test_stackoverflow_com(self):294    self.GoTo("https://stackoverflow.com/users/login")295    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",296                       is_pwd_creation=False)297  def test_store_steampowered_com(self):298    self.GoTo("https://store.steampowered.com//login/")299    self.CheckPwdField(300        "INPUT[id='input_password'][name='password'][type='password']"301        ".text_input",302        is_pwd_creation=False)303  def test_profile_theguardian_com(self):304    self.GoTo("https://profile.theguardian.com/signin")305    self.CheckPwdField(306        "INPUT[id='signin_field_password'][name='password'][type='password']"307        ".signin-form__field--password",308        is_pwd_creation=False)309  def test_thepiratebay_se(self):310    self.GoTo("https://thepiratebay.se/login")311    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",312                       is_pwd_creation=False)313  def test_torrentz_eu(self):314    self.GoTo("http://torrentz.eu/profile")315    self.CheckPwdField("INPUT[id='lpass'][name='pass'][type='password'].i",316                       is_pwd_creation=False)317  def test_login_tudou_com(self):318    self.GoTo("http://login.tudou.com/")319    self.CheckPwdField(320        "INPUT[id='password1'][name='password1'][type='password'].password",321        is_pwd_creation=False)322  def test_twitter_com(self):323    self.GoTo("https://twitter.com/")324    self.CheckPwdField(325        "INPUT[id='signin-password'][name='session[password]'][type='password']"326        ".flex-table-input",327        is_pwd_creation=False)328  def test_member_udn_com(self):329    self.GoTo("https://member.udn.com/member/login.jsp")330    self.CheckPwdField(331        "INPUT[id='password'][name='password'][type='password'].textfield",332        is_pwd_creation=False)333  def test_en_uptodown_com(self):334    SignInFormsTest.driver.maximize_window()335    self.GoTo("http://en.uptodown.com/ubuntu")336    self.Click("A.button > SPAN")337    self.CheckPwdField("INPUT[id='password'][type='password']",338                       is_pwd_creation=False)339  def test_vimeo_com(self):340    self.GoTo("https://vimeo.com/")341    self.Click("A.js-login_toggle")342    self.CheckPwdField(343        "INPUT[id='login_password'][name='password'][type='password']"344        ".js-login_password",345        is_pwd_creation=False)346  def test_web_de(self):347    self.GoTo("http://web.de/")348    self.Click("A.icon-freemail")349    self.CheckPwdField(350        "INPUT[id='inpFreemailLoginPassword'][name='password']"351        "[type='password']",352        is_pwd_creation=False)353  def test_weibo_com(self):354    self.GoTo("http://weibo.com/")355    self.Click("DIV.tab > A:nth-child(2)")356    self.CheckPwdField("INPUT[name='password'][type='password'].W_input",357                       is_pwd_creation=False)358  def test_en_wikipedia_org(self):359    self.GoTo("https://en.wikipedia.org/w/index.php?title=Special:UserLogin")360    self.CheckPwdField(361        "INPUT[id='wpPassword1'][name='wpPassword'][type='password']"362        ".loginPassword",363        is_pwd_creation=False)364  def test_www_avito_ru(self):365    self.GoTo("https://www.avito.ru/profile/login")366    self.CheckPwdField("INPUT[name='password'][type='password'].password-field",367                       is_pwd_creation=False)368  def test_www_babytree_com(self):369    self.GoTo("http://www.babytree.com/reg/login.php")370    self.CheckPwdField(371        "INPUT[name='password'][type='password'].login-input-text",372        is_pwd_creation=False)373  def test_www_booking_com(self):374    self.GoTo("http://www.booking.com/")375    self.Click("li.account_register_option div.sign_in_wrapper")376    self.CheckPwdField("INPUT[name='password'][type='password']",377                       is_pwd_creation=False)378  def test_www_buzzfeed_com(self):379    self.GoTo("http://www.buzzfeed.com/")380    self.Click(381        "DIV.page-nav__utilities > DIV[id='nav-signin'].nav-signin > "382        "DIV[id='usernav-signin'] > A[id='header-signin'].nav-signin-icon")383    self.CheckPwdField(384        "INPUT[name='password'][type='password'].js-user-password",385        is_pwd_creation=False)386  def test_www_dailymail_co_uk(self):387    self.GoTo("http://www.dailymail.co.uk/home/index.html")388    self.Click("A.js-login")389    self.CheckPwdField(390        "INPUT[id='reg-lbx-password-lightbox'][name='j_password']"391        "[type='password']",392        is_pwd_creation=False)393  def test_www_deviantart_com(self):394    self.GoTo("http://www.deviantart.com/")395    self.Click("TD[id='oh-loginbutton'] > A.oh-touch")396    self.CheckPwdField(397        "INPUT[id='login-password'][name='password'][type='password'].itext",398        is_pwd_creation=False)399  def test_www_dmm_com(self):400    self.GoTo("https://www.dmm.com/en/my/-/login/=/path=SgReFg__/")401    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",402                       is_pwd_creation=False)403  def test_www_douyu_com(self):404    self.GoTo("http://www.douyu.com/")405    SignInFormsTest.driver.maximize_window()406    self.Click("A.u-login")407    self.CheckPwdField("FORM > P > INPUT[name='password'][type='password'].ipt",408                       is_pwd_creation=False)409  def test_www_dropbox_com(self):410    self.GoTo("https://www.dropbox.com/")411    SignInFormsTest.driver.maximize_window()412    self.Click("A[id='sign-in'].sign-in")413    self.CheckPwdField("INPUT[name='login_password'][type='password']",414                       is_pwd_creation=False)415  def test_www_etsy_com(self):416    self.GoTo("https://www.etsy.com/")417    self.Click("A[id='sign-in'].signin-header-action")418    self.CheckPwdField(419        "INPUT[id='password-existing'][name='password'][type='password'].text",420        is_pwd_creation=False)421  def test_www_facebook_com(self):422    self.GoTo("https://www.facebook.com/")423    self.CheckPwdField(424        "INPUT[id='pass'][name='pass'][type='password'].inputtext",425        is_pwd_creation=False)426  def test_www_foxnews_com(self):427    self.GoTo("http://www.foxnews.com/")428    self.Click("A.login")429    self.CheckPwdField(430        "INPUT[id='capture_signIn_traditionalSignIn_password']"431        "[name='traditionalSignIn_password'][type='password']"432        ".capture_traditionalSignIn_password",433        is_pwd_creation=False)434  def test_www_homedepot_com(self):435    self.GoTo("http://www.homedepot.com/")436    self.Click("A[id='headerMyAccount'].headerMyAccount__button")437    self.Click("A.headerMyAccount__authLink")438    self.CheckPwdField(439        "INPUT[id='password'][name='logonPassword'][type='password']"440        ".width_332px",441        is_pwd_creation=False)442  def test_www_livejournal_com(self):443    self.GoTo("http://www.livejournal.com/")444    self.Click("A.s-header-item__link--login")445    self.CheckPwdField(446        "INPUT[id='lj_loginwidget_password'][name='password'][type='password']"447        ".b-input",448        is_pwd_creation=False)449  def test_www_mediafire_com(self):450    self.GoTo(451        "https://www.mediafire.com/templates/login_signup/login_signup.php")452    self.CheckPwdField(453        "INPUT[id='widget_login_pass'][name='login_pass'][type='password']",454        is_pwd_creation=False)455  def test_www_nytimes_com(self):456    self.GoTo("http://www.nytimes.com/")457    self.Click("DIV[id='instl_close'] > A.nytdGrowlNotifyCross"458              )  # Close overlay.459    self.Click("BUTTON.button.login-modal-trigger")460    self.CheckPwdField(461        "INPUT[id='login-password'][name='password'][type='password']"462        ".login-password",463        is_pwd_creation=False)464  def test_www_popads_net(self):465    self.GoTo("https://www.popads.net/")466    self.CheckPwdField(467        "INPUT[id='UserPassword'][name='data[User][password]']"468        "[type='password']",469        is_pwd_creation=False)470  def test_www_quora_com(self):471    self.GoTo("https://www.quora.com/")472    self.CheckPwdField(473        "INPUT[id*='password'][name='password'][type='password']"474        ".header_login_text_box",475        is_pwd_creation=False)476  def test_www_slideshare_net(self):477    self.GoTo("https://www.slideshare.net/login")478    self.CheckPwdField(479        "INPUT[id='user_password'][name='user_password'][type='password']",480        is_pwd_creation=False)481  def test_www_so_com(self):482    self.GoTo("https://www.so.com/")483    self.Click("A[id='user-login']")484    self.CheckPwdField(485        "INPUT[id*='password'][name='password'][type='password']"486        ".quc-input-password",487        is_pwd_creation=False)488  def test_www_sunmaker_com(self):489    self.GoTo("https://www.sunmaker.com/de/")490    self.CheckPwdField("INPUT[name='password'][type='password'].form-control",491                       is_pwd_creation=False)492  def test_www_tianya_cn(self):493    self.GoTo("http://www.tianya.cn/")494    self.CheckPwdField(495        "INPUT[id='password1'][name='vpassword'][type='password'].text-ipt",496        is_pwd_creation=False)497  def test_www_tribunnews_com(self):498    self.GoTo("http://www.tribunnews.com/")499    SignInFormsTest.driver.maximize_window()500    self.Click("A[id='login'].blue")501    self.CheckPwdField(502        "FORM[id='logform'].form  INPUT[name='password']"503        "[type='password'].input",504        is_pwd_creation=False)505  def test_www_tripadvisor_com(self):506    self.GoTo("https://www.tripadvisor.com/")507    self.Click("LI.login:nth-child(4) > SPAN.link.no_cpu")508    self.SwitchTo("#overlayRegFrame")509    self.CheckPwdField("INPUT[id='regSignIn.password'][type='password'].text",510                       is_pwd_creation=False)511  def test_www_walmart_com(self):512    self.GoTo("https://www.walmart.com/account/login")513    self.CheckPwdField(514        "INPUT[id='login-password'][name='login-password'][type='password']"515        ".js-password",516        is_pwd_creation=False)517  def test_www_wittyfeed_com(self):518    self.GoTo("http://www.wittyfeed.com/")519    self.Click("A.express")520    self.CheckPwdField(521        "DIV.signIn_passwordDiv > "522        "INPUT[name='password'][type='password'].form-control",523        is_pwd_creation=False)524  def test_www_yelp_com(self):525    self.GoTo("https://www.yelp.com/login")526    self.CheckPwdField(527        "FORM[id='ajax-login'].yform > "528        "INPUT[id='password'][name='password'][type='password']",529        is_pwd_creation=False)530  def test_www_zillow_com(self):531    self.GoTo("https://www.zillow.com")532    self.Click("A[id='login_opener'].zss-login-link")533    self.SwitchTo("DIV#login_content > IFRAME")534    self.CheckPwdField("INPUT[id='password'][name='password'][type='password']",535                       is_pwd_creation=False)536  def test_yandex_ru(self):537    self.GoTo("https://yandex.ru/")538    self.CheckPwdField("INPUT[name='passwd'][type='password'].input__input",539                       is_pwd_creation=False)540  def test_login_youku_com(self):541    self.GoTo("http://login.youku.com/user/login_win")542    self.CheckPwdField(543        "INPUT[id='password'][name='password'][type='password'].form_input",544        is_pwd_creation=False)545  def test_service_zol_com_cn(self):546    self.GoTo("http://service.zol.com.cn/user/siteLogin.php")547    self.CheckPwdField("INPUT[id='loginPwd'][type='password']",548                       is_pwd_creation=False)549if __name__ == "__main__":...pwsettings.py
Source:pwsettings.py  
1#!/usr/bin/env python2#3# Sets password settings.4# (Password complexity, history length, minimum password length, the minimum5# and maximum password age) on a Samba4 server6#7# Copyright Matthias Dieter Wallnoefer 20098# Copyright Andrew Kroeger 20099# Copyright Jelmer Vernooij 200910#11# This program is free software; you can redistribute it and/or modify12# it under the terms of the GNU General Public License as published by13# the Free Software Foundation; either version 3 of the License, or14# (at your option) any later version.15#16# This program is distributed in the hope that it will be useful,17# but WITHOUT ANY WARRANTY; without even the implied warranty of18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the19# GNU General Public License for more details.20#21# You should have received a copy of the GNU General Public License22# along with this program.  If not, see <http://www.gnu.org/licenses/>.23#24import samba.getopt as options25import ldb26from samba.auth import system_session27from samba.samdb import SamDB28from samba.dcerpc.samr import DOMAIN_PASSWORD_COMPLEX, DOMAIN_PASSWORD_STORE_CLEARTEXT29from samba.netcmd import Command, CommandError, Option30class cmd_pwsettings(Command):31    """Sets password settings32    Password complexity, history length, minimum password length, the minimum 33    and maximum password age) on a Samba4 server.34    """35    synopsis = "(show | set <options>)"36    takes_optiongroups = {37        "sambaopts": options.SambaOptions,38        "versionopts": options.VersionOptions,39        "credopts": options.CredentialsOptions,40        }41    takes_options = [42        Option("-H", help="LDB URL for database or target server", type=str),43        Option("--quiet", help="Be quiet", action="store_true"),44        Option("--complexity", type="choice", choices=["on","off","default"],45          help="The password complexity (on | off | default). Default is 'on'"),46        Option("--store-plaintext", type="choice", choices=["on","off","default"],47          help="Store plaintext passwords where account have 'store passwords with reversible encryption' set (on | off | default). Default is 'off'"),48        Option("--history-length",49          help="The password history length (<integer> | default).  Default is 24.", type=str),50        Option("--min-pwd-length",51          help="The minimum password length (<integer> | default).  Default is 7.", type=str),52        Option("--min-pwd-age",53          help="The minimum password age (<integer in days> | default).  Default is 1.", type=str),54        Option("--max-pwd-age",55          help="The maximum password age (<integer in days> | default).  Default is 43.", type=str),56          ]57    takes_args = ["subcommand"]58    def run(self, subcommand, H=None, min_pwd_age=None, max_pwd_age=None,59            quiet=False, complexity=None, store_plaintext=None, history_length=None,60            min_pwd_length=None, credopts=None, sambaopts=None,61            versionopts=None):62        lp = sambaopts.get_loadparm()63        creds = credopts.get_credentials(lp)64        samdb = SamDB(url=H, session_info=system_session(),65            credentials=creds, lp=lp)66        domain_dn = samdb.domain_dn()67        res = samdb.search(domain_dn, scope=ldb.SCOPE_BASE,68          attrs=["pwdProperties", "pwdHistoryLength", "minPwdLength",69                 "minPwdAge", "maxPwdAge"])70        assert(len(res) == 1)71        try:72            pwd_props = int(res[0]["pwdProperties"][0])73            pwd_hist_len = int(res[0]["pwdHistoryLength"][0])74            cur_min_pwd_len = int(res[0]["minPwdLength"][0])75            # ticks -> days76            cur_min_pwd_age = int(abs(int(res[0]["minPwdAge"][0])) / (1e7 * 60 * 60 * 24))77            cur_max_pwd_age = int(abs(int(res[0]["maxPwdAge"][0])) / (1e7 * 60 * 60 * 24))78        except Exception, e:79            raise CommandError("Could not retrieve password properties!", e)80        if subcommand == "show":81            self.message("Password informations for domain '%s'" % domain_dn)82            self.message("")83            if pwd_props & DOMAIN_PASSWORD_COMPLEX != 0:84                self.message("Password complexity: on")85            else:86                self.message("Password complexity: off")87            if pwd_props & DOMAIN_PASSWORD_STORE_CLEARTEXT != 0:88                self.message("Store plaintext passwords: on")89            else:90                self.message("Store plaintext passwords: off")91            self.message("Password history length: %d" % pwd_hist_len)92            self.message("Minimum password length: %d" % cur_min_pwd_len)93            self.message("Minimum password age (days): %d" % cur_min_pwd_age)94            self.message("Maximum password age (days): %d" % cur_max_pwd_age)95        elif subcommand == "set":96            msgs = []97            m = ldb.Message()98            m.dn = ldb.Dn(samdb, domain_dn)99            if complexity is not None:100                if complexity == "on" or complexity == "default":101                    pwd_props = pwd_props | DOMAIN_PASSWORD_COMPLEX102                    msgs.append("Password complexity activated!")103                elif complexity == "off":104                    pwd_props = pwd_props & (~DOMAIN_PASSWORD_COMPLEX)105                    msgs.append("Password complexity deactivated!")106            if store_plaintext is not None:107                if store_plaintext == "on" or store_plaintext == "default":108                    pwd_props = pwd_props | DOMAIN_PASSWORD_STORE_CLEARTEXT109                    msgs.append("Plaintext password storage for changed passwords activated!")110                elif store_plaintext == "off":111                    pwd_props = pwd_props & (~DOMAIN_PASSWORD_STORE_CLEARTEXT)112                    msgs.append("Plaintext password storage for changed passwords deactivated!")113            if complexity is not None or store_plaintext is not None:114                m["pwdProperties"] = ldb.MessageElement(str(pwd_props),115                  ldb.FLAG_MOD_REPLACE, "pwdProperties")116            if history_length is not None:117                if history_length == "default":118                    pwd_hist_len = 24119                else:120                    pwd_hist_len = int(history_length)121                if pwd_hist_len < 0 or pwd_hist_len > 24:122                    raise CommandError("Password history length must be in the range of 0 to 24!")123                m["pwdHistoryLength"] = ldb.MessageElement(str(pwd_hist_len),124                  ldb.FLAG_MOD_REPLACE, "pwdHistoryLength")125                msgs.append("Password history length changed!")126            if min_pwd_length is not None:127                if min_pwd_length == "default":128                    min_pwd_len = 7129                else:130                    min_pwd_len = int(min_pwd_length)131                if min_pwd_len < 0 or min_pwd_len > 14:132                    raise CommandError("Minimum password length must be in the range of 0 to 14!")133                m["minPwdLength"] = ldb.MessageElement(str(min_pwd_len),134                  ldb.FLAG_MOD_REPLACE, "minPwdLength")135                msgs.append("Minimum password length changed!")136            if min_pwd_age is not None:137                if min_pwd_age == "default":138                    min_pwd_age = 1139                else:140                    min_pwd_age = int(min_pwd_age)141                if min_pwd_age < 0 or min_pwd_age > 998:142                    raise CommandError("Minimum password age must be in the range of 0 to 998!")143                # days -> ticks144                min_pwd_age_ticks = -int(min_pwd_age * (24 * 60 * 60 * 1e7))145                m["minPwdAge"] = ldb.MessageElement(str(min_pwd_age_ticks),146                  ldb.FLAG_MOD_REPLACE, "minPwdAge")147                msgs.append("Minimum password age changed!")148            if max_pwd_age is not None:149                if max_pwd_age == "default":150                    max_pwd_age = 43151                else:152                    max_pwd_age = int(max_pwd_age)153                if max_pwd_age < 0 or max_pwd_age > 999:154                    raise CommandError("Maximum password age must be in the range of 0 to 999!")155                # days -> ticks156                max_pwd_age_ticks = -int(max_pwd_age * (24 * 60 * 60 * 1e7))157                m["maxPwdAge"] = ldb.MessageElement(str(max_pwd_age_ticks),158                  ldb.FLAG_MOD_REPLACE, "maxPwdAge")159                msgs.append("Maximum password age changed!")160            if max_pwd_age > 0 and min_pwd_age >= max_pwd_age:161                raise CommandError("Maximum password age (%d) must be greater than minimum password age (%d)!" % (max_pwd_age, min_pwd_age))162            samdb.modify(m)163            msgs.append("All changes applied successfully!")164            self.message("\n".join(msgs))165        else:...pass_policy.py
Source:pass_policy.py  
1import string2class BasePasswordPolicy(object):3    def pwd_complies(self, pwd):4        raise NotImplementedError()5class BasicPolicy(BasePasswordPolicy):6    def pwd_complies(self, pwd):7        return True8class RequiredLenPasswordPolicy(BasePasswordPolicy):9    def __init__(self, length):10        self._req_len = length11    def pwd_complies(self, pwd):12        return len(pwd) >= self._req_len13class ComplexPasswordPolicy(BasePasswordPolicy):14    digits = set(string.digits)15    uppercase = set(string.ascii_uppercase)16    lowercase = set(string.ascii_lowercase)17    upper_and_lowercase = set(string.ascii_uppercase + string.ascii_lowercase)18    non_symbols = set(19      string.digits + string.ascii_uppercase + string.ascii_lowercase)20    def __init__(self, required_length=8):21        self.blacklist = set()22        self.required_length = required_length23    def load_blacklist(self, fname):24        with open(fname, 'r') as blacklist:25            for line in blacklist:26                self.blacklist.add(line.strip('\n'))27    def has_group_symbols(self, pwd):28        return not self.all_from_group(pwd, self.non_symbols)29    def has_group(self, pwd, group):30        return any(map(lambda c: c in group, pwd))31    def all_from_group(self, pwd, group):32        return all(map(lambda c: c in group, pwd))33    def passes_blacklist(self, pwd):34        return (''.join(filter(35          lambda c: c in self.upper_and_lowercase, pwd)).lower()36            not in self.blacklist)37    def pwd_complies(self, pwd):38        if len(pwd) < self.required_length:39            return False40        if not self.has_group(pwd, self.digits):41            return False42        if not self.has_group(pwd, self.uppercase):43            return False44        if not self.has_group(pwd, self.lowercase):45            return False46        if self.all_from_group(pwd, self.non_symbols):47            return False48        return self.passes_blacklist(pwd)49class ComplexPasswordPolicyLowercase(ComplexPasswordPolicy):50    def pwd_complies(self, pwd):51        if len(pwd) < self.required_length:52            return False53        if not self.has_group(pwd, self.digits):54            return False55        if not self.has_group(pwd, self.upper_and_lowercase):56            return False57        if self.all_from_group(pwd, self.non_symbols):58            return False59        return self.passes_blacklist(pwd)60class OneUppercasePolicy(ComplexPasswordPolicy):61    def pwd_complies(self, pwd):62        if len(pwd) < self.required_length:63            return False64        if not self.has_group(pwd, self.uppercase):65            return False66        return self.passes_blacklist(pwd)67class SemiComplexPolicyLowercase(ComplexPasswordPolicy):68    def pwd_complies(self, pwd):69        count = 070        if len(pwd) < self.required_length:71            return False72        if self.has_group(pwd, self.digits):73            count += 174        if self.has_group(pwd, self.upper_and_lowercase):75            count += 176        if self.has_group_symbols(pwd):77            count += 178        return self.passes_blacklist(pwd) and count >= 279class SemiComplexPolicy(ComplexPasswordPolicy):80    def pwd_complies(self, pwd):81        count = 082        if len(pwd) < self.required_length:83            return False84        if self.has_group(pwd, self.digits):85            count += 186        if self.has_group(pwd, self.uppercase):87            count += 188        if self.has_group(pwd, self.lowercase):89            count += 190        if self.has_group_symbols(pwd):91            count += 192        return self.passes_blacklist(pwd) and count >= 393# Should match expand_operation.cc94policy_list = {95  'complex' : ComplexPasswordPolicy(),96  'basic' : BasicPolicy(),97  '1class8' : RequiredLenPasswordPolicy(8),98  'basic_long' : RequiredLenPasswordPolicy(16),99  'complex_lowercase' : ComplexPasswordPolicyLowercase(),100  'complex_long' : ComplexPasswordPolicy(16),101  'complex_long_lowercase' : ComplexPasswordPolicyLowercase(16),102  'semi_complex' : SemiComplexPolicy(12),103  'semi_complex_lowercase' : SemiComplexPolicyLowercase(12),104  '3class12' : SemiComplexPolicy(12),105  '2class12_all_lowercase' : SemiComplexPolicyLowercase(12),106  'one_uppercase' : OneUppercasePolicy(3)107}108class PasswordValidator(object):109    def __init__(self, alphabet):110        self._alpha = set(alphabet)111    def is_valid(self, pwd):112        return all([c in self._alpha for c in pwd])113class PasswordFilterer(object):114    def __init__(self, alphabet, policy):115        self._validator = PasswordValidator(alphabet)116        self._policy = get_policy(policy)117        self.number_removed = 0118        self.number_passed = 0119    def __call__(self, pwd):120        result = self._validator.is_valid(pwd) and self._policy.pwd_complies(pwd)121        self.number_removed += (0 if result else 1)122        self.number_passed += (1 if result else 0)123        return result124    def reset(self):125        self.number_removed = 0126        self.number_passed = 0127def policies():128    return list(policy_list.keys())129def get_policy(name):...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
