async def get_as_details(self,
                             ods_code: str,
                             interaction_id: str,
                             managing_organization: str = None,
                             party_key: str = None) -> List[Dict]:
        """
        Returns the device details for the given parameters

        :return: Dictionary of the attributes of the device associated with the given parameters
        """
        if not ods_code or not interaction_id:
            raise SDSException("org_code and interaction_id must be provided")

        query_parts = [("nhsIDCode", ods_code), ("objectClass", "nhsAs"),
                       ("nhsAsSvcIA", interaction_id),
                       ("nhsMhsManufacturerOrg", managing_organization),
                       ("nhsMHSPartyKey", party_key)]

        # TODO: can't use atm with Opentest as it lacks required schema attribute
        if str2bool(
                config.get_config('DISABLE_MANUFACTURER_ORG_SEARCH_PARAM',
                                  default=str(False))):
            query_parts.remove(
                ("nhsMhsManufacturerOrg", managing_organization))

        result = await self._get_ldap_data(query_parts, AS_ATTRIBUTES)
        return result
Ejemplo n.º 2
0
def _configure_ldap_connection(server) -> ldap3.Connection:
    lazy_ldap = str2bool(config.get_config("LAZY_LDAP", default=str(True)))
    if lazy_ldap:
        connection = ldap3.Connection(server,
                                      lazy=True,
                                      auto_bind=ldap3.AUTO_BIND_NO_TLS,
                                      client_strategy=ldap3.ASYNC)
    else:
        connection = ldap3.Connection(server,
                                      auto_bind=True,
                                      client_strategy=ldap3.REUSABLE)
    logger.info('LDAP connection configured successfully')
    return connection
Ejemplo n.º 3
0
def get_sds_client():
    use_mock = str2bool(
        config.get_config('MOCK_LDAP_RESPONSE', default=str(False)))
    if use_mock:
        pause_duration = int(config.get_config('MOCK_LDAP_PAUSE', default="0"))
        logger.warning(
            "!!! IMPORTANT !!! Using LDAP mock response with %sms delay",
            pause_duration)
        return SDSMockClient()
    else:
        sds_connection = sds_connection_factory.create_connection()
        search_base = config.get_config("LDAP_SEARCH_BASE")
        return SDSClient(sds_connection, search_base)
Ejemplo n.º 4
0
 def test_values_are_correctly_parsed_to_False(self):
     for value in ['false', 'False', 'FALSE']:
         self.assertFalse(str2bool(value))