Skip to content

Use project dir end point (#466) #1414

Use project dir end point (#466)

Use project dir end point (#466) #1414

GitHub Actions / Test Report ubuntu-latest:3.12 failed Oct 24, 2024 in 0s

89 tests run, 79 passed, 5 skipped, 5 failed.

Annotations

Check failure on line 211 in tests/jms/test_task_definition_templates.py

See this annotation in the file changed.

@github-actions github-actions / Test Report ubuntu-latest:3.12

test_task_definition_templates.test_template_permissions

ansys.hps.client.exceptions.ClientError: 403 Client Error: 403 Forbidden for: GET https://localhost:8443/hps/jms/api/v1/task_definition_templates/02y398x4Km0u9ViSw3QqJF/permissions?fields=all
Access to this resource has been restricted
Raw output
client = <ansys.hps.client.client.Client object at 0x7f6bc994fef0>
keycloak_client = <keycloak.keycloak_admin.KeycloakAdmin object at 0x7f6bc988bda0>
is_admin = True

    def test_template_permissions(client, keycloak_client, is_admin):
    
        jms_api = JmsApi(client)
    
        templates = jms_api.get_task_definition_templates()
    
        # a regular deployment should have some default templates
        # with read all permissions + some user defined ones with
        # either user or group permissions
        for template in templates:
>           permissions = jms_api.get_task_definition_template_permissions(template_id=template.id)

tests/jms/test_task_definition_templates.py:211: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py312-coverage/lib/python3.12/site-packages/ansys/hps/client/jms/api/jms_api.py:220: in get_task_definition_template_permissions
    return get_objects(
.tox/py312-coverage/lib/python3.12/site-packages/ansys/hps/client/jms/api/base.py:41: in get_objects
    r = session.get(url, params=query_params)
.tox/py312-coverage/lib/python3.12/site-packages/requests/sessions.py:602: in get
    return self.request("GET", url, **kwargs)
.tox/py312-coverage/lib/python3.12/site-packages/requests/sessions.py:589: in request
    resp = self.send(prep, **send_kwargs)
.tox/py312-coverage/lib/python3.12/site-packages/requests/sessions.py:710: in send
    r = dispatch_hook("response", hooks, r, **kwargs)
.tox/py312-coverage/lib/python3.12/site-packages/requests/hooks.py:30: in dispatch_hook
    _hook_data = hook(hook_data, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

response = <Response [403]>, args = ()
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}
r_content = {'description': 'Access to this resource has been restricted', 'title': '403 Forbidden'}
reason = '403 Forbidden'
description = 'Access to this resource has been restricted'
error_msg = '403 Client Error: 403 Forbidden for: GET https://localhost:8443/hps/jms/api/v1/task_definition_templates/02y398x4Km0u9ViSw3QqJF/permissions?fields=all\nAccess to this resource has been restricted'

    def raise_for_status(response, *args, **kwargs):
        """Automatically checks HTTP errors.
    
        This method mimics the requests.Response.raise_for_status() method.
        """
        if 400 <= response.status_code < 600:
    
            r_content = {}
            try:
                r_content = response.json()
            except ValueError:
                pass
    
            reason = r_content.get("title", None)  # jms api
            if not reason:
                reason = r_content.get("error", None)  # auth api
            if not reason:
                reason = response.reason
    
            description = r_content.get("description", None)  # jms api
            if not description:
                description = r_content.get("error_description", None)  # auth api
    
            if 400 <= response.status_code < 500:
                error_msg = "%s Client Error: %s for: %s %s" % (
                    response.status_code,
                    reason,
                    response.request.method,
                    response.url,
                )
                if description:
                    error_msg += f"\n{description}"
>               raise ClientError(error_msg, reason=reason, description=description, response=response)
E               ansys.hps.client.exceptions.ClientError: 403 Client Error: 403 Forbidden for: GET https://localhost:8443/hps/jms/api/v1/task_definition_templates/02y398x4Km0u9ViSw3QqJF/permissions?fields=all
E               Access to this resource has been restricted

.tox/py312-coverage/lib/python3.12/site-packages/ansys/hps/client/exceptions.py:98: ClientError

Check failure on line 299 in tests/jms/test_task_definition_templates.py

See this annotation in the file changed.

@github-actions github-actions / Test Report ubuntu-latest:3.12

test_task_definition_templates.test_template_permissions_update

AssertionError: assert 2 == 1
 +  where 2 = len([Permission(permission_type='user',value_id='69d8dbb6-ab69-48e2-90dd-b6d5bc0dac92',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
Raw output
client = <ansys.hps.client.client.Client object at 0x7f6bc994fef0>

    def test_template_permissions_update(client):
    
        jms_api = JmsApi(client)
    
        # create new template and check default permissions
        template = TaskDefinitionTemplate(name="my_template", version=uuid.uuid4())
        template = jms_api.create_task_definition_templates([template])[0]
        permissions = jms_api.get_task_definition_template_permissions(template_id=template.id)
>       assert len(permissions) == 1
E       AssertionError: assert 2 == 1
E        +  where 2 = len([Permission(permission_type='user',value_id='69d8dbb6-ab69-48e2-90dd-b6d5bc0dac92',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])

tests/jms/test_task_definition_templates.py:299: AssertionError

Check failure on line 324 in tests/jms/test_task_definition_templates.py

See this annotation in the file changed.

@github-actions github-actions / Test Report ubuntu-latest:3.12

test_task_definition_templates.test_template_anyone_permission

AssertionError: assert 2 == 1
 +  where 2 = len([Permission(permission_type='user',value_id='69d8dbb6-ab69-48e2-90dd-b6d5bc0dac92',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
Raw output
client = <ansys.hps.client.client.Client object at 0x7f6bc994fef0>
keycloak_client = <keycloak.keycloak_admin.KeycloakAdmin object at 0x7f6bc957e9f0>

    def test_template_anyone_permission(client, keycloak_client):
    
        jms_api = JmsApi(client)
    
        # create new template and check default permissions
        template = TaskDefinitionTemplate(name="my_template", version=uuid.uuid4())
        template = jms_api.create_task_definition_templates([template])[0]
        permissions = jms_api.get_task_definition_template_permissions(template_id=template.id)
>       assert len(permissions) == 1
E       AssertionError: assert 2 == 1
E        +  where 2 = len([Permission(permission_type='user',value_id='69d8dbb6-ab69-48e2-90dd-b6d5bc0dac92',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])

tests/jms/test_task_definition_templates.py:324: AssertionError

Check failure on line 394 in tests/jms/test_task_definition_templates.py

See this annotation in the file changed.

@github-actions github-actions / Test Report ubuntu-latest:3.12

test_task_definition_templates.test_template_delete

AssertionError: assert 2 == 1
 +  where 2 = len([Permission(permission_type='user',value_id='73a703e2-80d7-4926-9325-ceac1d7913d6',value_name='testuser-20aa88ba',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
Raw output
client = <ansys.hps.client.client.Client object at 0x7f6bc994fef0>
keycloak_client = <keycloak.keycloak_admin.KeycloakAdmin object at 0x7f6bc988b290>

    def test_template_delete(client, keycloak_client):
    
        auth_api = AuthApi(client)
    
        # create 2 non-admin users
        jms_api = JmsApi(client)
        user1, client1 = create_new_user_client(client.url, keycloak_client)
        assert not auth_api.user_is_admin(user1.id)
        jms_api1 = JmsApi(client1)
        user2, client2 = create_new_user_client(client.url, keycloak_client)
        assert not auth_api.user_is_admin(user2.id)
        jms_api2 = JmsApi(client2)
    
        # user1 creates new template
        template = TaskDefinitionTemplate(name="my_template", version=uuid.uuid4())
        template = jms_api1.create_task_definition_templates([template])[0]
        permissions = jms_api1.get_task_definition_template_permissions(template_id=template.id)
>       assert len(permissions) == 1
E       AssertionError: assert 2 == 1
E        +  where 2 = len([Permission(permission_type='user',value_id='73a703e2-80d7-4926-9325-ceac1d7913d6',value_name='testuser-20aa88ba',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])

tests/jms/test_task_definition_templates.py:394: AssertionError

Check failure on line 71 in tests/test_exceptions.py

See this annotation in the file changed.

@github-actions github-actions / Test Report ubuntu-latest:3.12

test_exceptions.test_client_error

AssertionError: assert '403 Forbidden' == '404 Not Found'
  
  - 404 Not Found
  + 403 Forbidden
Raw output
url = 'https://localhost:8443/hps', username = 'repadmin', password = 'repadmin'
client = <ansys.hps.client.client.Client object at 0x7f6bc994fef0>

    def test_client_error(url, username, password, client):
    
        except_obj = None
        try:
            client = Client(url, username, f"{password}_wrong")
        except ClientError as e:
            except_obj = e
            log.error(str(e))
    
        assert except_obj.reason == "invalid_grant"
        assert except_obj.description == "Invalid user credentials"
        assert except_obj.response.status_code == 401
    
        except_obj = None
        try:
            jms_api = JmsApi(client)
            jms_api.get_project(id="02q4bg9PVO2OvvhsmClb0E")
        except ClientError as e:
            except_obj = e
            log.error(str(e))
    
        # The answer that one would expect:
        # self.assertEqual(except_obj.reason, 'Not Found')
        # self.assertEqual(except_obj.response.status_code, 404)
        # The answer currently received when querying this with a user different from repadmin
>       assert except_obj.reason == "404 Not Found"
E       AssertionError: assert '403 Forbidden' == '404 Not Found'
E         
E         - 404 Not Found
E         + 403 Forbidden

tests/test_exceptions.py:71: AssertionError