Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_valid_ids_mixed_type(self):
self.assertTrue(verify_rp_id(b"example.com", "https://register.example.com"))
self.assertTrue(verify_rp_id("example.com", b"https://fido.example.com"))
self.assertTrue(verify_rp_id(b"example.com", b"https://www.example.com:444"))
def test_suffix_list(self):
self.assertFalse(verify_rp_id(b"co.uk", "https://foobar.co.uk"))
self.assertTrue(verify_rp_id(b"foobar.co.uk", "https://site.foobar.co.uk"))
self.assertFalse(verify_rp_id(b"appspot.com", "https://example.appspot.com"))
self.assertTrue(
verify_rp_id(b"example.appspot.com", "https://example.appspot.com")
)
def test_invalid_ids_mixed_type(self):
self.assertFalse(verify_rp_id(b"example.com", "http://example.com"))
self.assertFalse(verify_rp_id("example.com", b"http://www.example.com"))
self.assertFalse(verify_rp_id(b"example.com", b"https://example-test.com"))
def test_invalid_ids(self):
self.assertFalse(verify_rp_id("example.com", "http://example.com"))
self.assertFalse(verify_rp_id("example.com", "http://www.example.com"))
self.assertFalse(verify_rp_id("example.com", "https://example-test.com"))
self.assertFalse(
verify_rp_id("companyA.hosting.example.com", "https://register.example.com")
)
self.assertFalse(
verify_rp_id(
"companyA.hosting.example.com", "https://companyB.hosting.example.com"
)
def test_suffix_list(self):
self.assertFalse(verify_rp_id(b"co.uk", "https://foobar.co.uk"))
self.assertTrue(verify_rp_id(b"foobar.co.uk", "https://site.foobar.co.uk"))
self.assertFalse(verify_rp_id(b"appspot.com", "https://example.appspot.com"))
self.assertTrue(
verify_rp_id(b"example.appspot.com", "https://example.appspot.com")
)
def test_invalid_ids_mixed_type(self):
self.assertFalse(verify_rp_id(b"example.com", "http://example.com"))
self.assertFalse(verify_rp_id("example.com", b"http://www.example.com"))
self.assertFalse(verify_rp_id(b"example.com", b"https://example-test.com"))
def test_valid_ids(self):
self.assertTrue(verify_rp_id("example.com", "https://register.example.com"))
self.assertTrue(verify_rp_id("example.com", "https://fido.example.com"))
self.assertTrue(verify_rp_id("example.com", "https://www.example.com:444"))
def test_invalid_ids_mixed_type(self):
self.assertFalse(verify_rp_id(b"example.com", "http://example.com"))
self.assertFalse(verify_rp_id("example.com", b"http://www.example.com"))
self.assertFalse(verify_rp_id(b"example.com", b"https://example-test.com"))
def test_valid_ids(self):
self.assertTrue(verify_rp_id("example.com", "https://register.example.com"))
self.assertTrue(verify_rp_id("example.com", "https://fido.example.com"))
self.assertTrue(verify_rp_id("example.com", "https://www.example.com:444"))
def __init__(self, device, origin, verify=verify_rp_id):
super(Fido2Client, self).__init__(origin, verify)
self.ctap1_poll_delay = 0.25
try:
self.ctap2 = CTAP2(device)
self.info = self.ctap2.get_info()
if PinProtocolV1.VERSION in self.info.pin_protocols:
self.pin_protocol = PinProtocolV1(self.ctap2)
else:
self.pin_protocol = None
self._do_make_credential = self._ctap2_make_credential
self._do_get_assertion = self._ctap2_get_assertion
except (ValueError, CtapError):
self.ctap1 = CTAP1(device)
self.info = _CTAP1_INFO
self._do_make_credential = self._ctap1_make_credential