def test_validate_incorrect_oid(self): cert = self.readCert("mock-011-correct.cert") user = UziPassUser(self.succ, cert) validator = UziPassValidator(True, [], []) user["OidCa"] = "1.2.3.4" with self.assertRaises(exceptions.UziException, msg="Empty User Provided"): validator.validate(user)
def test_is_valid(self): cert = self.readCert("mock-011-correct.cert") user = UziPassUser(self.succ, cert) user["CardType"] = UZI_TYPE_CARE_PROVIDER user["Role"] = UZI_ROLE_DENTIST validator = UziPassValidator(True, [UZI_TYPE_CARE_PROVIDER], [UZI_ROLE_DENTIST]) self.assertTrue(validator.is_valid(user)) user["Role"] = UZI_ROLE_NURSE self.assertFalse(validator.is_valid(user))
def test_validate_incorrect_oid(self): cert = self.readCert("mock-011-correct.cert") user = UziPassUser(self.succ, cert) validator = UziPassValidator(True, [], []) user["OidCa"] = "1.2.3.4" with self.assertRaises( UziCaException, msg="CA OID not UZI register Care Provider or named employee", ): validator.validate(user)
def checkUser(self, path, message=None, types=[], roles=[], exception=UziException): cert = self.readCert(path) user = UziPassUser(self.succ, cert) with self.assertRaises(exception, msg=message): validator = UziPassValidator(True, types, roles) validator.validate(user)
def test_check_valid_admin_cert(self): cert = self.readCert("mock-012-correct-admin.cert") data = UziPassUser(self.succ, cert) self.assertEqual("00000000", data["AgbCode"]) self.assertEqual("N", data["CardType"]) self.assertEqual("john", data["givenName"]) self.assertEqual("2.16.528.1.1003.1.3.5.5.2", data["OidCa"]) self.assertEqual("01.015", data["Role"]) self.assertEqual("90000111", data["SubscriberNumber"]) self.assertEqual("doe-11111111", data["surName"]) self.assertEqual("11111111", data["UziNumber"]) self.assertEqual("1", data["UziVersion"])
def test_check_no_client_cert(self): with self.assertRaises(exceptions.UziExceptionClientCertError): UziPassUser(self.succ)
def test_check_ssl_client_failed(self): with self.assertRaises(exceptions.UziExceptionServerConfigError): UziPassUser()
def test_check_request_has_no_cert(self): with self.assertRaises(exceptions.UziExceptionServerConfigError): UziPassUser()
def checkCert(self, path, message=None): cert = self.readCert(path) with self.assertRaises(exceptions.UziException, msg=message): UziPassUser(self.succ, cert)