Best JavaScript code snippet using playwright-internal
testUpdateUser.py
Source:testUpdateUser.py
1import sys, unittest, AuthenticateShell2'''3 Authenticate update user end point.4 5 Purpose - Allows an active user to update their account information.6 If fields are ommitted or null, they will not be updated.7 8 Notes - User is from Africa. 9 Method signature:10 def update_user(self, accessCode='', address='', city='', state='',11 zipCode='', phone='', month=0, day=0, year=0,12 firstName='', lastName='', accessCodeExclude=False,13 addressExclude=False, cityExclude=False, stateExclude=False,14 zipCodeExclude=False, phoneExclude=False, monthExclude=False,15 dayExclude=False, yearExclude=False, firstNameExclude=False,16 lastNameExclude=False):17 18 Required:19 accessCode20 address21 city22 state23 zipCode24 phone25 month26 day27 year28 firstName29 lastName30 Test cases31 Successfully update a user.32 AccessCode missing from request call.33 Null AccessCode value. 34 Int AccessCode value. 35 Float AccessCode value. 36 String AccessCode value.37 Array AccessCode value. 38 Address missing from request call.39 Null Address value. 40 Int Address value. 41 Float Address value. 42 String Address value.43 Array Address value. 44 City missing from request call.45 Null City value. 46 Int City value. 47 Float City value. 48 String City value.49 Array City value. 50 State missing from request call.51 Null State value. 52 Int State value. 53 Float State value. 54 String State value x 2.55 Array State value. 56 ZipCode missing from request call.57 Null ZipCode value. 58 Int ZipCode value. 59 Float ZipCode value. 60 String ZipCode value.61 Array ZipCode value. 62 Phone missing from request call.63 Null Phone value. 64 Int Phone value. 65 Float Phone value. 66 String Phone value.67 Array Phone value. 68 Month missing from request call.69 Null Month value. 70 Int Month value. 71 Float Month value. 72 String Month value.73 Array Month value. 74 Day missing from request call.75 Null Day value. 76 Int Day value. 77 Float Day value. 78 String Day value.79 Array Day value. 80 Year missing from request call.81 Null Year value. 82 Int Year value. 83 Float Year value. 84 String Year value.85 Array Year value. 86 FirstName missing from request call.87 Null FirstName value. 88 Int FirstName value. 89 Float FirstName value. 90 String FirstName value.91 Array FirstName value. 92 LastName missing from request call.93 Null LastName value. 94 Int LastName value. 95 Float LastName value. 96 String LastName value.97 Array LastName value. 98'''99class TestUpdateUser(unittest.TestCase):100 @classmethod101 def setUpClass(cls):102 try:103 cls.user = AuthenticateShell.Authenticate() 104 cls.user.create_user(firstName = AuthenticateShell.data["firstName"], 105 lastName = AuthenticateShell.data["lastName"], 106 email = AuthenticateShell.data["email"], 107 phone = AuthenticateShell.data["phone"], 108 companyAdminKey = AuthenticateShell.data["company_admin_key"], 109 country = AuthenticateShell.data["countryAFR"])110 except:111 print("Unexpected error during setUpClass:", sys.exc_info()[0])112 @classmethod113 def tearDownClass(cls):114 try:115 pass116 except:117 print("Unexpected error during tearDownClass:", sys.exc_info()[0])118 # Successfully update a user.119 def test_success(self):120 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 121 address = AuthenticateShell.data["address"], 122 city = AuthenticateShell.data["city"],123 state = AuthenticateShell.data["state"], 124 zipCode = AuthenticateShell.data["zipCode"], 125 phone = AuthenticateShell.data["phone"],126 month = AuthenticateShell.data["month"], 127 day = AuthenticateShell.data["day"], 128 year = AuthenticateShell.data["year"],129 firstName = AuthenticateShell.data["updatedFirstName"], 130 lastName = AuthenticateShell.data["updatedLastName"])131 self.assertEqual(responseBody['successful'], True,132 msg='test_success assert#1 has failed.')133 self.assertEqual(responseBody['firstName'], AuthenticateShell.data["updatedFirstName"],134 msg='test_success assert#2 has failed.')135 self.assertEqual(responseBody['lastName'], AuthenticateShell.data["updatedLastName"],136 msg='test_success assert#3 has failed.')137 self.assertEqual(responseBody['companyId'], AuthenticateShell.data["company_admin_key"],138 msg='test_success assert#4 has failed.')139 self.assertEqual(responseBody['userId'], self.user.GetUserId(),140 msg='test_success assert#5 has failed.')141 self.assertEqual(responseBody['accessCode'], self.user.GetAccessCode(),142 msg='test_success assert#6 has failed.')143 # *********************************************************************144 # * AccessCode tests *145 # *********************************************************************146 147 148 149 # Missing AccessCode information from request call.150 def test_missingAccessCode(self):151 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 152 address = AuthenticateShell.data["address"], 153 city = AuthenticateShell.data["city"],154 state = AuthenticateShell.data["state"], 155 zipCode = AuthenticateShell.data["zipCode"], 156 phone = AuthenticateShell.data["phone"],157 month = AuthenticateShell.data["month"], 158 day = AuthenticateShell.data["day"], 159 year = AuthenticateShell.data["year"],160 firstName = AuthenticateShell.data["updatedFirstName"], 161 lastName = AuthenticateShell.data["updatedLastName"],162 accessCodeExclude = True)163 self.assertEqual(responseBody['errorMessage'], "accessCode required",164 msg='test_missingAccessCode assert#1 has failed.')165 166 167 168 # Test a null AccessCode.169 def test_nullAccessCode(self):170 responseBody = self.user.update_user(accessCode = '', 171 address = AuthenticateShell.data["address"], 172 city = AuthenticateShell.data["city"],173 state = AuthenticateShell.data["state"], 174 zipCode = AuthenticateShell.data["zipCode"], 175 phone = AuthenticateShell.data["phone"],176 month = AuthenticateShell.data["month"], 177 day = AuthenticateShell.data["day"], 178 year = AuthenticateShell.data["year"],179 firstName = AuthenticateShell.data["updatedFirstName"], 180 lastName = AuthenticateShell.data["updatedLastName"])181 self.assertEqual(responseBody['errorMessage'], "ERR: access code has expired or does not exist",182 msg='test_nullAccessCode assert#1 has failed.')183 # Test a int AccessCode.184 def test_intAccessCode(self):185 responseBody = self.user.update_user(accessCode = 123456789, 186 address = AuthenticateShell.data["address"], 187 city = AuthenticateShell.data["city"],188 state = AuthenticateShell.data["state"], 189 zipCode = AuthenticateShell.data["zipCode"], 190 phone = AuthenticateShell.data["phone"],191 month = AuthenticateShell.data["month"], 192 day = AuthenticateShell.data["day"], 193 year = AuthenticateShell.data["year"],194 firstName = AuthenticateShell.data["updatedFirstName"], 195 lastName = AuthenticateShell.data["updatedLastName"])196 self.assertEqual(responseBody['errorMessage'], 197 "ERR: access code has expired or does not exist",198 msg='test_intAccessCode assert#1 has failed.')199 # Test a float AccessCode.200 def test_floatAccessCode(self):201 responseBody = self.user.update_user(accessCode = 123.321, 202 address = AuthenticateShell.data["address"], 203 city = AuthenticateShell.data["city"],204 state = AuthenticateShell.data["state"], 205 zipCode = AuthenticateShell.data["zipCode"], 206 phone = AuthenticateShell.data["phone"],207 month = AuthenticateShell.data["month"], 208 day = AuthenticateShell.data["day"], 209 year = AuthenticateShell.data["year"],210 firstName = AuthenticateShell.data["updatedFirstName"], 211 lastName = AuthenticateShell.data["updatedLastName"])212 self.assertEqual(responseBody['errorMessage'], 213 "ERR: access code has expired or does not exist",214 msg='test_floatAccessCode assert#1 has failed.')215 216 217 218 # Test a string AccessCode value call.219 def test_stringAccessCode(self):220 responseBody = self.user.update_user(accessCode = 'invalid access code', 221 address = AuthenticateShell.data["address"], 222 city = AuthenticateShell.data["city"],223 state = AuthenticateShell.data["state"], 224 zipCode = AuthenticateShell.data["zipCode"], 225 phone = AuthenticateShell.data["phone"],226 month = AuthenticateShell.data["month"], 227 day = AuthenticateShell.data["day"], 228 year = AuthenticateShell.data["year"],229 firstName = AuthenticateShell.data["updatedFirstName"], 230 lastName = AuthenticateShell.data["updatedLastName"])231 self.assertEqual(responseBody['errorMessage'], 232 "ERR: access code has expired or does not exist",233 msg='test_stringAccessCode assert#1 has failed.')234 # Test an array AccessCode value call.235 def test_arrayAccessCode(self):236 responseBody = self.user.update_user(accessCode = [self.user.GetAccessCode()], 237 address = AuthenticateShell.data["address"], 238 city = AuthenticateShell.data["city"],239 state = AuthenticateShell.data["state"], 240 zipCode = AuthenticateShell.data["zipCode"], 241 phone = AuthenticateShell.data["phone"],242 month = AuthenticateShell.data["month"], 243 day = AuthenticateShell.data["day"], 244 year = AuthenticateShell.data["year"],245 firstName = AuthenticateShell.data["updatedFirstName"], 246 lastName = AuthenticateShell.data["updatedLastName"])247 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",248 msg='test_arrayAccessCode assert#1 has failed.')249 # *********************************************************************250 # * Address tests *251 # *********************************************************************252 253 254 255 # Missing Address information from request call.256 def test_missingAddress(self):257 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 258 address = AuthenticateShell.data["address"], 259 city = AuthenticateShell.data["city"],260 state = AuthenticateShell.data["state"], 261 zipCode = AuthenticateShell.data["zipCode"], 262 phone = AuthenticateShell.data["phone"],263 month = AuthenticateShell.data["month"], 264 day = AuthenticateShell.data["day"], 265 year = AuthenticateShell.data["year"],266 firstName = AuthenticateShell.data["updatedFirstName"], 267 lastName = AuthenticateShell.data["updatedLastName"],268 addressExclude = True)269 self.assertEqual(responseBody['successful'], True,270 msg='test_missingAddress assert#1 has failed.')271 272 273 274 # Test a null Address.275 def test_nullAddress(self):276 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 277 address = '', 278 city = AuthenticateShell.data["city"],279 state = AuthenticateShell.data["state"], 280 zipCode = AuthenticateShell.data["zipCode"], 281 phone = AuthenticateShell.data["phone"],282 month = AuthenticateShell.data["month"], 283 day = AuthenticateShell.data["day"], 284 year = AuthenticateShell.data["year"],285 firstName = AuthenticateShell.data["updatedFirstName"], 286 lastName = AuthenticateShell.data["updatedLastName"])287 self.assertEqual(responseBody['successful'], True,288 msg='test_nullAddress assert#1 has failed.')289 # Test a int Address.290 def test_intAddress(self):291 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 292 address = 12345123649874516789, 293 city = AuthenticateShell.data["city"],294 state = AuthenticateShell.data["state"], 295 zipCode = AuthenticateShell.data["zipCode"], 296 phone = AuthenticateShell.data["phone"],297 month = AuthenticateShell.data["month"], 298 day = AuthenticateShell.data["day"], 299 year = AuthenticateShell.data["year"],300 firstName = AuthenticateShell.data["updatedFirstName"], 301 lastName = AuthenticateShell.data["updatedLastName"])302 self.assertEqual(responseBody['successful'], True,303 msg='test_intAddress assert#1 has failed.')304 # Test a float Address.305 def test_floatAddress(self):306 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 307 address = 1111111111111.11111111111111111111, 308 city = AuthenticateShell.data["city"],309 state = AuthenticateShell.data["state"], 310 zipCode = AuthenticateShell.data["zipCode"], 311 phone = AuthenticateShell.data["phone"],312 month = AuthenticateShell.data["month"], 313 day = AuthenticateShell.data["day"], 314 year = AuthenticateShell.data["year"],315 firstName = AuthenticateShell.data["updatedFirstName"], 316 lastName = AuthenticateShell.data["updatedLastName"])317 self.assertEqual(responseBody['successful'], True,318 msg='test_floatAddress assert#1 has failed.')319 320 321 322 # Test a string Address value call.323 def test_stringAddress(self):324 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 325 address = 'Should pass street', 326 city = AuthenticateShell.data["city"],327 state = AuthenticateShell.data["state"], 328 zipCode = AuthenticateShell.data["zipCode"], 329 phone = AuthenticateShell.data["phone"],330 month = AuthenticateShell.data["month"], 331 day = AuthenticateShell.data["day"], 332 year = AuthenticateShell.data["year"],333 firstName = AuthenticateShell.data["updatedFirstName"], 334 lastName = AuthenticateShell.data["updatedLastName"])335 self.assertEqual(responseBody['successful'], True,336 msg='test_stringAddress assert#1 has failed.')337 # Test an array Address value call.338 def test_arrayAddress(self):339 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 340 address = [AuthenticateShell.data["address"]], 341 city = AuthenticateShell.data["city"],342 state = AuthenticateShell.data["state"], 343 zipCode = AuthenticateShell.data["zipCode"], 344 phone = AuthenticateShell.data["phone"],345 month = AuthenticateShell.data["month"], 346 day = AuthenticateShell.data["day"], 347 year = AuthenticateShell.data["year"],348 firstName = AuthenticateShell.data["updatedFirstName"], 349 lastName = AuthenticateShell.data["updatedLastName"])350 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",351 msg='test_arrayAddress assert#1 has failed.')352 353 # *********************************************************************354 # * City tests *355 # *********************************************************************356 357 358 359 # Missing City information from request call.360 def test_missingCity(self):361 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 362 address = AuthenticateShell.data["address"], 363 city = AuthenticateShell.data["city"],364 state = AuthenticateShell.data["state"], 365 zipCode = AuthenticateShell.data["zipCode"], 366 phone = AuthenticateShell.data["phone"],367 month = AuthenticateShell.data["month"], 368 day = AuthenticateShell.data["day"], 369 year = AuthenticateShell.data["year"],370 firstName = AuthenticateShell.data["updatedFirstName"], 371 lastName = AuthenticateShell.data["updatedLastName"],372 cityExclude = True)373 self.assertEqual(responseBody['successful'], True,374 msg='test_missingCity assert#1 has failed.')375 376 377 378 # Test a null City.379 def test_nullCity(self):380 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 381 address = AuthenticateShell.data["address"], 382 city = '',383 state = AuthenticateShell.data["state"], 384 zipCode = AuthenticateShell.data["zipCode"], 385 phone = AuthenticateShell.data["phone"],386 month = AuthenticateShell.data["month"], 387 day = AuthenticateShell.data["day"], 388 year = AuthenticateShell.data["year"],389 firstName = AuthenticateShell.data["updatedFirstName"], 390 lastName = AuthenticateShell.data["updatedLastName"])391 self.assertEqual(responseBody['successful'], True,392 msg='test_nullCity assert#1 has failed.')393 # Test a int City.394 #@unittest.skip("City value can be an integer currently")395 def test_intCity(self):396 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 397 address = AuthenticateShell.data["address"], 398 city = 3333333333333333333333333333333333,399 state = AuthenticateShell.data["state"], 400 zipCode = AuthenticateShell.data["zipCode"], 401 phone = AuthenticateShell.data["phone"],402 month = AuthenticateShell.data["month"], 403 day = AuthenticateShell.data["day"], 404 year = AuthenticateShell.data["year"],405 firstName = AuthenticateShell.data["updatedFirstName"], 406 lastName = AuthenticateShell.data["updatedLastName"])407 self.assertEqual(responseBody['successful'], True,408 msg='test_intCity assert#1 has failed.')409 # Test a float City.410 #@unittest.skip("City value can be an float currently")411 def test_floatCity(self):412 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 413 address = AuthenticateShell.data["address"], 414 city = 6666666666666666666666.66666666666,415 state = AuthenticateShell.data["state"], 416 zipCode = AuthenticateShell.data["zipCode"], 417 phone = AuthenticateShell.data["phone"],418 month = AuthenticateShell.data["month"], 419 day = AuthenticateShell.data["day"], 420 year = AuthenticateShell.data["year"],421 firstName = AuthenticateShell.data["updatedFirstName"], 422 lastName = AuthenticateShell.data["updatedLastName"])423 self.assertEqual(responseBody['successful'], True,424 msg='test_floatCity assert#1 has failed.')425 426 427 428 # Test a string City value call.429 def test_stringCity(self):430 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 431 address = AuthenticateShell.data["address"], 432 city = 'AuthenticateShell.data["city"]',433 state = AuthenticateShell.data["state"], 434 zipCode = AuthenticateShell.data["zipCode"], 435 phone = AuthenticateShell.data["phone"],436 month = AuthenticateShell.data["month"], 437 day = AuthenticateShell.data["day"], 438 year = AuthenticateShell.data["year"],439 firstName = AuthenticateShell.data["updatedFirstName"], 440 lastName = AuthenticateShell.data["updatedLastName"])441 self.assertEqual(responseBody['successful'], True,442 msg='test_stringCity assert#1 has failed.')443 # Test an array City value call.444 def test_arrayCity(self):445 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 446 address = AuthenticateShell.data["address"], 447 city = [AuthenticateShell.data["city"]],448 state = AuthenticateShell.data["state"], 449 zipCode = AuthenticateShell.data["zipCode"], 450 phone = AuthenticateShell.data["phone"],451 month = AuthenticateShell.data["month"], 452 day = AuthenticateShell.data["day"], 453 year = AuthenticateShell.data["year"],454 firstName = AuthenticateShell.data["updatedFirstName"], 455 lastName = AuthenticateShell.data["updatedLastName"])456 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",457 msg='test_arrayCity assert#1 has failed.')458 # *********************************************************************459 # * State tests *460 # *********************************************************************461 462 463 464 # Missing State information from request call.465 def test_missingState(self):466 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 467 address = AuthenticateShell.data["address"], 468 city = AuthenticateShell.data["city"],469 state = AuthenticateShell.data["state"], 470 zipCode = AuthenticateShell.data["zipCode"], 471 phone = AuthenticateShell.data["phone"],472 month = AuthenticateShell.data["month"], 473 day = AuthenticateShell.data["day"], 474 year = AuthenticateShell.data["year"],475 firstName = AuthenticateShell.data["updatedFirstName"], 476 lastName = AuthenticateShell.data["updatedLastName"],477 stateExclude = True)478 self.assertEqual(responseBody['successful'], True,479 msg='test_missingState assert#1 has failed.')480 481 482 483 # Test a null State.484 def test_nullState(self):485 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 486 address = AuthenticateShell.data["address"], 487 city = AuthenticateShell.data["city"],488 state = '', 489 zipCode = AuthenticateShell.data["zipCode"], 490 phone = AuthenticateShell.data["phone"],491 month = AuthenticateShell.data["month"], 492 day = AuthenticateShell.data["day"], 493 year = AuthenticateShell.data["year"],494 firstName = AuthenticateShell.data["updatedFirstName"], 495 lastName = AuthenticateShell.data["updatedLastName"])496 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid two digit postal(state) code',497 msg='test_nullState assert#1 has failed.')498 # Test a int State.499 def test_intState(self):500 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 501 address = AuthenticateShell.data["address"], 502 city = AuthenticateShell.data["city"],503 state = 12345698798764651341681365168, 504 zipCode = AuthenticateShell.data["zipCode"], 505 phone = AuthenticateShell.data["phone"],506 month = AuthenticateShell.data["month"], 507 day = AuthenticateShell.data["day"], 508 year = AuthenticateShell.data["year"],509 firstName = AuthenticateShell.data["updatedFirstName"], 510 lastName = AuthenticateShell.data["updatedLastName"])511 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid state',512 msg='test_intState assert#1 has failed.')513 # Test a float State.514 def test_floatState(self):515 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 516 address = AuthenticateShell.data["address"], 517 city = AuthenticateShell.data["city"],518 state = 1.2345698798764651341681365168, 519 zipCode = AuthenticateShell.data["zipCode"], 520 phone = AuthenticateShell.data["phone"],521 month = AuthenticateShell.data["month"], 522 day = AuthenticateShell.data["day"], 523 year = AuthenticateShell.data["year"],524 firstName = AuthenticateShell.data["updatedFirstName"], 525 lastName = AuthenticateShell.data["updatedLastName"])526 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid state',527 msg='test_floatState assert#1 has failed.')528 529 530 531 # Test a string State value call.532 def test_stringState(self):533 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 534 address = AuthenticateShell.data["address"], 535 city = AuthenticateShell.data["city"],536 state = 'AuthenticateShell.data["state"]', 537 zipCode = AuthenticateShell.data["zipCode"], 538 phone = AuthenticateShell.data["phone"],539 month = AuthenticateShell.data["month"], 540 day = AuthenticateShell.data["day"], 541 year = AuthenticateShell.data["year"],542 firstName = AuthenticateShell.data["updatedFirstName"], 543 lastName = AuthenticateShell.data["updatedLastName"])544 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid state',545 msg='test_stringState assert#1 has failed.')546 547 # Test a string State value call.548 def test_stringStateTwo(self):549 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 550 address = AuthenticateShell.data["address"], 551 city = AuthenticateShell.data["city"],552 state = 'CA', 553 zipCode = AuthenticateShell.data["zipCode"], 554 phone = AuthenticateShell.data["phone"],555 month = AuthenticateShell.data["month"], 556 day = AuthenticateShell.data["day"], 557 year = AuthenticateShell.data["year"],558 firstName = AuthenticateShell.data["updatedFirstName"], 559 lastName = AuthenticateShell.data["updatedLastName"])560 self.assertEqual(responseBody['successful'], True,561 msg='test_stringStateTwo assert#1 has failed.')562 # Test an array State value call.563 def test_arrayState(self):564 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 565 address = AuthenticateShell.data["address"], 566 city = AuthenticateShell.data["city"],567 state = [AuthenticateShell.data["state"]], 568 zipCode = AuthenticateShell.data["zipCode"], 569 phone = AuthenticateShell.data["phone"],570 month = AuthenticateShell.data["month"], 571 day = AuthenticateShell.data["day"], 572 year = AuthenticateShell.data["year"],573 firstName = AuthenticateShell.data["updatedFirstName"], 574 lastName = AuthenticateShell.data["updatedLastName"])575 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",576 msg='test_arrayState assert#1 has failed.')577 # *********************************************************************578 # * ZipCode tests *579 # *********************************************************************580 581 582 583 # Missing ZipCode information from request call.584 def test_missingZipCode(self):585 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 586 address = AuthenticateShell.data["address"], 587 city = AuthenticateShell.data["city"],588 state = AuthenticateShell.data["state"], 589 zipCode = AuthenticateShell.data["zipCode"], 590 phone = AuthenticateShell.data["phone"],591 month = AuthenticateShell.data["month"], 592 day = AuthenticateShell.data["day"], 593 year = AuthenticateShell.data["year"],594 firstName = AuthenticateShell.data["updatedFirstName"], 595 lastName = AuthenticateShell.data["updatedLastName"],596 zipCodeExclude = True)597 self.assertEqual(responseBody['successful'], True,598 msg='test_missingZipCode assert#1 has failed.')599 600 601 602 # Test a null ZipCode.603 def test_nullZipCode(self):604 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 605 address = AuthenticateShell.data["address"], 606 city = AuthenticateShell.data["city"],607 state = AuthenticateShell.data["state"], 608 zipCode = '', 609 phone = AuthenticateShell.data["phone"],610 month = AuthenticateShell.data["month"], 611 day = AuthenticateShell.data["day"], 612 year = AuthenticateShell.data["year"],613 firstName = AuthenticateShell.data["updatedFirstName"], 614 lastName = AuthenticateShell.data["updatedLastName"])615 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid zip code',616 msg='test_nullZipCode assert#1 has failed.')617 # Test a int ZipCode.618 def test_intZipCode(self):619 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 620 address = AuthenticateShell.data["address"], 621 city = AuthenticateShell.data["city"],622 state = AuthenticateShell.data["state"], 623 zipCode = 11111111111111111111111111, 624 phone = AuthenticateShell.data["phone"],625 month = AuthenticateShell.data["month"], 626 day = AuthenticateShell.data["day"], 627 year = AuthenticateShell.data["year"],628 firstName = AuthenticateShell.data["updatedFirstName"], 629 lastName = AuthenticateShell.data["updatedLastName"])630 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid zip code',631 msg='test_intZipCode assert#1 has failed.')632 # Test a float ZipCode.633 def test_floatZipCode(self):634 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 635 address = AuthenticateShell.data["address"], 636 city = AuthenticateShell.data["city"],637 state = AuthenticateShell.data["state"], 638 zipCode = 1111111111111111111111111.1, 639 phone = AuthenticateShell.data["phone"],640 month = AuthenticateShell.data["month"], 641 day = AuthenticateShell.data["day"], 642 year = AuthenticateShell.data["year"],643 firstName = AuthenticateShell.data["updatedFirstName"], 644 lastName = AuthenticateShell.data["updatedLastName"])645 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid zip code',646 msg='test_floatZipCode assert#1 has failed.')647 648 649 650 # Test a string ZipCode value call.651 def test_stringZipCode(self):652 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 653 address = AuthenticateShell.data["address"], 654 city = AuthenticateShell.data["city"],655 state = AuthenticateShell.data["state"], 656 zipCode = 'AuthenticateShell.data["zipCode"]', 657 phone = AuthenticateShell.data["phone"],658 month = AuthenticateShell.data["month"], 659 day = AuthenticateShell.data["day"], 660 year = AuthenticateShell.data["year"],661 firstName = AuthenticateShell.data["updatedFirstName"], 662 lastName = AuthenticateShell.data["updatedLastName"])663 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid zip code',664 msg='test_stringZipCode assert#1 has failed.')665 # Test an array ZipCode value call.666 def test_arrayZipCode(self):667 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 668 address = AuthenticateShell.data["address"], 669 city = AuthenticateShell.data["city"],670 state = AuthenticateShell.data["state"], 671 zipCode = [AuthenticateShell.data["zipCode"]], 672 phone = AuthenticateShell.data["phone"],673 month = AuthenticateShell.data["month"], 674 day = AuthenticateShell.data["day"], 675 year = AuthenticateShell.data["year"],676 firstName = AuthenticateShell.data["updatedFirstName"], 677 lastName = AuthenticateShell.data["updatedLastName"])678 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",679 msg='test_arrayZipCode assert#1 has failed.')680 681 # *********************************************************************682 # * Phone tests *683 # *********************************************************************684 685 686 687 # Missing Phone information from request call.688 def test_missingPhone(self):689 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 690 address = AuthenticateShell.data["address"], 691 city = AuthenticateShell.data["city"],692 state = AuthenticateShell.data["state"], 693 zipCode = AuthenticateShell.data["zipCode"], 694 phone = AuthenticateShell.data["phone"],695 month = AuthenticateShell.data["month"], 696 day = AuthenticateShell.data["day"], 697 year = AuthenticateShell.data["year"],698 firstName = AuthenticateShell.data["updatedFirstName"], 699 lastName = AuthenticateShell.data["updatedLastName"],700 phoneExclude = True)701 self.assertEqual(responseBody['successful'], True,702 msg='test_missingPhone assert#1 has failed.')703 704 705 706 # Test a null Phone.707 def test_nullPhone(self):708 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 709 address = AuthenticateShell.data["address"], 710 city = AuthenticateShell.data["city"],711 state = AuthenticateShell.data["state"], 712 zipCode = AuthenticateShell.data["zipCode"], 713 phone = '',714 month = AuthenticateShell.data["month"], 715 day = AuthenticateShell.data["day"], 716 year = AuthenticateShell.data["year"],717 firstName = AuthenticateShell.data["updatedFirstName"], 718 lastName = AuthenticateShell.data["updatedLastName"])719 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid phone number',720 msg='test_nullPhone assert#1 has failed.')721 # Test a int Phone.722 def test_intPhone(self):723 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 724 address = AuthenticateShell.data["address"], 725 city = AuthenticateShell.data["city"],726 state = AuthenticateShell.data["state"], 727 zipCode = AuthenticateShell.data["zipCode"], 728 phone = 999999999999999999999999999999999999,729 month = AuthenticateShell.data["month"], 730 day = AuthenticateShell.data["day"], 731 year = AuthenticateShell.data["year"],732 firstName = AuthenticateShell.data["updatedFirstName"], 733 lastName = AuthenticateShell.data["updatedLastName"])734 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid phone number',735 msg='test_intPhone assert#1 has failed.')736 # Test a float Phone.737 def test_floatPhone(self):738 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 739 address = AuthenticateShell.data["address"], 740 city = AuthenticateShell.data["city"],741 state = AuthenticateShell.data["state"], 742 zipCode = AuthenticateShell.data["zipCode"], 743 phone = 999999999.999999999999999999999999999,744 month = AuthenticateShell.data["month"], 745 day = AuthenticateShell.data["day"], 746 year = AuthenticateShell.data["year"],747 firstName = AuthenticateShell.data["updatedFirstName"], 748 lastName = AuthenticateShell.data["updatedLastName"])749 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid phone number',750 msg='test_floatPhone assert#1 has failed.')751 752 753 754 # Test a string Phone value call.755 def test_stringPhone(self):756 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 757 address = AuthenticateShell.data["address"], 758 city = AuthenticateShell.data["city"],759 state = AuthenticateShell.data["state"], 760 zipCode = AuthenticateShell.data["zipCode"], 761 phone = 'AuthenticateShell.data["phone"]',762 month = AuthenticateShell.data["month"], 763 day = AuthenticateShell.data["day"], 764 year = AuthenticateShell.data["year"],765 firstName = AuthenticateShell.data["updatedFirstName"], 766 lastName = AuthenticateShell.data["updatedLastName"])767 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid phone number',768 msg='test_stringPhone assert#1 has failed.')769 # Test an array Phone value call.770 def test_arrayPhone(self):771 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 772 address = AuthenticateShell.data["address"], 773 city = AuthenticateShell.data["city"],774 state = AuthenticateShell.data["state"], 775 zipCode = AuthenticateShell.data["zipCode"], 776 phone = [AuthenticateShell.data["phone"]],777 month = AuthenticateShell.data["month"], 778 day = AuthenticateShell.data["day"], 779 year = AuthenticateShell.data["year"],780 firstName = AuthenticateShell.data["updatedFirstName"], 781 lastName = AuthenticateShell.data["updatedLastName"])782 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",783 msg='test_arrayPhone assert#1 has failed.')784 # *********************************************************************785 # * Month tests *786 # *********************************************************************787 788 789 790 # Missing Month information from request call.791 def test_missingMonth(self):792 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 793 address = AuthenticateShell.data["address"], 794 city = AuthenticateShell.data["city"],795 state = AuthenticateShell.data["state"], 796 zipCode = AuthenticateShell.data["zipCode"], 797 phone = AuthenticateShell.data["phone"],798 month = AuthenticateShell.data["month"], 799 day = AuthenticateShell.data["day"], 800 year = AuthenticateShell.data["year"],801 firstName = AuthenticateShell.data["updatedFirstName"], 802 lastName = AuthenticateShell.data["updatedLastName"],803 monthExclude = True)804 self.assertEqual(responseBody['successful'], True,805 msg='test_missingMonth assert#1 has failed.')806 807 808 809 # Test a null Month.810 def test_nullMonth(self):811 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 812 address = AuthenticateShell.data["address"], 813 city = AuthenticateShell.data["city"],814 state = AuthenticateShell.data["state"], 815 zipCode = AuthenticateShell.data["zipCode"], 816 phone = AuthenticateShell.data["phone"],817 month = '', 818 day = AuthenticateShell.data["day"], 819 year = AuthenticateShell.data["year"],820 firstName = AuthenticateShell.data["updatedFirstName"], 821 lastName = AuthenticateShell.data["updatedLastName"])822 self.assertEqual(responseBody['successful'], True,823 msg='test_nullMonth assert#1 has failed.')824 # Test a int Month.825 def test_intMonth(self):826 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 827 address = AuthenticateShell.data["address"], 828 city = AuthenticateShell.data["city"],829 state = AuthenticateShell.data["state"], 830 zipCode = AuthenticateShell.data["zipCode"], 831 phone = AuthenticateShell.data["phone"],832 month = 666666666666666666666666666666, 833 day = AuthenticateShell.data["day"], 834 year = AuthenticateShell.data["year"],835 firstName = AuthenticateShell.data["updatedFirstName"], 836 lastName = AuthenticateShell.data["updatedLastName"])837 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid month',838 msg='test_intMonth assert#1 has failed.')839 # Test a float Month.840 def test_floatMonth(self):841 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 842 address = AuthenticateShell.data["address"], 843 city = AuthenticateShell.data["city"],844 state = AuthenticateShell.data["state"], 845 zipCode = AuthenticateShell.data["zipCode"], 846 phone = AuthenticateShell.data["phone"],847 month = 6666666666666.66666666666666666, 848 day = AuthenticateShell.data["day"], 849 year = AuthenticateShell.data["year"],850 firstName = AuthenticateShell.data["updatedFirstName"], 851 lastName = AuthenticateShell.data["updatedLastName"])852 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid month',853 msg='test_floatMonth assert#1 has failed.')854 855 856 857 # Test a string Month value call.858 def test_stringMonth(self):859 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 860 address = AuthenticateShell.data["address"], 861 city = AuthenticateShell.data["city"],862 state = AuthenticateShell.data["state"], 863 zipCode = AuthenticateShell.data["zipCode"], 864 phone = AuthenticateShell.data["phone"],865 month = 'AuthenticateShell.data["month"]', 866 day = AuthenticateShell.data["day"], 867 year = AuthenticateShell.data["year"],868 firstName = AuthenticateShell.data["updatedFirstName"], 869 lastName = AuthenticateShell.data["updatedLastName"])870 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid month',871 msg='test_stringMonth assert#1 has failed.')872 # Test an array Month value call.873 def test_arrayMonth(self):874 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 875 address = AuthenticateShell.data["address"], 876 city = AuthenticateShell.data["city"],877 state = AuthenticateShell.data["state"], 878 zipCode = AuthenticateShell.data["zipCode"], 879 phone = AuthenticateShell.data["phone"],880 month = [AuthenticateShell.data["month"]], 881 day = AuthenticateShell.data["day"], 882 year = AuthenticateShell.data["year"],883 firstName = AuthenticateShell.data["updatedFirstName"], 884 lastName = AuthenticateShell.data["updatedLastName"])885 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",886 msg='test_arrayMonth assert#1 has failed.')887 # *********************************************************************888 # * Day tests *889 # *********************************************************************890 891 892 893 # Missing Day information from request call.894 def test_missingDay(self):895 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 896 address = AuthenticateShell.data["address"], 897 city = AuthenticateShell.data["city"],898 state = AuthenticateShell.data["state"], 899 zipCode = AuthenticateShell.data["zipCode"], 900 phone = AuthenticateShell.data["phone"],901 month = AuthenticateShell.data["month"], 902 day = AuthenticateShell.data["day"], 903 year = AuthenticateShell.data["year"],904 firstName = AuthenticateShell.data["updatedFirstName"], 905 lastName = AuthenticateShell.data["updatedLastName"],906 dayExclude = True)907 self.assertEqual(responseBody['successful'], True,908 msg='test_missingDay assert#1 has failed.')909 910 911 912 # Test a null Day.913 def test_nullDay(self):914 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 915 address = AuthenticateShell.data["address"], 916 city = AuthenticateShell.data["city"],917 state = AuthenticateShell.data["state"], 918 zipCode = AuthenticateShell.data["zipCode"], 919 phone = AuthenticateShell.data["phone"],920 month = AuthenticateShell.data["month"], 921 day = '', 922 year = AuthenticateShell.data["year"],923 firstName = AuthenticateShell.data["updatedFirstName"], 924 lastName = AuthenticateShell.data["updatedLastName"])925 self.assertEqual(responseBody['successful'], True,926 msg='test_nullDay assert#1 has failed.')927 # Test a int Day.928 def test_intDay(self):929 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 930 address = AuthenticateShell.data["address"], 931 city = AuthenticateShell.data["city"],932 state = AuthenticateShell.data["state"], 933 zipCode = AuthenticateShell.data["zipCode"], 934 phone = AuthenticateShell.data["phone"],935 month = AuthenticateShell.data["month"], 936 day = 666666666666666666666666666666, 937 year = AuthenticateShell.data["year"],938 firstName = AuthenticateShell.data["updatedFirstName"], 939 lastName = AuthenticateShell.data["updatedLastName"])940 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid day',941 msg='test_intDay assert#1 has failed.')942 # Test a float Day.943 def test_floatDay(self):944 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 945 address = AuthenticateShell.data["address"], 946 city = AuthenticateShell.data["city"],947 state = AuthenticateShell.data["state"], 948 zipCode = AuthenticateShell.data["zipCode"], 949 phone = AuthenticateShell.data["phone"],950 month = AuthenticateShell.data["month"], 951 day = 666666666666666666666.666666666, 952 year = AuthenticateShell.data["year"],953 firstName = AuthenticateShell.data["updatedFirstName"], 954 lastName = AuthenticateShell.data["updatedLastName"])955 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid day',956 msg='test_floatDay assert#1 has failed.')957 958 959 960 # Test a string Day value call.961 def test_stringDay(self):962 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 963 address = AuthenticateShell.data["address"], 964 city = AuthenticateShell.data["city"],965 state = AuthenticateShell.data["state"], 966 zipCode = AuthenticateShell.data["zipCode"], 967 phone = AuthenticateShell.data["phone"],968 month = AuthenticateShell.data["month"], 969 day = 'AuthenticateShell.data["day"]', 970 year = AuthenticateShell.data["year"],971 firstName = AuthenticateShell.data["updatedFirstName"], 972 lastName = AuthenticateShell.data["updatedLastName"])973 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid day',974 msg='test_stringDay assert#1 has failed.')975 # Test an array Day value call.976 def test_arrayDay(self):977 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 978 address = AuthenticateShell.data["address"], 979 city = AuthenticateShell.data["city"],980 state = AuthenticateShell.data["state"], 981 zipCode = AuthenticateShell.data["zipCode"], 982 phone = AuthenticateShell.data["phone"],983 month = AuthenticateShell.data["month"], 984 day = [AuthenticateShell.data["day"]], 985 year = AuthenticateShell.data["year"],986 firstName = AuthenticateShell.data["updatedFirstName"], 987 lastName = AuthenticateShell.data["updatedLastName"])988 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",989 msg='test_arrayDay assert#1 has failed.')990 991 # *********************************************************************992 # * Year tests *993 # *********************************************************************994 995 996 997 # Missing Year information from request call.998 def test_missingYear(self):999 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1000 address = AuthenticateShell.data["address"], 1001 city = AuthenticateShell.data["city"],1002 state = AuthenticateShell.data["state"], 1003 zipCode = AuthenticateShell.data["zipCode"], 1004 phone = AuthenticateShell.data["phone"],1005 month = AuthenticateShell.data["month"], 1006 day = AuthenticateShell.data["day"], 1007 year = AuthenticateShell.data["year"],1008 firstName = AuthenticateShell.data["updatedFirstName"], 1009 lastName = AuthenticateShell.data["updatedLastName"],1010 yearExclude = True)1011 self.assertEqual(responseBody['successful'], True,1012 msg='test_missingYear assert#1 has failed.')1013 1014 1015 1016 # Test a null Year.1017 def test_nullYear(self):1018 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1019 address = AuthenticateShell.data["address"], 1020 city = AuthenticateShell.data["city"],1021 state = AuthenticateShell.data["state"], 1022 zipCode = AuthenticateShell.data["zipCode"], 1023 phone = AuthenticateShell.data["phone"],1024 month = AuthenticateShell.data["month"], 1025 day = AuthenticateShell.data["day"], 1026 year = '',1027 firstName = AuthenticateShell.data["updatedFirstName"], 1028 lastName = AuthenticateShell.data["updatedLastName"])1029 self.assertEqual(responseBody['successful'], True,1030 msg='test_nullYear assert#1 has failed.')1031 # Test a int Year.1032 def test_intYear(self):1033 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1034 address = AuthenticateShell.data["address"], 1035 city = AuthenticateShell.data["city"],1036 state = AuthenticateShell.data["state"], 1037 zipCode = AuthenticateShell.data["zipCode"], 1038 phone = AuthenticateShell.data["phone"],1039 month = AuthenticateShell.data["month"], 1040 day = AuthenticateShell.data["day"], 1041 year = 1111111111111111111111111111,1042 firstName = AuthenticateShell.data["updatedFirstName"], 1043 lastName = AuthenticateShell.data["updatedLastName"])1044 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid year',1045 msg='test_intYear assert#1 has failed.')1046 # Test a float Year.1047 def test_floatYear(self):1048 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1049 address = AuthenticateShell.data["address"], 1050 city = AuthenticateShell.data["city"],1051 state = AuthenticateShell.data["state"], 1052 zipCode = AuthenticateShell.data["zipCode"], 1053 phone = AuthenticateShell.data["phone"],1054 month = AuthenticateShell.data["month"], 1055 day = AuthenticateShell.data["day"], 1056 year = 1.1111111111111111111111111111,1057 firstName = AuthenticateShell.data["updatedFirstName"], 1058 lastName = AuthenticateShell.data["updatedLastName"])1059 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid year',1060 msg='test_floatYear assert#1 has failed.')1061 1062 1063 1064 # Test a string Year value call.1065 def test_stringYear(self):1066 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1067 address = AuthenticateShell.data["address"], 1068 city = AuthenticateShell.data["city"],1069 state = AuthenticateShell.data["state"], 1070 zipCode = AuthenticateShell.data["zipCode"], 1071 phone = AuthenticateShell.data["phone"],1072 month = AuthenticateShell.data["month"], 1073 day = AuthenticateShell.data["day"], 1074 year = 'AuthenticateShell.data["year"]',1075 firstName = AuthenticateShell.data["updatedFirstName"], 1076 lastName = AuthenticateShell.data["updatedLastName"])1077 self.assertEqual(responseBody['errorMessage'], 'Please enter a valid year',1078 msg='test_stringYear assert#1 has failed.')1079 # Test an array Year value call.1080 def test_arrayYear(self):1081 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1082 address = AuthenticateShell.data["address"], 1083 city = AuthenticateShell.data["city"],1084 state = AuthenticateShell.data["state"], 1085 zipCode = AuthenticateShell.data["zipCode"], 1086 phone = AuthenticateShell.data["phone"],1087 month = AuthenticateShell.data["month"], 1088 day = AuthenticateShell.data["day"], 1089 year = [AuthenticateShell.data["year"]],1090 firstName = AuthenticateShell.data["updatedFirstName"], 1091 lastName = AuthenticateShell.data["updatedLastName"])1092 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",1093 msg='test_arrayYear assert#1 has failed.')1094 # *********************************************************************1095 # * FirstName tests *1096 # *********************************************************************1097 1098 1099 1100 # Missing FirstName information from request call.1101 def test_missingFirstName(self):1102 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1103 address = AuthenticateShell.data["address"], 1104 city = AuthenticateShell.data["city"],1105 state = AuthenticateShell.data["state"], 1106 zipCode = AuthenticateShell.data["zipCode"], 1107 phone = AuthenticateShell.data["phone"],1108 month = AuthenticateShell.data["month"], 1109 day = AuthenticateShell.data["day"], 1110 year = AuthenticateShell.data["year"],1111 firstName = AuthenticateShell.data["updatedFirstName"], 1112 lastName = AuthenticateShell.data["updatedLastName"],1113 firstNameExclude = True)1114 self.assertEqual(responseBody['successful'], True,1115 msg='test_missingFirstName assert#1 has failed.')1116 1117 1118 1119 # Test a null FirstName.1120 def test_nullFirstName(self):1121 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1122 address = AuthenticateShell.data["address"], 1123 city = AuthenticateShell.data["city"],1124 state = AuthenticateShell.data["state"], 1125 zipCode = AuthenticateShell.data["zipCode"], 1126 phone = AuthenticateShell.data["phone"],1127 month = AuthenticateShell.data["month"], 1128 day = AuthenticateShell.data["day"], 1129 year = AuthenticateShell.data["year"],1130 firstName = '', 1131 lastName = AuthenticateShell.data["updatedLastName"])1132 self.assertEqual(responseBody['successful'], True,1133 msg='test_nullFirstName assert#1 has failed.')1134 # Test a int FirstName.1135 def test_intFirstName(self):1136 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1137 address = AuthenticateShell.data["address"], 1138 city = AuthenticateShell.data["city"],1139 state = AuthenticateShell.data["state"], 1140 zipCode = AuthenticateShell.data["zipCode"], 1141 phone = AuthenticateShell.data["phone"],1142 month = AuthenticateShell.data["month"], 1143 day = AuthenticateShell.data["day"], 1144 year = AuthenticateShell.data["year"],1145 firstName = 666666666666666666666666, 1146 lastName = AuthenticateShell.data["updatedLastName"])1147 self.assertEqual(responseBody['successful'], True,1148 msg='test_intFirstName assert#1 has failed.')1149 # Test a float FirstName.1150 def test_floatFirstName(self):1151 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1152 address = AuthenticateShell.data["address"], 1153 city = AuthenticateShell.data["city"],1154 state = AuthenticateShell.data["state"], 1155 zipCode = AuthenticateShell.data["zipCode"], 1156 phone = AuthenticateShell.data["phone"],1157 month = AuthenticateShell.data["month"], 1158 day = AuthenticateShell.data["day"], 1159 year = AuthenticateShell.data["year"],1160 firstName = 6.6666666666666, 1161 lastName = AuthenticateShell.data["updatedLastName"])1162 self.assertEqual(responseBody['successful'], True,1163 msg='test_floatFirstName assert#1 has failed.')1164 1165 1166 1167 # Test a string FirstName value call.1168 def test_stringFirstName(self):1169 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1170 address = AuthenticateShell.data["address"], 1171 city = AuthenticateShell.data["city"],1172 state = AuthenticateShell.data["state"], 1173 zipCode = AuthenticateShell.data["zipCode"], 1174 phone = AuthenticateShell.data["phone"],1175 month = AuthenticateShell.data["month"], 1176 day = AuthenticateShell.data["day"], 1177 year = AuthenticateShell.data["year"],1178 firstName = 'AuthenticateShell.data["updatedFirstName"]', 1179 lastName = AuthenticateShell.data["updatedLastName"])1180 self.assertEqual(responseBody['successful'], True,1181 msg='test_stringFirstName assert#1 has failed.')1182 # Test an array FirstName value call.1183 def test_arrayFirstName(self):1184 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1185 address = AuthenticateShell.data["address"], 1186 city = AuthenticateShell.data["city"],1187 state = AuthenticateShell.data["state"], 1188 zipCode = AuthenticateShell.data["zipCode"], 1189 phone = AuthenticateShell.data["phone"],1190 month = AuthenticateShell.data["month"], 1191 day = AuthenticateShell.data["day"], 1192 year = AuthenticateShell.data["year"],1193 firstName = [AuthenticateShell.data["updatedFirstName"]], 1194 lastName = AuthenticateShell.data["updatedLastName"])1195 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",1196 msg='test_arrayFirstName assert#1 has failed.')1197 # *********************************************************************1198 # * LastName tests *1199 # *********************************************************************1200 1201 1202 1203 # Missing LastName information from request call.1204 def test_missingLastName(self):1205 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1206 address = AuthenticateShell.data["address"], 1207 city = AuthenticateShell.data["city"],1208 state = AuthenticateShell.data["state"], 1209 zipCode = AuthenticateShell.data["zipCode"], 1210 phone = AuthenticateShell.data["phone"],1211 month = AuthenticateShell.data["month"], 1212 day = AuthenticateShell.data["day"], 1213 year = AuthenticateShell.data["year"],1214 firstName = AuthenticateShell.data["updatedFirstName"], 1215 lastName = AuthenticateShell.data["updatedLastName"],1216 lastNameExclude = True)1217 self.assertEqual(responseBody['successful'], True,1218 msg='test_missingLastName assert#1 has failed.')1219 1220 1221 1222 # Test a null LastName.1223 def test_nullLastName(self):1224 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1225 address = AuthenticateShell.data["address"], 1226 city = AuthenticateShell.data["city"],1227 state = AuthenticateShell.data["state"], 1228 zipCode = AuthenticateShell.data["zipCode"], 1229 phone = AuthenticateShell.data["phone"],1230 month = AuthenticateShell.data["month"], 1231 day = AuthenticateShell.data["day"], 1232 year = AuthenticateShell.data["year"],1233 firstName = AuthenticateShell.data["updatedFirstName"], 1234 lastName = '')1235 self.assertEqual(responseBody['successful'], True,1236 msg='test_nullLastName assert#1 has failed.')1237 # Test a int LastName.1238 def test_intLastName(self):1239 # Int LastName value.1240 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1241 address = AuthenticateShell.data["address"], 1242 city = AuthenticateShell.data["city"],1243 state = AuthenticateShell.data["state"], 1244 zipCode = AuthenticateShell.data["zipCode"], 1245 phone = AuthenticateShell.data["phone"],1246 month = AuthenticateShell.data["month"], 1247 day = AuthenticateShell.data["day"], 1248 year = AuthenticateShell.data["year"],1249 firstName = AuthenticateShell.data["updatedFirstName"], 1250 lastName = 555555555555555555555)1251 self.assertEqual(responseBody['successful'], True,1252 msg='test_intLastName assert#1 has failed.')1253 # Test a float LastName.1254 def test_floatLastName(self):1255 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1256 address = AuthenticateShell.data["address"], 1257 city = AuthenticateShell.data["city"],1258 state = AuthenticateShell.data["state"], 1259 zipCode = AuthenticateShell.data["zipCode"], 1260 phone = AuthenticateShell.data["phone"],1261 month = AuthenticateShell.data["month"], 1262 day = AuthenticateShell.data["day"], 1263 year = AuthenticateShell.data["year"],1264 firstName = AuthenticateShell.data["updatedFirstName"], 1265 lastName = 55555555.5555555555)1266 self.assertEqual(responseBody['successful'], True,1267 msg='test_floatLastName assert#1 has failed.')1268 1269 1270 1271 # Test a string LastName value call.1272 def test_stringLastName(self):1273 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1274 address = AuthenticateShell.data["address"], 1275 city = AuthenticateShell.data["city"],1276 state = AuthenticateShell.data["state"], 1277 zipCode = AuthenticateShell.data["zipCode"], 1278 phone = AuthenticateShell.data["phone"],1279 month = AuthenticateShell.data["month"], 1280 day = AuthenticateShell.data["day"], 1281 year = AuthenticateShell.data["year"],1282 firstName = AuthenticateShell.data["updatedFirstName"], 1283 lastName = 'AuthenticateShell.data["updatedLastName"]')1284 self.assertEqual(responseBody['successful'], True,1285 msg='test_stringLastName assert#1 has failed.')1286 # Test an array LastName value call.1287 def test_arrayLastName(self):1288 responseBody = self.user.update_user(accessCode = self.user.GetAccessCode(), 1289 address = AuthenticateShell.data["address"], 1290 city = AuthenticateShell.data["city"],1291 state = AuthenticateShell.data["state"], 1292 zipCode = AuthenticateShell.data["zipCode"], 1293 phone = AuthenticateShell.data["phone"],1294 month = AuthenticateShell.data["month"], 1295 day = AuthenticateShell.data["day"], 1296 year = AuthenticateShell.data["year"],1297 firstName = AuthenticateShell.data["updatedFirstName"], 1298 lastName = [AuthenticateShell.data["updatedLastName"]])1299 self.assertEqual(responseBody['errorMessage'], "An unknown error has occurred.",1300 msg='test_arrayLastName assert#1 has failed.')1301def suite():1302 suite = unittest.TestSuite()1303 suite.addTest(TestUpdateUser('test_success'))1304 suite.addTest(TestUpdateUser('test_missingAccessCode'))1305 suite.addTest(TestUpdateUser('test_nullAccessCode'))1306 suite.addTest(TestUpdateUser('test_intAccessCode'))1307 suite.addTest(TestUpdateUser('test_floatAccessCode'))1308 suite.addTest(TestUpdateUser('test_stringAccessCode'))1309 suite.addTest(TestUpdateUser('test_arrayAccessCode'))1310 suite.addTest(TestUpdateUser('test_missingAddress'))1311 suite.addTest(TestUpdateUser('test_nullAddress'))1312 suite.addTest(TestUpdateUser('test_intAddress'))1313 suite.addTest(TestUpdateUser('test_floatAddress'))1314 suite.addTest(TestUpdateUser('test_stringAddress'))1315 suite.addTest(TestUpdateUser('test_arrayAddress'))1316 suite.addTest(TestUpdateUser('test_missingCity'))1317 suite.addTest(TestUpdateUser('test_nullCity'))1318 suite.addTest(TestUpdateUser('test_intCity'))1319 suite.addTest(TestUpdateUser('test_floatCity'))1320 suite.addTest(TestUpdateUser('test_stringCity'))1321 suite.addTest(TestUpdateUser('test_arrayCity'))1322 suite.addTest(TestUpdateUser('test_missingState'))1323 suite.addTest(TestUpdateUser('test_nullState'))1324 suite.addTest(TestUpdateUser('test_intState'))1325 suite.addTest(TestUpdateUser('test_floatState'))1326 suite.addTest(TestUpdateUser('test_stringState'))1327 suite.addTest(TestUpdateUser('test_stringStateTwo'))1328 suite.addTest(TestUpdateUser('test_arrayState'))1329 suite.addTest(TestUpdateUser('test_missingZipCode'))1330 suite.addTest(TestUpdateUser('test_nullZipCode'))1331 suite.addTest(TestUpdateUser('test_intZipCode'))1332 suite.addTest(TestUpdateUser('test_floatZipCode'))1333 suite.addTest(TestUpdateUser('test_stringZipCode'))1334 suite.addTest(TestUpdateUser('test_arrayZipCode'))1335 suite.addTest(TestUpdateUser('test_missingPhone'))1336 suite.addTest(TestUpdateUser('test_nullPhone'))1337 suite.addTest(TestUpdateUser('test_intPhone'))1338 suite.addTest(TestUpdateUser('test_floatPhone'))1339 suite.addTest(TestUpdateUser('test_stringPhone'))1340 suite.addTest(TestUpdateUser('test_arrayPhone'))1341 suite.addTest(TestUpdateUser('test_missingMonth'))1342 suite.addTest(TestUpdateUser('test_nullMonth'))1343 suite.addTest(TestUpdateUser('test_intMonth'))1344 suite.addTest(TestUpdateUser('test_floatMonth'))1345 suite.addTest(TestUpdateUser('test_stringMonth'))1346 suite.addTest(TestUpdateUser('test_arrayMonth'))1347 suite.addTest(TestUpdateUser('test_missingDay'))1348 suite.addTest(TestUpdateUser('test_nullDay'))1349 suite.addTest(TestUpdateUser('test_intDay'))1350 suite.addTest(TestUpdateUser('test_floatDay'))1351 suite.addTest(TestUpdateUser('test_stringDay'))1352 suite.addTest(TestUpdateUser('test_arrayDay'))1353 suite.addTest(TestUpdateUser('test_missingYear'))1354 suite.addTest(TestUpdateUser('test_nullYear'))1355 suite.addTest(TestUpdateUser('test_intYear'))1356 suite.addTest(TestUpdateUser('test_floatYear'))1357 suite.addTest(TestUpdateUser('test_stringYear'))1358 suite.addTest(TestUpdateUser('test_arrayYear'))1359 suite.addTest(TestUpdateUser('test_missingFirstName'))1360 suite.addTest(TestUpdateUser('test_nullFirstName'))1361 suite.addTest(TestUpdateUser('test_intFirstName'))1362 suite.addTest(TestUpdateUser('test_floatFirstName'))1363 suite.addTest(TestUpdateUser('test_stringFirstName'))1364 suite.addTest(TestUpdateUser('test_arrayFirstName'))1365 suite.addTest(TestUpdateUser('test_missingLastName'))1366 suite.addTest(TestUpdateUser('test_nullLastName'))1367 suite.addTest(TestUpdateUser('test_intLastName'))1368 suite.addTest(TestUpdateUser('test_floatLastName'))1369 suite.addTest(TestUpdateUser('test_stringLastName'))1370 suite.addTest(TestUpdateUser('test_arrayLastName'))1371 1372 return suite1373 1374 1375 1376if __name__ == '__main__':1377 runner = unittest.TextTestRunner(verbosity=2)...
localauthenticator_test.py
Source:localauthenticator_test.py
1# Copyright 2016 Google Inc. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14"""Tests for pyu2f.convenience.localauthenticator."""15import base6416import sys17import mock18from pyu2f import errors19from pyu2f import model20from pyu2f.convenience import localauthenticator21if sys.version_info[:2] < (2, 7):22 import unittest2 as unittest # pylint: disable=g-import-not-at-top23else:24 import unittest # pylint: disable=g-import-not-at-top25# Input/ouput values recorded from a successful signing flow26SIGN_SUCCESS = {27 'app_id': 'test_app_id',28 'app_id_hash_encoded': 'TnMguTdPn7OcIO9f-0CgfQdY254bvc6WR-DTPZnJ49w=',29 'challenge': b'asdfasdf',30 'challenge_hash_encoded': 'qhJtbTQvsU0BmLLpDWes-3zFGbegR2wp1mv5BJ2BwC0=',31 'key_handle_encoded': ('iBbl9-VYt-XSdWeHVNX-gfQcXGzlrAQ7BcngVNUxWijIQQlnZEI'32 '4Vb0Bp2ydBCbIQu_5rNlKqPH6NK1TtnM7fA=='),33 'origin': 'test_origin',34 'signature_data_encoded': ('AQAAAI8wRQIhALlIPo6Hg8HwzELdYRIXnAnpsiHYCSXHex'35 'CS34eiS2ixAiBt3TRmKE1A9WyMjc3JGrGI7gSPg-QzDSNL'36 'aIj7JwcCTA=='),37 'client_data_encoded': ('eyJjaGFsbGVuZ2UiOiAiWVhOa1ptRnpaR1kiLCAib3JpZ2luI'38 'jogInRlc3Rfb3JpZ2luIiwgInR5cCI6ICJuYXZpZ2F0b3IuaW'39 'QuZ2V0QXNzZXJ0aW9uIn0='),40 'u2f_version': 'U2F_V2'41}42SIGN_SUCCESS['registered_key'] = model.RegisteredKey(43 base64.urlsafe_b64decode(SIGN_SUCCESS['key_handle_encoded']))44SIGN_SUCCESS['client_data'] = model.ClientData(45 model.ClientData.TYP_AUTHENTICATION,46 SIGN_SUCCESS['challenge'],47 SIGN_SUCCESS['origin'])48@mock.patch.object(sys, 'stderr', new=mock.MagicMock())49class LocalAuthenticatorTest(unittest.TestCase):50 @mock.patch.object(localauthenticator.u2f, 'GetLocalU2FInterface')51 def testSignSuccess(self, mock_get_u2f_method):52 """Test successful signing with a valid key."""53 # Prepare u2f mocks54 mock_u2f = mock.MagicMock()55 mock_get_u2f_method.return_value = mock_u2f56 mock_authenticate = mock.MagicMock()57 mock_u2f.Authenticate = mock_authenticate58 mock_authenticate.return_value = model.SignResponse(59 base64.urlsafe_b64decode(SIGN_SUCCESS['key_handle_encoded']),60 base64.urlsafe_b64decode(SIGN_SUCCESS['signature_data_encoded']),61 SIGN_SUCCESS['client_data']62 )63 # Call LocalAuthenticator64 challenge_data = [{'key': SIGN_SUCCESS['registered_key'],65 'challenge': SIGN_SUCCESS['challenge']}]66 authenticator = localauthenticator.LocalAuthenticator('testorigin')67 self.assertTrue(authenticator.IsAvailable())68 response = authenticator.Authenticate(SIGN_SUCCESS['app_id'],69 challenge_data)70 # Validate that u2f authenticate was called with the correct values71 self.assertTrue(mock_authenticate.called)72 authenticate_args = mock_authenticate.call_args[0]73 self.assertEqual(len(authenticate_args), 3)74 self.assertEqual(authenticate_args[0], SIGN_SUCCESS['app_id'])75 self.assertEqual(authenticate_args[1], SIGN_SUCCESS['challenge'])76 registered_keys = authenticate_args[2]77 self.assertEqual(len(registered_keys), 1)78 self.assertEqual(registered_keys[0], SIGN_SUCCESS['registered_key'])79 # Validate authenticator response80 self.assertEquals(response.get('clientData'),81 SIGN_SUCCESS['client_data_encoded'])82 self.assertEquals(response.get('signatureData'),83 SIGN_SUCCESS['signature_data_encoded'])84 self.assertEquals(response.get('applicationId'),85 SIGN_SUCCESS['app_id'])86 self.assertEquals(response.get('keyHandle'),87 SIGN_SUCCESS['key_handle_encoded'])88 @mock.patch.object(localauthenticator.u2f, 'GetLocalU2FInterface')89 def testSignMultipleIneligible(self, mock_get_u2f_method):90 """Test signing with multiple keys registered, but none eligible."""91 # Prepare u2f mocks92 mock_u2f = mock.MagicMock()93 mock_get_u2f_method.return_value = mock_u2f94 mock_authenticate = mock.MagicMock()95 mock_u2f.Authenticate = mock_authenticate96 mock_authenticate.side_effect = errors.U2FError(97 errors.U2FError.DEVICE_INELIGIBLE)98 # Call LocalAuthenticator99 challenge_item = {'key': SIGN_SUCCESS['registered_key'],100 'challenge': SIGN_SUCCESS['challenge']}101 challenge_data = [challenge_item, challenge_item]102 authenticator = localauthenticator.LocalAuthenticator('testorigin')103 with self.assertRaises(errors.U2FError) as cm:104 authenticator.Authenticate(SIGN_SUCCESS['app_id'],105 challenge_data)106 self.assertEquals(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)107 @mock.patch.object(localauthenticator.u2f, 'GetLocalU2FInterface')108 def testSignMultipleSuccess(self, mock_get_u2f_method):109 """Test signing with multiple keys registered and one is eligible."""110 # Prepare u2f mocks111 mock_u2f = mock.MagicMock()112 mock_get_u2f_method.return_value = mock_u2f113 mock_authenticate = mock.MagicMock()114 mock_u2f.Authenticate = mock_authenticate115 return_value = model.SignResponse(116 base64.urlsafe_b64decode(SIGN_SUCCESS['key_handle_encoded']),117 base64.urlsafe_b64decode(SIGN_SUCCESS['signature_data_encoded']),118 SIGN_SUCCESS['client_data']119 )120 mock_authenticate.side_effect = [121 errors.U2FError(errors.U2FError.DEVICE_INELIGIBLE),122 return_value123 ]124 # Call LocalAuthenticator125 challenge_item = {'key': SIGN_SUCCESS['registered_key'],126 'challenge': SIGN_SUCCESS['challenge']}127 challenge_data = [challenge_item, challenge_item]128 authenticator = localauthenticator.LocalAuthenticator('testorigin')129 response = authenticator.Authenticate(SIGN_SUCCESS['app_id'],130 challenge_data)131 # Validate that u2f authenticate was called with the correct values132 self.assertTrue(mock_authenticate.called)133 authenticate_args = mock_authenticate.call_args[0]134 self.assertEqual(len(authenticate_args), 3)135 self.assertEqual(authenticate_args[0], SIGN_SUCCESS['app_id'])136 self.assertEqual(authenticate_args[1], SIGN_SUCCESS['challenge'])137 registered_keys = authenticate_args[2]138 self.assertEqual(len(registered_keys), 1)139 self.assertEqual(registered_keys[0], SIGN_SUCCESS['registered_key'])140 # Validate authenticator response141 self.assertEquals(response.get('clientData'),142 SIGN_SUCCESS['client_data_encoded'])143 self.assertEquals(response.get('signatureData'),144 SIGN_SUCCESS['signature_data_encoded'])145 self.assertEquals(response.get('applicationId'),146 SIGN_SUCCESS['app_id'])147 self.assertEquals(response.get('keyHandle'),148 SIGN_SUCCESS['key_handle_encoded'])149if __name__ == '__main__':...
test_authenticate.py
Source:test_authenticate.py
...10}11class TestAuthenticate(TestBase):12 @patch("aws_okta_processor.commands.authenticate.JSONFileCache")13 @patch("aws_okta_processor.commands.authenticate.SAMLFetcher")14 def test_authenticate(self, mock_saml_fetcher, mock_json_file_cache):15 mock_saml_fetcher().fetch_credentials.return_value = CREDENTIALS16 auth = Authenticate(self.OPTIONS)17 credentials = auth.authenticate()18 mock_json_file_cache.assert_called_once_with()19 assert credentials == CREDENTIALS20 @patch("aws_okta_processor.commands.authenticate.print")21 def test_run(self, mock_print):22 auth = Authenticate(self.OPTIONS)23 auth.authenticate = (lambda: CREDENTIALS)24 auth.run()25 mock_print.assert_called_once_with(26 '{"AccessKeyId": "access_key_id", '27 '"SecretAccessKey": "secret_access_key", '28 '"SessionToken": "session_token", '29 '"Version": 1}'30 )31 @patch("aws_okta_processor.commands.authenticate.os")...
test_authenticate_header.py
Source:test_authenticate_header.py
1from authparser import AuthParser2def handler():3 pass4def test_single_scheme_single_line_implicit():5 # arrange6 parser = AuthParser()7 parser.add_handler('Basic', handler)8 # act9 authenticate = parser.get_challenge_header()10 # assert11 assert len(authenticate) == 112 assert 'WWW-Authenticate' in authenticate13 assert authenticate['WWW-Authenticate'] == 'Basic'14def test_single_scheme_single_line_explicit():15 # arrange16 parser = AuthParser()17 parser.add_handler('Basic', handler)18 # act19 authenticate = parser.get_challenge_header(multi_line=False)20 # assert21 assert len(authenticate) == 122 assert 'WWW-Authenticate' in authenticate23 assert authenticate['WWW-Authenticate'] == 'Basic'24def test_single_scheme_multi_line():25 # arrange26 parser = AuthParser()27 parser.add_handler('Basic', handler)28 # act29 authenticate = parser.get_challenge_header(multi_line=True)30 # assert31 assert len(authenticate) == 132 assert len(authenticate[0]) == 133 assert 'WWW-Authenticate' in authenticate[0]34 assert authenticate[0]['WWW-Authenticate'] == 'Basic'35def test_multiple_schemes():36 # arrange37 parser = AuthParser()38 parser.add_handler('Basic', handler)39 parser.add_handler('Bearer', handler)40 # act41 authenticate = parser.get_challenge_header(multi_line=True)42 # assert43 assert len(authenticate) == 244def test_multiple_schemes_single_line():45 # arrange46 parser = AuthParser()47 parser.add_handler('Basic', handler)48 parser.add_handler('Bearer', handler)49 # act50 authenticate = parser.get_challenge_header()51 # assert52 assert len(authenticate) == 153 assert 'WWW-Authenticate' in authenticate54 assert authenticate['WWW-Authenticate'] == 'Basic, Bearer'55def test_single_scheme_default_params():56 # arrange57 parser = AuthParser()58 parser.add_handler('Basic', handler, realm="pointw.com")59 # act60 authenticate = parser.get_challenge_header()61 # assert62 assert len(authenticate) == 163 assert 'WWW-Authenticate' in authenticate64 assert authenticate['WWW-Authenticate'] == 'Basic realm="pointw.com"'65def test_single_scheme_runtime_params():66 # arrange67 def basic_challenge(**kwargs):68 realm = kwargs.get('realm')69 if realm:70 return {'realm': realm}71 parser = AuthParser()72 parser.add_handler('Basic', handler, basic_challenge)73 # act74 authenticate = parser.get_challenge_header(realm="pointw.com")75 # assert76 assert len(authenticate) == 177 assert 'WWW-Authenticate' in authenticate78 assert authenticate['WWW-Authenticate'] == 'Basic realm="pointw.com"'79def test_multiple_schemes_runtime_params_single_line():80 # arrange81 def basic_challenge(**kwargs):82 realm = kwargs.get('realm')83 if realm:84 return {'realm': realm}85 def bearer_challenge(**kwargs):86 error = kwargs.get('error')87 if error:88 return {'error': 'invalid_token'}89 parser = AuthParser()90 parser.add_handler('Basic', handler, basic_challenge)91 parser.add_handler('Bearer', handler, bearer_challenge)92 # act93 authenticate = parser.get_challenge_header(realm="pointw.com", error=True)94 # assert95 assert len(authenticate) == 196 assert 'WWW-Authenticate' in authenticate97 assert authenticate['WWW-Authenticate'] == 'Basic realm="pointw.com", Bearer error="invalid_token"'98def test_multiple_schemes_runtime_params_multi_line():99 # arrange100 def basic_challenge(**kwargs):101 realm = kwargs.get('realm')102 if realm:103 return {'realm': realm}104 def bearer_challenge(**kwargs):105 error = kwargs.get('error')106 if error:107 return {'error': 'invalid_token'}108 parser = AuthParser()109 parser.add_handler('Basic', handler, basic_challenge)110 parser.add_handler('Bearer', handler, bearer_challenge)111 # act112 authenticate = parser.get_challenge_header(realm="pointw.com", error=True, multi_line=True)113 # assert114 assert len(authenticate) == 2115 assert len(authenticate[0]) == 1116 assert 'WWW-Authenticate' in authenticate[0]117 assert len(authenticate[1]) == 1118 assert 'WWW-Authenticate' in authenticate[1]119 assert authenticate[0]['WWW-Authenticate'] == 'Basic realm="pointw.com"'...
SettingsTab.py
Source:SettingsTab.py
...43 settingsPanel.initPanel.Show(False)44 return settingsPanel45 def OnClick(self,authenticatePanel,initPanel,event):46 obj =Delegate()47 isValid=obj.authenticate(authenticatePanel.pwdLabelText.getValue())48 if isValid :49 authenticatePanel.Show(False)50 initPanel.Show(True)51 else:52 authenticatePanel.loginFailedTxt.Show(True)53 def OnFocus(self,authenticatePanel,initPanel,event):54 authenticatePanel.Show(True)55 initPanel.Show(False)...
test_views.py
Source:test_views.py
...8class LoginViewTest(TestCase):9 ### Helper Functions10 def get_login_page(self):11 return self.client.get('/accounts/login/')12 def create_user_and_mock_authenticate(self, mock_authenticate):13 user = User.objects.create(username='mockuser', password='mypass')14 user.backend = ''15 mock_authenticate.return_value = user16 return user17 def login_user(self, username, password):18 return self.client.post(19 '/accounts/login/',20 data={'username': username, 'password': password}21 )22 ### Tests23 def test_login_page_can_be_accessed(self):24 self.assertEqual(self.get_login_page().status_code, 200)25 def test_uses_login_template(self):26 response = self.get_login_page()27 self.assertTemplateUsed(response, 'accounts/login.html')28 def test_renders_LoginForm(self):29 response = self.get_login_page()30 self.assertIsInstance(response.context['form'], LoginForm)31 @patch('accounts.views.authenticate')32 def test_calls_authenticate(self, mock_authenticate):33 mock_authenticate.return_value = None34 self.client.post(35 '/accounts/login/', 36 data={'username': 'mockuser', 'password': 'mypass'})37 mock_authenticate.assert_called_once_with(38 username='mockuser', password='mypass'39 )40 @patch('accounts.views.authenticate')41 def test_gets_logged_in_if_authenticate_returns_user(42 self, mock_authenticate):43 user = self.create_user_and_mock_authenticate(mock_authenticate)44 self.login_user(user.username, user.password)45 self.assertEqual(self.client.session[SESSION_KEY], str(user.pk))46 @patch('accounts.views.authenticate')47 def test_redirects_to_homepage_if_login_successful(48 self, mock_authenticate):49 user = self.create_user_and_mock_authenticate(mock_authenticate)50 response = self.login_user(user.username, user.password)51 self.assertRedirects(response, '/analise_criminal/')52 @patch('accounts.views.authenticate')53 def test_does_not_get_logged_in_if_authenticate_returns_None(54 self, mock_authenticate):55 mock_authenticate.return_value = None56 self.login_user('non-existing-user', 'non-existing-pass')57 self.assertNotIn(SESSION_KEY, self.client.session)58 @patch('accounts.views.authenticate')59 def test_shows_error_if_authentication_failed(self, mock_authenticate):60 mock_authenticate.return_value = None61 response = self.login_user('non-existing-user', 'non-existing-pass')...
AuthenticationComponentBase.py
Source:AuthenticationComponentBase.py
...65 AuthenticationActionType.DELETE, 66 self.authTypeDispatcher(objects).rootAuthenticate(AuthenticationActionType.DELETE)67 )68 return dispatcher69 def authenticate(self, route, objects):...
test_authenticator.py
Source:test_authenticator.py
...15 environ = {}16 password = 'somepass'17 user = CreateTestData.create_user('a_user', **{'password': password})18 identity = {'login': user.name, 'password': password}19 username = self.authenticate(environ, identity)20 assert username == user.name, username21 def test_authenticate_fails_if_user_is_deleted(self):22 environ = {}23 password = 'somepass'24 user = CreateTestData.create_user('a_user', **{'password': password})25 identity = {'login': user.name, 'password': password}26 user.delete()27 assert self.authenticate(environ, identity) is None28 def test_authenticate_fails_if_user_is_pending(self):29 environ = {}30 password = 'somepass'31 user = CreateTestData.create_user('a_user', **{'password': password})32 identity = {'login': user.name, 'password': password}33 user.set_pending()34 assert self.authenticate(environ, identity) is None35 def test_authenticate_fails_if_password_is_wrong(self):36 environ = {}37 user = CreateTestData.create_user('a_user')38 identity = {'login': user.name, 'password': 'wrong-password'}39 assert self.authenticate(environ, identity) is None40 def test_authenticate_fails_if_received_no_login_or_pass(self):41 environ = {}42 identity = {}43 assert self.authenticate(environ, identity) is None44 def test_authenticate_fails_if_received_just_login(self):45 environ = {}46 identity = {'login': 'some-user'}47 assert self.authenticate(environ, identity) is None48 def test_authenticate_fails_if_received_just_password(self):49 environ = {}50 identity = {'password': 'some-password'}51 assert self.authenticate(environ, identity) is None52 def test_authenticate_fails_if_user_doesnt_exist(self):53 environ = {}54 identity = {'login': 'inexistent-user'}...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 const cookies = await context.cookies();7 console.log(cookies);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch({ headless: false });13 const context = await browser.newContext();14 const page = await context.newPage();15 const cookies = await context.cookies();16 console.log(cookies);17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch({ headless: false });22 const context = await browser.newContext();23 const page = await context.newPage();24 const cookies = await context.cookies();25 console.log(cookies);26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch({ headless: false });31 const context = await browser.newContext();32 const page = await context.newPage();33 const cookies = await context.cookies();34 console.log(cookies);35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch({ headless: false });40 const context = await browser.newContext();41 const page = await context.newPage();42 const cookies = await context.cookies();43 console.log(cookies);44 await browser.close();45})();46const { chromium } = require('playwright');47(async () => {48 const browser = await chromium.launch({ headless: false });49 const context = await browser.newContext();50 const page = await context.newPage();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 await context.authenticate({6 });7 const page = await context.newPage();8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 await context.authenticate({15 });16 const page = await context.newPage();17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 await context.authenticate({24 });25 const page = await context.newPage();26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 await context.authenticate({33 });34 const page = await context.newPage();35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 await context.authenticate({42 });43 const page = await context.newPage();44 await browser.close();45})();46const {
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: 'google.png' });6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 await page.screenshot({ path: 'google.png' });13 await browser.close();14})();
Using AI Code Generation
1const { chromium } = require('playwright');2const { authenticate } = require('playwright/lib/server/authenticate');3const { createServer } = require('playwright/lib/server/server');4(async () => {5 const server = await createServer();6 const port = server.port;7 const token = await authenticate(server);8 server.close();9 const browser = await chromium.connectOverCDP({10 });11 const context = await browser.newContext();12 const page = await context.newPage();13 await page.screenshot({ path: 'example.png' });14 await browser.close();15})();16### `server = await createServer([options])`
Using AI Code Generation
1const { chromium } = require('playwright');2const { authenticate } = require('playwright/lib/server/browserServer');3const { createReadStream } = require('fs');4const path = require('path');5const { promisify } = require('util');6const { exec } = require('child_process');7const sleep = promisify(setTimeout);8(async () => {9 const browser = await chromium.launch({10 });11 const context = await browser.newContext();12 const page = await context.newPage();13 const browserWSEndpoint = browser.wsEndpoint();14 await browser.close();15 const { default: fetch } = require('node-fetch');16 const { chromium: chromium2 } = require('playwright');17 const browser2 = await chromium2.connect({18 });19 const context2 = await browser2.newContext();20 const page2 = await context2.newPage();21 await sleep(1000000000);22})();23const { chromium } = require('playwright');24const { authenticate } = require('playwright/lib/server/browserServer');25const { createReadStream } = require('fs');26const path = require('path');27const { promisify } = require('util');28const { exec } = require('child_process');29const sleep = promisify(setTimeout);30(async () => {31 const browser = await chromium.launch({32 });33 const context = await browser.newContext();34 const page = await context.newPage();35 const browserWSEndpoint = browser.wsEndpoint();36 await browser.close();37 const { default: fetch } = require('node-fetch');38 const { chromium: chromium2 } = require('playwright');39 const browser2 = await chromium2.connect({40 });41 const context2 = await browser2.newContext();42 const page2 = await context2.newPage();43 await sleep(1000000000);44})();
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!