|
53 | 53 | "authn_auth": "http://www.example.com/login" |
54 | 54 | } |
55 | 55 |
|
| 56 | +encode_fn = getattr(base64, 'encodebytes', base64.encodestring) |
| 57 | + |
56 | 58 |
|
57 | 59 | def generate_cert(): |
58 | 60 | sn = uuid.uuid4().urn |
@@ -177,7 +179,7 @@ def test_create_attribute_query1(self): |
177 | 179 | "E8042FB4-4D5B-48C3-8E14-8EDD852790DD", |
178 | 180 | format=saml.NAMEID_FORMAT_PERSISTENT, |
179 | 181 | message_id="id1") |
180 | | - reqstr = "%s" % req.to_string().decode('utf-8') |
| 182 | + reqstr = "%s" % req.to_string().decode() |
181 | 183 |
|
182 | 184 | assert req.destination == "https://idp.example.com/idp/" |
183 | 185 | assert req.id == "id1" |
@@ -411,7 +413,7 @@ def test_response_1(self): |
411 | 413 |
|
412 | 414 | resp_str = "%s" % resp |
413 | 415 |
|
414 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 416 | + resp_str = encode_fn(resp_str.encode()) |
415 | 417 |
|
416 | 418 | authn_response = self.client.parse_authn_request_response( |
417 | 419 | resp_str, BINDING_HTTP_POST, |
@@ -455,7 +457,7 @@ def test_response_1(self): |
455 | 457 | |
456 | 458 | authn=AUTHN) |
457 | 459 |
|
458 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 460 | + resp_str = encode_fn(resp_str.encode()) |
459 | 461 |
|
460 | 462 | self.client.parse_authn_request_response( |
461 | 463 | resp_str, BINDING_HTTP_POST, |
@@ -505,7 +507,7 @@ def test_response_2(self): |
505 | 507 |
|
506 | 508 | resp_str = "%s" % resp |
507 | 509 |
|
508 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 510 | + resp_str = encode_fn(resp_str.encode()) |
509 | 511 |
|
510 | 512 | authn_response = _client.parse_authn_request_response( |
511 | 513 | resp_str, BINDING_HTTP_POST, |
@@ -540,7 +542,7 @@ def test_response_3(self): |
540 | 542 |
|
541 | 543 | resp_str = "%s" % resp |
542 | 544 |
|
543 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 545 | + resp_str = encode_fn(resp_str.encode()) |
544 | 546 |
|
545 | 547 | authn_response = _client.parse_authn_request_response( |
546 | 548 | resp_str, BINDING_HTTP_POST, |
@@ -575,7 +577,7 @@ def test_response_4(self): |
575 | 577 |
|
576 | 578 | resp_str = "%s" % resp |
577 | 579 |
|
578 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 580 | + resp_str = encode_fn(resp_str.encode()) |
579 | 581 |
|
580 | 582 | authn_response = _client.parse_authn_request_response( |
581 | 583 | resp_str, BINDING_HTTP_POST, |
@@ -619,7 +621,7 @@ def test_response_5(self): |
619 | 621 |
|
620 | 622 | resp_str = "%s" % resp |
621 | 623 |
|
622 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 624 | + resp_str = encode_fn(resp_str.encode()) |
623 | 625 |
|
624 | 626 | authn_response = _client.parse_authn_request_response( |
625 | 627 | resp_str, BINDING_HTTP_POST, |
@@ -672,7 +674,7 @@ def test_response_6(self): |
672 | 674 |
|
673 | 675 | resp_str = "%s" % resp |
674 | 676 |
|
675 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 677 | + resp_str = encode_fn(resp_str.encode()) |
676 | 678 |
|
677 | 679 | authn_response = _client.parse_authn_request_response( |
678 | 680 | resp_str, BINDING_HTTP_POST, |
@@ -708,7 +710,7 @@ def test_response_7(self): |
708 | 710 |
|
709 | 711 | resp_str = "%s" % resp |
710 | 712 |
|
711 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 713 | + resp_str = encode_fn(resp_str.encode()) |
712 | 714 |
|
713 | 715 | authn_response = _client.parse_authn_request_response( |
714 | 716 | resp_str, BINDING_HTTP_POST, |
@@ -751,7 +753,7 @@ def test_response_8(self): |
751 | 753 |
|
752 | 754 | resp_str = "%s" % resp |
753 | 755 |
|
754 | | - resp_str = base64.encodestring(resp_str.encode('utf-8')) |
| 756 | + resp_str = encode_fn(resp_str.encode()) |
755 | 757 |
|
756 | 758 | authn_response = _client.parse_authn_request_response( |
757 | 759 | resp_str, BINDING_HTTP_POST, |
@@ -927,7 +929,7 @@ def test_sign_then_encrypt_assertion2(self): |
927 | 929 |
|
928 | 930 | # seresp = samlp.response_from_string(enctext) |
929 | 931 |
|
930 | | - resp_str = base64.encodestring(enctext.encode('utf-8')) |
| 932 | + resp_str = encode_fn(enctext.encode()) |
931 | 933 | # Now over to the client side |
932 | 934 | # Explicitely allow unsigned responses for this and the following 2 tests |
933 | 935 | self.client.want_response_signed = False |
@@ -1030,7 +1032,7 @@ def test_sign_then_encrypt_assertion_advice_1(self): |
1030 | 1032 |
|
1031 | 1033 | # seresp = samlp.response_from_string(enctext) |
1032 | 1034 |
|
1033 | | - resp_str = base64.encodestring(enctext.encode('utf-8')) |
| 1035 | + resp_str = encode_fn(enctext.encode()) |
1034 | 1036 | # Now over to the client side |
1035 | 1037 | resp = self.client.parse_authn_request_response( |
1036 | 1038 | resp_str, BINDING_HTTP_POST, |
@@ -1315,7 +1317,7 @@ def test_sign_then_encrypt_assertion_advice_2(self): |
1315 | 1317 |
|
1316 | 1318 | # seresp = samlp.response_from_string(enctext) |
1317 | 1319 |
|
1318 | | - resp_str = base64.encodestring(str(response).encode('utf-8')) |
| 1320 | + resp_str = encode_fn(str(response).encode()) |
1319 | 1321 | # Now over to the client side |
1320 | 1322 | resp = self.client.parse_authn_request_response( |
1321 | 1323 | resp_str, BINDING_HTTP_POST, |
|
0 commit comments