Exemplo n.º 1
0
def test_find_org_by_name_branch_name(session, auth_mock):  # pylint:disable=unused-argument
    """Assert that an org can be retrieved by its name annd branch nanme."""
    org = factory_org_service(org_info=TestOrgInfo.org2)
    dictionary = org.as_dict()
    org_name = dictionary['name']
    branch_name = dictionary['branch_name']

    found_org = OrgService.find_by_org_name(org_name)

    assert found_org
    assert found_org.get('orgs')[0].get('name') == org_name

    found_org = OrgService.find_by_org_name(org_name, branch_name=branch_name)

    assert found_org
    assert found_org.get('orgs')[0].get('name') == org_name
    assert found_org.get('orgs')[0].get('branch_name') == branch_name
Exemplo n.º 2
0
def test_find_org_by_name(session, auth_mock):  # pylint:disable=unused-argument
    """Assert that an org can be retrieved by its name."""
    org = factory_org_service()
    dictionary = org.as_dict()
    org_name = dictionary['name']

    found_org = OrgService.find_by_org_name(org_name)

    assert found_org
    assert found_org.get('orgs')[0].get('name') == org_name
Exemplo n.º 3
0
    def get():
        """Search orgs."""
        # Search based on request arguments
        business_identifier = request.args.get('affiliation', None)
        name = request.args.get('name', None)
        statuses = request.args.getlist('status', None)
        access_type = request.args.get('access_type', None)
        bcol_account_id = request.args.get('bcolAccountId', None)
        page = request.args.get('page', 1)
        limit = request.args.get('limit', 10)
        validate_name = request.args.get('validateName', 'False')

        try:
            token = g.jwt_oidc_token_info
            if validate_name.upper() == 'TRUE':
                response, status = OrgService.find_by_org_name(
                    name), http_status.HTTP_200_OK
            else:
                response, status = OrgService.search_orgs(
                    business_identifier=business_identifier,
                    access_type=access_type,
                    name=name,
                    statuses=statuses,
                    bcol_account_id=bcol_account_id,
                    page=page,
                    limit=limit,
                    token=token), http_status.HTTP_200_OK

            # If public user is searching , return 200 with empty results if orgs exist
            # Else return 204

            is_public_user = Role.PUBLIC_USER.value in token.get(
                'realm_access').get('roles')
            if is_public_user:  # public user cant get the details in search.Gets only status of orgs
                if response and response.get('orgs'):
                    status = http_status.HTTP_200_OK
                else:
                    status = http_status.HTTP_204_NO_CONTENT
                response = {}  # Do not return any results if searching by name

        except BusinessException as exception:
            response, status = {
                'code': exception.code,
                'message': exception.message
            }, exception.status_code
        return response, status
Exemplo n.º 4
0
    def get():
        """Search orgs."""
        org_search = OrgSearch(request.args.get('name', None),
                               request.args.get('branchName', None),
                               request.args.get('affiliation', None),
                               request.args.getlist('status', None),
                               request.args.getlist('accessType', None),
                               request.args.get('bcolAccountId', None),
                               request.args.get('id', None),
                               request.args.get('decisionMadeBy', None),
                               request.args.get('orgType', None),
                               int(request.args.get('page', 1)),
                               int(request.args.get('limit', 10)))
        validate_name = request.args.get('validateName', 'False')

        try:
            token = g.jwt_oidc_token_info
            if validate_name.upper() == 'TRUE':
                response, status = OrgService.find_by_org_name(org_name=org_search.name,
                                                               branch_name=org_search.branch_name), \
                                                                    http_status.HTTP_200_OK
            else:
                response, status = OrgService.search_orgs(
                    org_search), http_status.HTTP_200_OK

            is_public_user = Role.PUBLIC_USER.value in token.get(
                'realm_access').get('roles')
            if is_public_user:  # public user cant get the details in search.Gets only status of orgs
                if response and response.get('orgs'):
                    status = http_status.HTTP_200_OK
                else:
                    status = http_status.HTTP_204_NO_CONTENT
                response = {}  # Do not return any results if searching by name

        except BusinessException as exception:
            response, status = {
                'code': exception.code,
                'message': exception.message
            }, exception.status_code
        return response, status